]> git.mjollnir.org Git - moodle.git/commitdiff
some minor cleanup/bug fix
authortoyomoyo <toyomoyo>
Tue, 3 Jul 2007 06:20:07 +0000 (06:20 +0000)
committertoyomoyo <toyomoyo>
Tue, 3 Jul 2007 06:20:07 +0000 (06:20 +0000)
grade/export/grade_export_form.php
grade/export/lib.php
grade/export/ods/export.php
grade/export/ods/index.php
grade/export/txt/export.php
grade/export/txt/grade_export_txt_form.php
grade/export/txt/index.php
grade/export/xls/export.php
grade/export/xls/index.php
grade/export/xml/export.php
grade/export/xml/index.php

index dfda9fd6a9d1bfa38c7afc5b7cd0d2c802497b44..9326fea5221461a5b35093c15297a728d45fc426 100755 (executable)
@@ -9,7 +9,7 @@ class grade_export_form extends moodleform {
         $mform->addElement('header', 'general', get_string('gradeitemsinc', 'grades')); // TODO: localize
         $id = $this->_customdata['id']; // course id
         $mform->addElement('hidden', 'id', $id);
-        if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) {
+        if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) {
             foreach ($grade_items as $grade_item) {
                 $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->itemname, array('selected'=>'selected'), array(0, $grade_item->id));
                 $element->setChecked(1);
index 9890271c33973d2320fd5e8441522c9267b7bc6e..46caa062a09de41466ac1c36a1d2642dc3cc3faf 100755 (executable)
@@ -121,7 +121,7 @@ class grade_export {
             foreach ($itemids as $iid) {
                 
                 if ($iid) {
-                    $params->id = $iid;
+                    $params->id = clean_param($iid, PARAM_INT);
                     $gradeitems[] = new grade_item($params);
                 }              
             }  
index 20fd2053b069cb25b21ede912d65e9a2a32e86aa..a6528764b93c8ebea40da2ee020e87aabc5b77f7 100755 (executable)
@@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_ods.php');
  
 $id = required_param('id', PARAM_INT); // course id
-$itemids = explode(",", required_param('itemids', PARAM_NOTAGS));
+$itemids = explode(",", required_param('itemids', PARAM_RAW));
 $feedback = optional_param('feedback', '', PARAM_ALPHA); 
  
 // print all the exported data here
index 706dd007252bead36b7efe0ba4e4b40b72c8150a..97625668bed08e1dabb7a0be4db278e9c7cd9e56 100755 (executable)
@@ -25,9 +25,11 @@ require_once("../../../config.php");
 require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_ods.php');
 
-$id = required_param('id', PARAM_INT); // course id
-$feedback = optional_param('feedback', '', PARAM_ALPHA);
-
+$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));
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
 
@@ -38,9 +40,6 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     }
         
     // print the grades on screen for feedbacks
-    $course = get_record('course', 'id', $id);
-    $action = 'exporttxt';
-    print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
     
     $export = new grade_export($id, $data->itemids);
     $export->display_grades($feedback);
@@ -49,9 +48,7 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
     exit; 
 }
-$course = get_record('course', 'id', $id);
-$action = 'exportods';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+
 print_gradeitem_selections($id);
 print_footer();
 ?>
\ No newline at end of file
index 635b19f826c408d87c89ec8da4915be37b2cb378..48e01f5d523abf6501419c4990fb4a27f3f28309 100755 (executable)
@@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_txt.php');
  
 $id = required_param('id', PARAM_INT); // course id
-$itemids = explode(",", required_param('itemids', PARAM_NOTAGS));
+$itemids = explode(",", required_param('itemids', PARAM_RAW));
 $feedback = optional_param('feedback', '', PARAM_ALPHA); 
  
 // print all the exported data here
index d27770108b02aa02a8ff4e61c8bc35780db69ed8..df752c5dda14698f8a112a48e9027fd5c0f7226d 100755 (executable)
@@ -9,7 +9,7 @@ class grade_export_txt_form extends moodleform {
         $mform->addElement('header', 'general', 'Gradeitems to be included'); // TODO: localize
         $id = $this->_customdata['id']; // course id
         $mform->addElement('hidden', 'id', $id);
-        if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) {
+        if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) {
             foreach ($grade_items as $grade_item) {
                 $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->itemname, array('selected'=>'selected'), array(0, $grade_item->id));
                 $element->setChecked(1);
index 6f93d3abb584a9dd2b5b89a82e35fd20f92f8394..b0bd0fafa2738773ce8c2297c3ef9c7e45bcbea9 100755 (executable)
@@ -27,19 +27,19 @@ 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));
 
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
 
