From: jamiesensei Date: Fri, 20 Jun 2008 13:43:06 +0000 (+0000) Subject: MDL-14754 "rename and reorder quiz reports tabs" added new db table quiz_report that... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f37f30d43551f140c3d796089bbf2467203a5f1d;p=moodle.git MDL-14754 "rename and reorder quiz reports tabs" added new db table quiz_report that lists reports and has a field for their display order. Standard reports are automatically added to table. Reports that are not on disk are ignored. --- diff --git a/lang/en_utf8/quiz_overview.php b/lang/en_utf8/quiz_overview.php index 450a5ade76..11fbc43d1d 100644 --- a/lang/en_utf8/quiz_overview.php +++ b/lang/en_utf8/quiz_overview.php @@ -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'; diff --git a/lang/en_utf8/quiz_responses.php b/lang/en_utf8/quiz_responses.php index 55b99d8b5d..bf2c049677 100644 --- a/lang/en_utf8/quiz_responses.php +++ b/lang/en_utf8/quiz_responses.php @@ -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'; diff --git a/lang/en_utf8/quiz_statistics.php b/lang/en_utf8/quiz_statistics.php index 3a230bf4a8..465aadda81 100644 --- a/lang/en_utf8/quiz_statistics.php +++ b/lang/en_utf8/quiz_statistics.php @@ -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'; diff --git a/mod/quiz/db/install.xml b/mod/quiz/db/install.xml index ececa20da9..33f9d1b8f8 100755 --- a/mod/quiz/db/install.xml +++ b/mod/quiz/db/install.xml @@ -1,5 +1,5 @@ - @@ -87,7 +87,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -280,7 +280,7 @@
- +
@@ -293,9 +293,19 @@
+ + + + + + + + + +
- + @@ -311,5 +321,14 @@ + + + + + + + + + -
+ \ No newline at end of file diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php index 0c060d9ff0..6283f7392d 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -20,16 +20,60 @@ 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; } diff --git a/mod/quiz/tabs.php b/mod/quiz/tabs.php index 4b72032f16..f7e1306220 100644 --- a/mod/quiz/tabs.php +++ b/mod/quiz/tabs.php @@ -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; } } diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 7f6d0d745c..7615fc10c7 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -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)?