Hello everyone,
Is it possible to create a file in one activity and use it for the other activity in the same quiz?
For example,
I have a quiz named Python Workshop and I created a CodeRunner Question(test_one) where I ask students to write a python code that creates a random.dat(or any other file format) file that contains a bunch of random numbers.
And now I want to use the data in random.dat in other activity named test_two( which is in the same Python Workshop quiz)
Is there a way to do it with the help of CodeRunner?
Kindly help.
The short answer is no, because the Jobe server is stateless, unless you deliberately change it. For example, you could turn on a database or set up a directory with write access to everyone, although I strongly advise against either of those.
The ploy we use if we want to link randomised questions within a quiz is to use one of the fields of the STUDENT variable (see here: https://github.com/trampgeek/moodle-qtype_coderunner#the-twig-student-variable) as a random number seed. For example you might ask the student to write a make_file(username) function that uses the given username as a random number seed and writes a randomised to the current working directory. Then you can ask them to re-use that same function in later questions that require that file.