]> git.mjollnir.org Git - moodle.git/commitdiff
fixing broken headers
authortoyomoyo <toyomoyo>
Tue, 17 Jul 2007 03:32:10 +0000 (03:32 +0000)
committertoyomoyo <toyomoyo>
Tue, 17 Jul 2007 03:32:10 +0000 (03:32 +0000)
grade/export/ods/index.php
grade/export/txt/index.php
grade/export/xls/index.php
grade/export/xml/index.php
grade/import/csv/index.php
grade/import/lib.php
grade/import/xml/index.php

index 97625668bed08e1dabb7a0be4db278e9c7cd9e56..070bbc52eb5ca4804e59a56391c9125a44bee937 100755 (executable)
@@ -28,8 +28,12 @@ require_once('grade_export_ods.php');
 $id = required_param('id', PARAM_INT); // course id 
 $course = get_record('course', 'id', $id);
 $feedback = optional_param('feedback', '', PARAM_ALPHA);   
-$action = 'exportods';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('exportods', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
 
index b0bd0fafa2738773ce8c2297c3ef9c7e45bcbea9..6617f91f236b9e078edf1425a8e7e63bc6db7712 100755 (executable)
@@ -28,8 +28,12 @@ require_once('grade_export_txt.php');
 $id = required_param('id', PARAM_INT); // course id
 $feedback = optional_param('feedback', '', PARAM_ALPHA);
 $course = get_record('course', 'id', $id);
-$action = 'exporttxt'; // for printing header
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('exporttxt', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
index cc152c8fd8520e923e96b5020cc19b19e70e5d03..f23f6becf84d012964e2c5946a857e04b8de5f45 100755 (executable)
@@ -29,8 +29,12 @@ $id = required_param('id', PARAM_INT); // course id
 $course = get_record('course', 'id', $id);
 $feedback = optional_param('feedback', '', PARAM_ALPHA);
 
-$action = 'exporttxt';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('exportxls', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
index 0045e0a046d99d3d58d7060229e6aecb599493d4..b65f52e4f837e2241da701d88377f9487a909825 100755 (executable)
@@ -29,8 +29,12 @@ $id = required_param('id', PARAM_INT); // course id
 $course = get_record('course', 'id', $id);
 $feedback = optional_param('feedback', '', PARAM_ALPHA);
     
-$action = 'exportxml';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('exportxml', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
index 146b9556ddbb434a65517439ac504046b721a1f2..6782547ee294fa671a7f3c1219c6856424657bcf 100755 (executable)
@@ -28,8 +28,12 @@ if (isset($CFG->CSV_DELIMITER)) {
     $csv_delimiter2 = ",";
 }
 
-$action = 'importcsv';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('importcsv', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 
 $mform = new grade_import_form();
 //$mform2 = new grade_import_mapping_form();
@@ -52,8 +56,9 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
         error ('could not open file '.$filename);  
     }
     
+    $map = array();
     // loops mapping_0, mapping_1 .. mapping_n and construct $map array
-    foreach ($header as $i=>$head) {
+    foreach ($header as $i => $head) {
         $map[$i] = $formdata->{'mapping_'.$i};      
     }
 
@@ -208,7 +213,15 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
                                 $status = false;
                                 import_cleanup($importcode);
                                 notify(get_string('importfailed', 'grades'));
-                                break 3;                             
+                                break 3;
+                            }
+                            
+                            // check if grade item is locked if so, abort
+                            if ($gradeitem->locked) {
+                                $status = false;
+                                import_cleanup($importcode);
+                                notify(get_string('gradeitemlocked', 'grades'));
+                                break 3;  
                             }
 
                             unset($newgrade);
@@ -217,7 +230,7 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
                             $newgrades[] = $newgrade;
                         } // otherwise, we ignore this column altogether 
                           // because user has chosen to ignore them (e.g. institution, address etc)
-                    break;  
+                    break;
                 }
             }
 
@@ -227,21 +240,33 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
                 $status = false;
                 import_cleanup($importcode);
                 notify('user mapping error, could not find user!');
-                break; 
+                break;
             }
 
             // insert results of this students into buffer
             if (!empty($newgrades)) {
               
                 foreach ($newgrades as $newgrade) {
+                  
+                    // check if grade_grades is locked and if so, abort
+                    if ($grade_grades = new grade_grades(array('itemid'=>$newgrade->itemid, 'userid'=>$studentid))) {
+                        if ($grade_grades->locked) {
+                            // individual grade locked
+                            $status = false;
+                            import_cleanup($importcode);
+                            notify(get_string('gradegradeslocked', 'grades'));
+                            break 2;
+                        }
+                    }
+
                     $newgrade->import_code = $importcode;
                     $newgrade->userid = $studentid;
                     if (!insert_record('grade_import_values', $newgrade)) {
                         // could not insert into temporary table
                         $status = false;
                         import_cleanup($importcode);
-                        notify(get_string('importfailed', 'grades'));   
-                        break 2;                   
+                        notify(get_string('importfailed', 'grades'));
+                        break 2;
                     }
                 }
             }
