]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14754 "rename and reorder quiz reports tabs" added new db table quiz_report that...
authorjamiesensei <jamiesensei>
Fri, 20 Jun 2008 13:43:06 +0000 (13:43 +0000)
committerjamiesensei <jamiesensei>
Fri, 20 Jun 2008 13:43:06 +0000 (13:43 +0000)
lang/en_utf8/quiz_overview.php
lang/en_utf8/quiz_responses.php
lang/en_utf8/quiz_statistics.php
mod/quiz/db/install.xml
mod/quiz/db/upgrade.php
mod/quiz/tabs.php
mod/quiz/version.php

index 450a5ade76a7df698f3968105131298f87aa185d..11fbc43d1d4671e31882c34f1b89db47745131e2 100644 (file)
@@ -16,7 +16,7 @@ $string['optallstudents'] = 'all \'$a\'';
 $string['optattemptsonly'] = '\'$a\' with attempts only';
 $string['optnoattemptsonly'] = '\'$a\' with no attempts only';
 $string['optonlygradedattempts'] = 'only the attempt that is graded for each user ($a)';
-$string['overview'] = 'Overview';
+$string['overview'] = 'Grades';
 $string['overviewdownload'] = 'Overview download';
 $string['overviewdownload'] = 'Overview download';
 $string['overviewreportgraph'] = 'Bar Graph of Number of Students Achieving Grade Ranges';
index 55b99d8b5d871809e1d982a25551d9e411d06a2e..bf2c049677b9242f5b5247e4288250842407c3c6 100644 (file)
@@ -3,8 +3,8 @@
 
 
 $string['pagesize'] = 'Attempts per page:';
-$string['reportresponses'] = 'Detailed responses';
-$string['responses'] = 'Detailed responses';
+$string['reportresponses'] = 'Responses';
+$string['responses'] = 'Responses';
 $string['responsesoptions'] = 'Responses options';
 $string['responsestitle'] = 'Detailed responses';
 
index 3a230bf4a8a5d191d56f1dac7762202d7a4b5e35..465aadda8162c715fb32a25e4c0718867ddd8442 100644 (file)
@@ -2,7 +2,7 @@
       // quiz_analysis.php - created with Moodle 1.7 beta + (2006101003)
 
 
-$string['statistics'] = 'Quiz statistics';
+$string['statistics'] = 'Statistics';
 $string['calculatefrom'] = 'Calculate statistics from';
 
 
index ececa20da96d56ea5bdc31dca2edc3658da0855c..33f9d1b8f81afe8f5cd048f6c4727076acbafca5 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/quiz/db" VERSION="20070522" COMMENT="XMLDB file for Moodle mod/quiz"
+<XMLDB PATH="mod/quiz/db" VERSION="20080620" COMMENT="XMLDB file for Moodle mod/quiz"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -87,7 +87,7 @@
         <FIELD NAME="value" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemnumber"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="definition" UNIQUE="false" FIELDS="definition"/>
         <FIELD NAME="modulename" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="quiz" SEQUENCE="false" ENUM="false" PREVIOUS="id"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
     <TABLE NAME="question_states" COMMENT="Stores user responses to an attempt, and percentage grades" PREVIOUS="question_attempts" NEXT="question_sessions">
         <FIELD NAME="delay2" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="delay1"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
         <KEY NAME="originalquestion" TYPE="foreign" FIELDS="originalquestion" REFTABLE="question" REFFIELDS="id" PREVIOUS="newquestion"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="quiz_feedback" COMMENT="Feedback given to students based on their overall score on the test" PREVIOUS="quiz_question_versions">
+    <TABLE NAME="quiz_feedback" COMMENT="Feedback given to students based on their overall score on the test" PREVIOUS="quiz_question_versions" NEXT="quiz_report">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="quizid"/>
         <FIELD NAME="quizid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="feedbacktext"/>
         <KEY NAME="quizid" TYPE="foreign" FIELDS="quizid" REFTABLE="quiz" REFFIELDS="id" PREVIOUS="primary"/>
       </KEYS>
     </TABLE>
+    <TABLE NAME="quiz_report" COMMENT="table of reports from quiz and there display order. No need to worry about deleting old records. Only records with an equivalent directory are displayed." PREVIOUS="quiz_feedback">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="name of the report, same as the directory name" PREVIOUS="id" NEXT="displayorder"/>
+        <FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="display order for report tabs" PREVIOUS="name"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+    </TABLE>
   </TABLES>
   <STATEMENTS>
