Has anyone Kotlin or Swift running?

Has anyone Kotlin or Swift running?

by Luca Bösch -
Number of replies: 4

Hi CodeRunner community.

I'm going to (re-)raise a question that has come up.
Is anyone using the languages Kotlin or Swift in CodeRunner?
Regarding Kotlin an ancient forum post https://coderunner.org.nz/mod/forum/discuss.php?d=331#p1321 exists.

Thanks for any clue.
Luca

In reply to Luca Bösch

Re: Has anyone Kotlin or Swift running?

by Thomas Karp -
Hi,

not yet, but I'd like to, since I just started using Kotlin at school this week. Did you succeed?

Regards, Tom
In reply to Luca Bösch

Re: Has anyone Kotlin or Swift running?

by Thomas Karp -
Hi,

I finally was able to use Kotlin after a few hours of fiddling...
If you are still interested, I could try to describe my solution.

Regards, Tom
In reply to Thomas Karp

Re: Has anyone Kotlin or Swift running?

by Luca Bösch -

Oh, yes, Tom, that would be very interesting.
Thanks in advance!

Best,
Luca

In reply to Luca Bösch

Re: Has anyone Kotlin or Swift running?

by Thomas Karp -
Hi,

first, you have to install the Kotlin-compiler at the Jobe-Server. I use docker and expanded the existing version with this Dockerfile:

FROM trampgeek/jobeinabox

USER root

# Tools and JDK
RUN apt-get update && \
    apt-get install -y --no-install-recommends wget unzip default-jdk && \
    rm -rf /var/lib/apt/lists/*

# Kotlin-Version
ARG KOTLIN_VERSION=2.3.10

# Kotlin Compiler
RUN wget https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip && \
    unzip kotlin-compiler-${KOTLIN_VERSION}.zip -d /opt && \
    rm kotlin-compiler-${KOTLIN_VERSION}.zip

RUN ln -s /opt/kotlinc/bin/kotlinc /usr/bin/kotlinc && \
    ln -s /opt/kotlinc/bin/kotlin /usr/bin/kotlin

ENV PATH="${PATH}:/opt/kotlinc/bin"

Than I built the docker image:

sudo docker build -t jobe-kotlin .
and started it:

sudo docker run --rm -d -p 8000:80 --name jobe-kotlin-container jobe-kotlin
I had to increase the maximum execution time in the coderunner plugin. I did set 15 seconds. I don't know if 15s is necessary, but that worked for me.

I created 3 prototypes based on Python3. One prototype expects the students answer to be a whole kotlin program, the other one expects  Kotlin code that is included in the main function and one expects top-level-definitions like classes or functions. Every prototype uses testcases and TEST.extra, which is barely documented in the prototypes. If you look at the template you see how TEST.extra, TEST.testcode and STUDENT_ANSWER are combined. You find them attached.

You also find a simple demo question attached.

I had some AI-help and was not looking if every option is perfect, so I am sure there is potential to improve things, but I was very happy that it already worked. I didn't test it with my students yet, but at home my tests were fine.

If you have any questions, feel free to ask.
Kind regards, Tom