]> git.mjollnir.org Git - moodle.git/commitdiff
All modules are now suitable for the site page. They now all follow the same rules...
authorgustav_delius <gustav_delius>
Sun, 22 Aug 2004 14:38:47 +0000 (14:38 +0000)
committergustav_delius <gustav_delius>
Sun, 22 Aug 2004 14:38:47 +0000 (14:38 +0000)
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.

46 files changed:
course/enrol.php
lang/en/choice.php
lang/en/moodle.php
lib/datalib.php
lib/db/mysql.php
lib/moodlelib.php
mod/assignment/index.php
mod/assignment/lib.php
mod/assignment/view.php
mod/attendance/index.php
mod/attendance/lib.php
mod/chat/index.php
mod/chat/view.php
mod/choice/index.php
mod/choice/view.php
mod/dialogue/locallib.php
mod/exercise/locallib.php
mod/forum/post.php
mod/forum/search.php
mod/glossary/edit.php
mod/glossary/formats.php
mod/glossary/index.php
mod/glossary/print.php
mod/glossary/sql.php
mod/glossary/view.php
mod/journal/edit.php
mod/journal/index.php
mod/journal/lib.php
mod/journal/report.php
mod/lesson/import.php
mod/lesson/index.php
mod/quiz/category.php
mod/quiz/edit.php
mod/quiz/export.php
mod/quiz/import.php
mod/quiz/multiple.php
mod/quiz/question.php
mod/quiz/questiontypes/datasetdependent/categorydatasetdefinitions.php
mod/scorm/details.php
mod/survey/details.php
mod/survey/index.php
mod/survey/save.php
mod/wiki/index.php
mod/workshop/lib.php
mod/workshop/locallib.php
version.php

index 9f0c57588ef4b62f6bbf855b2cb35e0498d32776..bd2d7ee8ccec5f9f2606ac256af8d98d158c4b5c 100644 (file)
 
         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 
 
index 3be5e60b3086bd7fd8029eb3d5faf2d0f0bd249a..c7ea7d678d1b7b839e9db9404f19aeb86d09f5d2 100644 (file)
@@ -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.';
index 46e39bdc14288a2d96847321c53ac4c63c12e972..63ad4bdbaece056e1a38bf65c115b866d85171ea 100644 (file)
@@ -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.<br />Are you sure you wish to do this?';
 $string['enrolmentkey'] = 'Enrolment key';
 $string['enrolmentkeyfrom'] = 'This course requires an \'enrolment key\' - a one-time<BR>
index 5f54fb168118c0c108cf17349df7fd89f65a731f..2c530787a8e68ad7514c04a687d8fb68ec085272 100644 (file)
@@ -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
index 8db8532e1aa2134850e1d00128294e119aa91f65..cfc0648cc562517adf0f92f84802123a9360fee0 100644 (file)
@@ -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;
 
index 285bad3a4b07eb2a002a5afe0888a2ad05057f8b..752c0ebefee84fd4843021d9b256ee123b22557b 100644 (file)
@@ -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);
 }
 
index f288c48ec9b7f077704d4a0ead79c09224df9d8e..7cbe078eba95c0e9ba2918577b987fa880580758 100644 (file)
@@ -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 =  "<a href=\"submissions.php?id=$assignment->id\">" .
                              get_string("viewsubmissions", "assignment", $count) . "</a>$groupname";
             }
         } else {
-            if ($submission = assignment_get_submission($assignment, $USER)) {
-                if ($submission->timemodified <= $assignment->timedue) {
-                    $submitted = userdate($submission->timemodified);
-                } else {
-                    $submitted = "<font color=red>".userdate($submission->timemodified)."</font>";
+            if (isset($USER->id)) {
+                if ($submission = assignment_get_submission($assignment, $USER)) {
+                    if ($submission->timemodified <= $assignment->timedue) {
+                        $submitted = userdate($submission->timemodified);
+                    } else {
+                        $submitted = "<font color=red>".userdate($submission->timemodified)."</font>";
+                    }
                 }
-            } else {
-                $submitted = get_string("no");
             }
         }
 
index 0fd16af2b6b25c08c5a45f771e68d943dea87ab4..234c83daa98143851a984ea9a62da8c390f6ab8b 100644 (file)
@@ -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");
+    }
 }
 
 
