From f950af3c43b2f7b285824ba5d1635e09da0cfd2f Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sun, 22 Aug 2004 14:38:47 +0000 Subject: [PATCH] All modules are now suitable for the site page. They now all follow the same rules, namely that any students enrolled in at least one course is considered to be a student on the site. All the page headers work correctly also on the site course. On the site page the modules don't require login unless necessary or required by $CFG->forcelogin. --- course/enrol.php | 6 + lang/en/choice.php | 1 + lang/en/moodle.php | 1 + lib/datalib.php | 31 +- lib/db/mysql.php | 8 + lib/moodlelib.php | 30 +- mod/assignment/index.php | 17 +- mod/assignment/lib.php | 43 +- mod/assignment/view.php | 4 +- mod/attendance/index.php | 2 +- mod/attendance/lib.php | 400 +++++++++--------- mod/chat/index.php | 2 +- mod/chat/view.php | 2 +- mod/choice/index.php | 4 +- mod/choice/view.php | 8 +- mod/dialogue/locallib.php | 42 +- mod/exercise/locallib.php | 80 +++- mod/forum/post.php | 5 +- mod/forum/search.php | 15 +- mod/glossary/edit.php | 10 +- mod/glossary/formats.php | 24 +- mod/glossary/index.php | 2 +- mod/glossary/print.php | 2 +- mod/glossary/sql.php | 12 +- mod/glossary/view.php | 4 +- mod/journal/edit.php | 37 +- mod/journal/index.php | 2 +- mod/journal/lib.php | 74 ++-- mod/journal/report.php | 5 +- mod/lesson/import.php | 3 +- mod/lesson/index.php | 7 +- mod/quiz/category.php | 11 +- mod/quiz/edit.php | 3 +- mod/quiz/export.php | 19 +- mod/quiz/import.php | 5 +- mod/quiz/multiple.php | 9 +- mod/quiz/question.php | 5 +- .../categorydatasetdefinitions.php | 5 +- mod/scorm/details.php | 310 +++++++------- mod/survey/details.php | 5 +- mod/survey/index.php | 4 +- mod/survey/save.php | 9 +- mod/wiki/index.php | 2 +- mod/workshop/lib.php | 11 +- mod/workshop/locallib.php | 60 ++- version.php | 2 +- 46 files changed, 763 insertions(+), 580 deletions(-) diff --git a/course/enrol.php b/course/enrol.php index 9f0c57588e..bd2d7ee8cc 100644 --- a/course/enrol.php +++ b/course/enrol.php @@ -42,6 +42,12 @@ redirect($destination); } + +/// Users can't enroll to site course + if (!$course->category) { + print_header_simple(); + notice(get_string('enrollfirst'), $CFG->wwwroot); + } /// Double check just in case they are enrolled to start in the future diff --git a/lang/en/choice.php b/lang/en/choice.php index 3be5e60b30..c7ea7d678d 100644 --- a/lang/en/choice.php +++ b/lang/en/choice.php @@ -9,6 +9,7 @@ $string['choiceclose'] = 'Until'; $string['choicename'] = 'Choice name'; $string['choiceopen'] = 'Open'; $string['choicetext'] = 'Choice text'; +$string['havetologin'] = 'You have to log in before you can submit your choice'; $string['modulename'] = 'Choice'; $string['modulenameplural'] = 'Choices'; $string['mustchooseone'] = 'You must choose an answer before saving. Nothing was saved.'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 46e39bdc14..63ad4bdbae 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -378,6 +378,7 @@ $string['enable'] = 'Enable'; $string['encryptedcode'] = 'Encrypted code'; $string['enrolledincourse'] = 'Enrolled in course \"$a\"'; $string['enrolledincoursenot'] = 'Not enrolled in course \"$a\"'; +$string['enrollfirst'] = 'You have to enroll in one of the courses before you can use the site activities'; $string['enrolmentconfirmation'] = 'You are about to enroll yourself as a member of this course.
Are you sure you wish to do this?'; $string['enrolmentkey'] = 'Enrolment key'; $string['enrolmentkeyfrom'] = 'This course requires an \'enrolment key\' - a one-time
diff --git a/lib/datalib.php b/lib/datalib.php index 5f54fb1681..2c530787a8 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -947,8 +947,8 @@ function get_user_info_from_db($field, $value) { $user->admin = true; } - if ($site = get_site()) { // Everyone is always a member of the top course - $user->student[$site->id] = true; + if ($site = get_site()) { + $user->student[$site->id] = isstudent($site->id, $user->id); } /// Determine enrolments based on current enrolment module @@ -1152,15 +1152,6 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0, global $CFG; - $site = get_site(); - if (!$courseid or $courseid == $site->id) { - $sort = str_replace('s.timeaccess', 'lastaccess', $sort); // site users can't be sorted by timeaccess - if ($sort) { - $sort = "$sort $dir"; - } - return get_site_users($sort, '', $exceptions); - } - switch ($CFG->dbtype) { case "mysql": $fullname = " CONCAT(firstname,\" \",lastname) "; @@ -1179,7 +1170,15 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0, } $groupmembers = ''; - $select = "s.course = '$courseid' AND s.userid = u.id AND u.deleted = '0' "; + + // make sure it works on the site course + $select = "s.course = '$courseid' AND "; + $site = get_site(); + if ($courseid == $site->id) { + $select = ''; + } + + $select .= "s.userid = u.id AND u.deleted = '0' "; if (!$fields) { $fields = 'u.id, u.confirmed, u.username, u.firstname, u.lastname, '. @@ -1306,19 +1305,11 @@ function get_course_teachers($courseid, $sort="t.authority ASC", $exceptions='') /** * Returns all the users of a course: students and teachers -* -* If the "course" is actually the site, then return all site users. * * @param type description */ function get_course_users($courseid, $sort="timeaccess DESC", $exceptions='') { - $site = get_site(); - - if ($courseid == $site->id) { - return get_site_users($sort, '', $exceptions); - } - /// Using this method because the single SQL is too inefficient // Note that this has the effect that teachers and students are // sorted individually. Returns first all teachers, then all students diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 8db8532e1a..cfc0648cc5 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -821,6 +821,14 @@ function main_upgrade($oldversion=0) { execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)"); } } + + if ($oldversion < 2004082200) { // Making admins teachers on site course + $site = get_site(); + $admins = get_admins(); + foreach ($admins as $admin) { + add_teacher($admin->id, $site->id); + } + } return $result; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 285bad3a4b..752c0ebefe 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -430,6 +430,19 @@ function require_login($courseid=0, $autologinguest=true) { } } +function require_course_login($course, $autologinguest=true) { +// This is a weaker version of require_login which only requires login +// when called from within a course rather than the site page, unless +// the forcelogin option is turned on. + global $CFG; + if ($CFG->forcelogin) { + require_login(); + } + if ($course->category) { + require_login($course->id, $autologinguest); + } +} + function update_user_login_times() { global $USER; @@ -583,8 +596,8 @@ function isstudent($courseid, $userid=0) { if (isguest($userid)) { return false; } - return record_exists('user', 'id', $userid, 'confirmed', 1, 'deleted', 0); - } + return record_exists('user_students', 'userid', $userid); + } if (!$userid) { return !empty($USER->student[$courseid]); @@ -952,6 +965,15 @@ function add_admin($userid) { if (!record_exists("user_admins", "userid", $userid)) { if (record_exists("user", "id", $userid)) { $admin->userid = $userid; + + // any admin is also a teacher on the site course + $site = get_site(); + if (!record_exists('user_teachers', 'course', $site->id, 'userid', $userid)) { + if (!add_teacher($userid, $site->id)) { + return false; + } + } + return insert_record("user_admins", $admin); } return false; @@ -963,6 +985,10 @@ function remove_admin($userid) { /// Removes an admin from a site global $db; + // remove also from the list of site teachers + $site = get_site(); + remove_teacher($userid, $site->id); + return delete_records("user_admins", "userid", $userid); } diff --git a/mod/assignment/index.php b/mod/assignment/index.php index f288c48ec9..7cbe078eba 100644 --- a/mod/assignment/index.php +++ b/mod/assignment/index.php @@ -9,7 +9,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "assignment", "view all", "index.php?id=$course->id", ""); $strassignments = get_string("modulenameplural", "assignment"); @@ -52,6 +52,7 @@ $currentsection = ""; foreach ($assignments as $assignment) { + $submitted = get_string("no"); if (isteacher($course->id)) { if ($assignment->type == OFFLINE) { $submitted = "id\">" . @@ -62,14 +63,14 @@ get_string("viewsubmissions", "assignment", $count) . "$groupname"; } } else { - if ($submission = assignment_get_submission($assignment, $USER)) { - if ($submission->timemodified <= $assignment->timedue) { - $submitted = userdate($submission->timemodified); - } else { - $submitted = "".userdate($submission->timemodified).""; + if (isset($USER->id)) { + if ($submission = assignment_get_submission($assignment, $USER)) { + if ($submission->timemodified <= $assignment->timedue) { + $submitted = userdate($submission->timemodified); + } else { + $submitted = "".userdate($submission->timemodified).""; + } } - } else { - $submitted = get_string("no"); } } diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 0fd16af2b6..234c83daa9 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -423,14 +423,18 @@ function assignment_count_real_submissions($assignment, $groupid=0) { AND a.timemodified > 0 AND g.groupid = '$groupid' AND a.userid = g.userid "); - } else { + } else { + $select = "s.course = '$assignment->course' AND"; + $site = get_site(); + if ($assignment->course == $site->id) { + $select = ''; + } return count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}assignment_submissions a, {$CFG->prefix}user_students s WHERE a.assignment = '$assignment->id' AND a.timemodified > 0 - AND s.course = '$assignment->course' - AND a.userid = s.userid "); + AND $select a.userid = s.userid "); } } @@ -445,26 +449,36 @@ function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") { } else { $sort = "a.$sort $dir"; } + + $select = "s.course = '$assignment->course' AND"; + $site = get_site(); + if ($assignment->course == $site->id) { + $select = ''; + } return get_records_sql("SELECT a.* FROM {$CFG->prefix}assignment_submissions a, {$CFG->prefix}user_students s, {$CFG->prefix}user u WHERE a.userid = s.userid AND u.id = a.userid - AND s.course = '$assignment->course' - AND a.assignment = '$assignment->id' + AND $select a.assignment = '$assignment->id' ORDER BY $sort"); } function assignment_get_users_done($assignment) { /// Return list of users who have done an assignment global $CFG; + + $select = "s.course = '$assignment->course' AND"; + $site = get_site(); + if ($assignment->course == $site->id) { + $select = ''; + } return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s, {$CFG->prefix}assignment_submissions a - WHERE s.course = '$assignment->course' - AND s.userid = u.id + WHERE $select s.userid = u.id AND u.id = a.userid AND a.assignment = '$assignment->id' ORDER BY a.timemodified DESC"); @@ -473,7 +487,7 @@ function assignment_get_users_done($assignment) { function assignment_get_unmailed_submissions($cutofftime) { /// Return list of marked submissions that have not been mailed out for currently enrolled students global $CFG; - return get_records_sql("SELECT s.*, a.course, a.name + $records = get_records_sql("SELECT s.*, a.course, a.name FROM {$CFG->prefix}assignment_submissions s, {$CFG->prefix}assignment a, {$CFG->prefix}user_students us @@ -483,6 +497,19 @@ function assignment_get_unmailed_submissions($cutofftime) { AND s.assignment = a.id AND s.userid = us.userid AND a.course = us.course"); + $site = get_site(); + if (record_exists('assignment', 'course', $site->id)) { + $records += get_records_sql("SELECT s.*, a.course, a.name + FROM {$CFG->prefix}assignment_submissions s, + {$CFG->prefix}assignment a, + {$CFG->prefix}user_students us + WHERE s.mailed = 0 + AND s.timemarked < $cutofftime + AND s.timemarked > 0 + AND s.assignment = a.id + AND s.userid = us.userid + AND a.course = $site->id"); + } } diff --git a/mod/assignment/view.php b/mod/assignment/view.php index d2125115e0..1f058f30b4 100644 --- a/mod/assignment/view.php +++ b/mod/assignment/view.php @@ -31,7 +31,7 @@ } } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "assignment", "view", "view.php?id=$cm->id", $assignment->id, $cm->id); @@ -94,7 +94,7 @@ print_simple_box_end(); echo "
"; - if (!isteacher($course->id) and !isguest()) { + if (isstudent($course->id)) { $submission = assignment_get_submission($assignment, $USER); if ($assignment->type == OFFLINE) { diff --git a/mod/attendance/index.php b/mod/attendance/index.php index 2055f4113c..7922744f01 100644 --- a/mod/attendance/index.php +++ b/mod/attendance/index.php @@ -13,7 +13,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "attendance", "viewall", "index.php?id=$course->id", ""); diff --git a/mod/attendance/lib.php b/mod/attendance/lib.php index f37b96264b..bee964aff2 100755 --- a/mod/attendance/lib.php +++ b/mod/attendance/lib.php @@ -31,44 +31,44 @@ function attendance_add_module(&$mod) { } function attendance_add_instance($attendance) { - global $mod; + global $mod; $attendance->timemodified = time(); $attendance->dynsection = !empty($attendance->dynsection) ? 1 : 0; $attendance->autoattend = !empty($attendance->autoattend) ? 1 : 0; $attendance->grade = !empty($attendance->grade) ? 1 : 0; if (empty($attendance->day)) { $attendance->day = make_timestamp($attendance->theyear, - $attendance->themonth, $attendance->theday); + $attendance->themonth, $attendance->theday); } $attendance->notes = $attendance->name; $attendance->name=userdate($attendance->day, get_string("strftimedate")); - if ($attendance->notes) { - $attendance->name = $attendance->name . " - " . $attendance->notes; - } - $attendance->edited = 0; + if ($attendance->notes) { + $attendance->name = $attendance->name . " - " . $attendance->notes; + } + $attendance->edited = 0; if ($attendance->dynsection) { - if ($mod->course) { - if (! $course = get_record("course", "id", $mod->course)) { - error("Course is misconfigured"); - } - } + if ($mod->course) { + if (! $course = get_record("course", "id", $mod->course)) { + error("Course is misconfigured"); + } + } if ($course->format =="weeks") { -// floor($date_relative / 604800) + 1 - $attendance->section = floor(($attendance->day - $course->startdate)/604800) +1; - if($attendance->section > $course->numsections){ - $attendance->section = 0; - } - $attendance->section = "$attendance->section"; - $mod->section = "$attendance->section"; +// floor($date_relative / 604800) + 1 + $attendance->section = floor(($attendance->day - $course->startdate)/604800) +1; + if($attendance->section > $course->numsections){ + $attendance->section = 0; + } + $attendance->section = "$attendance->section"; + $mod->section = "$attendance->section"; } } - // insert the main record first - return $attendance->id = insert_record("attendance", $attendance); + // insert the main record first + return $attendance->id = insert_record("attendance", $attendance); } function attendance_update_instance($attendance) { - global $mod; + global $mod; $attendance->edited = 1; $attendance->timemodified = time(); // $attendance->oldid=$attendance->id; @@ -78,76 +78,76 @@ function attendance_update_instance($attendance) { $attendance->grade = !empty($attendance->grade) ? 1 : 0; $attendance->day = make_timestamp($attendance->theyear, - $attendance->themonth, $attendance->theday); + $attendance->themonth, $attendance->theday); $attendance->notes = $attendance->name; $attendance->name=userdate($attendance->day, get_string("strftimedate")); - if ($attendance->notes) { - $attendance->name = $attendance->name . " - " . $attendance->notes; - } + if ($attendance->notes) { + $attendance->name = $attendance->name . " - " . $attendance->notes; + } if ($attendance->dynsection) { - //get info about the course - if ($attendance->course) { - if (! $course = get_record("course", "id", $attendance->course)) { - error("Course is misconfigured"); - } - } - //work out which section this should be in - $attendance->section = floor(($attendance->day - $course->startdate)/604800) +1; - if (($attendance->section > $course->numsections) || ($attendance->section < 0)){ - $attendance->section = 0; - } -// $attendance->section = "$attendance->section"; - } - // get the data from the attendance grid + //get info about the course + if ($attendance->course) { + if (! $course = get_record("course", "id", $attendance->course)) { + error("Course is misconfigured"); + } + } + //work out which section this should be in + $attendance->section = floor(($attendance->day - $course->startdate)/604800) +1; + if (($attendance->section > $course->numsections) || ($attendance->section < 0)){ + $attendance->section = 0; + } +// $attendance->section = "$attendance->section"; + } + // get the data from the attendance grid if ($data = data_submitted()) { // Peel out all the data from variable names. $attrec->dayid = $attendance->id; if ($data) foreach ($data as $key => $val) { $pieces = explode('_',$key); if ($pieces[0] == 'student') { - $attrec->userid=$pieces[1]; + $attrec->userid=$pieces[1]; $attrec->hour=$pieces[2]; $attrec->status=$val; // clear out any old records for the student - delete_records("attendance_roll", + delete_records("attendance_roll", "dayid",$attrec->dayid, "hour", $attrec->hour, "userid",$attrec->userid); if ($attrec->status != 0) { // student is registered as absent or tardy - insert_record("attendance_roll",$attrec, false); + insert_record("attendance_roll",$attrec, false); } - } // if we have a piece of the student roll data + } // if we have a piece of the student roll data } // foreach for all form variables - } // if - - - if(!update_record("attendance", $attendance)){ - error("Couldn't update record"); - } - - if ($attendance->dynsection) { - //get section info - $section = get_record("course_sections", "course", $attendance->course, "section", $attendance->section); - - //remove module from the current section - if (! delete_mod_from_section($attendance->coursemodule, $mod->section)) { - notify("Could not delete module from existing section"); - } - - //update course with new module location - if(! set_field("course_modules", "section", $section->id, "id", $attendance->coursemodule)){ - notify("Could not update course module list"); - } - - //add module to the new section - if (! add_mod_to_section($attendance, NULL)) { - notify("Could not add module to new section"); - } - - rebuild_course_cache($section->course); - } - return true; + } // if + + + if(!update_record("attendance", $attendance)){ + error("Couldn't update record"); + } + + if ($attendance->dynsection) { + //get section info + $section = get_record("course_sections", "course", $attendance->course, "section", $attendance->section); + + //remove module from the current section + if (! delete_mod_from_section($attendance->coursemodule, $mod->section)) { + notify("Could not delete module from existing section"); + } + + //update course with new module location + if(! set_field("course_modules", "section", $section->id, "id", $attendance->coursemodule)){ + notify("Could not update course module list"); + } + + //add module to the new section + if (! add_mod_to_section($attendance, NULL)) { + notify("Could not add module to new section"); + } + + rebuild_course_cache($section->course); + } + return true; } function attendance_delete_instance($id) { @@ -174,46 +174,46 @@ function attendance_user_outline($course, $user, $mod, $attendance) { /// $return->time = the time they did it /// $return->info = a short text description /// for attendance, this would be a list present and tardy for every hour of the day - $tardies=count_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 1); - $absences=count_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 2); - + $tardies=count_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 1); + $absences=count_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 2); + // build longer string for tardies - if ($tardies > 0) { - $tardyrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 1, "hour ASC"); - if ($tardies == 1) { - $tardystring = "Tardy in hour " . $tardyrecs[0]->hour . ". "; - } elseif ($tardies == $attendance->hours) { - $tardystring = "Tardy in all hours. (" . $attendance->hours . ") "; - } else { - // build array of all tardies - $tarr = array(); - if ($tardyrecs) foreach ($tardyrecs as $tardyrec) { - array_push($tarr, $tardyrec->hour); - $tardystring = $tardystring . ", " . $tardyrec->hour; - } - $end=array_pop($tarr); - $tardystring = "Tardy in hours " . implode(", ", $tarr) . " and ". $end . ". "; - } - } else { $tardystring = "";} + if ($tardies > 0) { + $tardyrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 1, "hour ASC"); + if ($tardies == 1) { + $tardystring = "Tardy in hour " . $tardyrecs[0]->hour . ". "; + } elseif ($tardies == $attendance->hours) { + $tardystring = "Tardy in all hours. (" . $attendance->hours . ") "; + } else { + // build array of all tardies + $tarr = array(); + if ($tardyrecs) foreach ($tardyrecs as $tardyrec) { + array_push($tarr, $tardyrec->hour); + $tardystring = $tardystring . ", " . $tardyrec->hour; + } + $end=array_pop($tarr); + $tardystring = "Tardy in hours " . implode(", ", $tarr) . " and ". $end . ". "; + } + } else { $tardystring = "";} // build longer string for absences - if ($absences > 0) { - $absrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 2, "hour ASC"); - if ($absences == 1) { - $absstring = "Absent in hour " . $absrecs[0]->hour . "."; - } elseif ($absences == $attendance->hours) { - $absstring = "Absent in all hours. (" . $attendance->hours . ")"; - } else { - // build array of all absences - $aarr = array(); - if ($absrecs) foreach ($absrecs as $absrec) { - array_push($aarr, $absrec->hour); - } - $end=array_pop($aarr); - $absstring = "Absent in hours " . implode(", ", $aarr) . " and ". $end . "."; - } - } else { $absstring = "";} - $return->info=$tardystring . $absstring; - if ($return->info == "") $return->info = "No Tardies or Absences"; + if ($absences > 0) { + $absrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "status", 2, "hour ASC"); + if ($absences == 1) { + $absstring = "Absent in hour " . $absrecs[0]->hour . "."; + } elseif ($absences == $attendance->hours) { + $absstring = "Absent in all hours. (" . $attendance->hours . ")"; + } else { + // build array of all absences + $aarr = array(); + if ($absrecs) foreach ($absrecs as $absrec) { + array_push($aarr, $absrec->hour); + } + $end=array_pop($aarr); + $absstring = "Absent in hours " . implode(", ", $aarr) . " and ". $end . "."; + } + } else { $absstring = "";} + $return->info=$tardystring . $absstring; + if ($return->info == "") $return->info = "No Tardies or Absences"; return $return; } @@ -232,17 +232,17 @@ function attendance_user_complete($course, $user, $mod, $attendance) { if ($attrecs) { foreach ($attrecs as $attrec) { $grid[$attrec->hour]=$attrec->status; } } echo "\n"; // echo out the table header - for($j=1;$j<=$attendance->hours;$j++) { - echo "\n"; - } - echo ""; - for($j=1;$j<=$attendance->hours;$j++) { + for($j=1;$j<=$attendance->hours;$j++) { + echo "\n"; + } + echo ""; + for($j=1;$j<=$attendance->hours;$j++) { // set the attendance defaults for each student - if (isset($grid[$j])) { - $status = (($grid[$j] == 1) ? $T : $A); - } else {$status=$P;} + if (isset($grid[$j])) { + $status = (($grid[$j] == 1) ? $T : $A); + } else {$status=$P;} echo "\n"; - } /// for loop + } /// for loop echo "
Hour:".$j."
Status:".$j."
Status:".$status."
\n"; @@ -266,42 +266,42 @@ function attendance_cron () { global $CFG; echo "Attendance: Performing automatic attendance logging\n"; // look for all attendance instances set to autoattend - if (!$attendances = get_records("attendance", "autoattend", 1, "course ASC")) { + if (!$attendances = get_records("attendance", "autoattend", 1, "course ASC")) { return true; } - $td = attendance_find_today(time()); - $tm = attendance_find_tomorrow(time()); - if ($attendances) foreach($attendances as $attendance) { + $td = attendance_find_today(time()); + $tm = attendance_find_tomorrow(time()); + if ($attendances) foreach($attendances as $attendance) { if (($attendance->day >=$td ) && ($attendance->day < $tm)) { echo "Attendance: Taking attendance for $attendance->name\n"; - if(!isset($courses[$attendance->course]->students)) { - $courses[$attendance->course]->students = - attendance_get_course_students($attendance->course, "u.lastname ASC"); - } + if(!isset($courses[$attendance->course]->students)) { + $courses[$attendance->course]->students = + attendance_get_course_students($attendance->course, "u.lastname ASC"); + } if ($courses[$attendance->course]->students) { - foreach ($courses[$attendance->course]->students as $student) { - // first, clear out the records that may be there already - delete_records("attendance_roll", - "dayid",$attendance->id, - "userid",$student->id); - $wc = "userid = " . $student->id . " AND course = " . $attendance->course . - " AND time >= " . $td . " AND time < " . $tm; - $count = get_record_select("log",$wc,"COUNT(*) as c"); - if ($count->c == "0") { // then the student hasn't done anything today, so mark him absent - $attrec->dayid = $attendance->id; - $attrec->userid = $student->id; - $attrec->status = 2; // status 2 is absent - // mark ALL hours as absent for first version - for ($i=1;$i<=$attendance->hours;$i++) { - $attrec->hour = $i; - insert_record("attendance_roll",$attrec, false); - } // for loop to mark all hours absent - } // if student has no activity - } // foreach student in the list - } // if students exist + foreach ($courses[$attendance->course]->students as $student) { + // first, clear out the records that may be there already + delete_records("attendance_roll", + "dayid",$attendance->id, + "userid",$student->id); + $wc = "userid = " . $student->id . " AND course = " . $attendance->course . + " AND time >= " . $td . " AND time < " . $tm; + $count = get_record_select("log",$wc,"COUNT(*) as c"); + if ($count->c == "0") { // then the student hasn't done anything today, so mark him absent + $attrec->dayid = $attendance->id; + $attrec->userid = $student->id; + $attrec->status = 2; // status 2 is absent + // mark ALL hours as absent for first version + for ($i=1;$i<=$attendance->hours;$i++) { + $attrec->hour = $i; + insert_record("attendance_roll",$attrec, false); + } // for loop to mark all hours absent + } // if student has no activity + } // foreach student in the list + } // if students exist } // if the attendance roll is for today - } // for each attendance in the system + } // for each attendance in the system return true; } // function cron @@ -313,21 +313,21 @@ function attendance_grades($attendanceid) { if ($attendance->grade == "1") { $students = get_course_students($attendance->course); if ($students) { - foreach ($students as $student) { - $rolls = attendance_get_records("attendance_roll", - "dayid",$attendance->id, - "userid",$student->id); - $abs=$tar=0; - if ($rolls) { - foreach ($rolls as $roll) { - if ($roll->status == 1) {$tar++;} - elseif ($roll->status == 2) {$abs++;} - } // if rolls - $total = $attendance->hours - attendance_tally_overall_absences_decimal($abs, $tar); - $percent = ($total != 0)?$total/$attendance->hours:0; - $return->grades[$student->id] = ($percent == 0)?0.0:$attendance->maxgrade * $percent; - } else { $return->grades[$student->id] = $attendance->maxgrade; } - } // foreach student + foreach ($students as $student) { + $rolls = attendance_get_records("attendance_roll", + "dayid",$attendance->id, + "userid",$student->id); + $abs=$tar=0; + if ($rolls) { + foreach ($rolls as $roll) { + if ($roll->status == 1) {$tar++;} + elseif ($roll->status == 2) {$abs++;} + } // if rolls + $total = $attendance->hours - attendance_tally_overall_absences_decimal($abs, $tar); + $percent = ($total != 0)?$total/$attendance->hours:0; + $return->grades[$student->id] = ($percent == 0)?0.0:$attendance->maxgrade * $percent; + } else { $return->grades[$student->id] = $attendance->maxgrade; } + } // foreach student } // if students $return->maxgrade = $attendance->maxgrade; } else { // if attendance->grade == "1" @@ -376,20 +376,26 @@ function attendance_get_participants($attendanceid) { * STUDENT ID INTO THE RECORDSET * if courseid = 0 then return ALL students in all courses * -* @param int $courseid the id of the course -* @param string $sort a field name and ASC or DESC for a SQL 'ORDER BY' clause (optional) -* @return array(recorset) a list of all students in the specified course +* @param int $courseid the id of the course +* @param string $sort a field name and ASC or DESC for a SQL 'ORDER BY' clause (optional) +* @return array(recorset) a list of all students in the specified course Returns */ function attendance_get_course_students($courseid, $sort="u.lastaccess DESC") { global $CFG; + // make sure it works on the site course + $select = "s.course = '$courseid' AND"; + $site = get_site(); + if ($courseid == $site->id) { + $select = ''; + } return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.idnumber FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s - WHERE s.course = '$courseid' AND s.userid = u.id AND u.deleted = '0' + WHERE $select s.userid = u.id AND u.deleted = '0' ORDER BY $sort"); } @@ -400,15 +406,15 @@ function attendance_get_course_students($courseid, $sort="u.lastaccess DESC") { * Given a number of tardies and absences, determine the total * number of equivalent absences it adds up to. * -* @param int $absences the total number of absences for a span of time -* @param int $tardies the total number of tardies for a span of time -* @return float the number of absences it adds up to - may be a decimal! +* @param int $absences the total number of absences for a span of time +* @param int $tardies the total number of tardies for a span of time +* @return float the number of absences it adds up to - may be a decimal! */ function attendance_tally_overall_absences_decimal($absences, $tardies) { global $CFG; - if (isset($CFG->attendance_tardies_per_absence) && ($CFG->attendance_tardies_per_absence>0)) { - return $absences + ($tardies/$CFG->attendance_tardies_per_absence); - } else { return $absences; } + if (isset($CFG->attendance_tardies_per_absence) && ($CFG->attendance_tardies_per_absence>0)) { + return $absences + ($tardies/$CFG->attendance_tardies_per_absence); + } else { return $absences; } } /** @@ -418,23 +424,23 @@ function attendance_tally_overall_absences_decimal($absences, $tardies) { * number of equivalent absences it adds up to and express it as a string with * a possible fractional remainder * -* @param int $absences the total number of absences for a span of time -* @param int $tardies the total number of tardies for a span of time -* @return string the number of absences it adds up to - may have a fractional component! +* @param int $absences the total number of absences for a span of time +* @param int $tardies the total number of tardies for a span of time +* @return string the number of absences it adds up to - may have a fractional component! */ function attendance_tally_overall_absences_fraction($absences, $tardies) { global $CFG; - if (isset($CFG->attendance_tardies_per_absence) && ($CFG->attendance_tardies_per_absence>0)) { - $whole = floor($tardies/$CFG->attendance_tardies_per_absence); - $fractional=$tardies-($whole * $CFG->attendance_tardies_per_absence); - if ($absences + $whole > 0) { - return ($absences + $whole) . (($fractional > 0) ? " ". $fractional. "/". $CFG->attendance_tardies_per_absence : ""); - } else { - return (($fractional > 0) ? $fractional. "/". $CFG->attendance_tardies_per_absence : "0"); - } - } else { - return $absences.""; - } + if (isset($CFG->attendance_tardies_per_absence) && ($CFG->attendance_tardies_per_absence>0)) { + $whole = floor($tardies/$CFG->attendance_tardies_per_absence); + $fractional=$tardies-($whole * $CFG->attendance_tardies_per_absence); + if ($absences + $whole > 0) { + return ($absences + $whole) . (($fractional > 0) ? " ". $fractional. "/". $CFG->attendance_tardies_per_absence : ""); + } else { + return (($fractional > 0) ? $fractional. "/". $CFG->attendance_tardies_per_absence : "0"); + } + } else { + return $absences.""; + } } /** @@ -490,9 +496,9 @@ function attendance_get_records($table, $field1="", $value1="", $field2="", $val * first what section the specified attendance instance in the course is in, then all the * attendance records that are in the same section, regardless of the format of the course * -* @param int $instance id of the attendance instance in course_modules -* @param int $courseid the id of the course for which we're getting records -* @return (object)recordset associative array of records containing the attendance records we wanted +* @param int $instance id of the attendance instance in course_modules +* @param int $courseid the id of the course for which we're getting records +* @return (object)recordset associative array of records containing the attendance records we wanted */ function get_attendance_for_section($instance, $courseid) { global $CFG; @@ -548,9 +554,9 @@ AND md.name = 'attendance' AND md.id = cm.module AND m.id = cm.instance; * function will work with non-weekly formatted courses, though the results won't easily * correlate with the course view. But it will work regardless. * -* @param int $id the id of the attendance record we're using as a basis for the query -* @param int $courseid the id of the course for which we're getting records -* @return (object)recordset associative array of records containing the attendance records we wanted +* @param int $id the id of the attendance record we're using as a basis for the query +* @param int $courseid the id of the course for which we're getting records +* @return (object)recordset associative array of records containing the attendance records we wanted */ function get_attendance_for_week($id, $courseid) { global $CFG; @@ -576,8 +582,8 @@ function get_attendance_for_week($id, $courseid) { * * This function returns the timestamp for midnight of the day specified in the timestamp * -* @param timestamp $d The time to find the beginning of the day for -* @return timestamp midnight for that day +* @param timestamp $d The time to find the beginning of the day for +* @return timestamp midnight for that day */ function attendance_find_today($d) { // $da = getdate($d); @@ -594,8 +600,8 @@ function attendance_find_today($d) { * * This function returns the timestamp for midnight of the day after the timestamp specified * -* @param timestamp $d The time to find the next day of -* @return timestamp midnight of the next day +* @param timestamp $d The time to find the next day of +* @return timestamp midnight of the next day */ function attendance_find_tomorrow($d) { // add 24 hours to the current time - to solve end of month date issues diff --git a/mod/chat/index.php b/mod/chat/index.php index d5490644af..f2df2e3bd9 100644 --- a/mod/chat/index.php +++ b/mod/chat/index.php @@ -9,7 +9,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "chat", "view all", "index.php?id=$course->id", ""); diff --git a/mod/chat/view.php b/mod/chat/view.php index f940210877..e611f64c63 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -37,7 +37,7 @@ } } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "chat", "view", "view.php?id=$cm->id", $chat->id, $cm->id); diff --git a/mod/choice/index.php b/mod/choice/index.php index 378ab7c0b4..a90f67f371 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -9,7 +9,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "choice", "view all", "index?id=$course->id", ""); @@ -24,7 +24,7 @@ notice("There are no choices", "../../course/view.php?id=$course->id"); } - if ( $allanswers = get_records("choice_answers", "userid", $USER->id)) { + if ( isset($USER->id) and $allanswers = get_records("choice_answers", "userid", $USER->id)) { foreach ($allanswers as $aa) { $answers[$aa->choice] = $aa; } diff --git a/mod/choice/view.php b/mod/choice/view.php index c33c86f92f..3940a60738 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -13,7 +13,7 @@ error("Course is misconfigured"); } - require_login($course->id); + require_course_login($course); if (!$choice = choice_get_choice($cm->instance)) { error("Course module is incorrect"); @@ -22,8 +22,10 @@ for ($i=1; $i <= $CHOICE_MAX_NUMBER; $i++) { $answerchecked[$i] = ''; } - if ($current = get_record("choice_answers", "choice", $choice->id, "userid", $USER->id)) { + if (isset($USER->id) and $current = get_record("choice_answers", "choice", $choice->id, "userid", $USER->id)) { $answerchecked[$current->answer] = 'CHECKED'; + } else { + $current = false; } if ($form = data_submitted()) { @@ -113,6 +115,8 @@ echo "id\">"; if (isstudent($course->id) or isteacher($course->id, 0, false)) { echo ""; + } else { + print_string('havetologin', 'choice'); } echo "

"; diff --git a/mod/dialogue/locallib.php b/mod/dialogue/locallib.php index c563fa06fe..3db4752417 100644 --- a/mod/dialogue/locallib.php +++ b/mod/dialogue/locallib.php @@ -232,16 +232,46 @@ global $USER; ////////////////////////////////////////////////////////////////////////////////////// function dialogue_get_users_done($dialogue) { global $CFG; - return get_records_sql("SELECT u.* + + // make sure it works on the site course + $select = "s.course = '$dialogue->course' AND"; + $site = get_site(); + if ($courseid == $site->id) { + $select = ''; + } + if (!$students = get_records_sql("SELECT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}user_students s, + {$CFG->prefix}dialogue_entries j + WHERE ($select s.userid = u.id) + AND u.id = j.userid + AND j.dialogue = '$dialogue->id' + ORDER BY j.modified DESC")) { + $students = array(); + } + if (!$teachers = get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, - {$CFG->prefix}user_students s, - {$CFG->prefix}user_teachers t, + {$CFG->prefix}user_teachers s, {$CFG->prefix}dialogue_entries j - WHERE ((s.course = '$dialogue->course' AND s.userid = u.id) - OR (t.course = '$dialogue->course' AND t.userid = u.id)) + WHERE (s.course = '$dialogue->course' AND s.userid = u.id) AND u.id = j.userid AND j.dialogue = '$dialogue->id' - ORDER BY j.modified DESC"); + ORDER BY j.modified DESC")) { + $teachers = array(); + } + return $teachers + $students; + +// The following original version is very inefficient on large sites +// return get_records_sql("SELECT u.* +// FROM {$CFG->prefix}user u, +// {$CFG->prefix}user_students s, +// {$CFG->prefix}user_teachers t, +// {$CFG->prefix}dialogue_entries j +// WHERE ((s.course = '$dialogue->course' AND s.userid = u.id) +// OR (t.course = '$dialogue->course' AND t.userid = u.id)) +// AND u.id = j.userid +// AND j.dialogue = '$dialogue->id' +// ORDER BY j.modified DESC"); } diff --git a/mod/exercise/locallib.php b/mod/exercise/locallib.php index 8e8499689a..49d5bb86db 100644 --- a/mod/exercise/locallib.php +++ b/mod/exercise/locallib.php @@ -236,10 +236,16 @@ function exercise_count_assessments_by_teacher($exercise, $teacher) { /////////////////////////////////////////////////////////////////////////////////////////////// function exercise_count_student_submissions($exercise) { global $CFG; - - return count_records_sql("SELECT count(*) FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u - WHERE u.course = $exercise->course - AND s.userid = u.userid + + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + + return count_records_sql("SELECT count(*) FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u + WHERE $select s.userid = u.userid AND s.exerciseid = $exercise->id AND timecreated > 0"); } @@ -480,12 +486,18 @@ function exercise_delete_user_files($exercise, $user, $exception) { function exercise_get_best_submission_grades($exercise) { // Returns the grades of students' best submissions global $CFG; - + + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT DISTINCT u.userid, MAX(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a, {$CFG->prefix}user_students u - WHERE u.course = $exercise->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.exerciseid = $exercise->id AND s.late = 0 AND a.submissionid = s.id @@ -528,11 +540,18 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid = // just look at a single group if ($order == "grade") { // allow for multiple assessments of submissions (coming from different teachers) + + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM {$CFG->prefix}user_students u, {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s, {$CFG->prefix}exercise_assessments a - WHERE u.course = $exercise->course - AND g.groupid = $groupid + WHERE $select g.groupid = $groupid AND u.userid = g.userid AND s.userid = u.userid AND s.exerciseid = $exercise->id @@ -549,10 +568,16 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid = $order = "s.timecreated"; } + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT s.* FROM {$CFG->prefix}user_students u, {$CFG->prefix}user n, {$CFG->prefix}groups_members g, {$CFG->prefix}exercise_submissions s - WHERE u.course = $exercise->course - AND g.groupid = $groupid + WHERE $select g.groupid = $groupid AND u.userid = g.userid AND s.userid = u.userid AND n.id = u.userid @@ -563,10 +588,17 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid = else { // no group - all users if ($order == "grade") { // allow for multiple assessments of submissions (coming from different teachers) + + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT s.*, AVG(a.grade) AS grade FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a - WHERE u.course = $exercise->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.exerciseid = $exercise->id AND a.submissionid = s.id GROUP BY s.id @@ -581,10 +613,16 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid = $order = "s.timecreated"; } + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT s.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}user n - WHERE u.course = $exercise->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND n.id = u.userid AND s.exerciseid = $exercise->id ORDER BY $order"); @@ -629,12 +667,18 @@ function exercise_get_ungraded_assessments($exercise) { function exercise_get_ungraded_assessments_student($exercise) { global $CFG; // Return all assessments which have not been graded or just graded of student's submissions - + + // make sure it works on the site course + $select = "u.course = '$exercise->course' AND"; + $site = get_site(); + if ($exercise->course == $site->id) { + $select = ''; + } + $cutofftime =time() - $CFG->maxeditingtime; return get_records_sql("SELECT a.* FROM {$CFG->prefix}exercise_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}exercise_assessments a - WHERE u.course = $exercise->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.exerciseid = $exercise->id AND a.submissionid = s.id AND (a.timegraded = 0 OR a.timegraded > $cutofftime) diff --git a/mod/forum/post.php b/mod/forum/post.php index 042028fc03..90893e8f6d 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -406,9 +406,8 @@ $course = get_record('course', 'id', $forum->course); $strforums = get_string("modulenameplural", "forum"); - print_header("$course->shortname: $discussion->name: $post->subject", "$course->fullname", - "id>$course->shortname -> - id\">$strforums -> + print_header_simple("$discussion->name: $post->subject", "", + "id\">$strforums -> id\">$forum->name -> id\">$post->subject -> ". get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm)); diff --git a/mod/forum/search.php b/mod/forum/search.php index 51211e6307..ed147ec0d9 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -38,9 +38,8 @@ $searchform = forum_print_search_form($course, $search, true, "plain"); if (!$search) { - print_header("$course->shortname: $strsearch", "$course->fullname", - "id\">$course->shortname -> - id\">$strforums -> $strsearch", "search.search", + print_header_simple("$strsearch", "", + "id\">$strforums -> $strsearch", "search.search", "", "", " ", navmenu($course)); print_simple_box_start("center"); @@ -59,9 +58,8 @@ if (!$posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $perpage, $totalcount)) { - print_header("$course->shortname: $strsearchresults", "$course->fullname", - "id\">$course->shortname -> - id\">$strforums -> + print_header_simple("$strsearchresults", "", + "id\">$strforums -> id\">$strsearch -> \"$search\"", "search.search", "", "", " ", navmenu($course)); print_heading(get_string("nopostscontaining", "forum", $search)); @@ -79,9 +77,8 @@ exit; } - print_header("$course->shortname: $strsearchresults", "$course->fullname", - "id\">$course->shortname -> - id\">$strforums -> + print_header_simple("$strsearchresults", "", + "id\">$strforums -> id\">$strsearch -> \"$search\"", "search.search", "", "", $searchform, navmenu($course)); diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index a34a5c62be..084e38b114 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -72,9 +72,8 @@ if ( $confirm ) { $onsubmit = ""; } - print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - id\">$strglossaries -> + print_header_simple(strip_tags("$glossary->name"), "", + "id\">$strglossaries -> id\">$glossary->name -> $stredit", "form.text", "", true, "", navmenu($course, $cm)); @@ -247,9 +246,8 @@ if ($usehtmleditor = can_use_richtext_editor()) { $onsubmit = ""; } -print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - id\">$strglossaries -> +print_header_simple(strip_tags("$glossary->name"), "", + "id\">$strglossaries -> id\">$glossary->name -> $stredit", "", "", true, "", navmenu($course, $cm)); diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php index 0c4e7ab394..d7ae740f32 100644 --- a/mod/glossary/formats.php +++ b/mod/glossary/formats.php @@ -7,7 +7,7 @@ require_variable($id); optional_variable($mode); - + require_login(); if ( !isadmin() ) { error("You must be an admin to use this page."); @@ -52,7 +52,7 @@ $strmodulename = get_string("modulename", "glossary"); $strdisplayformats = get_string("displayformats","glossary"); - print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname, + print_header("$strmodulename: $strconfiguration", $site->fullname, "$stradmin -> ". "$strconfiguration -> ". "$strmanagemodules -> $strmodulename -> $strdisplayformats"); @@ -70,11 +70,11 @@ echo '
'; echo ''; ?> - - + - + - - - + + + - '; diff --git a/mod/glossary/index.php b/mod/glossary/index.php index ea43d6b9b3..f8454875cf 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -13,7 +13,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", ""); diff --git a/mod/glossary/print.php b/mod/glossary/print.php index b89165bc2f..995cf1ca85 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -30,7 +30,7 @@ $entriesbypage = $CFG->glossary_entbypage; } - print_header(strip_tags("$course->shortname: $glossary->name")); + print_header_simple(strip_tags("$glossary->name")); if ($CFG->forcelogin) { require_login(); diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index fbfc2b98cf..f7fa2af093 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -15,10 +15,10 @@ /// printpivot indicate if the pivot should be printed or not switch ($CFG->dbtype) { case 'postgres7': - $as = 'as'; + $as = 'as'; break; case 'mysql': - $as = ''; + $as = ''; break; } @@ -36,7 +36,7 @@ $fullpivot = 1; $userid = ''; - if ( $USER->id ) { + if ( isset($USER->id) ) { $userid = "OR ge.userid = $USER->id"; } switch ($tab) { @@ -218,12 +218,12 @@ $sqllimit = ''; if ( $offset >= 0 ) { - switch ($CFG->dbtype) { + switch ($CFG->dbtype) { case 'postgres7': - $sqllimit = " LIMIT $entriesbypage OFFSET $offset"; + $sqllimit = " LIMIT $entriesbypage OFFSET $offset"; break; case 'mysql': - $sqllimit = " LIMIT $offset, $entriesbypage"; + $sqllimit = " LIMIT $offset, $entriesbypage"; break; } } diff --git a/mod/glossary/view.php b/mod/glossary/view.php index bea8ebd2f2..42b3e05dfa 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -224,7 +224,9 @@ $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype and $glossary->rssarticles) { echo '
- name,"glossary"); ?> +
+ name,"glossary"); ?>
@@ -255,14 +255,14 @@

