]> git.mjollnir.org Git - moodle.git/commitdiff
fixed a bunch more foreach loops to test for null value on the iterated
authorjungwirr <jungwirr>
Tue, 4 May 2004 19:13:53 +0000 (19:13 +0000)
committerjungwirr <jungwirr>
Tue, 4 May 2004 19:13:53 +0000 (19:13 +0000)
collection

mod/attendance/index.php
mod/attendance/lib.php
mod/attendance/mod.html
mod/attendance/teacheredit.php
mod/attendance/viewall.php
mod/attendance/viewweek.php

index bd33774275c9948867841c3c735be49be1fff41c..0d99c1db0fe1a62577d6388e638dd3ef0c9f6744 100644 (file)
@@ -57,7 +57,7 @@
         $table->align = array ("LEFT", "LEFT", "LEFT");
     }
 
-    foreach ($attendances as $attendance) {
+   if ($attendances) foreach ($attendances as $attendance) {
         if (!$attendance->visible) {
             //Show dimmed if the mod is hidden
             $link = "<A class=\"dimmed\" HREF=\"view.php?id=$attendance->coursemodule\">$attendance->name</A>";
index 54063dd793ff443228b06a10d83ebfb49358ee19..276da0d09e75e57a789d13feb27fd43cd5f92d0a 100755 (executable)
@@ -101,7 +101,7 @@ function attendance_update_instance($attendance) {
   if ($data = data_submitted()) {      
     // Peel out all the data from variable names.
     $attrec->dayid = $attendance->id;
-    foreach ($data as $key => $val) {
+    if ($data) foreach ($data as $key => $val) {
       $pieces = explode('_',$key);
       if ($pieces[0] == 'student') {
          $attrec->userid=$pieces[1];
@@ -186,7 +186,7 @@ function attendance_user_outline($course, $user, $mod, $attendance) {
                } else { 
                        // build array of all tardies
                        $tarr = array();
-                       foreach ($tardyrecs as $tardyrec) {
+                       if ($tardyrecs) foreach ($tardyrecs as $tardyrec) {
                        array_push($tarr, $tardyrec->hour);
                        $tardystring = $tardystring . ", " . $tardyrec->hour;
                  }
@@ -204,7 +204,7 @@ function attendance_user_outline($course, $user, $mod, $attendance) {
                } else { 
                        // build array of all absences
                        $aarr = array();
-                       foreach ($absrecs as $absrec) {
+                       if ($absrecs) foreach ($absrecs as $absrec) {
                                array_push($aarr, $absrec->hour);
                        }
                        $end=array_pop($aarr);
@@ -270,7 +270,7 @@ function attendance_cron () {
   }
        $td = attendance_find_today(time());
        $tm = attendance_find_tomorrow(time());
-       foreach($attendances as $attendance) {
+       if ($attendances) foreach($attendances as $attendance) {
     if (($attendance->day >=$td ) && ($attendance->day < $tm)) {
     echo "Attendance: Taking attendance for $attendance->name\n";
 
index b40ae258a88e35b07fbf717dc56aa206c3190d37..e9b36771d4c886d74eab66847c2182667c3f1880 100755 (executable)
@@ -130,7 +130,7 @@ if ($form->hours >1) {
 
   $students = attendance_get_course_students($form->course, "u.lastname ASC");
   $i=0;
-  foreach ($students as $student) {
+  if ($students) foreach ($students as $student) {
     echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
     echo "<td align=\"left\" nowrap class=\"generaltablecell\"  style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
     echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->idnumber."</td>\n";
index b93308074f308ab8594716a3b20b6c9921c6c110..953fe51baf66f33e7bab8feab69b9afd04763c3f 100755 (executable)
@@ -170,7 +170,7 @@ if ($form->hours >1) {
 
   $students = attendance_get_course_students($form->course, "u.lastname ASC");
   $i=0;
-  foreach ($students as $student) {
+  if ($students) foreach ($students as $student) {
     echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
     echo "<td align=\"left\" nowrap class=\"generaltablecell\"  style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";
     echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->idnumber."</td>\n";
index c96cf9b40095da515d380a462b3dcced8d35906f..73903d2b54366f7a5b2fe41adbe3ef8d8a4f579d 100644 (file)
@@ -529,3 +529,5 @@ function attendance_HeaderingExcel($filename) {
 }
 
 ?>
+
+http://www.alpine-usa.com/company_info/press_release/010804_ipad.html
index c8f721fe7758e6701d1a829bf50ac5a8cc14710e..5b29b1070b621a1dda88c30acbeb3c8bcf6c08b1 100644 (file)
@@ -1,4 +1,4 @@
-<?  // $Id$
+sou<?  // $Id$
 /// This page prints all instances of attendance in a given week
 
     require_once("../../config.php");
@@ -49,7 +49,7 @@ if ($attendances) {
 /// create an array of all the attendance objects for the week
    $numatt=0;
    $numhours=0;
-   foreach ($attendances as $attendance){
+   if ($attendances) foreach ($attendances as $attendance){
      // store the raw attendance object
      $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id);
      $attendance->cmid = $cm->id;
@@ -123,7 +123,7 @@ if ($dlsub== "all") {
   $T = get_string("tardyshort","attendance");
   $P = get_string("presentshort","attendance");  
   $row=4;
-  foreach ($students as $student) {
+  if ($students) foreach ($students as $student) {
     $myxls->write_string($row,0,$student->lastname);
     $myxls->write_string($row,1,$student->firstname);
     $studentid=(($student->idnumber != "") ? $student->idnumber : " ");
@@ -188,7 +188,7 @@ if ($dlsub== "all") {
   $T = get_string("tardyshort","attendance");
   $P = get_string("presentshort","attendance");  
   $row=3;
-  foreach ($students as $student) {
+  if ($students) foreach ($students as $student) {
     echo $student->lastname;
     echo "\t".$student->firstname;
     $studentid=(($student->idnumber != "") ? $student->idnumber : " ");
@@ -403,7 +403,7 @@ while (($multipage || $onepage) && (!$endonepage)) {
   $A = get_string("absentshort","attendance");
   $T = get_string("tardyshort","attendance");
   $P = get_string("presentshort","attendance");  
-  foreach ($students as $student) {
+  if ($students) foreach ($students as $student) {
     if (isteacher($course->id)) {
       echo "<tr><td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$student->lastname."</td>\n";
       echo "<td align=\"left\" nowrap class=\"generaltablecell\"  style=\"border-top: 1px solid;\">".$student->firstname."</td>\n";