index d2125115e0db515627281aa3c8506ef6815093be..1f058f30b47c436fb42193400736efd63535d3dd 100644 (file)
@@ -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 "<br />";
 
-    if (!isteacher($course->id) and !isguest()) {
+    if (isstudent($course->id)) {
         $submission = assignment_get_submission($assignment, $USER);
 
         if ($assignment->type == OFFLINE) {
index 2055f4113c3efbff295dff68d52d4435ee89ee9d..7922744f016f5981964ef5161d8dc54bf9ccbc26 100644 (file)
@@ -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", "");
 
index f37b96264bca44fb22765fb142be648107f31433..bee964aff23eb46e33fb913e92de4110a874c2ec 100755 (executable)
@@ -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 "<table><tr><th>Hour:</th>\n";
     // echo out the table header
-       for($j=1;$j<=$attendance->hours;$j++) {
-               echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$j."</th>\n";
-         }
-         echo "</tr><tr><th>Status:</th>";
-       for($j=1;$j<=$attendance->hours;$j++) {
+    for($j=1;$j<=$attendance->hours;$j++) {
+        echo "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$j."</th>\n";
+      }
+      echo "</tr><tr><th>Status:</th>";
+    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 "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$status."</td>\n";
-       } /// for loop
+    } /// for loop
     echo "</tr></table>\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
index d5490644af4b542f9c17029362a13d65de83f25f..f2df2e3bd9a655c6f06c0e46316154e4fd867a8e 100644 (file)
@@ -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", "");
 
index f9402108773263b79f93505e5417350a4486d1fb..e611f64c63951ba0269310737506aa1c9b6e8c24 100644 (file)
@@ -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);
 
index 378ab7c0b46d80fba9d4b58de7f33ed3c21643c5..a90f67f371be03388ba73e25ebf0c0aada3eb31e 100644 (file)
@@ -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;
         }
index c33c86f92f128ff4ee75193561464545287f8c33..3940a6073834712248a4297b3ab55603889a006c 100644 (file)
@@ -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");
     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()) {
         echo "<INPUT type=hidden name=id value=\"$cm->id\">";
         if (isstudent($course->id) or isteacher($course->id, 0, false)) {
             echo "<INPUT type=submit value=\"".get_string("savemychoice","choice")."\">";
+        } else {
+            print_string('havetologin', 'choice');
         }
         echo "</P></FORM></CENTER>";
 
index c563fa06fe5a7db623a87321384b4a015e6239f1..3db47524176f8796f28a0d6ff3f6c69bf818d4c0 100644 (file)
@@ -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");
 }
 
 
index 8e8499689a7844df875a774ecb9cff1ac9a1418e..49d5bb86db2346fb8821ad04c53ec327db0f35ab 100644 (file)
@@ -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)
index 042028fc03ee029004856aa028ee2e6cac5b9ec2..90893e8f6d609843ef209a69ddfe01561821ac8a 100644 (file)
 
             $course = get_record('course', 'id', $forum->course);
             $strforums = get_string("modulenameplural", "forum");
-            print_header("$course->shortname: $discussion->name: $post->subject", "$course->fullname",
-                         "<a href=../../course/view.php?id=$course->id>$course->shortname</a> ->
-                          <a href=\"../forum/index.php?id=$course->id\">$strforums</a> -> 
+            print_header_simple("$discussion->name: $post->subject", "",
+                         "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> -> 
                           <a href=\"view.php?f=$forum->id\">$forum->name</a> -> 
                           <a href=\"discuss.php?d=$discussion->id\">$post->subject</a> -> ".
                           get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm));
