public function test_quiz_get_grade_format()
 {
     $quiz = new stdClass();
     $quiz->decimalpoints = 2;
     $this->assertEquals(quiz_get_grade_format($quiz), 2);
     $this->assertEquals($quiz->questiondecimalpoints, -1);
     $quiz->questiondecimalpoints = 2;
     $this->assertEquals(quiz_get_grade_format($quiz), 2);
     $quiz->decimalpoints = 3;
     $quiz->questiondecimalpoints = -1;
     $this->assertEquals(quiz_get_grade_format($quiz), 3);
     $quiz->questiondecimalpoints = 4;
     $this->assertEquals(quiz_get_grade_format($quiz), 4);
 }
Beispiel #2
0
/**
 * Round a grade to the correct number of decimal places, and format it for display.
 *
 * @param object $quiz The quiz table row, only $quiz->decimalpoints is used.
 * @param float $grade The grade to round.
 * @return float
 */
function quiz_format_question_grade($quiz, $grade)
{
    return format_float($grade, quiz_get_grade_format($quiz));
}
Beispiel #3
0
 /**
  * Get the number of decimal places for displyaing question marks.
  * @return int the number of decimal places.
  */
 public function get_decimal_places_for_question_marks()
 {
     return quiz_get_grade_format($this->get_quiz());
 }
 /**
  * Display the 'marked out of' information for a question.
  * Along with the regrade action.
  * @param \stdClass $quiz the quiz settings from the database.
  * @param \stdClass $question data from the question and quiz_slots tables.
  * @return string HTML to output.
  */
 public function marked_out_of_field($quiz, $question)
 {
     if ($question->length == 0) {
         $output = html_writer::span('', 'instancemaxmark decimalplaces_' . quiz_get_grade_format($quiz));
         $output .= html_writer::span($this->pix_icon('spacer', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), 'editing_maxmark');
         return html_writer::span($output, 'instancemaxmarkcontainer infoitem');
     }
     $output = html_writer::span(quiz_format_question_grade($quiz, $question->maxmark), 'instancemaxmark decimalplaces_' . quiz_get_grade_format($quiz), array('title' => get_string('maxmark', 'quiz')));
     $output .= html_writer::span(html_writer::link(new \moodle_url('#'), $this->pix_icon('t/editstring', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), array('class' => 'editing_maxmark', 'data-action' => 'editmaxmark', 'title' => get_string('editmaxmark', 'quiz'))));
     return html_writer::span($output, 'instancemaxmarkcontainer');
 }