Unable to update to 3.7.2+ from 3.7.1 due to local changes?

Unable to update to 3.7.2+ from 3.7.1 due to local changes?

by Raymond Frangie -
Number of replies: 2
When trying to perform a git pull on the moodle directory to download the latest updates, I get the following error:

Updating 79bd60b..8b89ab5
 error: Your local changes to the following files would be overwritten by merge:
 {{ mod/quiz/review.php}}
 Please, commit your changes or stash them before you can merge.
 Aborting

I have not performed any local changes to this file, I have no idea what these changes are. Performing a git diff on this file, I get the following:

diff --git a/mod/quiz/review.php b/mod/quiz/review.php
 index 28e94b0..e2f640c 100644
 --- a/mod/quiz/review.php
 +++ b/mod/quiz/review.php
 @@ -187,6 +187,17 @@ if (!empty($overtime)) {
{{ // Show marks (if the user is allowed to see marks at the moment).}}
 {{ $grade = quiz_rescale_grade($attempt->sumgrades, $quiz, false);}}
 +$additional_summary_data = $attemptobj->get_additional_summary_data($options);
 +$cbmattempt = array_key_exists('cbmdata',$additional_summary_data);
 +if($cbmattempt) {
 + $cbmdata = $additional_summary_data['cbmdata'];
 + //Scale CB grade to $quiz->grade
 + $a = new stdClass();
 + $a->grade = html_writer::tag('b', quiz_format_grade($quiz, $cbmdata['cbgradefraction'] * $quiz->grade));
 + $a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
 + $formattedgrade = get_string('cbgradeoutof', 'qbehaviour_deferredcbm', $a);
 + $additional_summary_data['qbehaviour_cbm_entire_quiz_cb_grade']['content'] = $formattedgrade;
 +}
 {{ if ($options->marks >= question_display_options::MARK_AND_MAX && quiz_has_grades($quiz)) {}}
{{ if ($attempt->state != quiz_attempt::FINISHED) {}}
 @@ 199,10 +210,42 @@ if ($options>marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
 {{ );}}
{{ } else {}}
 + // Default values without CBM
 + $marks = $attempt->sumgrades;
 + $showgrade = $grade;
 + $percent = $marks * 100 / $quiz->sumgrades;
 + // Handle if quiz and/or attempt use CBM
 + $cbmquiz = ($quiz->preferredbehaviour === 'immediatecbm') || ($quiz->preferredbehaviour === 'deferredcbm');
 + if ($cbmattempt) {
 + // Attempt was done with CBM
 + if ($cbmquiz) {
 + $marks = $cbmdata['averagecbm'] * $quiz->sumgrades;
 + $showgrade = $cbmdata['gradefraction'] * $quiz->grade;
 + $percent = $cbmdata['gradefraction'] * 100;
 {{+ }}}
 + else {
 + $marks = $cbmdata['accuracy'] * $quiz->sumgrades;
 + $showgrade = $cbmdata['accuracy'] * $quiz->grade;
 + $percent = $cbmdata['accuracy'] * 100;
 + $additional_summary_data['qbehaviour_cbm_grade_explanation'] = array(
 + 'title' => '',
 + 'content' => get_string('attemptwithcbm', 'qbehaviour_deferredcbm'),
 + );
 {{+ }}}
 {{+ }}}
 + else {
 + if ($cbmquiz) {
 + $additional_summary_data['qbehaviour_cbm_grade_explanation'] = array(
 + 'title' => '',
 + 'content' => get_string('attemptwithoutcbm', 'qbehaviour_deferredcbm'),
 + );
 {{+ }}}
 {{+ }}}
 +
 {{ // Show raw marks only if they are different from the grade (like on the view page).}}
 {{ if ($quiz->grade != $quiz->sumgrades) {}}
 {{ $a = new stdClass();}}
 - $a->grade = quiz_format_grade($quiz, $attempt->sumgrades);
 + $a->grade = quiz_format_grade($quiz, $marks);
 {{ $a->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);}}
 {{ $summarydata['marks'] = array(}}
 {{ 'title' => get_string('marks', 'quiz'),}}
 @@ 212,11 +255,11 @@ if ($options>marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
{{ // Now the scaled grade.}}
 {{ $a = new stdClass();}}
 - $a->grade = html_writer::tag('b', quiz_format_grade($quiz, $grade));
 + $a->grade = html_writer::tag('b', quiz_format_grade($quiz, $showgrade));
 {{ $a->maxgrade = quiz_format_grade($quiz, $quiz->grade);}}
 {{ if ($quiz->grade != 100) {}}
 {{ $a->percent = html_writer::tag('b', format_float(}}
 - $attempt->sumgrades * 100 / $quiz->sumgrades, 0));
 + $percent, 0));
 {{ $formattedgrade = get_string('outofpercent', 'quiz', $a);}}
 {{ } else {}}
 {{ $formattedgrade = get_string('outof', 'quiz', $a);}}
 @@ 229,7 +272,7 @@ if ($options>marks >= question_display_options::MARK_AND_MAX && quiz_has_grades
 {{ }}}
{{ // Any additional summary data from the behaviour.}}
 $summarydata = array_merge($summarydata, $attemptobj>get_additional_summary_data($options));
 +$summarydata = array_merge($summarydata, $additional_summary_data);
{{ // Feedback if there is any, and the user is allowed to see it now.}}
 {{ $feedback = $attemptobj->get_overall_feedback($grade);}}
 
I'm not sure what has changed or how to resolve this.

Your prompt assistance is greatly appreciated.

Cheers,
Ray


Average of ratings: -
In reply to Raymond Frangie

Re: Unable to update to 3.7.2+ from 3.7.1 due to local changes?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Looking at the code for that file for both versions... I've not done a comprehensive search but neither version appears to contain the changes you have above.

With respect, that file didn't change itself.

You have two options, to my mind...

1. Assume that someone/somehow has changed that file and revert it. The command you want is...

git checkout mod/quiz/review.php

...then try again.

2. Take the view that your code is in an undefined/unexplained state and pull a completely clean copy of 3.7.2.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Unable to update to 3.7.2+ from 3.7.1 due to local changes?

by Raymond Frangie -
Thanks Howard, the checkout command worked and the update has now completed successfully.

Cheers,
Ray