index 51211e6307de33ab23bf3fc3859fa60a741b3c2b..ed147ec0d9f3a84264ec48f16714962328df92ce 100644 (file)
@@ -38,9 +38,8 @@
     $searchform = forum_print_search_form($course, $search, true, "plain");
 
     if (!$search) {
-        print_header("$course->shortname: $strsearch", "$course->fullname",
-                 "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> -> 
-                  <A HREF=\"index.php?id=$course->id\">$strforums</A> -> $strsearch", "search.search",
+        print_header_simple("$strsearch", "",
+                 "<A HREF=\"index.php?id=$course->id\">$strforums</A> -> $strsearch", "search.search",
                   "", "", "&nbsp;", 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",
-                     "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> 
-                      <a href=\"index.php?id=$course->id\">$strforums</a> -> 
+            print_header_simple("$strsearchresults", "",
+                     "<a href=\"index.php?id=$course->id\">$strforums</a> -> 
                       <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search", 
                       "", "", "&nbsp;", navmenu($course));
             print_heading(get_string("nopostscontaining", "forum", $search));
@@ -79,9 +77,8 @@
             exit;
         }
 
-        print_header("$course->shortname: $strsearchresults", "$course->fullname",
-                 "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> 
-                  <a href=\"index.php?id=$course->id\">$strforums</a> -> 
+        print_header_simple("$strsearchresults", "",
+                 "<a href=\"index.php?id=$course->id\">$strforums</a> -> 
                   <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search", 
                   "", "",  $searchform, navmenu($course));
 
index a34a5c62be241b17f6067ea1c11ed331f639689d..084e38b114ca40759e6f561f7f532451f94e4f20 100644 (file)
@@ -72,9 +72,8 @@ if ( $confirm ) {
             $onsubmit = "";
         }
 
-        print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
-             "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
-              <A HREF=\"index.php?id=$course->id\">$strglossaries</A> ->
+        print_header_simple(strip_tags("$glossary->name"), "",
+             "<A HREF=\"index.php?id=$course->id\">$strglossaries</A> ->
               <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $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",
-             "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
-              <A HREF=\"index.php?id=$course->id\">$strglossaries</A> ->
+print_header_simple(strip_tags("$glossary->name"), "",
+             "<A HREF=\"index.php?id=$course->id\">$strglossaries</A> ->
               <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "",
               "", true, "", navmenu($course, $cm));
 
index 0c4e7ab39479685a0ac709f127320627e6046979..d7ae740f32818cb74d310f45d62b59e07ee9764c 100644 (file)
@@ -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,
                   "<a href=\"../../admin/index.php\">$stradmin</a> -> ".
                   "<a href=\"../../admin/configure.php\">$strconfiguration</a> -> ".
                   "<a href=\"../../admin/modules.php\">$strmanagemodules</a> -> <a href=\"../../admin/module.php?module=glossary\">$strmodulename</a> -> $strdisplayformats");
     echo '<form method="post" action="formats.php" name="form">';
     echo '<table width="90%" align="center" bgcolor="' . $THEME->cellheading . '" class="generalbox">';
     ?>
-       <tr>
-           <td colspan=3 align=center><strong>
-               <?php echo get_string('displayformat'.$displayformat->name,"glossary"); ?>
+    <tr>
+        <td colspan=3 align=center><strong>
+        <?php echo get_string('displayformat'.$displayformat->name,"glossary"); ?>
         </strong></td>
-       </tr>
+    </tr>
     <tr valign=top>
         <td align="right" width="20%"><?PHP print_string('popupformat','glossary'); ?></td>
         <td>
         <?php print_string("cnfshowgroup", "glossary") ?><br /><br />
         </td>
     </tr>
-       <tr>
-           <td colspan=3 align=center>
-               <input type="submit" value="<?php print_string("savechanges") ?>"></td>
-       </tr>
+    <tr>
+        <td colspan=3 align=center>
+        <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+    </tr>
     <input type="hidden" name=id    value="<?php p($id) ?>">
     <input type="hidden" name=mode    value="edit">
-       <?PHP
-       
+    <?PHP
+    
     print_simple_box_end();    
     echo '</form>';
 
index ea43d6b9b37a3e03d2953ab4a75f0a78e72143cb..f8454875cf1d6bd47779f8699f5a2cd0b8d7ec1b 100644 (file)
@@ -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", "");
 
index b89165bc2f2f8da6d7b718e33743fcddb89120bd..995cf1ca85d989cb21bb468aca8f495bb42c2ffc 100644 (file)
@@ -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();
index fbfc2b98cf3e762c7431b26c16bc5e69c04bfa65..f7fa2af09328f405fc90414d143f7f819874a71b 100644 (file)
 /// 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) {
     $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;
         }    
     }
index bea8ebd2f223df1e975a36e8684baa5dacf83fe7..42b3e05dfa8bda8291109d0429192be71c6387fd 100644 (file)
             $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype and $glossary->rssarticles) {
             echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td align="right">';
             $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 '</td></tr></table>';
         }
     
