Skip to content

Commit

Permalink
Corrected the stamp I just added and added a separate version field i…
Browse files Browse the repository at this point in the history
…nstead
  • Loading branch information
moodler committed Aug 23, 2003
1 parent b5012f3 commit 757a0ab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ function make_grades_menu($gradingtype) {
return $grades;
}

function make_unique_id_code($version=1) {
function make_unique_id_code($extra="") {

$hostname = "unknownhost";
if (!empty($_SERVER["HTTP_HOST"])) {
Expand All @@ -1702,8 +1702,11 @@ function make_unique_id_code($version=1) {

$random = random_string(6);

return "$hostname+$date+$random+$version";

if ($extra) {
return "$hostname+$date+$random+$extra";
} else {
return "$hostname+$date+$random";
}
}


Expand Down
6 changes: 5 additions & 1 deletion mod/quiz/db/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ function quiz_upgrade($oldversion) {
}

if ($oldversion < 2003082300) {
table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
table_column("quiz_questions", "", "stamp", "varchar", "255", "", "", "not null", "qtype");
}

if ($oldversion < 2003082301) {
table_column("quiz_questions", "stamp", "stamp", "varchar", "255", "", "", "not null");
table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp");
if ($questions = get_records("quiz_questions")) {
foreach ($questions as $question) {
$stamp = make_unique_id_code();
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/db/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ CREATE TABLE `prefix_quiz_questions` (
`defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL,
`qtype` smallint(6) NOT NULL default '0',
`stamp` varchar(255) NOT NULL default '',
`version` int(10) NOT NULL default '1',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='The quiz questions themselves';
# --------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions mod/quiz/db/postgres7.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ function quiz_upgrade($oldversion) {
table_column("quiz", "", "attemptonlast", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "attempts");

table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
}

if ($oldversion < 2003082301) {
table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp");
if ($questions = get_records("quiz_questions")) {
foreach ($questions as $question) {
$stamp = make_unique_id_code();
Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/db/postgres7.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ CREATE TABLE prefix_quiz_questions (
image varchar(255) NOT NULL default '',
defaultgrade integer NOT NULL default '1',
qtype integer NOT NULL default '0',
stamp varchar(255) NOT NULL default ''
stamp varchar(255) NOT NULL default '',
version integer NOT NULL default '1'
);
# --------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////

$module->version = 2003082300; // The (date) version of this module
$module->version = 2003082301; // The (date) version of this module
$module->cron = 0; // How often should cron check this module (seconds)?
?>

0 comments on commit 757a0ab

Please sign in to comment.