-    <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
+    <STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display" NEXT="insert quiz_report">
       <SENTENCES>
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('quiz', 'add', 'quiz', 'name')" />
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('quiz', 'update', 'quiz', 'name')" />
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('quiz', 'continue attempt', 'quiz', 'name')" />
       </SENTENCES>
     </STATEMENT>
+    <STATEMENT NAME="insert quiz_report" TYPE="insert" TABLE="quiz_report" COMMENT="Initial insert of records on table quiz_report" PREVIOUS="insert log_display">
+      <SENTENCES>
+        <SENTENCE TEXT="(name, displayorder) VALUES ('overview', '10000')" />
+        <SENTENCE TEXT="(name, displayorder) VALUES ('responses', '9000')" />
+        <SENTENCE TEXT="(name, displayorder) VALUES ('statistics', '8000')" />
+        <SENTENCE TEXT="(name, displayorder) VALUES ('regrade', '7000')" />
+        <SENTENCE TEXT="(name, displayorder) VALUES ('grading', '6000')" />
+      </SENTENCES>
+    </STATEMENT>
   </STATEMENTS>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 0c060d9ff0956829f8a6f396dba514ca666db423..6283f7392d23be0629a22591e845de889b0d725f 100644 (file)
 function xmldb_quiz_upgrade($oldversion=0) {
 
     global $CFG, $THEME, $DB;
+    
+    $dbman = $DB->get_manager();
 
     $result = true;
 
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
 //===== 1.9.0 upgrade line ======//
 
+    if ($result && $oldversion < 2008062000) {
+
+    /// Define table quiz_report to be created
+        $table = new xmldb_table('quiz_report');
+
+    /// Adding fields to table quiz_report
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
+        $table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+
+    /// Adding keys to table quiz_report
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+    /// Conditionally launch create table for quiz_report
+        if (!$dbman->table_exists($table)) {
+            $result = $result && $dbman->create_table($table);
+        }
+
+    }
+    if ($result && $oldversion < 2008062001) {
+        $reporttoinsert = new object();
+        $reporttoinsert->name = 'overview';
+        $reporttoinsert->displayorder = 10000;
+        $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
+
+        $reporttoinsert = new object();
+        $reporttoinsert->name = 'responses';
+        $reporttoinsert->displayorder = 9000;
+        $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
+
+        $reporttoinsert = new object();
+        $reporttoinsert->name = 'statistics';
+        $reporttoinsert->displayorder = 8000;
+        $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
+
+        $reporttoinsert = new object();
+        $reporttoinsert->name = 'regrade';
+        $reporttoinsert->displayorder = 7000;
+        $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
+
+        $reporttoinsert = new object();
+        $reporttoinsert->name = 'grading';
+        $reporttoinsert->displayorder = 6000;
+        $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
+    }
+
+
     return $result;
 }
 
index 4b72032f16b4e6b0a834ce3f38331b284393edaf..f7e13062208db2e097fc1cf8d4d88f3b3c045b2a 100644 (file)
@@ -6,7 +6,7 @@
  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  * @package quiz
  */
-
+global $DB;
 if (empty($quiz)) {
     print_error('cannotcallscript');
 }
@@ -51,17 +51,26 @@ if ($currenttab == 'reports' and isset($mode)) {
     $activated[] = 'reports';
 
     // Standard reports we want to show first.
-    $reportlist = array ('overview', 'regrade', 'grading', 'analysis');
+    
+    $reportrs = $DB->get_recordset('quiz_report', null, 'displayorder DESC', 'id, name');
     // Reports that are restricted by capability.
     $reportrestrictions = array(
         'regrade' => 'mod/quiz:grade',
         'grading' => 'mod/quiz:grade'
     );
+    $reportdirs = get_list_of_plugins("mod/quiz/report");
+    //order the reports tab in descending order of displayorder
+    $reportlist = array();
+    foreach ($reportrs as $key => $rs) {
+        if (in_array($rs->name, $reportdirs)) {
+            $reportlist[]=$rs->name;
+        }
+    }
 
-    $allreports = get_list_of_plugins("mod/quiz/report");
-    foreach ($allreports as $report) {
+    //add any other reports on the end
+    foreach ($reportdirs as $report) {
         if (!in_array($report, $reportlist)) {
-            $reportlist[] = $report;
+            $reportlist[]=$report;
         }
     }
 
index 7f6d0d745c3ec3aadeb685c2dc371a0172ba1a26..7615fc10c75ffc9787e950a1d824a505274d24ff 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101509;   // The (date) version of this module
+$module->version  = 2008062001;   // The (date) version of this module
 $module->requires = 2007101509;   // Requires this Moodle version
 $module->cron     = 0;            // How often should cron check this module (seconds)?