Logging runs

Logging runs

de către Oli Howson-
Număr de răspunsuri: 10

In light of my previous question working out, I have a followup.

I'd like to log some data whenever this question is run:

  • timestamp of a run
  • user id
  • size n of a variable in the code

Now I can get the timestamp and the size easily enough - and I'm sure I can figure out a logging system (sqlite, log files, etc etc) but unsure how to access a user id from moodle?


*edit: I know this is accessible in the twig template - I was referring rather to the Python3 code 

Ca răspuns la Oli Howson

Re: Logging runs

de către Oli Howson-
I'm on fire today - have answered my own question - you can access the ID using {{STUDENT.ID}} or some such within python code. I don't know if this is *our* student ID or an internal coderunner one but for my purposes it doesn't really matter as long as I can differentiate between the student runs (so I can tell if student X ran 40 times and student Y only 4)

Now I need to persuade someone to give me a file to log to!
Ca răspuns la Oli Howson

Re: Logging runs

de către Richard Lobb-

Yep, the {{STUDENT}} variable is what I was going to suggest. The id attribute is Moodle's database id, not your student id but it seems you're happy with that. Other attributes are available too -- see here.

The jobe server is normally stateless but you might be able to persuade your system administrator to give you access to a writeable file. If not, an alternative approach would be to use CodeRunner's downloadquizattempts script - see here. This gives you pretty much all the details of every submission by every student, from which you should be able to extract what you want. 

Ca răspuns la Richard Lobb

Re: Logging runs

de către Tim Hunt-

He couldn't persuade me ;-)

However I was able to suggest yet another approach: Use the Responses report in the quiz to download all the responses in JSON format (or similar) and then process them offline.

Ca răspuns la Tim Hunt

Re: Logging runs

de către Oli Howson-

Haha :)

Maybe an accessible 'log' function could be on the future code-runner wish list? Somewhere you can stick some immutable data above/beyond just logging the user input.


Ca răspuns la Oli Howson

Re: Logging runs

de către Tim Hunt-

I am inclined to disagree with this.

Almost any analysis you want to do on the student input is likely to be quite fast processing.

If you try to do the analysis at the time you process the student input, then you have to know ahead of time what data you need to capture, and you have to implement that without bugs.

If, on the other had, you capture the raw input. Then you can process it later multiple times, and refine your analysis code iteratively as you come to understand the data.

Ca răspuns la Tim Hunt

Re: Logging runs

de către Richard Lobb-

I agree with Tim - I think logging is a job for Moodle, not for individual question types. As Tim says you can download all the responses to a quiz or use CodeRunner's downloadquizaattempts script, mentioned above. The standard Moodle download responses is the best option if it gives you what you want, but it only gives you the students' final submissions to a quiz attempt, not all the individual clicks on the Check or Precheck buttons. Unless it has changed since the last time I looked. The downloadquizattempts script gives you everything.

Ca răspuns la Richard Lobb

Re: Logging runs

de către Tim Hunt-

For quite a while now, the quiz responses report has had an option where you can select 'Last try', 'All tries' or 'First try'. (You can see an example here https://qa.moodledemo.net/mod/quiz/report.php?id=30&mode=responses.)

I am not sure what CodeRunner considers a try (hopefully all checks. Not sure if I think prechecks should cound). If it is not working, we should fix it. The key method to override is ... actually, I don't remember exactly.

I from a quick search of the code I think it is https://github.com/moodle/moodle/blob/master/question/behaviour/behaviourtypebase.php#L105 and https://github.com/moodle/moodle/blob/master/question/behaviour/behaviourbase.php#L716.

Ca răspuns la Tim Hunt

Please turn on the URL autolinking filter

de către Tim Hunt-

Richard, please can you turn on the URL autolinking filter here :-)

Ca răspuns la Tim Hunt

Re: Logging runs

de către Oli Howson-

Certainly hope it captures all - I expect my students to be running maybe 10-15 times and want to capture all.

Ca răspuns la Tim Hunt

Re: Logging runs

de către Richard Lobb-

Thanks Tim. I thought I tried the "All tries" option years ago and concluded it only gave me the last try on each quiz attempt. But ... it seems to work fine now. Which is great news, and makes my downloadquizattempts script much less useful, though sometimes we also want the time of each submission and what marks it got. So I won't throw it away, yet.