]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10984 Added 3 elements to the Grade Export GUIs, and a stub for action to be...
authornicolasconnault <nicolasconnault>
Mon, 27 Aug 2007 12:23:50 +0000 (12:23 +0000)
committernicolasconnault <nicolasconnault>
Mon, 27 Aug 2007 12:23:50 +0000 (12:23 +0000)
grade/export/grade_export_form.php
grade/export/lib.php
grade/export/txt/grade_export_txt.php
grade/export/xml/grade_export_xml.php
grade/export/xml/index.php
index.php

index 658a481a5ebf2ab0e8fda507aae9f8b105ce5916..0c4fb62d5577723b4a3128910f0583ac6b95fccd 100755 (executable)
@@ -11,10 +11,22 @@ class grade_export_form extends moodleform {
         } else {
             $plugin = 'unknown';
         }
+
+        $mform->addElement('header', 'options', get_string('options'));
+
         $mform->addElement('advcheckbox', 'export_letters', get_string('exportletters', 'grades'));
         $mform->setDefault('export_letters', 0);
-        $mform->setHelpButton('export_letters', array(false, get_string('exportletters', 'grades'),
-                          false, true, false, get_string("exportlettershelp", 'grades')));
+        $mform->setHelpButton('export_letters', array(false, get_string('exportletters', 'grades'), false, true, false, get_string("exportlettershelp", 'grades')));
+
+        $mform->addElement('advcheckbox', 'publish', get_string('publish', 'grades'));
+        $mform->setDefault('publish', 0);
+        $mform->setHelpButton('publish', array(false, get_string('publish', 'grades'), false, true, false, get_string("publishhelp", 'grades')));
+
+        $mform->addElement('textarea', 'iplist', get_string('iplist', 'grades'), array('cols' => 40, 'rows' => 5));
+        $mform->setHelpButton('iplist', array(false, get_string('iplist', 'grades'), false, true, false, get_string("iplisthelp", 'grades')));
+
+        $mform->addElement('password', 'password', get_string('password'));
+        $mform->setHelpButton('password', array(false, get_string('password', 'grades'), false, true, false, get_string("passwordhelp", 'grades')));
 
         $mform->addElement('header', 'general', get_string('gradeitemsinc', 'grades')); // TODO: localize
 
@@ -23,23 +35,23 @@ class grade_export_form extends moodleform {
         if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) {
             $noidnumber = false;
             foreach ($grade_items as $grade_item) {
-                
+
                 if ($plugin != 'xmlexport' || $grade_item->idnumber) {
                     $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->get_name(), array('selected'=>'selected'), array(0, $grade_item->id));
                     $element->setChecked(1);
                 } else {
                     $noidnumber = true;
-                    $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->get_name(), array('disabled'=>'disabled'), array(0, $grade_item->id));               
+                    $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->get_name(), array('disabled'=>'disabled'), array(0, $grade_item->id));
                 }
-                
+
                 $mform->addElement($element);
             }
         }
-        
+
         if ($noidnumber) {
-            $mform->addElement('static', 'noidnumber',  '', get_string('noidnumber')); 
+            $mform->addElement('static', 'noidnumber',  '', get_string('noidnumber'));
         }
-        
+
         $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
         $mform->addElement('select', 'previewrows', 'Preview rows', $options); // TODO: localize
         $mform->setType('previewrows', PARAM_INT);
