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
}
}
- $admin->user = $user->id;
+ $admin->userid = $user->id;
$admin->id = insert_record("user_admins", $admin);
$admins[] = $user;
}
error("SERIOUS ERROR: Could not create admin user record !!!");
}
- $admin->user = $user->id;
+ $admin->userid = $user->id;
if (! insert_record("user_admins", $admin)) {
error("Could not make user $user->id an admin !!!");
error("Could not find site-level course");
}
- $teacher->user = $user->id;
+ $teacher->userid = $user->id;
$teacher->course = $site->id;
$teacher->authority = 1;
if (! insert_record("user_teachers", $teacher)) {
// and so the next 86400 seconds worth of logs are printed.
if ($course->category) {
- $selector = "WHERE l.course='$course->id' AND l.user = u.id";
+ $selector = "WHERE l.course='$course->id' AND l.userid = u.id";
} else {
- $selector = "WHERE l.user = u.id"; // Show all courses
+ $selector = "WHERE l.userid = u.id"; // Show all courses
if ($ccc = get_courses(-1)) {
foreach ($ccc as $cc) {
$courses[$cc->id] = "$cc->shortname";
}
if ($user) {
- $selector .= " AND l.user = '$user'";
+ $selector .= " AND l.userid = '$user'";
}
if ($date) {
echo "<TD NOWRAP ALIGN=right><FONT SIZE=2>".userdate($log->time, "%A")."</TD>";
echo "<TD NOWRAP><FONT SIZE=2>".userdate($log->time, "%d %B %Y, %I:%M %p")."</TD>";
echo "<TD NOWRAP><FONT SIZE=2>";
- link_to_popup_window("$CFG->wwwroot/lib/ipatlas/plot.php?address=$log->ip&user=$log->user", "ipatlas","$log->ip", 400, 700);
+ link_to_popup_window("$CFG->wwwroot/lib/ipatlas/plot.php?address=$log->ip&user=$log->userid", "ipatlas","$log->ip", 400, 700);
echo "</TD>";
- echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"../user/view.php?id=$log->user&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>";
+ echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"../user/view.php?id=$log->userid&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>";
echo "<TD NOWRAP><FONT SIZE=2>";
link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
echo "</TD>";
}
}
- $teacher->user = $user->id;
+ $teacher->userid = $user->id;
$teacher->course = $course->id;
if ($teachers) {
$teacher->authority = 2;
}
foreach ($rank as $num => $vals) {
- if (! $teacher = get_record("user_teachers", "course", "$course->id", "user", "$num")) {
+ if (! $teacher = get_record("user_teachers", "course", "$course->id", "userid", "$num")) {
error("No such teacher in course $course->shortname with user id $num");
}
$teacher->role = $vals[r];
function update_record($table, $dataobject) {
/// Update a record in a table
/// $dataobject is an object containing needed data
+/// Relies on $dataobject having a variable "id" to
+/// specify the record to update
global $db, $CFG;
if ( $result->RecordCount() == 1 ) {
$user = (object)$result->fields;
- $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_students WHERE user = '$user->id' ");
+ $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_students WHERE userid = '$user->id' ");
while (!$rs->EOF) {
$course = $rs->fields["course"];
$user->student["$course"] = true;
$rs->MoveNext();
}
- $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_teachers WHERE user = '$user->id' ");
+ $rs = $db->Execute("SELECT course FROM {$CFG->prefix}user_teachers WHERE userid = '$user->id' ");
while (!$rs->EOF) {
$course = $rs->fields["course"];
$user->teacher["$course"] = true;
$rs->MoveNext();
}
- $rs = $db->Execute("SELECT * FROM {$CFG->prefix}user_admins WHERE user = '$user->id' ");
+ $rs = $db->Execute("SELECT * FROM {$CFG->prefix}user_admins WHERE userid = '$user->id' ");
while (!$rs->EOF) {
$user->admin = true;
$rs->MoveNext();
return record_exists_sql("SELECT u.id
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_admins a
- WHERE u.id = a.user
+ WHERE u.id = a.userid
AND u.username = '$username'
AND u.password = '$md5password'");
}
global $CFG;
- return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_admins a
- WHERE a.user = u.id
- ORDER BY u.id ASC");
+ return get_records_sql("SELECT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}user_admins a
+ WHERE a.userid = u.id
+ ORDER BY u.id ASC");
}
global $CFG;
return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s
- WHERE s.course = '$courseid' AND s.user = u.id AND u.deleted = '0'
+ WHERE s.course = '$courseid' AND s.userid = u.id AND u.deleted = '0'
ORDER BY $sort");
}
global $CFG;
return get_records_sql("SELECT u.*,t.authority,t.role FROM {$CFG->prefix}user u, {$CFG->prefix}user_teachers t
- WHERE t.course = '$courseid' AND t.user = u.id AND u.deleted = '0'
+ WHERE t.course = '$courseid' AND t.userid = u.id AND u.deleted = '0'
ORDER BY $sort");
}
}
/// return get_records_sql("SELECT u.* FROM user u, user_students s, user_teachers t
-/// WHERE (s.course = '$courseid' AND s.user = u.id) OR
-/// (t.course = '$courseid' AND t.user = u.id)
+/// WHERE (s.course = '$courseid' AND s.userid = u.id) OR
+/// (t.course = '$courseid' AND t.userid = u.id)
/// ORDER BY $sort");
}
{$CFG->prefix}user_students s
WHERE lastaccess > '0'
AND lastaccess < '$cutofftime'
- AND u.id = s.user
+ AND u.id = s.userid
GROUP BY u.id");
}
$timenow = time();
$info = addslashes($info);
- $result = $db->Execute("INSERT INTO log
- SET time = '$timenow',
- user = '$USER->id',
- course = '$course',
- ip = '$REMOTE_ADDR',
- module = '$module',
- action = '$action',
- url = '$url',
- info = '$info'");
+ $result = $db->Execute("INSERT INTO log (time,
+ userid,
+ course,
+ ip,
+ module,
+ action,
+ url,
+ info)
+ VALUES ('$timenow',
+ '$USER->id',
+ '$course',
+ '$REMOTE_ADDR',
+ '$module',
+ '$action',
+ '$url',
+ '$info')");
+
if (!$result) {
echo "<P>Error: Could not insert a new entry to the Moodle log</P>"; // Don't throw an error
}
return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
FROM {$CFG->prefix}log
- WHERE user = '$userid'
+ WHERE userid = '$userid'
AND course = '$courseid'
AND `time` > '$coursestart'
GROUP BY day ");
return get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour, count(*) as num
FROM {$CFG->prefix}log
- WHERE user = '$userid'
+ WHERE userid = '$userid'
AND course = '$courseid'
AND `time` > '$daystart'
GROUP BY hour ");
set_config("guestloginbutton", 1);
}
+ if ($oldversion < 2002122300) {
+ execute_sql("ALTER TABLE `log` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `user_admins` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `user_students` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `user_teachers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `user_students` CHANGE `start` `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `user_students` CHANGE `end` `timeend` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ }
+
return true;
}
CREATE TABLE `prefix_log` (
`id` int(10) unsigned NOT NULL auto_increment,
`time` int(10) unsigned NOT NULL default '0',
- `user` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
`ip` varchar(15) NOT NULL default '',
`course` int(10) unsigned NOT NULL default '0',
`module` varchar(10) NOT NULL default '',
CREATE TABLE `prefix_user_admins` (
`id` int(10) unsigned NOT NULL auto_increment,
- `user` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM COMMENT='One record per administrator user';
CREATE TABLE `prefix_user_students` (
`id` int(10) unsigned NOT NULL auto_increment,
- `user` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
`course` int(10) unsigned NOT NULL default '0',
- `start` int(10) unsigned NOT NULL default '0',
- `end` int(10) unsigned NOT NULL default '0',
+ `timestart` int(10) unsigned NOT NULL default '0',
+ `timeend` int(10) unsigned NOT NULL default '0',
`time` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
CREATE TABLE `prefix_user_teachers` (
`id` int(10) unsigned NOT NULL auto_increment,
- `user` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
`course` int(10) unsigned NOT NULL default '0',
`authority` int(10) NOT NULL default '3',
`role` varchar(40) NOT NULL default '',
CREATE TABLE log (
id SERIAL PRIMARY KEY,
time integer NOT NULL default '0',
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
ip varchar(15) NOT NULL default '',
course integer NOT NULL default '0',
module varchar(10) NOT NULL default '',
CREATE TABLE user_admins (
id SERIAL PRIMARY KEY,
- "user" integer NOT NULL default '0'
+ userid integer NOT NULL default '0'
);
CREATE TABLE user_students (
id SERIAL PRIMARY KEY,
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
course integer NOT NULL default '0',
- "start" integer NOT NULL default '0',
- "end" integer NOT NULL default '0',
+ timestart integer NOT NULL default '0',
+ timeend integer NOT NULL default '0',
time integer NOT NULL default '0'
);
CREATE TABLE user_teachers (
id SERIAL PRIMARY KEY,
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
course integer NOT NULL default '0',
authority integer NOT NULL default '3',
role varchar(40) NOT NULL default ''
global $USER;
if (!$userid) {
- return record_exists("user_admins", "user", $USER->id);
+ return record_exists("user_admins", "userid", $USER->id);
}
- return record_exists("user_admins", "user", $userid);
+ return record_exists("user_admins", "userid", $userid);
}
return $USER->teacher[$courseid];
}
- return record_exists("user_teachers", "user", $userid, "course", $courseid);
+ return record_exists("user_teachers", "userid", $userid, "course", $courseid);
}
return $USER->student[$courseid];
}
- $timenow = time(); // todo: add time check below
+ // $timenow = time(); // todo: add time check below
- return record_exists("user_students", "user", $userid, "course", $courseid);
+ return record_exists("user_students", "userid", $userid, "course", $courseid);
}
function isguest($userid=0) {
/// Enrols a student in a given course
global $db;
- $record->user = $user;
+ $record->userid = $user;
$record->course = $course;
$record->start = 0;
$record->end = 0;
$record->time = time();
- return insert_record("user", $record);
+ return insert_record("user_students", $record);
}
function unenrol_student($user, $course=0) {
/// First delete any crucial stuff that might still send mail
if ($forums = get_records("forum", "course", $course)) {
foreach ($forums as $forum) {
- delete_records("forum_subscriptions", "forum", $forum->id, "user", $user);
+ delete_records("forum_subscriptions", "forum", $forum->id, "userid", $user);
}
}
- return delete_records("user_students", "user", $user, "course", $course);
+ return delete_records("user_students", "userid", $user, "course", $course);
} else {
- delete_records("forum_subscriptions", "user", $user);
- return delete_records("user_students", "user", $user);
+ delete_records("forum_subscriptions", "userid", $user);
+ return delete_records("user_students", "userid", $user);
}
}
/// First delete any crucial stuff that might still send mail
if ($forums = get_records("forum", "course", $course)) {
foreach ($forums as $forum) {
- delete_records("forum_subscriptions", "forum", $forum->id, "user", $user);
+ delete_records("forum_subscriptions", "forum", $forum->id, "userid", $user);
}
}
- return delete_records("user_teachers", "user", $user, "course", $course);
+ return delete_records("user_teachers", "userid", $user, "course", $course);
} else {
- delete_records("forum_subscriptions", "user", $user);
- return delete_records("user_teachers", "user", $user);
+ delete_records("forum_subscriptions", "userid", $user);
+ return delete_records("user_teachers", "userid", $user);
}
}
/// Removes an admin from a site
global $db;
- return delete_records("user_admins", "user", $user);
+ return delete_records("user_admins", "userid", $user);
}
if ($oldversion < 2002111500) {
execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` ");
}
+ if ($oldversion < 2002122300) {
+ execute_sql("ALTER TABLE `assignment_submissions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ }
return true;
}
CREATE TABLE `prefix_assignment_submissions` (
`id` int(10) unsigned NOT NULL auto_increment,
`assignment` int(10) unsigned NOT NULL default '0',
- `user` int(10) unsigned NOT NULL default '0',
+ `userid` int(10) unsigned NOT NULL default '0',
`timecreated` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
`numfiles` int(10) unsigned NOT NULL default '0',
CREATE TABLE assignment_submissions (
id SERIAL PRIMARY KEY,
assignment integer NOT NULL default '0',
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
timecreated integer NOT NULL default '0',
timemodified integer NOT NULL default '0',
numfiles integer NOT NULL default '0',
echo "Processing assignment submission $submission->id\n";
- if (! $user = get_record("user", "id", "$submission->user")) {
- echo "Could not find user $post->user\n";
+ if (! $user = get_record("user", "id", "$submission->userid")) {
+ echo "Could not find user $post->userid\n";
continue;
}
/// Must return an array of grades, indexed by user, and a max grade.
$return->grades = get_records_menu("assignment_submissions", "assignment",
- $assignmentid, "", "user,grade");
+ $assignmentid, "", "userid,grade");
$return->maxgrade = get_field("assignment", "grade", "id", "$assignmentid");
return $return;
}
FROM {$CFG->prefix}assignment a,
{$CFG->prefix}user u
WHERE a.id = '$log->info'
- AND u.id = '$log->user'");
+ AND u.id = '$log->userid'");
}
function assignment_get_all_submissions($assignment) {
return get_records_sql("SELECT a.*
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}user_students s
- WHERE a.user = s.user
+ WHERE a.userid = s.userid
AND s.course = '$assignment->course'
AND a.assignment = '$assignment->id'
ORDER BY a.timemodified DESC");
{$CFG->prefix}user_students s,
{$CFG->prefix}assignment_submissions a
WHERE s.course = '$assignment->course'
- AND s.user = u.id
- AND u.id = a.user
+ AND s.userid = u.id
+ AND u.id = a.userid
AND a.assignment = '$assignment->id'
ORDER BY a.timemodified DESC");
}
}
function assignment_get_submission($assignment, $user) {
- return get_record("assignment_submissions", "assignment", $assignment->id, "user", $user->id);
+ return get_record("assignment_submissions", "assignment", $assignment->id, "userid", $user->id);
}
function assignment_print_difference($time) {
/// Make some easy ways to reference submissions
if ($submissions = assignment_get_all_submissions($assignment)) {
foreach ($submissions as $submission) {
- $submissionbyuser[$submission->user] = $submission;
+ $submissionbyuser[$submission->userid] = $submission;
}
}
foreach($users as $user) {
if (!isset($submissionbyuser[$user->id])) { // Need to create empty entry
$newsubmission->assignment = $assignment->id;
- $newsubmission->user = $user->id;
+ $newsubmission->userid = $user->id;
$newsubmission->timecreated = time();
if (!insert_record("assignment_submissions", $newsubmission)) {
error("Could not insert a new empty submission");
$newsubmission->mailed = 0; // Make sure mail goes out (again, even)
$newsubmission->id = $num;
if (! update_record("assignment_submissions", $newsubmission)) {
- notify(get_string("failedupdatefeedback", "assignment", $submission->user));
+ notify(get_string("failedupdatefeedback", "assignment", $submission->userid));
} else {
$count++;
}
echo "<FORM ACTION=submissions.php METHOD=post>\n";
foreach ($submissions as $submission) {
- $user = $users[$submission->user];
+ $user = $users[$submission->userid];
assignment_print_submission($assignment, $user, $submission, $teachers, $grades);
}
}
} else {
$newsubmission->assignment = $assignment->id;
- $newsubmission->user = $USER->id;
+ $newsubmission->userid = $USER->id;
$newsubmission->timecreated = time();
$newsubmission->timemodified = time();
$newsubmission->numfiles = 1;
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002111500;
+$module->version = 2002122300;
$module->cron = 60;
?>
execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`");
}
+ if ($oldversion < 2002122300) {
+ execute_sql("ALTER TABLE `choice_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ }
return true;
}
CREATE TABLE prefix_choice_answers (\r
id int(10) unsigned NOT NULL auto_increment,\r
choice int(10) unsigned NOT NULL default '0',\r
- user int(10) unsigned NOT NULL default '0',\r
+ userid int(10) unsigned NOT NULL default '0',\r
answer tinyint(4) NOT NULL default '0',\r
timemodified int(10) NOT NULL default '0',\r
PRIMARY KEY (id),\r
// This function does anything necessary to upgrade
// older versions to match current functionality
- if ($oldversion < 2002090800) {
- execute_sql(" ALTER TABLE `choice` CHANGE `answer1` `answer1` VARCHAR( 255 )");
- execute_sql(" ALTER TABLE `choice` CHANGE `answer2` `answer2` VARCHAR( 255 )");
- }
- if ($oldversion < 2002102400) {
- execute_sql(" ALTER TABLE `choice` ADD `answer3` varchar(255) NOT NULL AFTER `answer2`");
- execute_sql(" ALTER TABLE `choice` ADD `answer4` varchar(255) NOT NULL AFTER `answer3`");
- execute_sql(" ALTER TABLE `choice` ADD `answer5` varchar(255) NOT NULL AFTER `answer4`");
- execute_sql(" ALTER TABLE `choice` ADD `answer6` varchar(255) NOT NULL AFTER `answer5`");
- }
return true;
}
CREATE TABLE choice_answers (
id SERIAL PRIMARY KEY,
choice integer NOT NULL default '0',
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
answer integer NOT NULL default '0',
timemodified integer NOT NULL default '0'
);
notice("There are no choices", "../../course/view.php?id=$course->id");
}
- if ( $allanswers = get_records("choice_answers", "user", $USER->id)) {
+ if ( $allanswers = get_records("choice_answers", "userid", $USER->id)) {
foreach ($allanswers as $aa) {
$answers[$aa->choice] = $aa;
}
$CHOICE_MAX_NUMBER = 6;
function choice_user_outline($course, $user, $mod, $choice) {
- if ($current = get_record("choice_answers", "choice", $choice->id, "user", $user->id)) {
+ if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $user->id)) {
$result->info = "'".choice_get_answer($choice, $current->answer)."'";
$result->time = $current->timemodified;
return $result;
function choice_user_complete($course, $user, $mod, $choice) {
- if ($current = get_record("choice_answers", "choice", $choice->id, "user", $user->id)) {
+ if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $user->id)) {
$result->info = "'".choice_get_answer($choice, $current->answer)."'";
$result->time = $current->timemodified;
echo get_string("answered", "choice").": $result->info , last updated ".userdate($result->time);
if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
foreach ($allanswers as $aa) {
- $answers[$aa->user] = $aa;
+ $answers[$aa->userid] = $aa;
}
} else {
$answers = array () ;
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002102400;
+$module->version = 2002122300;
$module->cron = 0;
?>
error("Course module is incorrect");
}
- if ($current = get_record("choice_answers", "choice", $choice->id, "user", $USER->id)) {
+ if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $USER->id)) {
$answerchecked[$current->answer] = "CHECKED";
}
add_to_log($course->id, "choice", "update", "view.php?id=$cm->id", "$choice->id");
} else {
$newanswer->choice = $choice->id;
- $newanswer->user = $USER->id;
+ $newanswer->userid = $USER->id;
$newanswer->answer = $form->answer;
$newanswer->timemodified = $timenow;
if (! insert_record("choice_answers", $newanswer)) {
execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` ");
}
+ if ($oldversion < 2002122300) {
+ execute_sql("ALTER TABLE `forum_posts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `forum_ratings` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ execute_sql("ALTER TABLE `forum_subscriptions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ }
+
return true;
}
id int(10) unsigned NOT NULL auto_increment,
discussion int(10) unsigned NOT NULL default '0',
parent int(10) unsigned NOT NULL default '0',
- user int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
created int(10) unsigned NOT NULL default '0',
modified int(10) unsigned NOT NULL default '0',
mailed tinyint(1) unsigned NOT NULL default '0',
CREATE TABLE prefix_forum_ratings (
id int(10) unsigned NOT NULL auto_increment,
- user int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
post int(10) unsigned NOT NULL default '0',
time int(10) unsigned NOT NULL default '0',
rating tinyint(4) NOT NULL default '0',
CREATE TABLE prefix_forum_subscriptions (
id int(10) unsigned NOT NULL auto_increment,
- user int(10) unsigned NOT NULL default '0',
+ userid int(10) unsigned NOT NULL default '0',
forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
// This function does anything necessary to upgrade
// older versions to match current functionality
- if ($oldversion < 2002073008) {
- execute_sql("DELETE FROM modules WHERE name = 'discuss' ");
- execute_sql("ALTER TABLE `discuss` RENAME `forum_discussions` ");
- execute_sql("ALTER TABLE `discuss_posts` RENAME `forum_posts` ");
- execute_sql("ALTER TABLE `discuss_ratings` RENAME `forum_ratings` ");
- execute_sql("ALTER TABLE `forum` CHANGE `intro` `intro` TEXT NOT NULL ");
- execute_sql("ALTER TABLE `forum` ADD `forcesubscribe` INTEGER DEFAULT '0' NOT NULL AFTER `assessed`");
- execute_sql("ALTER TABLE `forum` CHANGE `type` `type` ENUM( 'single', 'news', 'social', 'general',
- 'eachuser', 'teacher' ) DEFAULT 'general' NOT NULL ");
- execute_sql("ALTER TABLE `forum_posts` CHANGE `discuss` `discussion` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'add', 'forum', 'name') ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'add discussion', 'forum_discussions', 'name') ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'add post', 'forum_posts', 'subject') ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'update post', 'forum_posts', 'subject') ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'view discussion', 'forum_discussions', 'name') ");
- execute_sql("DELETE FROM log_display WHERE module = 'discuss' ");
- execute_sql("UPDATE log SET action = 'view discussion' WHERE module = 'discuss' AND action = 'view' ");
- execute_sql("UPDATE log SET action = 'add discussion' WHERE module = 'discuss' AND action = 'add' ");
- execute_sql("UPDATE log SET module = 'forum' WHERE module = 'discuss' ");
- notify("Renamed all the old discuss tables (now part of forum) and created new forum_types");
- }
-
- if ($oldversion < 2002080100) {
- execute_sql("INSERT INTO log_display VALUES ('forum', 'view subscribers', 'forum', 'name') ");
- execute_sql("INSERT INTO log_display VALUES ('forum', 'update', 'forum', 'name') ");
- }
-
- if ($oldversion < 2002082900) {
- execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ");
- }
-
- if ($oldversion < 2002091000) {
- if (! execute_sql(" ALTER TABLE `forum_posts` ADD `attachment` VARCHAR(100) NOT NULL AFTER `message` ")) {
- echo "<P>Don't worry about this error - your server already had this upgrade applied";
- }
- }
-
- if ($oldversion < 2002100300) {
- execute_sql(" ALTER TABLE `forum` CHANGE `open` `open` INTEGER DEFAULT '2' NOT NULL ");
- execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
- execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
- }
- if ($oldversion < 2002101001) {
- execute_sql(" ALTER TABLE `forum_posts` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `message` ");
- }
+ global $CFG;
return true;
id SERIAL PRIMARY KEY,
discussion integer NOT NULL default '0',
parent integer NOT NULL default '0',
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
created integer NOT NULL default '0',
modified integer NOT NULL default '0',
mailed integer NOT NULL default '0',
CREATE TABLE forum_ratings (
id SERIAL PRIMARY KEY,
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
post integer NOT NULL default '0',
time integer NOT NULL default '0',
rating integer NOT NULL default '0'
CREATE TABLE forum_subscriptions (
id SERIAL PRIMARY KEY,
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
forum integer NOT NULL default '0'
);
# --------------------------------------------------------
print_string("processingpost", "forum", $post->id);
echo " ... ";
- if (! $userfrom = get_record("user", "id", "$post->user")) {
- echo "Could not find user $post->user\n";
+ if (! $userfrom = get_record("user", "id", "$post->userid")) {
+ echo "Could not find user $post->userid\n";
continue;
}
}
if ($ratings = forum_get_user_grades($forumid)) {
foreach ($ratings as $rating) {
- $u = $rating->user;
+ $u = $rating->userid;
$r = $rating->rating;
if (!isset($sumrating[$u])) {
$sumrating[$u][1] = 0;
/// Gets a post with all info ready for forum_print_post
global $CFG;
- return get_record_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
+ return get_record_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.id = '$postid'
- AND p.user = u.id");
+ AND p.userid = u.id");
}
function forum_get_discussion_posts($discussion, $sort) {
/// Gets posts with all info ready for forum_print_post
global $CFG;
- return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
+ return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.discussion = $discussion
AND p.parent > 0
- AND p.user = u.id $sort");
+ AND p.userid = u.id $sort");
}
function forum_get_child_posts($parent) {
/// Gets posts with all info ready for forum_print_post
global $CFG;
- return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
+ return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.parent = '$parent'
- AND p.user = u.id
+ AND p.userid = u.id
ORDER BY p.created ASC");
}
$notteacherforum = "";
}
- return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture,u.id as userid
+ return get_records_sql("SELECT p.*,u.firstname,u.lastname,u.email,u.picture
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}user u,
{$CFG->prefix}forum f
WHERE (p.message LIKE '%$search%' OR p.subject LIKE '%$search%')
- AND p.user = u.id
+ AND p.userid = u.id
AND p.discussion = d.id
AND d.course = '$courseid'
AND d.forum = f.id
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}user u
WHERE r.post = '$postid'
- AND r.user = u.id
+ AND r.userid = u.id
ORDER BY $sort");
}
/// Get all the posts for a user in a forum suitable for forum_print_post
global $CFG;
- return get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
+ return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum f,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
WHERE f.id = '$forumid'
AND d.forum = f.id
AND p.discussion = d.id
- AND p.user = '$userid'
- AND p.user = u.id
+ AND p.userid = '$userid'
+ AND p.userid = u.id
ORDER BY p.modified ASC");
}
if ($log->action == "add post") {
- return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture, u.id as userid
+ return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE p.id = '$log->info'
AND d.id = p.discussion
- AND p.user = u.id
+ AND p.userid = u.id
AND u.deleted <> '1'");
} else if ($log->action == "add discussion") {
- return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture, u.id as userid
+ return get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE d.id = '$log->info'
AND d.firstpost = p.id
- AND p.user = u.id
+ AND p.userid = u.id
AND u.deleted <> '1'");
}
return NULL;
/// Get all user grades for a forum
global $CFG;
- return get_records_sql("SELECT r.id, p.user, r.rating
+ return get_records_sql("SELECT r.id, p.userid, r.rating
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_ratings r
FROM {$CFG->prefix}forum_posts
WHERE parent > 0
AND discussion = '$discussionid'
- AND user <> '$userid' ")) {
+ AND userid <> '$userid' ")) {
if ($rated = get_record_sql("SELECT count(*) as num
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_ratings r
WHERE p.discussion = '$discussionid'
AND p.id = r.post
- AND r.user = '$userid'")) {
+ AND r.userid = '$userid'")) {
$difference = $posts->num - $rated->num;
if ($difference > 0) {
return $difference;
} else {
$userselect = "";
}
- return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
+ return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE d.forum = '$forum'
AND p.discussion = d.id
AND p.parent= 0
- AND p.user = u.id $userselect
+ AND p.userid = u.id $userselect
ORDER BY p.created $forum_sort");
}
global $CFG;
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture,
- u.id as userid, f.type as forumtype, f.name as forumname, f.id as forumid
+ f.type as forumtype, f.name as forumname, f.id as forumid
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u,
WHERE d.course = '$courseid'
AND p.discussion = d.id
AND p.parent = 0
- AND p.user = u.id
+ AND p.userid = u.id
AND u.id = '$userid'
AND d.forum = f.id
ORDER BY p.created ASC");
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_subscriptions s
WHERE s.forum = '$forum->id'
- AND s.user = u.id
+ AND s.userid = u.id
AND u.deleted <> 1");
}
function forum_print_rating($post, $user) {
global $FORUM_POST_RATINGS;
- if ($rating = get_record("forum_ratings", "user", $user, "post", $post)) {
+ if ($rating = get_record("forum_ratings", "userid", $user, "post", $post)) {
if ($FORUM_POST_RATINGS[$rating->rating]) {
echo "<FONT SIZE=-1>".get_string("youratedthis", "forum").": <FONT COLOR=green>";
echo $FORUM_POST_RATINGS[$rating->rating];
$post->discussion = 0;
$post->parent = 0;
- $post->user = $USER->id;
+ $post->userid = $USER->id;
$post->created = $timenow;
$post->modified = $timenow;
$post->mailed = 0;
if (forum_is_forcesubscribed($forumid)) {
return true;
}
- return record_exists("forum_subscriptions", "user", $userid, "forum", $forumid);
+ return record_exists("forum_subscriptions", "userid", $userid, "forum", $forumid);
}
function forum_subscribe($userid, $forumid) {
/// Adds user to the subscriber list
- $sub->user = $userid;
+ $sub->userid = $userid;
$sub->forum = $forumid;
return insert_record("forum_subscriptions", $sub);
function forum_unsubscribe($userid, $forumid) {
/// Removes user from the subscriber list
- return delete_records("forum_subscriptions", "user", $userid, "forum", $forumid);
+ return delete_records("forum_subscriptions", "userid", $userid, "forum", $forumid);
}
global $USER;
- $ownpost = ($USER->id == $post->user);
+ $ownpost = ($USER->id == $post->userid);
$reply = forum_user_can_post($forum);
forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $rate=false);
if ($posts = forum_get_discussion_posts($discussion, $sort)) {
foreach ($posts as $post) {
- $ownpost = ($USER->id == $post->user);
+ $ownpost = ($USER->id == $post->userid);
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
}
} else {
echo "<UL>";
if ($depth > 0) {
- $ownpost = ($USER->id == $post->user);
+ $ownpost = ($USER->id == $post->userid);
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed); // link=true?
echo "<BR>";
} else {
if ($posts = forum_get_child_posts($parent)) {
foreach ($posts as $post) {
- $ownpost = ($USER->id == $post->user);
+ $ownpost = ($USER->id == $post->userid);
echo "<UL>";
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
<input type="hidden" name=forum value="<? p($post->forum) ?>">
<input type="hidden" name=discussion value="<? p($post->discussion) ?>">
<input type="hidden" name=parent value="<? p($post->parent) ?>">
- <input type="hidden" name=user value="<? p($post->user) ?>">
+ <input type="hidden" name=user value="<? p($post->userid) ?>">
<input type="hidden" name=edit value="<? p($post->edit) ?>">
<input type="submit" value="<? print_string("savechanges"); ?>">
</td>
$post->discussion = 0; // ie discussion # not defined yet
$post->parent = 0;
$post->subject = "";
- $post->user = $USER->id;
+ $post->userid = $USER->id;
$post->message = "";
$post->format = $defaultformat;
$post->discussion = $parent->discussion;
$post->parent = $parent->id;
$post->subject = $parent->subject;
- $post->user = $USER->id;
+ $post->userid = $USER->id;
$post->message = "";
$post->format = $defaultformat;
if (! $post = forum_get_post_full($edit)) {
error("Post ID was incorrect");
}
- if ($post->user <> $USER->id) {
+ if ($post->userid <> $USER->id) {
error("You can't edit other people's posts!");
}
if ((time() - $post->created) > $CFG->maxeditingtime) {
if (! $forum = get_record("forum", "id", $discussion->forum)) {
error("The forum number was incorrect ($discussion->forum)");
}
- if (($post->user <> $USER->id) and !isteacher($forum->course)) {
+ if (($post->userid <> $USER->id) and !isteacher($forum->course)) {
error("You can't delete other people's posts!");
}
continue;
}
if ($rating) {
- if (record_exists("forum_ratings", "user", $USER->id, "post", $post)) {
+ if (record_exists("forum_ratings", "userid", $USER->id, "post", $post)) {
error("You've rated this question before ($post)");
} else {
unset($newrating);
- $newrating->user = $USER->id;
+ $newrating->userid = $USER->id;
$newrating->time = time();
$newrating->post = $post;
$newrating->rating = $rating;
error("Course ID was incorrect");
}
- if (!isteacher($course->id) and $USER->id != $post->user) {
+ if (!isteacher($course->id) and $USER->id != $post->userid) {
error("You can only look at results for posts you own");
}
require("../../config.php");
require("lib.php");
- require_variable($id); // course id
- optional_variable($search, ""); // user id
+ require_variable($id); // course id
+ optional_variable($search, ""); // search string
$search = strip_tags($search);
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002101001;
+$module->version = 2002122300;
$module->cron = 60;
?>
if ($oldversion < 2002101200) {
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
}
+ if ($oldversion < 2002122300) {
+ execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
+ }
+
return $result;
}
CREATE TABLE prefix_journal_entries (\r
id int(10) unsigned NOT NULL auto_increment,\r
journal int(10) unsigned NOT NULL default '0',\r
- user int(10) unsigned NOT NULL default '0',\r
+ userid int(10) unsigned NOT NULL default '0',\r
modified int(10) unsigned NOT NULL default '0',\r
text text NOT NULL,\r
format tinyint(2) NOT NULL default '0',\r
$result = true;
- if ($oldversion < 20020810) {
- if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` INTEGER DEFAULT '0' NOT NULL")) {
- $result = false;
- }
- }
- if ($oldversion < 2002101200) {
- execute_sql(" ALTER TABLE `journal_entries` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `text` ");
- }
-
return $result;
}
CREATE TABLE journal_entries (
id SERIAL PRIMARY KEY,
journal integer NOT NULL default '0',
- "user" integer NOT NULL default '0',
+ userid integer NOT NULL default '0',
modified integer NOT NULL default '0',
text text NOT NULL default '',
format integer NOT NULL default '0',
error("Course module is incorrect");
}
- $entry = get_record("journal_entries", "user", $USER->id, "journal", $journal->id);
+ $entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id);
/// If data submitted, then process and store.
}
add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id");
} else {
- $newentry->user = $USER->id;
+ $newentry->userid = $USER->id;
$newentry->journal = $journal->id;
$newentry->modified = $timenow;
$newentry->text = $text;
foreach ($journals as $journal) {
- $entrytext = get_field("journal_entries", "text", "user", $USER->id, "journal", $journal->id");
+ $entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id");
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if ($journal->daysopen) {
// STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
function journal_user_outline($course, $user, $mod, $journal) {
- if ($entry = get_record("journal_entries", "user", $user->id, "journal", $journal->id)) {
+ if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
$numwords = count(preg_split("/\w\b/", $entry->text)) - 1;
function journal_user_complete($course, $user, $mod, $journal) {
- if ($entry = get_record("journal_entries", "user", $user->id, "journal", $journal->id)) {
+ if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
print_simple_box_start();
if ($entry->modified) {
echo "Processing journal entry $entry->id\n";
- if (! $user = get_record("user", "id", "$entry->user")) {
- echo "Could not find user $post->user\n";
+ if (! $user = get_record("user", "id", "$entry->userid")) {
+ echo "Could not find user $entry->userid\n";
continue;
}
/// Must return an array of grades, indexed by user, and a max grade.
global $JOURNAL_RATING;
- if ($return->grades = get_records_menu("journal_entries", "journal", $journalid, "", "user,rating")) {
+ if ($return->grades = get_records_menu("journal_entries", "journal", $journalid, "", "userid,rating")) {
foreach ($return->grades as $key => $value) {
if ($value) {
$return->grades[$key] = $JOURNAL_RATING[$value];
{$CFG->prefix}user_students s,
{$CFG->prefix}user_teachers t,
{$CFG->prefix}journal_entries j
- WHERE ((s.course = '$journal->course' AND s.user = u.id)
- OR (t.course = '$journal->course' AND t.user = u.id))
- AND u.id = j.user
+ WHERE ((s.course = '$journal->course' AND s.userid = u.id)
+ OR (t.course = '$journal->course' AND t.userid = u.id))
+ AND u.id = j.userid
AND j.journal = '$journal->id'
ORDER BY j.modified DESC");
}
{$CFG->prefix}user u
WHERE e.id = '$log->info'
AND e.journal = j.id
- AND e.user = u.id");
+ AND e.userid = u.id");
}
// OTHER JOURNAL FUNCTIONS ///////////////////////////////////////////////////////////////////
// make some easy ways to access the entries.
if ( $eee = get_records("journal_entries", "journal", $journal->id)) {
foreach ($eee as $ee) {
- $entrybyuser[$ee->user] = $ee;
+ $entrybyuser[$ee->userid] = $ee;
$entrybyentry[$ee->id] = $ee;
}
$newentry->mailed = 0; // Make sure mail goes out (again, even)
$newentry->id = $num;
if (! update_record("journal_entries", $newentry)) {
- notify("Failed to update the journal feedback for user $entry->user");
+ notify("Failed to update the journal feedback for user $entry->userid");
} else {
$count++;
}
- $entrybyuser[$entry->user]->rating = $vals[r];
- $entrybyuser[$entry->user]->comment = $vals[c];
- $entrybyuser[$entry->user]->teacher = $USER->id;
- $entrybyuser[$entry->user]->timemarked = $timenow;
+ $entrybyuser[$entry->userid]->rating = $vals[r];
+ $entrybyuser[$entry->userid]->comment = $vals[c];
+ $entrybyuser[$entry->userid]->teacher = $USER->id;
+ $entrybyuser[$entry->userid]->timemarked = $timenow;
}
}
add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users");
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002101200;
+$module->version = 2002122300;
$module->cron = 60;
?>
}
- if ($entry = get_record("journal_entries", "user", $USER->id, "journal", $journal->id)) {
+ if ($entry = get_record("journal_entries", "userid", $USER->id, "journal", $journal->id)) {
if (empty($entry->text)) {
echo "<P ALIGN=center><B>".get_string("blankentry","journal")."</B></P>";
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;
}
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',
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`)
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;
}
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',
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'
);
/// 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";
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;
}
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) {
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;
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");
}
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;
}
$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)) {
}
} 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)) {
}
}
- $users[$attempt->user] = $attempt->user;
+ $users[$attempt->userid] = $attempt->userid;
}
if ($users) {
$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));
}
// 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)?
?>
function resource_user_outline($course, $user, $mod, $resource) {
- if ($logs = get_records_sql("SELECT * FROM log
- WHERE user='$user->id' AND module='resource'
- AND action='view' AND info='$resource->id'
- ORDER BY time ASC")) {
+ if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
+ AND action='view' AND info='$resource->id'", "time ASC")) {
$numviews = count($logs);
$lastlog = array_pop($logs);
function resource_user_complete($course, $user, $mod, $resource) {
global $CFG, $THEME;
- if ($logs = get_records_sql("SELECT * FROM log
- WHERE user='$user->id' AND module='resource'
- AND action='view' AND info='$resource->id'
- ORDER BY time ASC")) {
-
+ if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
+ AND action='view' AND info='$resource->id'", "time ASC")) {
$numviews = count($logs);
$lastlog = array_pop($logs);
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002101700;
+$module->version = 2002122300;
$module->cron = 0;
?>
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;
}
CREATE TABLE prefix_survey_analysis (\r
id int(10) unsigned NOT NULL auto_increment,\r
survey int(10) unsigned NOT NULL default '0',\r
- user int(10) unsigned NOT NULL default '0',\r
+ userid int(10) unsigned NOT NULL default '0',\r
notes text NOT NULL,\r
PRIMARY KEY (id),\r
UNIQUE KEY id (id)\r
\r
CREATE TABLE prefix_survey_answers (\r
id int(10) unsigned NOT NULL auto_increment,\r
- user int(10) unsigned NOT NULL default '0',\r
+ userid int(10) unsigned NOT NULL default '0',\r
survey int(10) unsigned NOT NULL default '0',\r
question int(10) unsigned NOT NULL default '0',\r
time int(10) unsigned default NULL,\r
// 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;
}
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 ''
);
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,
}
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;
}
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";
if ($aaa) {
foreach ($aaa as $a) {
- if ($a->user == $sid) {
+ if ($a->userid == $sid) {
if ($a->answer1) {
$studbuckets1[$i] += $a->answer1;
$studcount1[$i]++;
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]++;
}
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);
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) {
{$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) {
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) {
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)) {
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];
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002110903;
+$module->version = 2002122300;
$module->cron = 0;
?>
echo "</FORM></P></TD>";
}
}
- if ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or
- (isteacher($course->id) and isstudent($course->id, $user->id)) ) {
+ if ($course->category and
+ ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or
+ (isteacher($course->id) and isstudent($course->id, $user->id))) ) {
echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
echo "<INPUT type=hidden name=id value=\"$course->id\">";
echo "<INPUT type=hidden name=user value=\"$user->id\">";
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2002121200; // The current version is a date (YYYYMMDDXX)
+$version = 2002122300; // The current version is a date (YYYYMMDDXX)
$release = "1.0.8 dev"; // User-friendly version number