@@ -256,11 +281,10 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
                         // the grade item for this is not updated
                         $newfeedback->import_code = $importcode;
                         $newfeedback->userid = $studentid;
-                        insert_record('grade_import_values', $newfeedback);  
+                        insert_record('grade_import_values', $newfeedback);
                     }
                 }
             }
-            
         }
 
         /// at this stage if things are all ok, we commit the changes from temp table 
index 93ae6459cf01cff36c555137d4f8615b1910f158..5fb1a0c4a81488c27e772f4b6bc7bcfddc1d5b4e 100755 (executable)
@@ -74,9 +74,9 @@ function grade_import_commit($courseid, $importcode) {
                     return false;
                 }
             }
-        } 
+        }
     }
-        
+
     /// then find all existing items
 
     if ($gradeitems = get_records_sql("SELECT DISTINCT (itemid) 
@@ -95,26 +95,26 @@ function grade_import_commit($courseid, $importcode) {
             }
             // get all grades with this item
             if ($grades = get_records('grade_import_values', 'itemid', $itemid)) {
-                
+
                 // make the grardes array for update_grade
                 foreach ($grades as $grade) {
                     if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, NULL, NULL, $grade->feedback)) {
                         $failed = 1;
-                        break 2; 
+                        break 2;
                     }
                 }
-                //$itemdetails -> idnumber = $gradeitem->idnumber;                
-                $modifieditems[] = $itemid;                                      
+                //$itemdetails -> idnumber = $gradeitem->idnumber;
+                $modifieditems[] = $itemid;
 
-            }                    
+            }
                 
             if (!empty($failed)) {
                 import_cleanup($importcode);
-                return false;        
-            }      
+                return false;
+            }
         }
     }
-    
+
     notify(get_string('importsuccess', 'grades'));
     print_continue($CFG->wwwroot.'/course/view.php?id='.$courseid);
     // clean up
@@ -127,9 +127,9 @@ function grade_import_commit($courseid, $importcode) {
  * @param string importcode - import batch identifier
  */
 function import_cleanup($importcode) {
-    // remove entries from buffer table 
+    // remove entries from buffer table
     delete_records('grade_import_values', 'import_code', $importcode);
-    delete_records('grade_import_newitem', 'import_code', $importcode);  
+    delete_records('grade_import_newitem', 'import_code', $importcode);
 }
 
 /// Returns the file as one big long string
index 3e37a94e691b117ae7d5458330f3815ec7ea6afe..a2478d22232e377c50e148e6fed46a280dcb57df 100755 (executable)
@@ -16,8 +16,12 @@ require_once('../lib.php');
 require_once('../grade_import_form.php');
 require_once($CFG->dirroot.'/grade/lib.php');
 
-$action = 'importxml';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+$strgrades = get_string('grades', 'grades');
+$actionstr = get_string('importxml', 'grades');
+$gradenav = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>";
+$gradenav .= " -> <a href=\"$CFG->wwwroot/grade/index.php?id=$course->id\">$strgrades</a>";
+$gradenav .= " -> $actionstr";
+print_header($course->shortname.': '.get_string('grades'), $course->fullname, $gradenav);
 
 $mform = new grade_import_form();