+    // $itemids consists of ints and ",", will be cleaned in the main export class
     if (!is_array($data->itemids)) {
         $itemidsurl = $data->itemids;
     } else {
         $itemidsurl = implode(",",$data->itemids);
     }
-        
-    $course = get_record('course', 'id', $id);
-    $action = 'exporttxt';
-    print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
     
     $export = new grade_export($id, $data->itemids);
     $export->display_grades($feedback);
@@ -49,42 +49,10 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     exit; 
 }
 
-
-$course = get_record('course', 'id', $id);
-$action = 'exporttxt';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+// print the form to choose what grade_items to export
 include_once('grade_export_txt_form.php');
 $mform = new grade_export_txt_form(qualified_me(), array('id'=>$id));
 $mform->display();
 
-/*
-// print_gradeitem_selections($id);
-// print all items for selections
-// make this a standard function in lib maybe
-if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) {
-    echo '<form action="index.php" method="post">';
-    echo '<div>';
-    foreach ($grade_items as $grade_item) {
-            
-        echo '<br/><input type="checkbox" name="itemids[]" value="'.$grade_item->id.'" checked="checked"/>';
-            
-        if ($grade_item->itemtype == 'category') {
-            // grade categories should be displayed bold
-            echo '<b>'.$grade_item->itemname.'</b>';
-        } else {
-            echo $grade_item->itemname;
-        } 
-    }
-    echo '<br/>';
-    echo 'tab<input type="radio" name="separator" value="tab"/>';
-    echo 'comma<input type="radio" name="separator" value="comma" checked="checked"/>';
-    echo '<input type="hidden" name="id" value="'.$id.'"/>';
-    echo '<input type="hidden" name="sesskey" value="'.sesskey().'"/>';
-    echo '<br/>';
-    echo '<input type="submit" value="'.get_string('submit').'" />';
-    echo '</div>';
-    echo '</form>';
-}
-*/
 print_footer();
 ?>
\ No newline at end of file
index d734cb28327295266a7d6cb5f10c046f663ced23..a848cb5403561fe04a959e411edb6b143850dd0c 100755 (executable)
@@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_xls.php');
  
 $id = required_param('id', PARAM_INT); // course id
-$itemids = explode(",", required_param('itemids', PARAM_NOTAGS));
+$itemids = explode(",", required_param('itemids', PARAM_RAW));
 $feedback = optional_param('feedback', '', PARAM_ALPHA); 
  
 // print all the exported data here
index 30552c6c4d129ab7782978dd8aa3934b1ef3aa89..cc152c8fd8520e923e96b5020cc19b19e70e5d03 100755 (executable)
@@ -26,8 +26,12 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_xls.php');
 
 $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));
+
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
 
@@ -38,9 +42,6 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     }
         
     // print the grades on screen for feedbacks
-    $course = get_record('course', 'id', $id);
-    $action = 'exporttxt';
-    print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
     
     $export = new grade_export($id, $data->itemids);
     $export->display_grades($feedback);
@@ -49,9 +50,7 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
     exit; 
 }
-$course = get_record('course', 'id', $id);
-$action = 'exportxls';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+
 print_gradeitem_selections($id);
 print_footer();
 ?>
\ No newline at end of file
index d9b79f1884aaf225e898b6215136df992ffd7bd9..21876523afb3f4df56ca67b20269db52a87a7601 100755 (executable)
@@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_xml.php');
  
 $id = required_param('id', PARAM_INT); // course id
-$itemids = explode(",", required_param('itemids', PARAM_NOTAGS));
+$itemids = explode(",", required_param('itemids', PARAM_RAW));
 $feedback = optional_param('feedback', '', PARAM_ALPHA); 
  
 // print all the exported data here
index 280bf9a7a30ec6497890367f2c2a14548c5544de..0045e0a046d99d3d58d7060229e6aecb599493d4 100755 (executable)
@@ -25,8 +25,12 @@ require_once("../../../config.php");
 require_once($CFG->dirroot.'/grade/export/lib.php');
 require_once('grade_export_xml.php');
 
-$id = required_param('id', PARAM_INT); // course id
+$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));
 
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
@@ -38,10 +42,7 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     }
         
     // print the grades on screen for feedbacks
-    $course = get_record('course', 'id', $id);
-    $action = 'exportxml';
-    print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
-    
+   
     $export = new grade_export($id, $data->itemids);
     $export->display_grades($feedback);
     
@@ -49,9 +50,7 @@ if (($data = data_submitted()) && confirm_sesskey()) {
     redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
     exit;
 }
-$course = get_record('course', 'id', $id);
-$action = 'exportxml';
-print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
+
 print_gradeitem_selections($id);
 print_footer();
 ?>
\ No newline at end of file