]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11282 Using notice_yesno(), but not sure how to provide a backlink with the cance...
authornicolasconnault <nicolasconnault>
Fri, 14 Sep 2007 19:32:50 +0000 (19:32 +0000)
committernicolasconnault <nicolasconnault>
Fri, 14 Sep 2007 19:32:50 +0000 (19:32 +0000)
lang/en_utf8/grades.php
lib/gradelib.php
mod/quiz/lib.php

index 0fd5eab7044e92e596510ebcd0e4c58c1b9d5074..01575ac17dc03bc5f1288b2e9ee05c9c901c44fe 100644 (file)
@@ -163,6 +163,7 @@ $string['gradeexceptions'] = 'Grade Exceptions';
 $string['gradeexceptionshelp'] = 'Grade Exceptions Help';
 $string['gradehelp'] = 'Grade Help';
 $string['gradeitem'] = 'Grade item';
+$string['gradeitemislocked'] = 'This activity is locked in the gradebook. If you regrade it, the grades held internally by this activity will be different from the ones in the gradebook, the latter which will remain unchanged. Are you sure you want to proceed with the regrading?';
 $string['gradeitemlocked'] = 'Grading locked';
 $string['gradeitemsinc'] = 'Grade items to be included';
 $string['gradeitemaddusers'] = 'Exclude from Grading';
index 6b92779d853cc8c1dbbb5bca6117d528222b0309..7e73029f4dd9d1011ea7cdc7e2ea16daba255b15 100644 (file)
@@ -98,6 +98,7 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance,
     }
 
 /// Create or update the grade_item if needed
+
     if (!$grade_item) {
         if ($itemdetails) {
             $itemdetails = (array)$itemdetails;
@@ -127,8 +128,14 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance,
 
     } else {
         if ($grade_item->is_locked()) {
-            debugging('Grading item is locked!');
-            return GRADE_UPDATE_ITEM_LOCKED;
+            $confirm_regrade = optional_param('confirm_regrade', 0, PARAM_INT);
+            if (!$confirm_regrade) {
+                $message = get_string('gradeitemislocked', 'grades', $grade_item->itemname);
+                $back_link = '';
+                $regrade_link = qualified_me() . '&amp;confirm_regrade=1';
+                notice_yesno($message, $regrade_link, $back_link);
+                return GRADE_UPDATE_ITEM_LOCKED;
+            }
         }
 
         if ($itemdetails) {
index dd23884a58357c03c70d1fa6ba5a5198f9be30aa..484506dfbbd58958358164f63db9cc2cdabbb376 100644 (file)
@@ -17,11 +17,11 @@ require_once($CFG->libdir.'/questionlib.php');
 /**#@+
  * The different review options are stored in the bits of $quiz->review
  * These constants help to extract the options
- * 
+ *
  * This is more of a mess than you might think necessary, because originally
  * it was though that 3x6 bits were enough, but then they ran out. PHP integers
  * are only reliably 32 bits signed, so the simplest solution was then to
- * add 4x3 more bits. 
+ * add 4x3 more bits.
  */
 /**
  * The first 6 + 4 bits refer to the time immediately after the attempt
@@ -561,7 +561,7 @@ function quiz_print_recent_mod_activity($activity, $course, $detail=false) {
 /**
  * Pre-process the quiz options form data, making any necessary adjustments.
  * Called by add/update instance in this file, and the save code in admin/module.php.
- * 
+ *
  * @param object $quiz The variables set on the form.
  */
 function quiz_process_options(&$quiz) {
@@ -598,7 +598,7 @@ function quiz_process_options(&$quiz) {
                 $quiz->feedbacktext[$i] = trim($quiz->feedbacktext[$i]);
             }
         }
-    
+
         // Check the boundary value is a number or a percentage, and in range.
         $i = 0;
         while (!empty($quiz->feedbackboundaries[$i])) {
@@ -623,7 +623,7 @@ function quiz_process_options(&$quiz) {
             $i += 1;
         }
         $numboundaries = $i;
-    
+
         // Check there is nothing in the remaining unused fields.
         for ($i = $numboundaries; $i < count($quiz->feedbackboundaries); $i += 1) {
             if (!empty($quiz->feedbackboundaries[$i]) && trim($quiz->feedbackboundaries[$i]) != '') {
@@ -846,7 +846,7 @@ function quiz_question_list_instances($questionid) {
 /**
  * Implementation of the function for printing the form elements that control
  * whether the course reset functionality affects the quiz.
- * @param $course The course id of the course the user is thinking of resetting. 
+ * @param $course The course id of the course the user is thinking of resetting.
  */
 function quiz_reset_course_form($course) {
     echo '<p>';
@@ -859,19 +859,19 @@ function quiz_reset_course_form($course) {
  * quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
  * set and true.
  * @param $data the data submitted from the reset course forum.
- * @param $showfeedback whether to output progress information as the reset 
+ * @param $showfeedback whether to output progress information as the reset
  *      progresses.
  */
 function quiz_delete_userdata($data, $showfeedback=true) {
     global $CFG;
-    
+
     if (empty($data->reset_quiz_attempts)) {
         return;
     }
-    
+
     $conditiononquizids = 'quiz IN (SELECT id FROM ' .
             $CFG->prefix . 'quiz q WHERE q.course = ' . $data->courseid . ')';
-    
+
     $attemptids = get_records_select('quiz_attempts', $conditiononquizids, '', 'id, uniqueid');
     if ($attemptids) {
         if ($showfeedback) {
@@ -900,18 +900,18 @@ function quiz_delete_userdata($data, $showfeedback=true) {
 /**
  * Checks whether the current user is allowed to view a file uploaded in a quiz.
  * Teachers can view any from their courses, students can only view their own.
- * 
+ *
  * @param int $attemptid int attempt id
  * @param int $questionid int question id
- * @return boolean to indicate access granted or denied  
+ * @return boolean to indicate access granted or denied
  */
 function quiz_check_file_access($attemptid, $questionid) {
     global $USER;
-    
+
     $attempt = get_record("quiz_attempts", 'id', $attemptid);
     $quiz = get_record("quiz", 'id', $attempt->quiz);
     $context = get_context_instance(CONTEXT_COURSE, $quiz->course);
-    
+
     // access granted if the current user submitted this file
     if ($attempt->userid == $USER->id) {
         return true;
@@ -919,8 +919,8 @@ function quiz_check_file_access($attemptid, $questionid) {
     } else if (has_capability('mod/quiz:viewreports', $context) || has_capability('mod/quiz:grade', $context)) {
         return true;
     }
-    
-    // otherwise, this user does not have permission    
+
+    // otherwise, this user does not have permission
     return false;
 }
 ?>