mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Changes throughout Moodle to remove any reserved words from the
Moodle tables. ie user -> userid in many tables, plus in user_students start -> starttime and end -> endtime I've just done all this as carefully as I could ... I don't think I missed anything but it's pretty intensive work and I'd be fooling myself if I didn't think I'd missed a couple. Note that this version should pretty much be able to bootstrap itself using PostgreSQL now ... but this is untested
This commit is contained in:
parent
1f48942e7d
commit
ebc3bd2b24
68 changed files with 277 additions and 461 deletions
|
@ -24,6 +24,11 @@ function quiz_upgrade($oldversion) {
|
|||
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2002122300) {
|
||||
execute_sql("ALTER TABLE `quiz_grades` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
||||
execute_sql("ALTER TABLE `quiz_attempts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ CREATE TABLE `prefix_quiz_answers` (
|
|||
CREATE TABLE `prefix_quiz_attempts` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`quiz` int(10) unsigned NOT NULL default '0',
|
||||
`user` int(10) unsigned NOT NULL default '0',
|
||||
`userid` int(10) unsigned NOT NULL default '0',
|
||||
`attempt` smallint(6) NOT NULL default '0',
|
||||
`sumgrades` varchar(10) NOT NULL default '0.0',
|
||||
`timestart` int(10) unsigned NOT NULL default '0',
|
||||
|
@ -86,7 +86,7 @@ CREATE TABLE `prefix_quiz_categories` (
|
|||
CREATE TABLE `prefix_quiz_grades` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`quiz` int(10) unsigned NOT NULL default '0',
|
||||
`user` int(10) unsigned NOT NULL default '0',
|
||||
`userid` int(10) unsigned NOT NULL default '0',
|
||||
`grade` varchar(10) NOT NULL default '0.0',
|
||||
`timemodified` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
|
|
|
@ -6,24 +6,6 @@ function quiz_upgrade($oldversion) {
|
|||
|
||||
global $CFG;
|
||||
|
||||
if ($oldversion < 2002101800) {
|
||||
execute_sql(" ALTER TABLE `quiz_attempts` ".
|
||||
" ADD `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `sumgrades` , ".
|
||||
" ADD `timefinish` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timestart` ");
|
||||
execute_sql(" UPDATE `quiz_attempts` SET timestart = timemodified ");
|
||||
execute_sql(" UPDATE `quiz_attempts` SET timefinish = timemodified ");
|
||||
}
|
||||
if ($oldversion < 2002102101) {
|
||||
execute_sql(" DELETE FROM log_display WHERE module = 'quiz' ");
|
||||
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'view', 'quiz', 'name') ");
|
||||
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'report', 'quiz', 'name') ");
|
||||
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'attempt', 'quiz', 'name') ");
|
||||
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'submit', 'quiz', 'name') ");
|
||||
}
|
||||
if ($oldversion < 2002102600) {
|
||||
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ CREATE TABLE quiz_answers (
|
|||
CREATE TABLE quiz_attempts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
quiz integer NOT NULL default '0',
|
||||
"user" integer NOT NULL default '0',
|
||||
userid integer NOT NULL default '0',
|
||||
attempt integer NOT NULL default '0',
|
||||
sumgrades varchar(10) NOT NULL default '0.0',
|
||||
timestart integer NOT NULL default '0',
|
||||
|
@ -81,7 +81,7 @@ CREATE TABLE quiz_categories (
|
|||
CREATE TABLE quiz_grades (
|
||||
id SERIAL PRIMARY KEY,
|
||||
quiz integer NOT NULL default '0',
|
||||
"user" integer NOT NULL default '0',
|
||||
userid integer NOT NULL default '0',
|
||||
grade varchar(10) NOT NULL default '0.0',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
|
|
@ -154,7 +154,7 @@ function quiz_user_outline($course, $user, $mod, $quiz) {
|
|||
/// Used for user activity reports.
|
||||
/// $return->time = the time they did it
|
||||
/// $return->info = a short text description
|
||||
if ($grade = get_record("quiz_grades", "user", $user->id, "quiz", $quiz->id)) {
|
||||
if ($grade = get_record("quiz_grades", "userid", $user->id, "quiz", $quiz->id)) {
|
||||
|
||||
if ($grade->grade) {
|
||||
$result->info = get_string("grade").": $grade->grade";
|
||||
|
@ -198,7 +198,7 @@ function quiz_cron () {
|
|||
function quiz_grades($quizid) {
|
||||
/// Must return an array of grades, indexed by user, and a max grade.
|
||||
|
||||
$return->grades = get_records_menu("quiz_grades", "quiz", $quizid, "", "user,grade");
|
||||
$return->grades = get_records_menu("quiz_grades", "quiz", $quizid, "", "userid,grade");
|
||||
$return->maxgrade = get_field("quiz", "grade", "id", "$quizid");
|
||||
return $return;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ function quiz_get_grade_records($quiz) {
|
|||
FROM {$CFG->prefix}quiz_grades qg,
|
||||
{$CFG->prefix}user u
|
||||
WHERE qg.quiz = '$quiz->id'
|
||||
AND qg.user = u.id");
|
||||
AND qg.userid = u.id");
|
||||
}
|
||||
|
||||
function quiz_get_answers($question) {
|
||||
|
@ -794,7 +794,7 @@ function quiz_print_cat_question_list($categoryid) {
|
|||
|
||||
function quiz_start_attempt($quizid, $userid, $numattempt) {
|
||||
$attempt->quiz = $quizid;
|
||||
$attempt->user = $userid;
|
||||
$attempt->userid = $userid;
|
||||
$attempt->attempt = $numattempt;
|
||||
$attempt->timestart = time();
|
||||
$attempt->timefinish = 0;
|
||||
|
@ -805,12 +805,12 @@ function quiz_start_attempt($quizid, $userid, $numattempt) {
|
|||
|
||||
function quiz_get_user_attempt_unfinished($quizid, $userid) {
|
||||
// Returns an object containing an unfinished attempt (if there is one)
|
||||
return get_record("quiz_attempts", "quiz", $quizid, "user", $userid, "timefinish", 0);
|
||||
return get_record("quiz_attempts", "quiz", $quizid, "userid", $userid, "timefinish", 0);
|
||||
}
|
||||
|
||||
function quiz_get_user_attempts($quizid, $userid) {
|
||||
// Returns a list of all attempts by a user
|
||||
return get_records_select("quiz_attempts", "quiz = '$quizid' AND user = '$userid' AND timefinish > 0",
|
||||
return get_records_select("quiz_attempts", "quiz = '$quizid' AND userid = '$userid' AND timefinish > 0",
|
||||
"attempt ASC");
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ function quiz_get_user_attempts_string($quiz, $attempts, $bestgrade) {
|
|||
|
||||
function quiz_get_best_grade($quizid, $userid) {
|
||||
/// Get the best current grade for a particular user in a quiz
|
||||
if (!$grade = get_record("quiz_grades", "quiz", $quizid, "user", $userid)) {
|
||||
if (!$grade = get_record("quiz_grades", "quiz", $quizid, "userid", $userid)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,7 @@ function quiz_save_best_grade($quiz, $userid) {
|
|||
$bestgrade = quiz_calculate_best_grade($quiz, $attempts);
|
||||
$bestgrade = (($bestgrade / $quiz->sumgrades) * $quiz->grade);
|
||||
|
||||
if ($grade = get_record("quiz_grades", "quiz", $quiz->id, "user", $userid)) {
|
||||
if ($grade = get_record("quiz_grades", "quiz", $quiz->id, "userid", $userid)) {
|
||||
$grade->grade = $bestgrade;
|
||||
$grade->timemodified = time();
|
||||
if (!update_record("quiz_grades", $grade)) {
|
||||
|
@ -861,7 +861,7 @@ function quiz_save_best_grade($quiz, $userid) {
|
|||
}
|
||||
} else {
|
||||
$grade->quiz = $quiz->id;
|
||||
$grade->user = $userid;
|
||||
$grade->userid = $userid;
|
||||
$grade->grade = round($bestgrade, 2);
|
||||
$grade->timemodified = time();
|
||||
if (!insert_record("quiz_grades", $grade)) {
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
$users[$attempt->user] = $attempt->user;
|
||||
$users[$attempt->userid] = $attempt->userid;
|
||||
}
|
||||
|
||||
if ($users) {
|
||||
|
@ -169,14 +169,14 @@
|
|||
$table->width = array(10, "*", "*", 20);
|
||||
|
||||
foreach ($grades as $grade) {
|
||||
$picture = print_user_picture($grade->user, $course->id, $grade->picture, false, true);
|
||||
$picture = print_user_picture($grade->userid, $course->id, $grade->picture, false, true);
|
||||
|
||||
if ($attempts = quiz_get_user_attempts($quiz->id, $grade->user)) {
|
||||
if ($attempts = quiz_get_user_attempts($quiz->id, $grade->userid)) {
|
||||
$userattempts = quiz_get_user_attempts_string($quiz, $attempts, $grade->grade);
|
||||
}
|
||||
|
||||
$table->data[] = array ($picture,
|
||||
"<A HREF=\"$CFG->wwwroot/user/view.php?id=$grade->user&course=$course->id\">$grade->firstname $grade->lastname</A>",
|
||||
"<A HREF=\"$CFG->wwwroot/user/view.php?id=$grade->userid&course=$course->id\">$grade->firstname $grade->lastname</A>",
|
||||
"$userattempts", round($grade->grade,0));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2002102600; // The (date) version of this module
|
||||
$module->version = 2002122300; // The (date) version of this module
|
||||
$module->cron = 0; // How often should cron check this module (seconds)?
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue