MDL-20636 Fix for Bug 11593 merged from our 1.9 version. #268

This commit is contained in:
Tim Hunt 2011-03-16 14:34:19 +00:00
parent 9f622ce7d8
commit 6d03fd9830
9 changed files with 23 additions and 14 deletions

View File

@ -168,7 +168,7 @@ foreach ($quizzes as $quiz) {
$grade = '';
$feedback = '';
if ($quiz->grade && array_key_exists($quiz->id, grades)) {
if ($alloptions->marks) {
if ($alloptions->marks >= question_display_options::MARK_AND_MAX) {
$a = new stdClass();
$a->grade = quiz_format_grade($quiz, $grades[$quiz->id]);
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade);

View File

@ -606,10 +606,12 @@ function quiz_grade_item_update($quiz, $grades = NULL) {
mod_quiz_display_options::LATER_WHILE_OPEN);
$closedreviewoptions = mod_quiz_display_options::make_from_quiz($quiz,
mod_quiz_display_options::AFTER_CLOSE);
if (!$openreviewoptions->marks && !$closedreviewoptions->marks) {
if ($openreviewoptions->marks < question_display_options::MARK_AND_MAX &&
$closedreviewoptions->marks < question_display_options::MARK_AND_MAX) {
$params['hidden'] = 1;
} else if (!$openreviewoptions->marks && $closedreviewoptions->marks) {
} else if ($openreviewoptions->marks < question_display_options::MARK_AND_MAX &&
$closedreviewoptions->marks >= question_display_options::MARK_AND_MAX) {
if ($quiz->timeclose) {
$params['hidden'] = $quiz->timeclose;
} else {
@ -810,7 +812,7 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
$tmpactivity->content->attemptid = $attempt->id;
$tmpactivity->content->attempt = $attempt->attempt;
if (quiz_has_grades($quiz) && $options->marks) {
if (quiz_has_grades($quiz) && $options->marks >= question_display_options::MARK_AND_MAX) {
$tmpactivity->content->sumgrades = quiz_format_grade($quiz, $attempt->sumgrades);
$tmpactivity->content->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);
} else {

View File

@ -1043,13 +1043,16 @@ function quiz_get_review_options($quiz, $attempt, $context) {
* for all attempts.
*/
function quiz_get_combined_reviewoptions($quiz, $attempts) {
$fields = array('marks', 'feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
$fields = array('feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
$someoptions = new stdClass();
$alloptions = new stdClass();
foreach ($fields as $field) {
$someoptions->$field = false;
$alloptions->$field = true;
}
$someoptions->marks = question_display_options::HIDDEN;
$alloptions->marks = question_display_options::MARK_AND_MAX;
foreach ($attempts as $attempt) {
$attemptoptions = mod_quiz_display_options::make_from_quiz($quiz,
quiz_attempt_state($quiz, $attempt));
@ -1057,6 +1060,8 @@ function quiz_get_combined_reviewoptions($quiz, $attempts) {
$someoptions->$field = $someoptions->$field || $attemptoptions->$field;
$alloptions->$field = $alloptions->$field && $attemptoptions->$field;
}
$someoptions->marks = max($someoptions->marks, $attemptoptions->marks);
$alloptions->marks = min($alloptions->marks, $attemptoptions->marks);
}
return array($someoptions, $alloptions);
}

View File

@ -63,7 +63,8 @@ abstract class quiz_attempt_report extends quiz_default_report {
}
$reviewoptions = mod_quiz_display_options::make_from_quiz($quiz, $when);
$this->showgrades = quiz_has_grades($quiz) && ($reviewoptions->marks ||
$this->showgrades = quiz_has_grades($quiz) &&
($reviewoptions->marks >= question_display_options::MARK_AND_MAX ||
has_capability('moodle/grade:viewhidden', $this->context));
return $this->showgrades;

View File

@ -176,7 +176,7 @@ if ($page == 0) {
// Show marks (if the user is allowed to see marks at the moment).
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz, false);
if ($options->marks && quiz_has_grades($quiz)) {
if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades($quiz)) {
if (!$attempt->timefinish) {
$rows[] = '<tr><th scope="row" class="cell">' . get_string('grade') . '</th><td class="cell">' .

View File

@ -102,7 +102,7 @@ $table->attributes['class'] = 'generaltable quizsummaryofattempt boxaligncenter'
$table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
$table->align = array('left', 'left');
$table->size = array('', '');
$markscolumn = $displayoptions->marks;
$markscolumn = $displayoptions->marks >= question_display_options::MARK_AND_MAX;
if ($markscolumn) {
$table->head[] = get_string('marks', 'quiz');
$table->align[] = 'left';

View File

@ -170,9 +170,9 @@ if ($attempts) {
$attemptcolumn = $quiz->attempts != 1;
$gradecolumn = $someoptions->marks && quiz_has_grades($quiz);
$gradecolumn = $someoptions->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades($quiz);
$markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades);
$overallstats = $alloptions->marks;
$overallstats = $alloptions->marks >= question_display_options::MARK_AND_MAX;
$feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback;
@ -248,7 +248,7 @@ if ($attempts) {
$row[] = $datecompleted;
if ($markcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->marks) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX) {
$row[] = quiz_format_grade($quiz, $attempt->sumgrades);
} else {
$row[] = '';
@ -259,7 +259,7 @@ if ($attempts) {
$attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz, false);
if ($gradecolumn) {
if ($attemptoptions->marks && $attempt->timefinish > 0) {
if ($attemptoptions->marks >= question_display_options::MARK_AND_MAX && $attempt->timefinish > 0) {
$formattedgrade = quiz_format_grade($quiz, $attemptgrade);
// highlight the highest grade if appropriate
if ($overallstats && !$attempt->preview && $numattempts > 1 && !is_null($mygrade) &&

View File

@ -53,7 +53,8 @@ class qbehaviour_adaptive_renderer extends qbehaviour_renderer {
// Try to find the last graded step.
$gradedstep = $this->get_graded_step($qa);
if (is_null($gradedstep) || $qa->get_max_mark() == 0 || !$options->marks) {
if (is_null($gradedstep) || $qa->get_max_mark() == 0 ||
$options->marks < question_display_options::MARK_AND_MAX) {
return '';
}

View File

@ -85,7 +85,7 @@ class qbehaviour_deferredcbm_renderer extends qbehaviour_renderer {
question_cbm::get_string($qa->get_last_behaviour_var('_assumedcertainty'))));
}
if ($options->marks) {
if ($options->marks >= question_display_options::MARK_AND_MAX) {
$a->rawmark = format_float(
$qa->get_last_behaviour_var('_rawfraction') * $qa->get_max_mark(), $options->markdp);
$a->mark = $qa->format_mark($options->markdp);