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.

This commit is contained in:
jamiesensei
2008-06-20 13:43:06 +00:00
parent e5bd3250fa
commit f37f30d435
7 changed files with 94 additions and 22 deletions
+1 -1
View 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';
+2 -2
View 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';
+1 -1
View 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';
+26 -7
View File
@@ -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"/>
@@ -129,7 +129,7 @@
<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">
@@ -204,7 +204,7 @@
<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"/>
@@ -280,7 +280,7 @@
<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"/>
@@ -293,9 +293,19 @@
<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')" />
@@ -311,5 +321,14 @@
<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>
+49 -5
View File
@@ -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;
}
+14 -5
View 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;
}
}
+1 -1
View 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)?