index 211ef42954befa5a2638b5aa37c33e987bdab7dd..082854e3c60ac9c15913df9658913d8475395cc0 100755 (executable)
@@ -56,6 +56,7 @@ class grade_export {
     var $columnidnumbers = array(); // Collect all gradeitem id numbers
     var $students = array();
     var $course; // course
+    var $publish; // Whether to publish this data via URL, or dump it to browser as usual
 
     // common strings
     var $strgrades;
@@ -68,7 +69,7 @@ class grade_export {
      * @param boolean $export_letters Whether to export letter grade_items as literal letters, or as numerical values
      * @note Exporting as letters will lead to data loss if that exported set it re-imported.
      */
-    function grade_export($id, $itemids = '', $export_letters=false) {
+    function grade_export($id, $itemids = '', $export_letters=false, $publish=false) {
         global $CFG, $COURSE;
 
         if ($export_letters) {
@@ -77,6 +78,7 @@ class grade_export {
             $letters = $report->get_grade_letters();
         }
 
+        $this->publish = $publish;
         $this->strgrades = get_string("grades");
         $this->strgrade = get_string("grade");
         $this->itemids = $itemids;
@@ -243,10 +245,10 @@ class grade_export {
 
         $i = 0;
         foreach ($this->grades as $studentid => $studentgrades) {
-            
+
             // number of preview rows
             if ($i++ == $rows) {
-                break; 
+                break;
             }
             echo '<tr>';
             $student = $this->students[$studentid];
index dbc40f027ccdc9d1315637eed27213af00bd7715..9d0b8585c1e5235d99e6141978f79500a14e6114 100755 (executable)
@@ -44,6 +44,8 @@ class grade_export_txt extends grade_export {
 
         global $CFG;
 
+        $retval = '';
+
         /// Whether this plugin is entitled to update export time
         if ($expplugins = explode(",", $CFG->gradeexport)) {
             if (in_array($this->format, $expplugins)) {
@@ -62,7 +64,7 @@ class grade_export_txt extends grade_export {
 
 /// Print names of all the fields
 
-        echo get_string("firstname")."$this->separator".
+        $retval .= get_string("firstname")."$this->separator".
              get_string("lastname")."{$this->separator}".
              get_string("idnumber")."{$this->separator}".
              get_string("institution")."{$this->separator}".
@@ -70,14 +72,14 @@ class grade_export_txt extends grade_export {
              get_string("email");
         foreach ($this->columns as $column) {
             $column = strip_tags($column);
-            echo "{$this->separator}$column";
+            $retval .= "{$this->separator}$column";
 
             /// add a column_feedback column
             if ($feedback) {
-                echo "{$this->separator}{$column}_feedback";
+                $retval .= "{$this->separator}{$column}_feedback";
             }
         }
-        echo "{$this->separator}".get_string("total")."\n";
+        $retval .= "{$this->separator}".get_string("total")."\n";
 
 /// Print all the lines of data.
         foreach ($this->grades as $studentid => $studentgrades) {
@@ -86,14 +88,14 @@ class grade_export_txt extends grade_export {
             if (empty($this->totals[$student->id])) {
                 $this->totals[$student->id] = '';
             }
-            echo "$student->firstname{$this->separator}$student->lastname{$this->separator}$student->idnumber{$this->separator}$student->institution{$this->separator}$student->department{$this->separator}$student->email";
+            $retval .= "$student->firstname{$this->separator}$student->lastname{$this->separator}$student->idnumber{$this->separator}$student->institution{$this->separator}$student->department{$this->separator}$student->email";
 
             foreach ($studentgrades as $gradeitemid => $grade) {
                 $grade = strip_tags($grade);
-                echo "{$this->separator}$grade";
+                $retval .= "{$this->separator}$grade";
 
                 if ($feedback) {
-                    echo "{$this->separator}".array_shift($this->comments[$student->id]);
+                    $retval .= "{$this->separator}".array_shift($this->comments[$student->id]);
                 }
 
                 /// if export flag needs to be set
@@ -110,10 +112,12 @@ class grade_export_txt extends grade_export {
                     $grade_grade->update();
                 }
             }
-            echo "{$this->separator}".$this->totals[$student->id];
-            echo "\n";
+            $retval .= "{$this->separator}".$this->totals[$student->id];
+            $retval .= "\n";
         }
 
+        echo $retval;
+
         exit;
     }
 }
index bcf47dfaba543994034ec6f860e020d9a91903fe..c28e19472717fc1924ad9ae3ab48244b97e4543d 100755 (executable)
@@ -30,11 +30,16 @@ class grade_export_xml extends grade_export {
 
     /**
      * To be implemented by child classes
+     * @param boolean $feedback
+     * @param boolean $publish Whether to output directly, or send as a file
+     * @return string
      */
     function print_grades($feedback = false) {
 
         global $CFG;
 
+        $retval = '';
+
         /// Whether this plugin is entitled to update export time
         if ($expplugins = explode(",", $CFG->gradeexport)) {
             if (in_array($this->format, $expplugins)) {
@@ -51,17 +56,14 @@ class grade_export_xml extends grade_export {
         /// Calculate file name
         $downloadfilename = clean_filename("{$this->course->shortname} $this->strgrades.xml");
 
-        //header("Content-type: text/xml; charset=UTF-8");
-        //header("Content-Disposition: attachment; filename=\"$downloadfilename\"");
-
         /// time stamp to ensure uniqueness of batch export
-        echo '<results batch="xml_export_'.time().'">';
+        $retval .= '<results batch="xml_export_'.time().'">';
 
         foreach ($this->columnidnumbers as $index => $idnumber) {
 
             // studentgrades[] index should match with corresponding $index
             foreach ($this->grades as $studentid => $studentgrades) {
-                echo '<result>';
+                $retval .= '<result>';
 
                 // state can be new, or regrade
                 // require comparing of timestamps in db
@@ -82,6 +84,7 @@ class grade_export_xml extends grade_export {
                 $grade_grade = new grade_grade($params);
 
                 // if exported, check grade_history, if modified after export, set state to regrade
+                $status = 'new';
                 if (!empty($grade_grade->exported)) {
                     //TODO: use timemodified or something else instead
 /*                    if (record_exists_select('grade_history', 'itemid = '.$gradeitem->id.' AND userid = '.$studentid.' AND timemodified > '.$grade_grade->exported)) {
@@ -94,16 +97,16 @@ class grade_export_xml extends grade_export {
                     $status = 'new';
                 }
 
-                echo '<state>'.$status.'</state>';
+                $retval .= '<state>'.$status.'</state>';
                 // only need id number
-                echo '<assignment>'.$idnumber.'</assignment>';
+                $retval .= '<assignment>'.$idnumber.'</assignment>';
                 // this column should be customizable to use either student id, idnumber, uesrname or email.
-                echo '<student>'.$studentid.'</student>';
-                echo '<score>'.$studentgrades[$index].'</score>';
+                $retval .= '<student>'.$studentid.'</student>';
+                $retval .= '<score>'.$studentgrades[$index].'</score>';
                 if ($feedback) {
-                    echo '<feedback>'.$this->comments[$studentid][$index].'</feedback>';
+                    $retval .= '<feedback>'.$this->comments[$studentid][$index].'</feedback>';
                 }
-                echo '</result>';
+                $retval .= '</result>';
 
                 // timestamp this if needed
                 if ($export) {
@@ -113,7 +116,15 @@ class grade_export_xml extends grade_export {
                 }
             }
         }
-        echo '</results>';
+        $retval .= '</results>';
+
+        if ($this->publish) {
+            header("Content-type: text/xml; charset=UTF-8");
+            header("Content-Disposition: attachment; filename=\"$downloadfilename\"");
+        }
+
+        echo $retval;
+
         exit;
     }
 }
index 98b7183c2a6e21f0ef9ff02ca66a6dbf643109db..0af3bc51d104262c296fda4ed1293a58f929fe76 100755 (executable)
@@ -47,6 +47,7 @@ $navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course-
 
 print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
 print_grade_plugin_selector($id, 'export', 'xml');
+
 // process post information
 if (($data = data_submitted()) && confirm_sesskey()) {
 
@@ -58,7 +59,12 @@ if (($data = data_submitted()) && confirm_sesskey()) {
 
     // print the grades on screen for feedbacks
 
-    $export = new grade_export($id, $data->itemids, $data->export_letters);
+    $export = new grade_export($id, $data->itemids, $data->export_letters, $data->publish);
+
+    if ($data->publish) {
+        // Record an entry in the 'published' table: people can now access this data by URL
+    }
+
     $export->display_grades($feedback, $data->previewrows);
 
     // this redirect should trigger a download prompt
index de0dad8da58e9f8768da70968ced7db926800839..8923cb02ae08c8ee3f3e9078e8bfda84328c8927 100644 (file)
--- a/index.php
+++ b/index.php
                                             BLOCK_L_MAX_WIDTH);
     $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
                                             BLOCK_R_MAX_WIDTH);
-
-    print_header($SITE->fullname, $SITE->fullname, 'home', '',
+    $navigation = build_navigation(array(array('name' => get_string('home'), 'link' => null, 'type' => 'misc')));
+    print_header($SITE->fullname, $SITE->fullname, $navigation, '',
                  '<meta name="description" content="'. s(strip_tags($SITE->summary)) .'" />',
                  true, '', user_login_string($SITE).$langmenu);