- ">
+ ">
'; $tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name); - rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext); + if (isset($USER->id)) { + rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext); + } echo '
'; } diff --git a/mod/journal/edit.php b/mod/journal/edit.php index b2310da668..95cf1f0f53 100644 --- a/mod/journal/edit.php +++ b/mod/journal/edit.php @@ -1,6 +1,6 @@ text = clean_text($form->text, $form->format); - if ($entry) { + if ($entry) { $newentry->id = $entry->id; $newentry->text = $form->text; $newentry->format = $form->format; $newentry->modified = $timenow; - if (! update_record("journal_entries", $newentry)) { - error("Could not update your journal"); - } + if (! update_record("journal_entries", $newentry)) { + error("Could not update your journal"); + } add_to_log($course->id, "journal", "update entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); - } else { + } else { $newentry->userid = $USER->id; $newentry->journal = $journal->id; $newentry->text = $form->text; $newentry->format = $form->format; $newentry->modified = $timenow; - if (! $newentry->id = insert_record("journal_entries", $newentry)) { - error("Could not insert a new journal entry"); - } + if (! $newentry->id = insert_record("journal_entries", $newentry)) { + error("Could not insert a new journal entry"); + } add_to_log($course->id, "journal", "add entry", "view.php?id=$cm->id", "$newentry->id", $cm->id); - } - - redirect("view.php?id=$cm->id"); - die; - } + } + + redirect("view.php?id=$cm->id"); + die; + } /// Otherwise fill and print the form. @@ -75,9 +75,8 @@ $entry->format = $defaultformat; } - print_header("$course->shortname: $journal->name", "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - id\">$strjournals -> + print_header_simple("$journal->name", "", + "id\">$strjournals -> id\">$journal->name -> $stredit", "", "", true, "", navmenu($course, $cm)); @@ -87,7 +86,7 @@ echo "
"; - include("edit.html"); + include("edit.html"); if ($usehtmleditor) { use_html_editor("text"); diff --git a/mod/journal/index.php b/mod/journal/index.php index 90a503c9cd..a395d65a93 100644 --- a/mod/journal/index.php +++ b/mod/journal/index.php @@ -9,7 +9,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "journal", "view all", "index.php?id=$course->id", ""); $strjournal = get_string("modulename", "journal"); diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 56d7843178..073c75091c 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -68,36 +68,39 @@ function journal_user_complete_index($course, $user, $journal, $journalopen, $he print_simple_box_end(); echo "
"; echo "
"; + + if (isstudent($course->id) or isteacher($course->id)) { - print_simple_box_start("right", "90%"); - - if ($journalopen) { - echo "

