mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
fixed another foreach problem in lib.
Added a todo section to the README
This commit is contained in:
parent
6b7deae418
commit
51383e2cdf
2 changed files with 55 additions and 43 deletions
|
@ -21,3 +21,10 @@ Quick install instructions
|
||||||
|
|
||||||
4) Go to the site configuration page -> modules section -> attendance
|
4) Go to the site configuration page -> modules section -> attendance
|
||||||
to specify your preferences for the module (optional)
|
to specify your preferences for the module (optional)
|
||||||
|
|
||||||
|
New Feature and fix list:
|
||||||
|
|
||||||
|
Automatic attendance loggin based on IP address range
|
||||||
|
Attendance logging by email/Imode (via cel phone)
|
||||||
|
Specify a range of attendance times for automatic attendance logging.
|
||||||
|
Tighter integration with the new calendar features.
|
||||||
|
|
|
@ -187,9 +187,9 @@ function attendance_user_outline($course, $user, $mod, $attendance) {
|
||||||
// build array of all tardies
|
// build array of all tardies
|
||||||
$tarr = array();
|
$tarr = array();
|
||||||
foreach ($tardyrecs as $tardyrec) {
|
foreach ($tardyrecs as $tardyrec) {
|
||||||
array_push($tarr, $tardyrec->hour);
|
array_push($tarr, $tardyrec->hour);
|
||||||
$tardystring = $tardystring . ", " . $tardyrec->hour;
|
$tardystring = $tardystring . ", " . $tardyrec->hour;
|
||||||
}
|
}
|
||||||
$end=array_pop($tarr);
|
$end=array_pop($tarr);
|
||||||
$tardystring = "Tardy in hours " . implode(", ", $tarr) . " and ". $end . ". ";
|
$tardystring = "Tardy in hours " . implode(", ", $tarr) . " and ". $end . ". ";
|
||||||
}
|
}
|
||||||
|
@ -226,14 +226,15 @@ function attendance_user_complete($course, $user, $mod, $attendance) {
|
||||||
|
|
||||||
$attrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "", "", "hour ASC");
|
$attrecs=attendance_get_records("attendance_roll", "dayid", $attendance->id, "userid", $user->id, "", "", "hour ASC");
|
||||||
// fill an array with the absences and tardies, as those are the only records actually stored
|
// fill an array with the absences and tardies, as those are the only records actually stored
|
||||||
|
|
||||||
$grid = array();
|
$grid = array();
|
||||||
foreach ($attrecs as $attrec) { $grid[$attrec->hour]=$attrec->status; }
|
if ($attrecs) { foreach ($attrecs as $attrec) { $grid[$attrec->hour]=$attrec->status; } }
|
||||||
echo "<table><tr><th>Hour:</th>\n";
|
echo "<table><tr><th>Hour:</th>\n";
|
||||||
// echo out the table header
|
// echo out the table header
|
||||||
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 "<th valign=\"top\" align=\"center\" nowrap class=\"generaltableheader\">".$j."</th>\n";
|
||||||
}
|
}
|
||||||
echo "</tr><tr><th>Status:</th>";
|
echo "</tr><tr><th>Status:</th>";
|
||||||
for($j=1;$j<=$attendance->hours;$j++) {
|
for($j=1;$j<=$attendance->hours;$j++) {
|
||||||
// set the attendance defaults for each student
|
// set the attendance defaults for each student
|
||||||
if (isset($grid[$j])) {
|
if (isset($grid[$j])) {
|
||||||
|
@ -266,7 +267,7 @@ function attendance_cron () {
|
||||||
// look for all attendance instances set to autoattend
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
$td = attendance_find_today(time());
|
$td = attendance_find_today(time());
|
||||||
$tm = attendance_find_tomorrow(time());
|
$tm = attendance_find_tomorrow(time());
|
||||||
foreach($attendances as $attendance) {
|
foreach($attendances as $attendance) {
|
||||||
|
@ -277,25 +278,27 @@ function attendance_cron () {
|
||||||
$courses[$attendance->course]->students =
|
$courses[$attendance->course]->students =
|
||||||
attendance_get_course_students($attendance->course, "u.lastname ASC");
|
attendance_get_course_students($attendance->course, "u.lastname ASC");
|
||||||
}
|
}
|
||||||
foreach ($courses[$attendance->course]->students as $student) {
|
if ($courses[$attendance->course]->students) {
|
||||||
// first, clear out the records that may be there already
|
foreach ($courses[$attendance->course]->students as $student) {
|
||||||
delete_records("attendance_roll",
|
// first, clear out the records that may be there already
|
||||||
"dayid",$attendance->id,
|
delete_records("attendance_roll",
|
||||||
"userid",$student->id);
|
"dayid",$attendance->id,
|
||||||
$wc = "userid = " . $student->id . " AND course = " . $attendance->course .
|
"userid",$student->id);
|
||||||
" AND time >= " . $td . " AND time < " . $tm;
|
$wc = "userid = " . $student->id . " AND course = " . $attendance->course .
|
||||||
$count = get_record_select("log",$wc,"COUNT(*) as c");
|
" AND time >= " . $td . " AND time < " . $tm;
|
||||||
if ($count->c == "0") { // then the student hasn't done anything today, so mark him absent
|
$count = get_record_select("log",$wc,"COUNT(*) as c");
|
||||||
$attrec->dayid = $attendance->id;
|
if ($count->c == "0") { // then the student hasn't done anything today, so mark him absent
|
||||||
$attrec->userid = $student->id;
|
$attrec->dayid = $attendance->id;
|
||||||
$attrec->status = 2; // status 2 is absent
|
$attrec->userid = $student->id;
|
||||||
// mark ALL hours as absent for first version
|
$attrec->status = 2; // status 2 is absent
|
||||||
for ($i=1;$i<=$attendance->hours;$i++) {
|
// mark ALL hours as absent for first version
|
||||||
$attrec->hour = $i;
|
for ($i=1;$i<=$attendance->hours;$i++) {
|
||||||
insert_record("attendance_roll",$attrec, false);
|
$attrec->hour = $i;
|
||||||
} // for loop to mark all hours absent
|
insert_record("attendance_roll",$attrec, false);
|
||||||
} // if student has no activity
|
} // for loop to mark all hours absent
|
||||||
} // foreach student in the list
|
} // if student has no activity
|
||||||
|
} // foreach student in the list
|
||||||
|
} // if students exist
|
||||||
} // if the attendance roll is for today
|
} // if the attendance roll is for today
|
||||||
} // for each attendance in the system
|
} // for each attendance in the system
|
||||||
return true;
|
return true;
|
||||||
|
@ -308,21 +311,23 @@ function attendance_grades($attendanceid) {
|
||||||
$attendance = get_record("attendance", "id", $attendanceid);
|
$attendance = get_record("attendance", "id", $attendanceid);
|
||||||
if ($attendance->grade == "1") {
|
if ($attendance->grade == "1") {
|
||||||
$students = get_course_students($attendance->course);
|
$students = get_course_students($attendance->course);
|
||||||
foreach ($students as $student) {
|
if ($students) {
|
||||||
$rolls = attendance_get_records("attendance_roll",
|
foreach ($students as $student) {
|
||||||
"dayid",$attendance->id,
|
$rolls = attendance_get_records("attendance_roll",
|
||||||
"userid",$student->id);
|
"dayid",$attendance->id,
|
||||||
$abs=$tar=0;
|
"userid",$student->id);
|
||||||
if ($rolls) {
|
$abs=$tar=0;
|
||||||
foreach ($rolls as $roll) {
|
if ($rolls) {
|
||||||
if ($roll->status == 1) {$tar++;}
|
foreach ($rolls as $roll) {
|
||||||
elseif ($roll->status == 2) {$abs++;}
|
if ($roll->status == 1) {$tar++;}
|
||||||
}
|
elseif ($roll->status == 2) {$abs++;}
|
||||||
$total = $attendance->hours - attendance_tally_overall_absences_decimal($abs, $tar);
|
} // if rolls
|
||||||
$percent = ($total != 0)?$total/$attendance->hours:0;
|
$total = $attendance->hours - attendance_tally_overall_absences_decimal($abs, $tar);
|
||||||
$return->grades[$student->id] = ($percent == 0)?0.0:$attendance->maxgrade * $percent;
|
$percent = ($total != 0)?$total/$attendance->hours:0;
|
||||||
} else { $return->grades[$student->id] = $attendance->maxgrade; }
|
$return->grades[$student->id] = ($percent == 0)?0.0:$attendance->maxgrade * $percent;
|
||||||
} // foreach student
|
} else { $return->grades[$student->id] = $attendance->maxgrade; }
|
||||||
|
} // foreach student
|
||||||
|
} // if students
|
||||||
$return->maxgrade = $attendance->maxgrade;
|
$return->maxgrade = $attendance->maxgrade;
|
||||||
} else { // if attendance->grade == "1"
|
} else { // if attendance->grade == "1"
|
||||||
$return->grades = NULL;
|
$return->grades = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue