Skip to content

Commit

Permalink
MDL-52750 quiz reviewQ/comment: add page title & student name
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Jan 15, 2016
1 parent e8d5100 commit a4100d4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
14 changes: 14 additions & 0 deletions mod/quiz/comment.php
Expand Up @@ -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()) {
Expand All @@ -44,13 +45,26 @@

// 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();

// 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'),
Expand Down
2 changes: 2 additions & 0 deletions mod/quiz/lang/en/quiz.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/renderer.php
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/review.php
Expand Up @@ -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)),
Expand Down
18 changes: 16 additions & 2 deletions mod/quiz/reviewquestion.php
Expand Up @@ -44,22 +44,26 @@
// 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');

// Check permissions - warning there is similar code in review.php and
// 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();
}
Expand All @@ -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'),
Expand Down

0 comments on commit a4100d4

Please sign in to comment.