coursemodule\">"; - echo get_string("edit")."

"; - } else { - echo "

coursemodule\">"; - echo get_string("view")."

"; - } - - if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) { - if ($entry->modified) { - echo "

".get_string("lastedited").": ".userdate($entry->modified)."

"; - } - if ($entry->text) { - echo format_text($entry->text, $entry->format); + print_simple_box_start("right", "90%"); + + if ($journalopen) { + echo "

coursemodule\">"; + echo get_string("edit")."

"; + } else { + echo "

coursemodule\">"; + echo get_string("view")."

"; } - if ($entry->teacher) { - $grades = make_grades_menu($journal->assessed); - journal_print_feedback($course, $entry, $grades); + + if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) { + if ($entry->modified) { + echo "

".get_string("lastedited").": ".userdate($entry->modified)."

"; + } + if ($entry->text) { + echo format_text($entry->text, $entry->format); + } + if ($entry->teacher) { + $grades = make_grades_menu($journal->assessed); + journal_print_feedback($course, $entry, $grades); + } + } else { + print_string("noentry", "journal"); } - } else { - print_string("noentry", "journal"); + + print_simple_box_end(); + echo "
"; + echo "
"; } - print_simple_box_end(); - echo "
"; - echo "
"; - } @@ -311,14 +314,20 @@ function journal_scale_used ($journalid,$scaleid) { function journal_get_users_done($journal) { global $CFG; + // make sure it works on the site course + $select = "s.course = '$journal->course' AND"; + $site = get_site(); + if ($journal->course == $site->id) { + $select = ''; + } + $studentjournals = get_records_sql ("SELECT u.* FROM {$CFG->prefix}journal_entries j, {$CFG->prefix}user u, {$CFG->prefix}user_students s WHERE j.userid = u.id AND s.userid = u.id - AND j.journal = $journal->id - AND s.course = $journal->course + AND $select j.journal = $journal->id ORDER BY j.modified DESC"); $teacherjournals = get_records_sql ("SELECT u.* @@ -357,14 +366,21 @@ function journal_count_entries($journal, $groupid=0) { AND j.userid = g.userid"); } else { /// Count all the entries from the whole course + + // make sure it works on the site course + $select = "s.course = '$journal->course' AND"; + $site = get_site(); + if ($journal->course == $site->id) { + $select = ''; + } + $studentjournals = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}journal_entries j, {$CFG->prefix}user u, {$CFG->prefix}user_students s WHERE j.userid = u.id AND s.userid = u.id - AND j.journal = $journal->id - AND s.course = $journal->course "); + AND $select j.journal = $journal->id"); $teacherjournals = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}journal_entries j, diff --git a/mod/journal/report.php b/mod/journal/report.php index 064339a82c..0e5922a8a0 100644 --- a/mod/journal/report.php +++ b/mod/journal/report.php @@ -38,9 +38,8 @@ $strentries = get_string("entries", "journal"); $strjournals = get_string("modulenameplural", "journal"); - print_header("$course->shortname: $strjournals", "$course->fullname", - "id\">$course->shortname -> - id\">$strjournals -> + print_header_simple("$strjournals", "", + "id\">$strjournals -> id\">$journal->name -> $strentries", "", "", true); diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 85883a3ef0..c82b7756b5 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -29,8 +29,7 @@ $strimportquestions = get_string("importquestions", "lesson"); $strlessons = get_string("modulenameplural", "lesson"); - print_header("$course->shortname: $strimportquestions", "$course->shortname: $strimportquestions", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> ". + print_header_simple("$strimportquestions", " $strimportquestions", "id>$strlessons -> id\">$lesson->name-> $strimportquestions"); if ($form = data_submitted()) { /// Filename diff --git a/mod/lesson/index.php b/mod/lesson/index.php index 5dcba6df65..c88ad3e6f9 100644 --- a/mod/lesson/index.php +++ b/mod/lesson/index.php @@ -11,7 +11,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "lesson", "view all", "index.php?id=$course->id", ""); @@ -68,10 +68,11 @@ $due = "".userdate($lesson->deadline).""; } + $grade_value = ''; if ($course->format == "weeks" or $course->format == "topics") { if (isteacher($course->id)) { $grade_value = $lesson->grade; - } else { + } elseif (isstudent($course->id)) { // it's a student, show their mean or maximum grade if ($lesson->usemaxgrade) { $grade = get_record_sql("SELECT MAX(grade) as grade FROM {$CFG->prefix}lesson_grades @@ -83,8 +84,6 @@ if ($grade) { // grades are stored as percentages $grade_value = number_format($grade->grade * $lesson->grade / 100, 1); - } else { - $grade_value = 0; } } $table->data[] = array ($lesson->section, $link, $grade_value, $due); diff --git a/mod/quiz/category.php b/mod/quiz/category.php index a9300f1d6d..119952c931 100644 --- a/mod/quiz/category.php +++ b/mod/quiz/category.php @@ -1,8 +1,8 @@ shortname: $streditcategories", "$course->shortname: $streditcategories", - "wwwroot/course/view.php?id=$course->id\">$course->shortname - -> $streditingquiz -> $streditcategories"); + print_header_simple("$streditcategories", " $streditcategories", + "$streditingquiz -> $streditcategories"); /// Delete category if the user wants to delete it @@ -120,7 +119,7 @@ } } } - } + } /// Get the existing categories diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 0ba6ebd586..1422210cc3 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -164,8 +164,7 @@ $strediting = get_string(isset($modform->instance) ? "editingquiz" : "editquestions", "quiz"); $strheading = empty($modform->name) ? $strediting : $modform->name; - print_header("$course->shortname: $strediting", "$course->shortname: $strheading", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> ". + print_header_simple("$strediting", "$strheading", "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes -> $strediting"); // Print basic page layout. diff --git a/mod/quiz/export.php b/mod/quiz/export.php index bfb5dac7cc..818beeaff3 100644 --- a/mod/quiz/export.php +++ b/mod/quiz/export.php @@ -27,16 +27,15 @@ $strquizzes = get_string('modulenameplural', 'quiz'); $streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz"); - print_header("$course->shortname: $strexportquestions", "$course->shortname: $strexportquestions", - "wwwroot/course/view.php?id=$course->id\">$course->shortname ". - "-> wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". + print_header_simple("$strexportquestions", "$strexportquestions", + "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". " -> $streditingquiz -> $strexportquestions"); if ($form = data_submitted()) { /// Filename if (! is_readable("format/$form->format/format.php")) { - error("Format not known ($form->format)"); + error("Format not known ($form->format)"); } require("format.php"); // Parent class @@ -45,18 +44,18 @@ $format = new quiz_file_format(); if (! $format->exportpreprocess($category, $course)) { // Do anything before that we need to - error("Error occurred during pre-processing!", - "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); + error("Error occurred during pre-processing!", + "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); } if (! $format->exportprocess($exportfilename)) { // Process the export data - error("Error occurred during processing!", - "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); + error("Error occurred during processing!", + "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); } if (! $format->exportpostprocess()) { // In case anything needs to be done after - error("Error occurred during post-processing!", - "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); + error("Error occurred during post-processing!", + "$CFG->wwwroot/mod/quiz/export.php?category=$category->id"); } echo "
"; diff --git a/mod/quiz/import.php b/mod/quiz/import.php index d7a0490a7a..0148c61192 100644 --- a/mod/quiz/import.php +++ b/mod/quiz/import.php @@ -27,9 +27,8 @@ $strquizzes = get_string('modulenameplural', 'quiz'); $streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz"); - print_header("$course->shortname: $strimportquestions", "$course->shortname: $strimportquestions", - "wwwroot/course/view.php?id=$course->id\">$course->shortname ". - "-> wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". + print_header_simple("$strimportquestions", "$strimportquestions", + "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". " -> $streditingquiz -> $strimportquestions"); if ($form = data_submitted()) { /// Filename diff --git a/mod/quiz/multiple.php b/mod/quiz/multiple.php index 47c86cf274..eb93ac7648 100644 --- a/mod/quiz/multiple.php +++ b/mod/quiz/multiple.php @@ -1,8 +1,8 @@ modform->instance) ? "editingquiz" : "editquestions", "quiz"); $strcreatemultiple = get_string("createmultiple", "quiz"); - print_header("$course->shortname: $strcreatemultiple", "$course->shortname: $strcreatemultiple", - "wwwroot/course/view.php?id=$course->id\">$course->shortname ". - " -> wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". + print_header_simple("$strcreatemultiple", "$strcreatemultiple", + "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". " -> $streditingquiz -> $strcreatemultiple"); diff --git a/mod/quiz/question.php b/mod/quiz/question.php index ad4ea871f0..55b1aa47a8 100644 --- a/mod/quiz/question.php +++ b/mod/quiz/question.php @@ -58,9 +58,8 @@ $streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz"); $streditingquestion = get_string("editingquestion", "quiz"); - print_header("$course->shortname: $streditingquestion", "$course->shortname: $streditingquestion", - "wwwroot/course/view.php?id=$course->id\">$course->shortname ". - "-> wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". + print_header_simple("$streditingquestion", "$streditingquestion", + "wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes". " -> $streditingquiz -> $streditingquestion"); if (isset($delete)) { diff --git a/mod/quiz/questiontypes/datasetdependent/categorydatasetdefinitions.php b/mod/quiz/questiontypes/datasetdependent/categorydatasetdefinitions.php index 6e21bdb062..08ed9667f3 100644 --- a/mod/quiz/questiontypes/datasetdependent/categorydatasetdefinitions.php +++ b/mod/quiz/questiontypes/datasetdependent/categorydatasetdefinitions.php @@ -31,9 +31,8 @@ $strdefinedataset = get_string("datasetdefinitions", "quiz", $category->name); $strquestions = get_string("questions", "quiz"); - print_header("$course->shortname: $strdefinedataset", "$course->shortname: $strdefinedataset", - "wwwroot/course/view.php?id=$course->id\">$course->shortname - -> $streditingquiz -> $strdefinedataset"); + print_header_simple("$strdefinedataset", "$strdefinedataset", + "$streditingquiz -> $strdefinedataset"); if ($form = data_submitted()) { /// Filename diff --git a/mod/scorm/details.php b/mod/scorm/details.php index e86943f1ba..bbea86e5d2 100755 --- a/mod/scorm/details.php +++ b/mod/scorm/details.php @@ -19,20 +19,20 @@ $strediting = get_string("validateascorm", "scorm"); $strname = get_string("name"); - print_header("$course->shortname: $strediting", "$course->shortname: $strediting", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> $strediting"); + print_header_simple("$strediting", "$strediting", + "$strediting"); if (!$form->name or !$form->reference or !$form->summary) { error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]); } - - // - // Create a temporary directory to unzip package and validate imsmanifest - // + + // + // Create a temporary directory to unzip package and validate imsmanifest + // - $coursedir = "$CFG->dataroot/$course->id"; + $coursedir = "$CFG->dataroot/$course->id"; - if ($scormdir = make_upload_directory("$course->id/$CFG->moddata/scorm")) { + if ($scormdir = make_upload_directory("$course->id/$CFG->moddata/scorm")) { if ($tempdir = scorm_datadir($scormdir, $form->datadir)) { copy ("$coursedir/$form->reference", $tempdir."/".basename($form->reference)); if (empty($CFG->unzip)) { // Use built-in php-based unzip function @@ -49,145 +49,145 @@ } else { $result = "packagedir"; } - } else { - $result = "datadir"; - } - $errorlogs = ''; - if (($result != "regular") && ($result != "found")) { - if ($CFG->scorm_validate == 'domxml') { - foreach ($errors as $error) { - $errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n"; - } - } - // - // Delete files and temporary directory - // - if (is_dir($tempdir)) - scorm_delete_files($tempdir); - } else { - // - // Delete package file - // - unlink ($tempdir."/".basename($form->reference)); - if ($form->mode == "update") { - $fp = fopen($coursedir."/".$form->reference,"r"); - $fstat = fstat($fp); - fclose($fp); - if (get_field("scorm","timemodified","id",$form->instance) < $fstat["mtime"]) - $form->launch = 0; - } - } - // - // Print validation result - // - print_simple_box_start("center", "", "$THEME->cellheading"); - echo "\n"; - echo " \n"; - echo " \n"; - if ($errorlogs != '') { - $lines = round(count($errors)/4); - if ($lines < 5) { - $lines = 5; - } - echo " \n"; - } - if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance))) - echo " \n"; - echo "

$strname:

$form->name

".get_string("validation","scorm").":

".get_string($result,"scorm")."

".get_string("errorlogs","scorm").":

".get_string("trackingloose","scorm")."

\n"; - if (($result == "regular") || ($result == "found")){ - if (empty($form->auto)) { - $form->auto = ""; - } - if (empty($form->maxgrade)) { - $form->maxgrade = ""; - } - if (empty($form->grademethod)) { - $form->grademethod = "0"; - } - echo "destination\">\n"; - - //$form->popup = $CFG->scorm_popup; - $strnewwindow = get_string("newwindow", "scorm"); + } else { + $result = "datadir"; + } + $errorlogs = ''; + if (($result != "regular") && ($result != "found")) { + if ($CFG->scorm_validate == 'domxml') { + foreach ($errors as $error) { + $errorlogs .= get_string($error->type,"scorm",$error->data) . ".\n"; + } + } + // + // Delete files and temporary directory + // + if (is_dir($tempdir)) + scorm_delete_files($tempdir); + } else { + // + // Delete package file + // + unlink ($tempdir."/".basename($form->reference)); + if ($form->mode == "update") { + $fp = fopen($coursedir."/".$form->reference,"r"); + $fstat = fstat($fp); + fclose($fp); + if (get_field("scorm","timemodified","id",$form->instance) < $fstat["mtime"]) + $form->launch = 0; + } + } + // + // Print validation result + // + print_simple_box_start("center", "", "$THEME->cellheading"); + echo "\n"; + echo " \n"; + echo " \n"; + if ($errorlogs != '') { + $lines = round(count($errors)/4); + if ($lines < 5) { + $lines = 5; + } + echo " \n"; + } + if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance))) + echo " \n"; + echo "

$strname:

$form->name

".get_string("validation","scorm").":

".get_string($result,"scorm")."

".get_string("errorlogs","scorm").":

".get_string("trackingloose","scorm")."

\n"; + if (($result == "regular") || ($result == "found")){ + if (empty($form->auto)) { + $form->auto = ""; + } + if (empty($form->maxgrade)) { + $form->maxgrade = ""; + } + if (empty($form->grademethod)) { + $form->grademethod = "0"; + } + echo "destination\">\n"; + + //$form->popup = $CFG->scorm_popup; + $strnewwindow = get_string("newwindow", "scorm"); $strnewwindowopen = get_string("newwindowopen", "scorm"); - foreach ($SCORM_WINDOW_OPTIONS as $optionname) { - $stringname = "str$optionname"; - $$stringname = get_string("new$optionname", "scorm"); - $window->$optionname = ""; - $jsoption[] = "\"$optionname\""; + foreach ($SCORM_WINDOW_OPTIONS as $optionname) { + $stringname = "str$optionname"; + $$stringname = get_string("new$optionname", "scorm"); + $window->$optionname = ""; + $jsoption[] = "\"$optionname\""; } $alljsoptions = implode(",", $jsoption); - + if ($form->instance) { // Re-editing - if ($form->popup == "") { + if ($form->popup == "") { $newwindow = ""; // Disable the new window foreach ($SCORM_WINDOW_OPTIONS as $optionname) { - $defaultvalue = "scorm_popup$optionname"; - $window->$optionname = $CFG->$defaultvalue; - } - } else { - $newwindow = "checked"; + $defaultvalue = "scorm_popup$optionname"; + $window->$optionname = $CFG->$defaultvalue; + } + } else { + $newwindow = "checked"; $rawoptions = explode(',', $form->popup); foreach ($rawoptions as $rawoption) { - $option = explode('=', trim($rawoption)); - if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) { - $optionname = $option[0]; - $optionvalue = $option[1]; - if ($optionname == "height" or $optionname == "width") { - $window->$optionname = $optionvalue; - } else if ($optionvalue == 1) { - $window->$optionname = "checked"; - } - } - } - } - } else { - foreach ($SCORM_WINDOW_OPTIONS as $optionname) { + $option = explode('=', trim($rawoption)); + if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) { + $optionname = $option[0]; + $optionvalue = $option[1]; + if ($optionname == "height" or $optionname == "width") { + $window->$optionname = $optionvalue; + } else if ($optionvalue == 1) { + $window->$optionname = "checked"; + } + } + } + } + } else { + foreach ($SCORM_WINDOW_OPTIONS as $optionname) { $defaultvalue = "scorm_popup$optionname"; $window->$optionname = $CFG->$defaultvalue; - } - $newwindow = $CFG->scorm_popup; - } - + } + $newwindow = $CFG->scorm_popup; + } + ?> - - - - - - - -

:

- grademethod", ""); - helpbutton("grademethod", get_string("grademethod","scorm"), "scorm"); - ?> -

:

- =1; $i--) { - $grades[$i] = $i; - } + + + + + + + + - - - - - - + choose_from_menu($grades, "maxgrade", "$form->maxgrade", ""); + helpbutton("maxgrade", get_string("maximumgrade"), "scorm"); + ?> + + + + + + + @@ -239,32 +239,32 @@

:

+ grademethod", ""); + helpbutton("grademethod", get_string("grademethod","scorm"), "scorm"); + ?> +

:

+ =1; $i--) { + $grades[$i] = $i; + } - choose_from_menu($grades, "maxgrade", "$form->maxgrade", ""); - helpbutton("maxgrade", get_string("maximumgrade"), "scorm"); - ?> -

