@@ -1095,33 +1095,49 @@ function quiz_review_option_form_to_db($fromform, $field) {
10951095}
10961096
10971097/**
1098- * In place editable callback for slot displaynumber .
1098+ * In place editable callback to quiz slots .
10991099 *
1100- * @param string $itemtype slotdisplarnumber
1100+ * @param string $itemtype the slot type
11011101 * @param int $itemid the id of the slot in the quiz_slots table
1102- * @param string $newvalue the new value for displaynumber field for a given slot in the quiz_slots table
1102+ * @param string $newvalue the new value for a given slot in the quiz_slots table
11031103 * @return \core\output\inplace_editable|void
11041104 */
11051105function mod_quiz_inplace_editable (string $ itemtype , int $ itemid , string $ newvalue ): \core \output \inplace_editable {
11061106 global $ DB ;
11071107
1108- if ($ itemtype === 'slotdisplaynumber ' ) {
1109- // Work out which quiz and slot this is.
1110- $ slot = $ DB ->get_record ('quiz_slots ' , ['id ' => $ itemid ], '* ' , MUST_EXIST );
1111- $ quizobj = quiz_settings::create ($ slot ->quizid );
1108+ // Work out which quiz and slot this is.
1109+ $ slot = $ DB ->get_record ('quiz_slots ' , ['id ' => $ itemid ], '* ' , MUST_EXIST );
1110+ $ quizobj = quiz_settings::create ($ slot ->quizid );
1111+
1112+ // Validate the context, and check the required capability.
1113+ $ context = $ quizobj ->get_context ();
1114+ \core_external \external_api::validate_context ($ context );
1115+ require_capability ('mod/quiz:manage ' , $ context );
11121116
1113- // Validate the context, and check the required capability.
1114- $ context = $ quizobj ->get_context ();
1115- \core_external \external_api::validate_context ($ context );
1116- require_capability ('mod/quiz:manage ' , $ context );
1117+ $ structure = $ quizobj ->get_structure ();
11171118
1119+ if ($ itemtype === 'slotdisplaynumber ' ) {
11181120 // Update the value - truncating the size of the DB column.
1119- $ structure = $ quizobj ->get_structure ();
11201121 $ structure ->update_slot_display_number ($ itemid , core_text::substr ($ newvalue , 0 , 16 ));
11211122
11221123 // Prepare the element for the output.
11231124 return $ structure ->make_slot_display_number_in_place_editable ($ itemid , $ context );
11241125 }
1126+ if ($ itemtype === 'slotmaxmark ' ) {
1127+ if ($ structure ->update_slot_maxmark ($ slot , $ newvalue )) {
1128+ // Grade has really changed.
1129+ $ gradecalculator = $ quizobj ->get_grade_calculator ();
1130+ quiz_delete_previews ($ quizobj ->get_quiz ());
1131+ $ gradecalculator ->recompute_quiz_sumgrades ();
1132+ $ gradecalculator ->recompute_all_attempt_sumgrades ();
1133+ $ gradecalculator ->recompute_all_final_grades ();
1134+ quiz_update_grades ($ quizobj ->get_quiz ());
1135+ }
1136+
1137+ // Prepare the element for the output - reload structure to ensure totals are correct.
1138+ $ structure = $ quizobj ->get_structure ();
1139+ return $ structure ->make_slot_maxmark_in_place_editable ($ itemid , $ context );
1140+ }
11251141}
11261142
11271143/**
0 commit comments