bfh / moodle-quiz_archive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Name the person who made a change in the question response history (if not the student)

LisaE14 opened this issue · comments

Since Moodle 3.11 you can see which person made changes in the question response history (if not the student).
https://tracker.moodle.org/browse/MDL-71030

It would be great if you could add this also on the archive page.

@PhilippImhof maybe you could help me out with this one.
Your support is immensely valued!

I see that the link is there, only the name isn't fetched.
image
In branch https://github.com/bfh/moodle-quiz_archive/tree/showeditor I do experiment when creating the passed options array exactly identically as in function https://github.com/moodle/moodle/blob/14414fe253f8cb96c4b1a69c45145e9e2df41f33/question/engine/renderer.php#L520 but it wouldn't resolve the issue.

I've discovered something that would help moodle/moodle@master...lucaboesch:MDL-80083-master but does this make any sense to you, @PhilippImhof?

I am happy to have a look, I already have an idea, but I'm not sure.

So, I found the source of the problem and have the solution. For one, we have to add $displayoptions->userinfoinhistory = $userid; here:

$displayoptions = $attemptobj->get_display_options_with_edit_link(true, $slot, "");
$displayoptions->marks = 2;
$displayoptions->manualcomment = 1;
$displayoptions->feedback = 1;
$displayoptions->history = $this->options->showhistory;
$displayoptions->rightanswer = $this->options->showright;
$displayoptions->correctness = 1;
$displayoptions->numpartscorrect = 1;
$displayoptions->flags = 1;
$displayoptions->manualcommentlink = 0;

This will make sure that the authoring user is displayed whenever it is different from the student who took the quiz.

And with that, we don't get the user name yet, because there is an error in the constructor of the question_attempt_step class:

https://github.com/moodle/moodle/blob/14414fe253f8cb96c4b1a69c45145e9e2df41f33/question/engine/questionattemptstep.php#L115-L138

The $user property is never initialized; the constructor is missing something like $this->user = core_user::get_user($this->userid);. I am going to open an issue in the Moodle tracker, unless you already have?

The patch in questionattemptstep.php alone does help.
Add
$this->user = core_user::get_user($this->userid);
in line 139 for example.
No, I didn't open any tracker issue.

You are right, $displayoptions->userinfoinhistory somehow gets set even if we don't do it in the loop, so that line is not needed. I'll prepare a patch to core and ping you for peer review. It would be good to get that integrated before December, because that will be the last bugfix release for LTS 4.1.

I'm waiting for CiBoT to do his job, but otherwise everything is ready at MDL-80086

This is going to bee fixed by MDL-80086, @LisaE14, therefore closing.

@lucaboesch I have prepared a PR according to Tim's suggestion. You'd probably like to reopen the issue and close it once the PR is merged?