:

- auto); - ?> -

:

+ auto); + ?> +

- - - - - - - - - - - - -
- " /> - " /> -
+ + + + + + + + + + + + +
+ " /> + " /> +
-
+
" onClick="document.location='wwwroot ?>/course/view.php?id=id ?>';">
shortname: $streditingasurvey", "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname". - " -> id\">$strsurveys". + print_header_simple("$streditingasurvey", "", + "id\">$strsurveys". " -> $form->name ($streditingasurvey)"); if (!$form->name or !$form->template) { diff --git a/mod/survey/index.php b/mod/survey/index.php index 87f7887a24..cf5d76cd41 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -9,7 +9,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", ""); @@ -42,7 +42,7 @@ $currentsection = ''; foreach ($surveys as $survey) { - if (survey_already_done($survey->id, $USER->id)) { + if (isset($USER->id) and survey_already_done($survey->id, $USER->id)) { $ss = $strdone; } else { $ss = $strnotdone; diff --git a/mod/survey/save.php b/mod/survey/save.php index 6098088711..1c270b3a24 100644 --- a/mod/survey/save.php +++ b/mod/survey/save.php @@ -1,7 +1,7 @@ shortname: $strsurveysaved", "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - id\">$strsurveys -> $survey->name -> $strsurveysaved", ""); + print_header_simple("$strsurveysaved", "", + "id\">$strsurveys -> $survey->name -> $strsurveysaved", ""); notice(get_string("thanksforanswers","survey", $USER->firstname), "$CFG->wwwroot/course/view.php?id=$course->id"); diff --git a/mod/wiki/index.php b/mod/wiki/index.php index d98ab64bc3..031dff2562 100644 --- a/mod/wiki/index.php +++ b/mod/wiki/index.php @@ -12,7 +12,7 @@ error("Course ID is incorrect"); } - require_login($course->id); + require_course_login($course); add_to_log($course->id, "wiki", "view all", "index.php?id=$course->id", ""); diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index 0366e08fbc..93523ba138 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1202,10 +1202,17 @@ function workshop_get_student_submissions($workshop, $order = "title") { if ($order == "grade") { $order = "$workshop->teacherweight * s.teachergrade + $workshop->peerweight * s.peergrade DESC"; } + + // make sure it works on the site course + $select = "u.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}user a - WHERE u.course = $workshop->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND a.id = u.userid AND s.workshopid = $workshop->id AND s.timecreated > 0 diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 9f54ad6b74..d3d93ba39f 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -247,11 +247,17 @@ function workshop_count_self_assessments($workshop, $user) { ////////////////////////////////////////////////////////////////////////////////////// function workshop_count_student_submissions($workshop) { global $CFG; - - return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s, + + // make sure it works on the site course + $select = "s.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + + return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u - WHERE u.course = $workshop->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.workshopid = $workshop->id AND timecreated > 0"); } @@ -506,12 +512,18 @@ function workshop_get_comments($assessment) { function workshop_get_student_assessments($workshop, $user) { // Return all assessments on the student submissions by a user, order by youngest first, oldest last global $CFG; - + + // make sure it works on the site course + $select = "u.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a - WHERE u.course = $workshop->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.workshopid = $workshop->id AND a.submissionid = s.id AND a.userid = $user->id @@ -523,11 +535,17 @@ function workshop_get_student_assessments($workshop, $user) { function workshop_get_student_submission_assessments($workshop) { // Return all assessments on the student submissions, order by youngest first, oldest last global $CFG; - + + // make sure it works on the site course + $select = "u.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a - WHERE u.course = $workshop->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.workshopid = $workshop->id AND a.submissionid = s.id ORDER BY a.timecreated DESC"); @@ -587,12 +605,18 @@ function workshop_get_ungraded_assessments($workshop) { function workshop_get_ungraded_assessments_student($workshop) { global $CFG; // Return all assessments which have not been graded or just graded of student's submissions - + + // make sure it works on the site course + $select = "u.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + $cutofftime = time() - $CFG->maxeditingtime; return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s, {$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a - WHERE u.course = $workshop->course - AND s.userid = u.userid + WHERE $select s.userid = u.userid AND s.workshopid = $workshop->id AND a.submissionid = s.id AND (a.timegraded = 0 OR a.timegraded > $cutofftime) @@ -641,10 +665,18 @@ function workshop_get_user_assessments_done($workshop, $user) { ////////////////////////////////////////////////////////////////////////////////////// function workshop_get_users_done($workshop) { global $CFG; + + // make sure it works on the site course + $select = "s.course = '$workshop->course' AND"; + $site = get_site(); + if ($workshop->course == $site->id) { + $select = ''; + } + return get_records_sql("SELECT u.* FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s, {$CFG->prefix}workshop_submissions a - WHERE s.course = '$workshop->course' AND s.user = u.id + WHERE $select s.user = u.id AND u.id = a.user AND a.workshop = '$workshop->id' ORDER BY a.timemodified DESC"); } diff --git a/version.php b/version.php index be2f4439fd..90b211a002 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ // database to determine whether upgrades should // be performed (see lib/db/*.php) -$version = 2004082100; // The current version is a date (YYYYMMDDXX) +$version = 2004082200; // The current version is a date (YYYYMMDDXX) $release = "1.4 aiming-for-beta-soon"; // User-friendly version number -- 2.39.5