mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-3633 Don't show the attempt number column on the quiz view page if the quiz only allows one attempt.
This commit is contained in:
parent
237806f4f0
commit
152d3c0242
5 changed files with 64 additions and 29 deletions
|
@ -412,8 +412,10 @@ $string['noquestionsfound'] = 'No questions found';
|
|||
$string['noquestionsinfile'] = 'There are no questions in the import file';
|
||||
$string['noresponse'] = 'No Response';
|
||||
$string['noreview'] = 'You are not allowed to review this quiz';
|
||||
$string['noreviewshort'] = 'Not permitted';
|
||||
$string['noview'] = 'Logged-in user is not allowed to view this quiz';
|
||||
$string['noreviewuntil'] = 'You are not allowed to review this quiz until $a';
|
||||
$string['noreviewuntilshort'] = 'Available $a';
|
||||
$string['noscript'] = 'JavaScript must be enabled to continue!';
|
||||
$string['notavailable'] = 'This quiz is not currently available';
|
||||
$string['notavailabletostudents'] = 'Note: This quiz is not currently available to your students';
|
||||
|
@ -557,6 +559,7 @@ $string['reviewopen'] = 'Later, while the quiz is still open';
|
|||
$string['reviewoptions'] = 'Students may review';
|
||||
$string['reviewoptionsheading'] = 'Review options';
|
||||
$string['reviewresponse'] = 'Review response';
|
||||
$string['reviewthisattempt'] = 'Review your responses to this attempt';
|
||||
$string['rqp'] = 'Remote Question';
|
||||
$string['rqps'] = 'Remote Questions';
|
||||
$string['save'] = 'Save';
|
||||
|
|
|
@ -319,37 +319,57 @@ class quiz_access_manager {
|
|||
* @param object $attempt the attempt object
|
||||
* @return string some HTML, the $linktext either unmodified or wrapped in a link to the review page.
|
||||
*/
|
||||
public function make_review_link($linktext, $attempt, $canpreview, $reviewoptions) {
|
||||
public function make_review_link($attempt, $canpreview, $reviewoptions) {
|
||||
global $CFG;
|
||||
|
||||
/// If review of responses is not allowed, or the attempt is still open, don't link.
|
||||
if (!$reviewoptions->responses || !$attempt->timefinish) {
|
||||
return $linktext;
|
||||
if (!$attempt->timefinish) {
|
||||
return '';
|
||||
}
|
||||
if (!$reviewoptions->responses) {
|
||||
$message = $this->cannot_review_message($reviewoptions, true);
|
||||
if ($message) {
|
||||
return '<span class="noreviewmessage">' . $message . '</span>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$linktext = get_string('review', 'quiz');
|
||||
|
||||
/// It is OK to link, does it need to be in a secure window?
|
||||
if ($this->securewindow_required($canpreview)) {
|
||||
return $this->_securewindowrule->make_review_link($linktext, $attempt->id);
|
||||
} else {
|
||||
return '<a href="' . $this->_quizobj->review_url($attempt->id) . '">' . $linktext . '</a>';
|
||||
return '<a href="' . $this->_quizobj->review_url($attempt->id) . '" title="' .
|
||||
get_string('reviewthisattempt', 'quiz') . '">' . $linktext . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If $reviewoptions->responses is false, meaning that students can't review this
|
||||
* attempt at the moment, return an appropriate string explaining why.
|
||||
*
|
||||
* @param object $reviewoptions as obtained from quiz_get_reviewoptions.
|
||||
* @param boolean $short if true, return a shorter string.
|
||||
* @return string an appropraite message.
|
||||
*/
|
||||
public function cannot_review_message($reviewoptions) {
|
||||
public function cannot_review_message($reviewoptions, $short = false) {
|
||||
$quiz = $this->_quizobj->get_quiz();
|
||||
if ($short) {
|
||||
$langstrsuffix = 'short';
|
||||
$dateformat = get_string('strftimedatetimeshort', 'langconfig');
|
||||
} else {
|
||||
$langstrsuffix = '';
|
||||
$dateformat = '';
|
||||
}
|
||||
if ($reviewoptions->quizstate == QUIZ_STATE_IMMEDIATELY) {
|
||||
return '';
|
||||
} else if ($reviewoptions->quizstate == QUIZ_STATE_OPEN && $quiz->timeclose &&
|
||||
($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES)) {
|
||||
return get_string('noreviewuntil', 'quiz', userdate($quiz->timeclose));
|
||||
return get_string('noreviewuntil' . $langstrsuffix, 'quiz', userdate($quiz->timeclose, $dateformat));
|
||||
} else {
|
||||
return get_string('noreview', 'quiz');
|
||||
return get_string('noreview' . $langstrsuffix, 'quiz');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +731,7 @@ class securewindow_access_rule extends quiz_access_rule_base {
|
|||
* @return string HTML for the link.
|
||||
*/
|
||||
public function make_review_link($linktext, $attemptid) {
|
||||
return link_to_popup_window($this->_quizobj->review_url($attemptid),
|
||||
return button_to_popup_window($this->_quizobj->review_url($attemptid),
|
||||
'quizpopup', $linktext, '', '', '', $this->windowoptions, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php // $Id$
|
||||
/**
|
||||
* This page prints a review of a particular question attempt
|
||||
*
|
||||
* This page allows the teacher to enter a manual grade for a particular question.
|
||||
* This page is expected to only be used in a popup window.
|
||||
* *
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package quiz
|
||||
*/
|
||||
|
@ -12,15 +13,7 @@
|
|||
$attemptid =required_param('attempt', PARAM_INT); // attempt id
|
||||
$questionid =required_param('question', PARAM_INT); // question id
|
||||
|
||||
if (! $attempt = $DB->get_record('quiz_attempts', array('uniqueid' => $attemptid))) {
|
||||
print_error('invalidattemptid', 'quiz');
|
||||
}
|
||||
if (! $quiz = $DB->get_record('quiz', array('id' => $attempt->quiz))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id' => $quiz->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
$attemptobj = new quiz_attempt($attemptid);
|
||||
|
||||
// Teachers are only allowed to comment and grade on closed attempts
|
||||
if (!($attempt->timefinish > 0)) {
|
||||
|
|
|
@ -175,6 +175,8 @@
|
|||
// Work out which columns we need, taking account what data is available in each attempt.
|
||||
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
|
||||
|
||||
$attemptcolumn = $quiz->attempts != 1;
|
||||
|
||||
$gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades;
|
||||
$markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades);
|
||||
$overallstats = $alloptions->scores;
|
||||
|
@ -184,9 +186,17 @@
|
|||
|
||||
// Prepare table header
|
||||
$table->class = 'generaltable quizattemptsummary';
|
||||
$table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz'));
|
||||
$table->align = array('center', 'left');
|
||||
$table->size = array('', '');
|
||||
$table->head = array();
|
||||
$table->align = array();
|
||||
$table->size = array();
|
||||
if ($attemptcolumn) {
|
||||
$table->head[] = get_string('attempt', 'quiz');
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
$table->head[] = get_string('timecompleted', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades);
|
||||
$table->align[] = 'left';
|
||||
$table->size[] = '';
|
||||
if ($markcolumn) {
|
||||
$table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades);
|
||||
$table->align[] = 'center';
|
||||
|
@ -197,6 +207,9 @@
|
|||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
$table->head[] = get_string('review', 'quiz');
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
if ($feedbackcolumn) {
|
||||
$table->head[] = get_string('feedback', 'quiz');
|
||||
$table->align[] = 'left';
|
||||
|
@ -214,10 +227,12 @@
|
|||
$row = array();
|
||||
|
||||
// Add the attempt number, making it a link, if appropriate.
|
||||
if ($attempt->preview) {
|
||||
$row[] = $accessmanager->make_review_link(get_string('preview', 'quiz'), $attempt, $canpreview, $attemptoptions);
|
||||
} else {
|
||||
$row[] = $accessmanager->make_review_link($attempt->attempt, $attempt, $canpreview, $attemptoptions);
|
||||
if ($attemptcolumn) {
|
||||
if ($attempt->preview) {
|
||||
$row[] = get_string('preview', 'quiz');
|
||||
} else {
|
||||
$row[] = $attempt->attempt;
|
||||
}
|
||||
}
|
||||
|
||||
// prepare strings for time taken and date completed
|
||||
|
@ -239,8 +254,7 @@
|
|||
|
||||
if ($markcolumn && $attempt->timefinish > 0) {
|
||||
if ($attemptoptions->scores) {
|
||||
$row[] = $accessmanager->make_review_link(quiz_format_grade($quiz, $attempt->sumgrades),
|
||||
$attempt, $canpreview, $attemptoptions);
|
||||
$row[] = quiz_format_grade($quiz, $attempt->sumgrades);
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
@ -258,12 +272,14 @@
|
|||
$table->rowclass[$attempt->attempt] = 'bestrow';
|
||||
}
|
||||
|
||||
$row[] = $accessmanager->make_review_link($formattedgrade, $attempt, $canpreview, $attemptoptions);
|
||||
$row[] = $formattedgrade;
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$row[] = $accessmanager->make_review_link($attempt, $canpreview, $attemptoptions);
|
||||
|
||||
if ($feedbackcolumn && $attempt->timefinish > 0) {
|
||||
if ($attemptoptions->overallfeedback) {
|
||||
$row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id);
|
||||
|
|
|
@ -1036,6 +1036,9 @@ table.message_search_results td {
|
|||
table.quizattemptsummary .bestrow td {
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
table.quizattemptsummary .noreviewmessage {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
#mod-quiz-attempt #quiz-timer-outer {
|
||||
border-color: #dddddd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue