-<?PHP
-
-function attendance_upgrade($oldversion) {
-/// This function does anything necessary to upgrade
-/// older versions to match current functionality
-
- global $CFG;
-
- if ($oldversion < 2003091001) {
-
- # Do something ...
-
- }
-
- return true;
-}
-
-?>
+<?PHP\r
+\r
+function attendance_upgrade($oldversion) {\r
+/// This function does anything necessary to upgrade \r
+/// older versions to match current functionality \r
+\r
+ global $CFG;\r
+\r
+ if ($oldversion < 2003091801) {\r
+\r
+ execute_sql("ALTER TABLE `attendance` ADD `edited` TINYINT( 1 ) DEFAULT '0' NOT NULL;");\r
+ execute_sql("UPDATE `attendance` set `edited` = 1;");\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+?>\r
-#\r
-# Table structure for table `prefix_attendance`\r
-#\r
-\r
-CREATE TABLE prefix_attendance (\r
- id int(10) unsigned NOT NULL auto_increment,\r
- name varchar(255) NOT NULL default '',\r
- course int(10) NOT NULL default '0',\r
- day int(10) unsigned NOT NULL default '0',\r
- hours tinyint(1) NOT NULL default '0',\r
- roll tinyint(1) NOT NULL default '0',\r
- notes varchar(64) NOT NULL default '',\r
- timemodified int(10) unsigned NOT NULL default '0',\r
- dynsection tinyint(1) NOT NULL default '0',\r
- PRIMARY KEY (id)\r
-) TYPE=MyISAM;\r
-\r
-#\r
-# Table structure for table `prefix_attendance_roll`\r
-#\r
-\r
-CREATE TABLE prefix_attendance_roll (\r
- id int(11) NOT NULL auto_increment,\r
- dayid int(10) unsigned NOT NULL default '0',\r
- userid int(11) NOT NULL default '0',\r
- hour tinyint(1) unsigned NOT NULL default '0',\r
- status int(11) NOT NULL default '0',\r
- notes varchar(64) NOT NULL default '',\r
- PRIMARY KEY (id)\r
-) TYPE=MyISAM;\r
+#
+# Table structure for table `prefix_attendance`
+#
+
+CREATE TABLE prefix_attendance (
+ id int(10) unsigned NOT NULL auto_increment,
+ name varchar(255) NOT NULL default '',
+ course int(10) NOT NULL default '0',
+ day int(10) unsigned NOT NULL default '0',
+ hours tinyint(1) NOT NULL default '0',
+ roll tinyint(1) NOT NULL default '0',
+ notes varchar(64) NOT NULL default '',
+ timemodified int(10) unsigned NOT NULL default '0',
+ dynsection tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (id)
+) TYPE=MyISAM;
+
+#
+# Table structure for table `prefix_attendance_roll`
+#
+
+CREATE TABLE prefix_attendance_roll (
+ id int(11) NOT NULL auto_increment,
+ dayid int(10) unsigned NOT NULL default '0',
+ userid int(11) NOT NULL default '0',
+ hour tinyint(1) unsigned NOT NULL default '0',
+ status int(11) NOT NULL default '0',
+ notes varchar(64) NOT NULL default '',
+ PRIMARY KEY (id)
+) TYPE=MyISAM;
if (isset($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)) {
function attendance_update_instance($attendance) {
global $mod;
+ $attendance->edited = 1;
$attendance->timemodified = time();
// $attendance->oldid=$attendance->id;
$attendance->id = $attendance->instance;
for($j=1;$j<=$form->hours;$j++) {
// set the attendance defaults for each student
$r1c=$r2c=$r3c=" ";
- if ($sroll[$student->id][$j]->status == 1) {$r2c="checked";}
- elseif ($sroll[$student->id][$j]->status == 2) {$r3c="checked";}
- else {$r1c="checked";}
- $radio1="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"0\" ".$r1c.">";
+ $rollstatus = (($form->edited==0)?$CFG->attendance_default_student_status:$sroll[$student->id][$j]->status);
+ if ($rollstatus==1) {$r2c="checked";}
+ elseif ($rollstatus==2) {$r3c="checked";}
+ else {$r1c="checked";}
+ $radio1="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"0\" ".$r1c.">";
$radio2="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"1\" ".$r2c.">";
- $radio3="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"2\" ".$r3c.">";
- echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$radio1."</td>\n";
- echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio2."</td>\n";
- echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio3."</td>\n";
+ $radio3="<input type=\"radio\" name=\"student_".$student->id."_".$j."\" value=\"2\" ".$r3c.">";
+ echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-left: 1px dotted; border-top: 1px solid;\">".$radio1."</td>\n";
+ echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio2."</td>\n";
+ echo "<td align=\"left\" nowrap class=\"generaltablecell\" style=\"border-top: 1px solid;\">".$radio3."</td>\n";
} // for loop
echo "</tr>\n";
// $radio1="<input type=\"radio\" name=\"student_".$student->id."\" value=\"0\" checked>";