Somewhat of a side topic . . .

Somewhat of a side topic . . .

por Chris VESSEY -
Número de respuestas: 2

This could probably also land in the Dev forum, but I will ask it here.  I had a look through the topics back a fair bit, and I can't see where it was asked, so I'm going to apologize in advance if there's any overlap.

Now, to the point:  is there any way to access any of the user data in Moodle from within CodeRunner?  We can use Moodle to, for example, create a quiz that can only be viewed by a specific user, identified by their institutional ID.  As an example, let's say our ID was 0300999

We can make a quiz that only the user with that unique ID (which is managed by our IT section) can see.

But - is there a way to access that ID number within CodeRunner, from (for example) a template?  I had a look in the template, and while I see lots of randomization stuff and how to implement that - I'd like to know if we can use the ID number and twig that into results.

We teach our intro courses in Python.

For assignments and other work, our students use PyCharm-EDU.  Often they like to work on questions with that IDE, because of its debugging abilities, while doing a quiz object (which might appear to them as an assignment.)  In that instance, it'd be nice to be able to not only randomize the problem they get, but randomize the data within the problem according to their unchanging ID.  Currently, I use the hidden customization code to set each student's output to use a specific random seed, so while it's random, it's the same random each time.  That's fine, but it'd be nice to be able to use that ID as a seed, so each student gets their own unique sequence, based on their ID, that is repeatable.

Does anyone know if such a thing is possible?

Thanks in advance!

En respuesta a Chris VESSEY

Re: Somewhat of a side topic . . .

por Richard Lobb -
It sounds like what you need is the STUDENT variable, which is available to Twig when expanding the template. So for example {{ STUDENT.id }} is the student ID. See the documentation here: https://github.com/trampgeek/moodle-qtype_coderunner#the-twig-student-variable