index b2310da6688caf1052c31d6c455e29693fd983cb..95cf1f0f5392be009b4d535f0eff0d45761a5529 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP // $Id$
 
-       require_once("../../config.php");
+    require_once("../../config.php");
 
     require_variable($id);    // Course Module ID
 
 
     if ($form = data_submitted()) {
 
-               $timenow = time();
+        $timenow = time();
 
         $form->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",
-                 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> 
-                  <A HREF=\"index.php?id=$course->id\">$strjournals</A> -> 
+    print_header_simple("$journal->name", "",
+                 "<A HREF=\"index.php?id=$course->id\">$strjournals</A> -> 
                   <A HREF=\"view.php?id=$cm->id\">$journal->name</A> -> $stredit", "",
                   "", true, "", navmenu($course, $cm));
 
@@ -87,7 +86,7 @@
 
     echo "<br />";
 
-       include("edit.html");
+    include("edit.html");
 
     if ($usehtmleditor) {
         use_html_editor("text");
index 90a503c9cd933a6feb05007ad8d6b15b1a42404a..a395d65a93e2701a9eda7e52d93d9e82aa0a711a 100644 (file)
@@ -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");
index 56d78431788c7113d7e9d73881575fd99d065577..073c75091c7121a377d9137dc870c5da89dc6f5b 100644 (file)
@@ -68,36 +68,39 @@ function journal_user_complete_index($course, $user, $journal, $journalopen, $he
     print_simple_box_end();
     echo "<br clear=all />";
     echo "<br />";
+    
+    if (isstudent($course->id) or isteacher($course->id)) {
 
-    print_simple_box_start("right", "90%");
-
-    if ($journalopen) {
-        echo "<p align=right><a href=\"edit.php?id=$journal->coursemodule\">";
-        echo get_string("edit")."</a></p>";
-    } else {
-        echo "<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
-        echo get_string("view")."</a></p>";
-    }
-
-    if ($entry = get_record("journal_entries", "userid", $user->id, "journal", $journal->id)) {
-        if ($entry->modified) {
-            echo "<p align=\"center\"><font size=1>".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
-        }
-        if ($entry->text) {
-            echo format_text($entry->text, $entry->format);
+        print_simple_box_start("right", "90%");
+    
+        if ($journalopen) {
+            echo "<p align=right><a href=\"edit.php?id=$journal->coursemodule\">";
+            echo get_string("edit")."</a></p>";
+        } else {
+            echo "<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
+            echo get_string("view")."</a></p>";
         }
-        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 "<p align=\"center\"><font size=1>".get_string("lastedited").": ".userdate($entry->modified)."</font></p>";
+            }
+            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 "<br clear=all />";
+        echo "<br />";
     }
 
-    print_simple_box_end();
-    echo "<br clear=all />";
-    echo "<br />";
-
 }
 
 
@@ -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,
index 064339a82cd3c0040a377d8caecc7638bf34e2bb..0e5922a8a0eabacbfc10bc16b624f76d3a5aad2c 100644 (file)
@@ -38,9 +38,8 @@
     $strentries = get_string("entries", "journal");
     $strjournals = get_string("modulenameplural", "journal");
 
-    print_header("$course->shortname: $strjournals", "$course->fullname",
-                 "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
-                  <a href=\"index.php?id=$course->id\">$strjournals</a> ->
+    print_header_simple("$strjournals", "",
+                 "<a href=\"index.php?id=$course->id\">$strjournals</a> ->
                   <a href=\"view.php?id=$cm->id\">$journal->name</a> -> $strentries", "", "", true);
 
 
index 85883a3ef0fef5543e41ea5e00eb603f8d1c84f2..c82b7756b542ccb70fe05c6de79b7949335056e2 100644 (file)
@@ -29,8 +29,7 @@
     $strimportquestions = get_string("importquestions", "lesson");
     $strlessons = get_string("modulenameplural", "lesson");
 
-    print_header("$course->shortname: $strimportquestions", "$course->shortname: $strimportquestions",
-                 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> ". 
+    print_header_simple("$strimportquestions", " $strimportquestions",
                  "<A HREF=index.php?id=$course->id>$strlessons</A> -> <a href=\"view.php?id=$cm->id\">$lesson->name</a>-> $strimportquestions");
 
     if ($form = data_submitted()) {   /// Filename
index 5dcba6df653d59fd9dd67d41bdc43497141d7dfb..c88ad3e6f9b09f728902785ba93f95467ad7d309 100644 (file)
@@ -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", "");
 
             $due = "<FONT COLOR=\"red\">".userdate($lesson->deadline)."</FONT>";
         }
 
+        $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);
index a9300f1d6dc0406c46ea2367c5de669f8faeb8c7..119952c931ff9cdd8c3ca6b881c0bc4dd5d315f8 100644 (file)
@@ -1,8 +1,8 @@
 <?PHP // $Id$
       // Allows a teacher to create, edit and delete categories
 
-       require_once("../../config.php");
-       require_once("lib.php");
+    require_once("../../config.php");
+    require_once("lib.php");
 
     require_variable($id);   // course
 
@@ -39,9 +39,8 @@
                                  "quiz");
     $streditcategories = get_string("editcategories", "quiz");
 
-    print_header("$course->shortname: $streditcategories", "$course->shortname: $streditcategories",
-                 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
-                   -> <A HREF=\"edit.php\">$streditingquiz</A> -> $streditcategories");
+    print_header_simple("$streditcategories", " $streditcategories",
+                 "<A HREF=\"edit.php\">$streditingquiz</A> -> $streditcategories");
 
 
 /// Delete category if the user wants to delete it
                 }
             }
         }
