adding student's name & surname to attempt review

adding student's name & surname to attempt review

by Massimiliano Del Gatto -
Number of replies: 1

Hello! 

I would be grateful if someone could suggest how to hack the page 'mod/quiz/review.php?attempt=###' so as to display the name and surname of the student who took the quiz on top of the table of the attempt review details. I see the student's name, surname and profile picture on the left, in the navigation block, which is excellent for an on-line use of the attempt review activity, but when I print the attempt review (for record storage), that is not included (=BIIIIIIG problem).

The arrow in the picture points to the place where I would like to display the student's information (the box in red).

My moodle version is 3.0+ (Build: 20151209)

Hope someone could help.

Massimiliano

Attachment Students-name-hack.jpg
Average of ratings: -
In reply to Massimiliano Del Gatto

Re: adding student's name & surname to attempt review

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Massimiliano,

Not recommended to hack core files and the Moodle you are using is no longer supported. However, since your Moodle is no longer supported, the odds are you will not wipe out your hack with an upgrade. So this is pretty easy to do.

Open  the file for editing at: yourmoodle/mod/quiz/review.php

Go to the blank line at line number 229 and add two more blank lines.

Past the following code into line 230:

// This will add a name line under the grade. e.g. Name Owen Money.
$student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
$summarydata['user'] = array(
    'title'   => get_string('name', 'quiz'),
    'content' => new action_link(new moodle_url('/user/view.php', array(
                 'id' => $student->id, 'course' => $attemptobj->get_courseid())),
                 fullname($student, true)),
);

Save your modified review.php file.

Verify that it works by going to review a quiz results, and you should see something similar to the picture, even when Appearance is not set to show the user picture.