Display Total Autograded marks in review attempt report before grading answers manually

Display Total Autograded marks in review attempt report before grading answers manually

by Shahab Mohd -
Number of replies: 3

Moodle Version : 2.6

We have quizzes which are having both manually graded and autograded questions in a single quiz. After the quiz is attempted and before manual grading is done, Grade summary column in mod/quiz/review.php shows the message "Not yet graded"


Is it possible to  change the grade row to display as 

" Not yet graded ( Total auto graded marks : xx)"  

by calculating the autograded questions before the manual graded are submitted ?

 If it is possible,  can somebody help me on how to change the codes?

Moodle Version : 2.6

Thanking you

Average of ratings: -
In reply to Shahab Mohd

Re: Display Total Autograded marks in review attempt report before grading answers manually

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You would need to change review.php, the bit that prepares the data for that table: https://github.com/moodle/moodle/blob/master/mod/quiz/review.php#L186

You would need to copy the for loop out of question_usage::get_total_mark(), and change the calculation to treat needs_grading as 0, rather than aborting the calculation. https://github.com/moodle/moodle/blob/master/question/engine/questionusage.php#L363. ($attemptobj->get_quba() will give you the usage object.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Display Total Autograded marks in review attempt report before grading answers manually

by Shahab Mohd -
Thanks Tim,

As you advised I copied the loop out of question_usage::get_total_mark(), and changed the calculation to treat needs_grading as 0, rather than aborting the calculation.

But now if there is a needs_grading answer , the review page appears as blank. 


if ($attempt->state != quiz_attempt::FINISHED) {
        // Cannot display grade.

    } else if (is_null($grade)) {
		$mark=0;
		foreach ($this->questionattempts as $qa) {
            if ($qa->get_max_mark() > 0 && $qa->get_state() == question_state::$needsgrading) {
                $mark += 0;
            }
            $mark += $qa->get_mark();
        }
					
        $summarydata['grade'] = array(
            'title'   => get_string('grade', 'quiz'),
            'content' => quiz_format_grade($quiz, $grade . $mark)  //$ grade = null will return notyetgraded string
			);

Debug message shows the following error

Fatal error: Using $this when not in object context in \mod\quiz\review.php on line 194


In reply to Shahab Mohd

Re: Display Total Autograded marks in review attempt report before grading answers manually

by Shahab Mohd -
Hope some body can help me on object usage  in the above context  as Tim advised.  

. I searched and tried several methods but was unsuccessful. I am new to php and moodle programming

$attemptobj->get_quba()