-       }
+    }
 
 
 /// Get the existing categories
index 0ba6ebd5868b213d17a61377fb0eccb18973657a..1422210cc3a13a7133d650d6e94de1ab5f4eb1fa 100644 (file)
     $strediting = get_string(isset($modform->instance) ? "editingquiz" : "editquestions", "quiz");
     $strheading = empty($modform->name) ? $strediting : $modform->name;
 
-    print_header("$course->shortname: $strediting", "$course->shortname: $strheading",
-                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> ".
+    print_header_simple("$strediting", "$strheading",
                  "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a> -> $strediting");
 
     // Print basic page layout.
index bfb5dac7cc5b200f3fd442f7c1ddecd129c771d4..818beeaff3d746bbbd052d8e829f6f6250a97bda 100644 (file)
     $strquizzes = get_string('modulenameplural', 'quiz');
     $streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz");
 
-    print_header("$course->shortname: $strexportquestions", "$course->shortname: $strexportquestions",
-                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
-                 "-> <a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
+    print_header_simple("$strexportquestions", "$strexportquestions",
+                 "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
                   " -> <a href=\"edit.php\">$streditingquiz</a> -> $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
     $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 "<hr>";
index d7a0490a7aea9f9cd6f4f22642e7a6972488f3d3..0148c61192635197be118e0a4fe3decf8cd9b14b 100644 (file)
@@ -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",
-                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
-                 "-> <a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
+    print_header_simple("$strimportquestions", "$strimportquestions",
+                 "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
                   " -> <a href=\"edit.php\">$streditingquiz</a> -> $strimportquestions");
 
     if ($form = data_submitted()) {   /// Filename
index 47c86cf274085be6ae7f845df44f6b1d346f6a16..eb93ac7648a30e08e4bc02f76138972346d63e12 100644 (file)
@@ -1,8 +1,8 @@
 <?PHP // $Id$
       // A quick way to add lots of questions to a category (and a quiz)
 
-       require_once("../../config.php");
-       require_once("lib.php");
+    require_once("../../config.php");
+    require_once("lib.php");
 
     require_variable($category);
 
     $streditingquiz = get_string(isset($SESSION->modform->instance) ? "editingquiz" : "editquestions", "quiz");
     $strcreatemultiple = get_string("createmultiple", "quiz");
 
-    print_header("$course->shortname: $strcreatemultiple", "$course->shortname: $strcreatemultiple",
-                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
-                 " -> <a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
+    print_header_simple("$strcreatemultiple", "$strcreatemultiple",
+                 "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
                  " -> <a href=\"edit.php\">$streditingquiz</a> -> $strcreatemultiple");
 
 
index ad4ea871f0cd2eee925769376b170db9af07e072..55b1aa47a8d77531d428855de0eff3d650812cfc 100644 (file)
@@ -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",
-                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
-                 "-> <a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
+    print_header_simple("$streditingquestion", "$streditingquestion",
+                 "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
                   " -> <a href=\"edit.php\">$streditingquiz</a> -> $streditingquestion");
 
     if (isset($delete)) {
index 6e21bdb062f2277e82b3a031f14f3bf751104acd..08ed9667f34ec773a8b4d31e4b46c7e61867390e 100644 (file)
@@ -31,9 +31,8 @@
     $strdefinedataset = get_string("datasetdefinitions", "quiz", $category->name);
     $strquestions = get_string("questions", "quiz");
 
-    print_header("$course->shortname: $strdefinedataset", "$course->shortname: $strdefinedataset",
-                 "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
-                  -> <A HREF=\"../../edit.php\">$streditingquiz</A> -> $strdefinedataset");
+    print_header_simple("$strdefinedataset", "$strdefinedataset",
+                 "<A HREF=\"../../edit.php\">$streditingquiz</A> -> $strdefinedataset");
 
     if ($form = data_submitted()) {   /// Filename
 
index e86943f1ba944a04c078b87f4f311596f60477cb..bbea86e5d2935d53bd7b4cb5c8ec176b1da4ad1d 100755 (executable)
         $strediting = get_string("validateascorm", "scorm");
         $strname = get_string("name");
 
-        print_header("$course->shortname: $strediting", "$course->shortname: $strediting",
-                      "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> $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
             } 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 "<table cellpadding=\"5\" align=\"center\">\n";
-       echo "    <tr><td align=\"right\" nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>\n";
-       echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("validation","scorm").":</b></p></td><td><p>".get_string($result,"scorm")."</p></a></td></tr>\n";
-       if ($errorlogs != '') {
-           $lines = round(count($errors)/4);
-           if ($lines < 5) {
-               $lines = 5;
-           }
-           echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("errorlogs","scorm").":</b></p></td><td><textarea rows=\"".$lines."\" cols=\"30\" readonly>".$errorlogs."</textarea></a></td></tr>\n";
-       }
-       if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance)))
-           echo "    <tr><td align=\"center\" colspan=\"2\" nowrap><p><b>".get_string("trackingloose","scorm")."</b></p></td></tr>\n";
-       echo "</table>\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 "<form name=\"theform\" method=\"post\" action=\"$form->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 "<table cellpadding=\"5\" align=\"center\">\n";
+        echo "    <tr><td align=\"right\" nowrap><p><b>$strname:</b></p></td><td><p>$form->name</p></a></td></tr>\n";
+        echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("validation","scorm").":</b></p></td><td><p>".get_string($result,"scorm")."</p></a></td></tr>\n";
+        if ($errorlogs != '') {
+            $lines = round(count($errors)/4);
+            if ($lines < 5) {
+                $lines = 5;
+            }
+            echo "    <tr><td align=\"right\" nowrap><p><b>".get_string("errorlogs","scorm").":</b></p></td><td><textarea rows=\"".$lines."\" cols=\"30\" readonly>".$errorlogs."</textarea></a></td></tr>\n";
+        }
+        if (($form->mode == "update") && ($form->launch == 0) && (get_records("scorm_sco_users","scormid",$form->instance)))
+        echo "    <tr><td align=\"center\" colspan=\"2\" nowrap><p><b>".get_string("trackingloose","scorm")."</b></p></td></tr>\n";
+        echo "</table>\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 "<form name=\"theform\" method=\"post\" action=\"$form->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;
+            }
+        
 ?>
-       <table cellpadding="5" align="center">
-         <tr valign=top>
-           <td align=right><p><b><?php print_string("grademethod", "scorm") ?>:</b></p></td>
-           <td>
-             <?php
-               $options = array();
-               $options[0] = get_string("gradescoes", "scorm");
-               $options[1] = get_string("gradehighest", "scorm");
-               $options[2] = get_string("gradeaverage", "scorm");
-               choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
-               helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
-             ?>
-           </td>
-         </tr>
-         <tr valign=top>
-           <td align=right><p><b><?php print_string("maximumgrade") ?>:</b></p></td>
-           <td>
-             <?php
-               for ($i=100; $i>=1; $i--) {
-                   $grades[$i] = $i;
-               }
+    <table cellpadding="5" align="center">
+      <tr valign=top>
+            <td align=right><p><b><?php print_string("grademethod", "scorm") ?>:</b></p></td>
+            <td>
+              <?php
+            $options = array();
+            $options[0] = get_string("gradescoes", "scorm");
+            $options[1] = get_string("gradehighest", "scorm");
+            $options[2] = get_string("gradeaverage", "scorm");
+            choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
+            helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
+              ?>
+            </td>
+      </tr>
+      <tr valign=top>
+            <td align=right><p><b><?php print_string("maximumgrade") ?>:</b></p></td>
+            <td>
+              <?php
+            for ($i=100; $i>=1; $i--) {
+                    $grades[$i] = $i;
+            }
 
-               choose_from_menu($grades, "maxgrade", "$form->maxgrade", "");
-               helpbutton("maxgrade", get_string("maximumgrade"), "scorm");
-             ?>
-           </td>
-         </tr>
-         <tr valign=top>
-           <td align=right><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
-           <td>
-           <?php
-               $options = array();
-               $options[0]=get_string("no");
-               $options[1]=get_string("yes");
-               choose_from_menu ($options, "auto", $form->auto);
-           ?>
-           </td>
-         </tr>
-         <tr valign="top">
+            choose_from_menu($grades, "maxgrade", "$form->maxgrade", "");
+            helpbutton("maxgrade", get_string("maximumgrade"), "scorm");
+              ?>
+            </td>
+      </tr>
+      <tr valign=top>
+        <td align=right><p><b><?php print_string("autocontinue","scorm") ?>:</b></p></td>
+        <td>
+        <?php
+            $options = array();
+            $options[0]=get_string("no");
+            $options[1]=get_string("yes");
+            choose_from_menu ($options, "auto", $form->auto);
+        ?>
+        </td>
+      </tr>
+      <tr valign="top">
             <td align="right" nowrap>
                 <p><b><?php p($strnewwindow) ?></b></p>
             </td>
              </td>
            </tr>
         </table>
-        <input type="hidden" name="reference"  value="<?php p($form->reference) ?>" />
-        <input type="hidden" name="datadir"    value="<?php p(substr($tempdir,strlen($scormdir))) ?>" />
-        <input type="hidden" name="summary"    value="<?php p($form->summary) ?>" />
-        <input type="hidden" name="name"       value="<?php p($form->name) ?>" />
-       <input type="hidden" name="launch"      value="<?php p($form->launch) ?>" />
-        <input type="hidden" name="course"     value="<?php p($form->course) ?>" />
-        <input type="hidden" name="coursemodule"       value="<?php p($form->coursemodule) ?>" />
-        <input type="hidden" name="section"    value="<?php p($form->section) ?>" />
-        <input type="hidden" name="module"     value="<?php p($form->module) ?>" />
-        <input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
-        <input type="hidden" name="instance"   value="<?php p($form->instance) ?>" />
-        <input type="hidden" name="mode"       value="<?php p($form->mode) ?>" />
-       <div align="center">
-           <input type="submit" value="<?php print_string("savechanges") ?>" />
-           <input type="submit" name=cancel value="<?php print_string("cancel") ?>" />
-       </div>
+        <input type="hidden" name="reference"   value="<?php p($form->reference) ?>" />
+        <input type="hidden" name="datadir" value="<?php p(substr($tempdir,strlen($scormdir))) ?>" />
+        <input type="hidden" name="summary" value="<?php p($form->summary) ?>" />
+        <input type="hidden" name="name"    value="<?php p($form->name) ?>" />
+    <input type="hidden" name="launch"  value="<?php p($form->launch) ?>" />
+        <input type="hidden" name="course"  value="<?php p($form->course) ?>" />
+        <input type="hidden" name="coursemodule"    value="<?php p($form->coursemodule) ?>" />
+        <input type="hidden" name="section" value="<?php p($form->section) ?>" />
+        <input type="hidden" name="module"  value="<?php p($form->module) ?>" />
+        <input type="hidden" name="modulename"  value="<?php p($form->modulename) ?>" />
+        <input type="hidden" name="instance"    value="<?php p($form->instance) ?>" />
+        <input type="hidden" name="mode"    value="<?php p($form->mode) ?>" />
+    <div align="center">
+        <input type="submit" value="<?php print_string("savechanges") ?>" />
+        <input type="submit" name=cancel value="<?php print_string("cancel") ?>" />
+    </div>
         </form>
 <?php
-       } else {
+        } else {
 ?>
-       <center>
+    <center>
            <input type="button" value="<?php print_string("continue") ?>" onClick="document.location='<?php echo $CFG->wwwroot ?>/course/view.php?id=<?php echo $course->id ?>';">
         </center>
 <?php
-       }
-       print_simple_box_end();
+    }
+    print_simple_box_end();
         print_footer($course);
     } else {
            error("This script was called incorrectly");
index 5ca79fedbece8f8550ad5a6001552ecd0941a1f7..31846cf2afdbba6d4235881d1be7ec51574bf01f 100644 (file)
@@ -17,9 +17,8 @@
         $streditingasurvey = get_string("editingasurvey", "survey");
         $strsurveys = get_string("modulenameplural", "survey");
 
-        print_header("$course->shortname: $streditingasurvey", "$course->fullname",
-                      "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>".
-                      " -> <a href=\"index.php?id=$course->id\">$strsurveys</a>".
+        print_header_simple("$streditingasurvey", "",
+                      "<a href=\"index.php?id=$course->id\">$strsurveys</a>".
                       " -> $form->name ($streditingasurvey)");
 
         if (!$form->name or !$form->template) {
index 87f7887a247149d9d5ea74d3882d478601ee1bdf..cf5d76cd41d4c4aec53d5adffe073b39f9228730 100644 (file)
@@ -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;
index 6098088711a8e5ce1645ccee4d12f2a27ea2b96f..1c270b3a244503bfa83619eca775c9c18d1793bb 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP // $Id$
 
-       require_once('../../config.php');
-       require_once('lib.php');
+    require_once('../../config.php');
+    require_once('lib.php');
 
 
 // Make sure this is a legitimate posting
@@ -89,9 +89,8 @@
     $strsurveys = get_string("modulenameplural", "survey");
     $strsurveysaved = get_string("surveysaved", "survey");
 
-       print_header("$course->shortname: $strsurveysaved", "$course->fullname", 
-        "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
-         <a href=\"index.php?id=$course->id\">$strsurveys</a> -> $survey->name -> $strsurveysaved", "");
+    print_header_simple("$strsurveysaved", "", 
+        "<a href=\"index.php?id=$course->id\">$strsurveys</a> -> $survey->name -> $strsurveysaved", "");
 
 
     notice(get_string("thanksforanswers","survey", $USER->firstname), "$CFG->wwwroot/course/view.php?id=$course->id");
index d98ab64bc332f90b23465447a61f0bc35921eadd..031dff2562b4ab3c2d902a148c0e96877ebb0988 100644 (file)
@@ -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", "");
 
index 0366e08fbc12577f4e960054b10947a288f58baa..93523ba13829d024eb22daae0969b333ec6d5374 100644 (file)
@@ -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
index 9f54ad6b74f8210b7daa789c868d8c6ec559f1e0..d3d93ba39fa66cae689f158ed1fbc5303f581843 100644 (file)
@@ -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");
 }
index be2f4439fd675dd94949f0fb84785f7cbe76b16f..90b211a0027fb199675d326da87c63b654f881f6 100644 (file)
@@ -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