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:
moodler 2002-12-23 09:39:26 +00:00
parent 1f48942e7d
commit ebc3bd2b24
68 changed files with 277 additions and 461 deletions

View file

@ -151,6 +151,10 @@ function survey_upgrade($oldversion) {
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm3', `shorttext` = 'attlsm3', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Separate Learning'");
}
if ($oldversion < 2002122300) {
execute_sql("ALTER TABLE `survey_analysis` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
execute_sql("ALTER TABLE `survey_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
}

View file

@ -45,7 +45,7 @@ INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`,
CREATE TABLE prefix_survey_analysis (
id int(10) unsigned NOT NULL auto_increment,
survey int(10) unsigned NOT NULL default '0',
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
notes text NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id)
@ -63,7 +63,7 @@ CREATE TABLE prefix_survey_analysis (
CREATE TABLE prefix_survey_answers (
id int(10) unsigned NOT NULL auto_increment,
user int(10) unsigned NOT NULL default '0',
userid int(10) unsigned NOT NULL default '0',
survey int(10) unsigned NOT NULL default '0',
question int(10) unsigned NOT NULL default '0',
time int(10) unsigned default NULL,

View file

@ -4,153 +4,7 @@ function survey_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
if ($oldversion < 2002081400) {
execute_sql(" ALTER TABLE `survey_questions` DROP `owner` ");
execute_sql(" ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'focus on interesting issues' WHERE id = 1 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'important to my practice' WHERE id = 2 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'improve my practice' WHERE id = 3 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'connects with my practice' WHERE id = 4 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my learning' WHERE id = 5 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of my own ideas' WHERE id = 6 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of other students' WHERE id = 7 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m critical of readings' WHERE id = 8 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I explain my ideas' WHERE id = 9 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I ask for explanations' WHERE id =10 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I\'m asked to explain' WHERE id =11 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students respond to me' WHERE id =12 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor stimulates thinking' WHERE id =13 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor encourages me' WHERE id =14 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor models discourse' WHERE id =15 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor models self-reflection' WHERE id =16 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students encourage me' WHERE id =17 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students praise me' WHERE id =18 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students value me' WHERE id =19 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'student empathise' WHERE id =20 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I understand other students' WHERE id =21 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'students understand me' WHERE id =22 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'I understand the tutor' WHERE id =23 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'tutor understands me' WHERE id =24 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =25 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =26 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =27 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =28 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Peer Support' WHERE id =29 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interpretation' WHERE id =30 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Relevance' WHERE id =31 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Reflective Thinking' WHERE id =32 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Interactivity' WHERE id =33 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'Tutor Support' WHERE id =34 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =35 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =36 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =37 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =38 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =39 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =40 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =41 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =42 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =43 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =44 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'focus quality of argument' WHERE id =45 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'play devil\'s advocate' WHERE id =46 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'where people come from' WHERE id =47 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'understand different people' WHERE id =48 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'interact with variety' WHERE id =49 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'enjoy hearing opinions' WHERE id =50 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'strengthen by argue' WHERE id =51 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'know why people do' WHERE id =52 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'argue with authors' WHERE id =53 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'remain objective' WHERE id =54 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'think WITH people' WHERE id =55 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'use criteria to evaluate' WHERE id =56 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'try to understand' WHERE id =57 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'point out weaknesses' WHERE id =58 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'put myself in their shoes' WHERE id =59 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'putting on trial' WHERE id =60 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'i value logic most' WHERE id =61 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'insight from empathy' WHERE id =62 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'make effort to extend' WHERE id =63 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = 'what\'s wrong\?' WHERE id =64 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =65 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =66 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =67 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =68 ");
execute_sql(" UPDATE `survey_questions` SET `shorttext` = '' WHERE id =69 ");
}
if ($oldversion < 2002110903) {
if (! execute_sql("ALTER TABLE `survey_questions` ADD `shorttext` VARCHAR(30) NOT NULL AFTER `text` ")) {
notify("If you get an error above, don't worry, just ignore it. Everything is OK.");
}
execute_sql("UPDATE `survey` SET `name` = 'collesaname', `intro` = 'collesaintro' WHERE name = 'COLLES (Actual)' AND template = 0 ");
execute_sql("UPDATE `survey` SET `name` = 'collespname', `intro` = 'collespintro' WHERE name = 'COLLES (Preferred)' AND template = 0");
execute_sql("UPDATE `survey` SET `name` = 'collesapname', `intro` = 'collesapintro' WHERE name = 'COLLES (Preferred and Actual)' AND template = 0");
execute_sql("UPDATE `survey` SET `name` = 'attlsname', `intro` = 'attlsintro' WHERE name = 'ATTLS (20 item version)' AND template = 0");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles1', `shorttext` = 'colles1short', `options` = 'scaletimes5' WHERE `shorttext` = 'focus on interesting issues'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles2', `shorttext` = 'colles2short', `options` = 'scaletimes5' WHERE `shorttext` = 'important to my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles3', `shorttext` = 'colles3short', `options` = 'scaletimes5' WHERE `shorttext` = 'improve my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles4', `shorttext` = 'colles4short', `options` = 'scaletimes5' WHERE `shorttext` = 'connects with my practice'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles5', `shorttext` = 'colles5short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles6', `shorttext` = 'colles6short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of my own ideas'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles7', `shorttext` = 'colles7short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of other students'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles8', `shorttext` = 'colles8short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m critical of readings'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles9', `shorttext` = 'colles9short', `options` = 'scaletimes5' WHERE `shorttext` = 'I explain my ideas'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles10', `shorttext` = 'colles10short', `options` = 'scaletimes5' WHERE `shorttext` = 'I ask for explanations'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles11', `shorttext` = 'colles11short', `options` = 'scaletimes5' WHERE `shorttext` = 'I\'m asked to explain'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles12', `shorttext` = 'colles12short', `options` = 'scaletimes5' WHERE `shorttext` = 'students respond to me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles13', `shorttext` = 'colles13short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor stimulates thinking'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles14', `shorttext` = 'colles14short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor encourages me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles15', `shorttext` = 'colles15short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models discourse'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles16', `shorttext` = 'colles16short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor models self-reflection'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles17', `shorttext` = 'colles17short', `options` = 'scaletimes5' WHERE `shorttext` = 'students encourage me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles18', `shorttext` = 'colles18short', `options` = 'scaletimes5' WHERE `shorttext` = 'students praise me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles19', `shorttext` = 'colles19short', `options` = 'scaletimes5' WHERE `shorttext` = 'students value me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles20', `shorttext` = 'colles20short', `options` = 'scaletimes5' WHERE `shorttext` = 'student empathise'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles21', `shorttext` = 'colles21short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand other students'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles22', `shorttext` = 'colles22short', `options` = 'scaletimes5' WHERE `shorttext` = 'students understand me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles23', `shorttext` = 'colles23short', `options` = 'scaletimes5' WHERE `shorttext` = 'I understand the tutor'");
execute_sql("UPDATE `survey_questions` SET `text` = 'colles24', `shorttext` = 'colles24short', `options` = 'scaletimes5' WHERE `shorttext` = 'tutor understands me'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm1', `shorttext` = 'collesm1short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Relevance'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm2', `shorttext` = 'collesm2short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Reflective Thinking'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm3', `shorttext` = 'collesm3short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interactivity'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm4', `shorttext` = 'collesm4short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Tutor Support'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm5', `shorttext` = 'collesm5short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Peer Support'");
execute_sql("UPDATE `survey_questions` SET `text` = 'collesm6', `shorttext` = 'collesm6short', `intro` = 'collesmintro', `options` = 'scaletimes5' WHERE `text` = 'Interpretation'");
execute_sql("UPDATE `survey_questions` SET `text` = 'howlong', `options` = 'howlongoptions' WHERE `text` = 'How long did this survey take you to complete\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'othercomments' WHERE `text` = 'Do you have any other comments\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls1', `shorttext` = 'attls1short', `options` = 'scaleagree5' WHERE `shorttext` = 'focus quality of argument'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls2', `shorttext` = 'attls2short', `options` = 'scaleagree5' WHERE `shorttext` = 'play devil\'s advocate'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls3', `shorttext` = 'attls3short', `options` = 'scaleagree5' WHERE `shorttext` = 'where people come from'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls4', `shorttext` = 'attls4short', `options` = 'scaleagree5' WHERE `shorttext` = 'understand different people'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls5', `shorttext` = 'attls5short', `options` = 'scaleagree5' WHERE `shorttext` = 'interact with variety'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls6', `shorttext` = 'attls6short', `options` = 'scaleagree5' WHERE `shorttext` = 'enjoy hearing opinions'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls7', `shorttext` = 'attls7short', `options` = 'scaleagree5' WHERE `shorttext` = 'strengthen by argue'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls8', `shorttext` = 'attls8short', `options` = 'scaleagree5' WHERE `shorttext` = 'know why people do'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls9', `shorttext` = 'attls9short', `options` = 'scaleagree5' WHERE `shorttext` = 'argue with authors'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls10', `shorttext` = 'attls10short', `options` = 'scaleagree5' WHERE `shorttext` = 'remain objective'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls11', `shorttext` = 'attls11short', `options` = 'scaleagree5' WHERE `shorttext` = 'think WITH people'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls12', `shorttext` = 'attls12short', `options` = 'scaleagree5' WHERE `shorttext` = 'use criteria to evaluate'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls13', `shorttext` = 'attls13short', `options` = 'scaleagree5' WHERE `shorttext` = 'try to understand'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls14', `shorttext` = 'attls14short', `options` = 'scaleagree5' WHERE `shorttext` = 'point out weaknesses'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls15', `shorttext` = 'attls15short', `options` = 'scaleagree5' WHERE `shorttext` = 'put myself in their shoes'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls16', `shorttext` = 'attls16short', `options` = 'scaleagree5' WHERE `shorttext` = 'putting on trial'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls17', `shorttext` = 'attls17short', `options` = 'scaleagree5' WHERE `shorttext` = 'i value logic most'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls18', `shorttext` = 'attls18short', `options` = 'scaleagree5' WHERE `shorttext` = 'insight from empathy'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls19', `shorttext` = 'attls19short', `options` = 'scaleagree5' WHERE `shorttext` = 'make effort to extend'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attls20', `shorttext` = 'attls20short', `options` = 'scaleagree5' WHERE `shorttext` = 'what\'s wrong\?'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm1', `shorttext` = 'attlsm1', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Attitudes Towards Thinking and Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm2', `shorttext` = 'attlsm2', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Connected Learning'");
execute_sql("UPDATE `survey_questions` SET `text` = 'attlsm3', `shorttext` = 'attlsm3', `options` = 'scaleagree5', `intro` = 'attlsmintro' WHERE `text` = 'Separate Learning'");
}
global $CFG;
return true;
}

View file

@ -44,7 +44,7 @@ INSERT INTO survey (id, course, template, days, timecreated, timemodified, name,
CREATE TABLE survey_analysis (
id SERIAL PRIMARY KEY,
survey integer NOT NULL default '0',
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
notes text NOT NULL default ''
);
@ -60,7 +60,7 @@ CREATE TABLE survey_analysis (
CREATE TABLE survey_answers (
id SERIAL PRIMARY KEY,
"user" integer NOT NULL default '0',
userid integer NOT NULL default '0',
survey integer NOT NULL default '0',
question integer NOT NULL default '0',
time integer default NULL,

View file

@ -94,15 +94,15 @@
}
foreach ($aaa as $a) {
if (!$results["$a->user"]) { // init new array
$results["$a->user"]["time"] = $a->time;
if (!$results["$a->userid"]) { // init new array
$results["$a->userid"]["time"] = $a->time;
foreach ($order as $key => $qid) {
$results["$a->user"]["$qid"]["answer1"] = "";
$results["$a->user"]["$qid"]["answer2"] = "";
$results["$a->userid"]["$qid"]["answer1"] = "";
$results["$a->userid"]["$qid"]["answer2"] = "";
}
}
$results["$a->user"]["$a->question"]["answer1"] = $a->answer1;
$results["$a->user"]["$a->question"]["answer2"] = $a->answer2;
$results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
$results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
}
@ -136,7 +136,7 @@
if (! $u = get_record("user", "id", $user)) {
error("Error finding student # $user");
}
if ($n = get_record("survey_analysis", "survey", $survey->id, "user", $user)) {
if ($n = get_record("survey_analysis", "survey", $survey->id, "userid", $user)) {
$notes = $n->notes;
} else {
$notes = "No notes made";

View file

@ -402,7 +402,7 @@
if ($aaa) {
foreach ($aaa as $a) {
if ($a->user == $sid) {
if ($a->userid == $sid) {
if ($a->answer1) {
$studbuckets1[$i] += $a->answer1;
$studcount1[$i]++;
@ -548,7 +548,7 @@
if ($aaa) {
foreach ($aaa as $a) {
$index = $indexof[$a->question];
if ($a->user == $sid) {
if ($a->userid == $sid) {
if ($a->answer1) {
$studbuckets1[$index] += $a->answer1;
$studcount1[$index]++;

View file

@ -78,7 +78,7 @@ function survey_delete_instance($id) {
}
function survey_user_outline($course, $user, $mod, $survey) {
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND user='$user->id'")) {
if ($answers = get_records_select("survey_answers", "survey='$survey->id' AND userid='$user->id'")) {
$lastanswer = array_pop($answers);
@ -139,7 +139,7 @@ function survey_log_info($log) {
FROM {$CFG->prefix}survey s,
{$CFG->prefix}user u
WHERE s.id = '$log->info'
AND u.id = '$log->user'");
AND u.id = '$log->userid'");
}
function survey_get_responses($survey) {
@ -149,55 +149,56 @@ function survey_get_responses($survey) {
{$CFG->prefix}user AS u
WHERE a.answer1 <> '0' AND a.answer2 <> '0'
AND a.survey = $survey
AND a.user = u.id
GROUP BY a.user
AND a.userid = u.id
GROUP BY a.userid
ORDER BY a.time ASC");
}
function survey_get_analysis($survey, $user) {
global $db, $CFG;
global $CFG;
return get_record_sql("SELECT notes
FROM {$CFG->prefix}survey_analysis
WHERE survey='$survey'
AND user='$user'");
AND userid='$user'");
}
function survey_update_analysis($survey, $user, $notes) {
global $db, $CFG;
global $CFG;
return $db->Execute("UPDATE {$CFG->prefix}survey_analysis
return execute_sql("UPDATE {$CFG->prefix}survey_analysis
SET notes='$notes'
WHERE survey='$survey'
AND user='$user'");
AND userid='$user'");
}
function survey_add_analysis($survey, $user, $notes) {
global $db, $CFG;
return $db->Execute("INSERT INTO {$CFG->prefix}survey_analysis
SET notes='$notes',
survey='$survey',
user='$user'");
}
function survey_get_user_answers($surveyid, $questionid) {
global $CFG;
return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
FROM survey_answers sa,
user u
FROM {$CFG->prefix}survey_answers sa,
{$CFG->prefix}user u
WHERE sa.survey = '$surveyid'
AND sa.question = $questionid
AND u.id = sa.user
AND u.id = sa.userid
ORDER BY sa.answer1,sa.answer2 ASC");
}
// MODULE FUNCTIONS ////////////////////////////////////////////////////////
function survey_add_analysis($survey, $user, $notes) {
global $CFG;
$record->survey = $survey;
$record->userid = $user;
$record->notes = $notes;
return insert_record("survey_analysis", $record, false);
}
function survey_already_done($survey, $user) {
return record_exists("survey_answers", "survey", $survey, "user", $user);
return record_exists("survey_answers", "survey", $survey, "userid", $user);
}
function survey_count_responses($survey) {

View file

@ -217,9 +217,9 @@
foreach ($aaa as $a) {
echo "<TR>";
echo "<TD WIDTH=35>";
print_user_picture($a->user, $course->id, $a->picture, false);
print_user_picture($a->userid, $course->id, $a->picture, false);
echo "</TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->user\">$a->firstname $a->lastname</A></TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->userid\">$a->firstname $a->lastname</A></TD>";
echo "<TD><P>".userdate($a->time, "%d %B %Y, %I:%M %p")."</TD>";
echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer1) {
@ -261,7 +261,7 @@
error("Student doesn't exist");
}
print_header("$survey->name: $$user->firstname $user->lastname",
print_header("$survey->name: $user->firstname $user->lastname",
get_string("analysisof", "survey", "$user->firstname $user->lastname"));
if (isset($notes)) {

View file

@ -65,7 +65,7 @@
foreach ($answers as $key => $val) {
$newdata->time = $timenow;
$newdata->user = $USER->id;
$newdata->userid = $USER->id;
$newdata->survey = $survey->id;
$newdata->question = $key;
$newdata->answer1 = $val[0];

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002110903;
$module->version = 2002122300;
$module->cron = 0;
?>