From a4100d4de3dfb383d557ab8510731ba030dc1a0d Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 13 Jan 2016 13:37:15 +0000 Subject: [PATCH] MDL-52750 quiz reviewQ/comment: add page title & student name --- mod/quiz/comment.php | 14 ++++++++++++++ mod/quiz/lang/en/quiz.php | 2 ++ mod/quiz/renderer.php | 3 ++- mod/quiz/review.php | 6 +++--- mod/quiz/reviewquestion.php | 18 ++++++++++++++++-- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index c1961ab2a8d22..08942de22db2b 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -32,6 +32,7 @@ $PAGE->set_url('/mod/quiz/comment.php', array('attempt' => $attemptid, 'slot' => $slot)); $attemptobj = quiz_attempt::create($attemptid); +$student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); // Can only grade finished attempts. if (!$attemptobj->is_finished()) { @@ -44,6 +45,9 @@ // Print the page header. $PAGE->set_pagelayout('popup'); +$PAGE->set_title(get_string('manualgradequestion', 'quiz', array( + 'question' => format_string($attemptobj->get_question_name($slot)), + 'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student)))); $PAGE->set_heading($attemptobj->get_course()->fullname); $output = $PAGE->get_renderer('mod_quiz'); echo $output->header(); @@ -51,6 +55,16 @@ // Prepare summary information about this question attempt. $summarydata = array(); +// Student name. +$userpicture = new user_picture($student); +$userpicture->courseid = $attemptobj->get_courseid(); +$summarydata['user'] = array( + 'title' => $userpicture, + 'content' => new action_link(new moodle_url('/user/view.php', array( + 'id' => $student->id, 'course' => $attemptobj->get_courseid())), + fullname($student, true)), +); + // Quiz name. $summarydata['quizname'] = array( 'title' => get_string('modulename', 'quiz'), diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index 7f5f0844474fd..bf8cf68f543ef 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -458,6 +458,7 @@ $string['makecopy'] = 'Save as new question'; $string['managetypes'] = 'Manage question types and servers'; $string['manualgrading'] = 'Grading'; +$string['manualgradequestion'] = 'Manually grade question {$a->question} in {$a->quiz} by {$a->user}'; $string['mark'] = 'Submit'; $string['markall'] = 'Submit page'; $string['marks'] = 'Marks'; @@ -771,6 +772,7 @@ $string['reviewnever'] = 'Never allow review'; $string['reviewofattempt'] = 'Review of attempt {$a}'; $string['reviewofpreview'] = 'Review of preview'; +$string['reviewofquestion'] = 'Review of question {$a->question} in {$a->quiz} by {$a->user}'; $string['reviewopen'] = 'Later, while the quiz is still open'; $string['reviewoptions'] = 'Students may review'; $string['reviewoptionsheading'] = 'Review options'; diff --git a/mod/quiz/renderer.php b/mod/quiz/renderer.php index b11ed81803e30..55417311ad3ee 100644 --- a/mod/quiz/renderer.php +++ b/mod/quiz/renderer.php @@ -92,10 +92,11 @@ public function review_question_page(quiz_attempt $attemptobj, $slot, $seq, /** * Renders the review question pop-up. * + * @param quiz_attempt $attemptobj an instance of quiz_attempt. * @param string $message Why the review is not allowed. * @return string html to output. */ - public function review_question_not_allowed($message) { + public function review_question_not_allowed(quiz_attempt $attemptobj, $message) { $output = ''; $output .= $this->header(); $output .= $this->heading(format_string($attemptobj->get_quiz_name(), true, diff --git a/mod/quiz/review.php b/mod/quiz/review.php index eebab6b5460a9..be91bd64b6a6a 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -134,10 +134,10 @@ if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() != $USER->id) { // If showuserpicture is true, the picture is shown elsewhere, so don't repeat it. $student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); - $usrepicture = new user_picture($student); - $usrepicture->courseid = $attemptobj->get_courseid(); + $userpicture = new user_picture($student); + $userpicture->courseid = $attemptobj->get_courseid(); $summarydata['user'] = array( - 'title' => $usrepicture, + 'title' => $userpicture, 'content' => new action_link(new moodle_url('/user/view.php', array( 'id' => $student->id, 'course' => $attemptobj->get_courseid())), fullname($student, true)), diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index e7bcf91f27524..7a6e2a189e4e2 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -44,11 +44,15 @@ // Check login. require_login($attemptobj->get_course(), false, $attemptobj->get_cm()); $attemptobj->check_review_capability(); +$student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); $accessmanager = $attemptobj->get_access_manager(time()); $options = $attemptobj->get_display_options(true); $PAGE->set_pagelayout('popup'); +$PAGE->set_title(get_string('reviewofquestion', 'quiz', array( + 'question' => format_string($attemptobj->get_question_name($slot)), + 'quiz' => format_string($attemptobj->get_quiz_name()), 'user' => fullname($student)))); $PAGE->set_heading($attemptobj->get_course()->fullname); $output = $PAGE->get_renderer('mod_quiz'); @@ -56,10 +60,10 @@ // quiz_attempt::check_file_access. If you change on, change them all. if ($attemptobj->is_own_attempt()) { if (!$attemptobj->is_finished()) { - echo $output->review_question_not_allowed(get_string('cannotreviewopen', 'quiz')); + echo $output->review_question_not_allowed($attemptobj, get_string('cannotreviewopen', 'quiz')); die(); } else if (!$options->attempt) { - echo $output->review_question_not_allowed( + echo $output->review_question_not_allowed($attemptobj, $attemptobj->cannot_review_message()); die(); } @@ -71,6 +75,16 @@ // Prepare summary informat about this question attempt. $summarydata = array(); +// Student name. +$userpicture = new user_picture($student); +$userpicture->courseid = $attemptobj->get_courseid(); +$summarydata['user'] = array( + 'title' => $userpicture, + 'content' => new action_link(new moodle_url('/user/view.php', array( + 'id' => $student->id, 'course' => $attemptobj->get_courseid())), + fullname($student, true)), +); + // Quiz name. $summarydata['quizname'] = array( 'title' => get_string('modulename', 'quiz'),