diff --git a/mod/attendance/README.txt b/mod/attendance/README.txt deleted file mode 100644 index 8a9aaea358d..00000000000 --- a/mod/attendance/README.txt +++ /dev/null @@ -1,30 +0,0 @@ -ATTENDANCE version 0.1 ----------------------- - - -By Russell Jungwirth (jungwirr@surebluestudios.com) - - -This is the attendance module created and maintained by Russell J. Jungwirth -of Sureblue Studios. (surebluestudios.com) It allows for attendance to be -tracked for an arbitrary number of hours per instance. Instances are -labelled by date. Attendance is tracked for all instances in a given course -as well. - -Quick install instructions - -1) Copy attendance.php into lang/en/attendance.php - -2) Move this folder to become mod/attendance - -3) Visit your admin page to install the module - -4) Go to the site configuration page -> modules section -> attendance - 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. diff --git a/mod/attendance/add.php b/mod/attendance/add.php deleted file mode 100644 index c9cf4765b1e..00000000000 --- a/mod/attendance/add.php +++ /dev/null @@ -1,286 +0,0 @@ -modform)) { // Variables are stored in the session - $mod = $SESSION->modform; - unset($SESSION->modform); - } else { - $mod = (object)$_POST; - } - - if (isset($cancel)) { - if (!empty($SESSION->returnpage)) { - $return = $SESSION->returnpage; - unset($SESSION->returnpage); - redirect($return); - } else { - redirect("view.php?id=$mod->course"); - } - } - - if (!isteacheredit($mod->course)) { - error("You can't modify this course!"); - } - - $modlib = "lib.php"; - if (file_exists($modlib)) { - include_once($modlib); - } else { - error("This module is missing important code! ($modlib)"); - } - -/* // set the information for the new instances - $attendance->dynsection = !empty($attendance->dynsection) ? 1 : 0; - $attendance->day = make_timestamp($attendance->theyear, - $attendance->themonth, $attendance->theday); - $attendance->name=userdate($attendance->day, get_string("strftimedate")); - if ($attendance->notes) { - $attendance->name = $attendance->name . " - " . $attendance->notes; - } -*/ - $curdate = make_timestamp($mod->startyear, $mod->startmonth, $mod->startday); - $stopdate = make_timestamp($mod->endyear, $mod->endmonth, $mod->endday); - $enddate = $curdate + $mod->numsections * 604800; - if ($curdate > $stopdate) { - error(get_string("endbeforestart", "attendance")); - } - if ($enddate < $curdate) { - error(get_string("startafterend", "attendance")); - } - if ($stopdate > $enddate) { - // if stop date is after end of course, just move it to end of course - $stopdate = $enddate; - } - while ($curdate <= $stopdate) { - $mod->day = $curdate; - $mod->name=userdate($mod->day, get_string("strftimedate")); - if (isset($mod->notes)) {$mod->name = $mod->name . " - " . $mod->notes;} - switch(userdate($curdate, "%u")) { - case 1: if (!empty($mod->mon)) {attendance_add_module($mod);}break; - case 2: if (!empty($mod->tue)) {attendance_add_module($mod);}break; - case 3: if (!empty($mod->wed)) {attendance_add_module($mod);}break; - case 4: if (!empty($mod->thu)) {attendance_add_module($mod);}break; - case 5: if (!empty($mod->fri)) {attendance_add_module($mod);}break; - case 6: if (!empty($mod->sat)) {attendance_add_module($mod);}break; - case 7: if (!empty($mod->sun)) {attendance_add_module($mod);}break; - } // switch - $curdate = $curdate + 86400; // add one day to the date - } // while for days - - if (!empty($SESSION->returnpage)) { - $return = $SESSION->returnpage; - unset($SESSION->returnpage); - redirect($return); - } else { - redirect("index.php?id=$mod->course"); - } - exit; - -} else { -/// ----------------------------------------------------------------------------------- -/// ------------------ SECTION FOR MAKING THE FORM TO BE POSTED ----------------------- -/// ----------------------------------------------------------------------------------- - -/// @include_once("$CFG->dirroot/mod/attendance/lib.php"); -/// error_reporting(E_ALL); - - require_variable($id); - require_variable($section); - - if (! $course = get_record("course", "id", $id)) { - error("This course doesn't exist"); - } - - if (! $module = get_record("modules", "name", "attendance")) { - error("This module type doesn't exist"); - } - - $form->section = $section; // The section number itself - $form->course = $course->id; - $form->module = $module->id; - $form->modulename = $module->name; - $form->instance = ""; - $form->coursemodule = ""; - $form->mode = "add"; - - $sectionname = get_string("name$course->format"); - $fullmodulename = strtolower(get_string("modulename", $module->name)); - - if ($form->section) { - $heading->what = $fullmodulename; - $heading->to = "$sectionname $form->section"; - $pageheading = get_string("addingmultiple", "attendance"); - } else { - $pageheading = get_string("addingmultiple", "attendance"); - } - - if (!isteacheredit($course->id)) { - error("You can't modify this course!"); - } - - $streditinga = get_string("editinga", "moodle", $fullmodulename); - $strmodulenameplural = get_string("modulenameplural", $module->name); - - if ($course->category) { - print_header("$course->shortname: $streditinga", "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural -> - $streditinga", "form.name", "", false); - } else { - print_header("$course->shortname: $streditinga", "$course->fullname", - "$streditinga", "form.name", "", false); - } - - unset($SESSION->modform); // Clear any old ones that may be hanging around. - - - $icon = "modpixpath/$module->name/icon.gif\" alt=\"\" /> "; - - print_heading_with_help($pageheading, "mods", $module->name, $icon); - print_simple_box_start('center'); - - -/// Print the main part of the page - - // adaptation of mod code to view code needs this: - @include_once("$CFG->dirroot/mod/attendance/lib.php"); - //require_once("lib.php") -// determine the end date for the course based on the number of sections and the start date -$course->enddate = $course->startdate + $course->numsections * 604800; - -if (isset($CFG->attendance_dynsection) && ($CFG->attendance_dynsection == "1")) { $form->dynsection = 1; } -if (isset($CFG->attendance_autoattend) && ($CFG->attendance_autoattend == "1")) { $form->autoattend = 1; } -if (isset($CFG->attendance_grade) && ($CFG->attendance_grade == "1")) { $form->grade = 1; } -$form->maxgrade = isset($CFG->attendance_maxgrade)?$CFG->attendance_maxgrade:0; -$form->hours = isset($CFG->attendance_default_hours)?$CFG->attendance_default_hours:1; - -?> -
-
-" /> -" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

:

startdate) ?>

:

enddate) ?>

:

- - - - - - - - - - - - - - - -

:

- - -

:

- - - - -

:

hours, "1","","1") ?> - -

:

- - - -

:

maxgrade, "0","","0"); - helpbutton("maxgrade", get_string("maxgradevalue","attendance"), "attendance"); -?>
- - - - - - - - - -
-" /> -" /> -
-
- - diff --git a/mod/attendance/backuplib.php b/mod/attendance/backuplib.php deleted file mode 100644 index 08c49c457d0..00000000000 --- a/mod/attendance/backuplib.php +++ /dev/null @@ -1,140 +0,0 @@ -id) - // | - // | - // | - // attendance_roll - // (UL,pk->id, fk->dayid) - // - // Meaning: pk->primary key field of the table - // fk->foreign key to link with parent - // nt->nested field (recursive data) - // CL->course level info - // UL->user level info - // files->table may have files) - // - //----------------------------------------------------------- - - function attendance_backup_mods($bf,$preferences) { - - global $CFG; - - $status = true; - - //Iterate over attendance table - $attendances = get_records ("attendance","course",$preferences->backup_course,"id"); - if ($attendances) { - foreach ($attendances as $attendance) { - //Start mod - fwrite ($bf,start_tag("MOD",3,true)); - //Print choice data - fwrite ($bf,full_tag("ID",4,false,$attendance->id)); - fwrite ($bf,full_tag("MODTYPE",4,false,"attendance")); - fwrite ($bf,full_tag("NAME",4,false,$attendance->name)); - fwrite ($bf,full_tag("DAY",4,false,$attendance->day)); - fwrite ($bf,full_tag("HOURS",4,false,$attendance->hours)); - fwrite ($bf,full_tag("ROLL",4,false,$attendance->roll)); - fwrite ($bf,full_tag("NOTES",4,false,$attendance->notes)); - fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$attendance->timemodified)); - fwrite ($bf,full_tag("DYNSECTION",4,false,$attendance->dynsection)); - fwrite ($bf,full_tag("EDITED",4,false,$attendance->edited)); - fwrite ($bf,full_tag("AUTOATTEND",4,false,$attendance->autoattend)); - //if we've selected to backup users info, then execute backup_attendance_roll - if ($preferences->mods["attendance"]->userinfo) { - $status = backup_attendance_roll($bf,$preferences,$attendance->id); - } - //End mod - $status =fwrite ($bf,end_tag("MOD",3,true)); - } - } - return $status; - } - - //Backup attendance_roll contents (executed from attendance_backup_mods) - function backup_attendance_roll ($bf,$preferences,$attendance) { - - global $CFG; - - $status = true; - - $attendance_rolls = get_records("attendance_roll","dayid",$attendance,"id"); - //If there is rolls - if ($attendance_rolls) { - //Write start tag - $status =fwrite ($bf,start_tag("ROLLS",4,true)); - //Iterate over each roll - foreach ($attendance_rolls as $att_rol) { - //Start roll - $status =fwrite ($bf,start_tag("ROLL",5,true)); - //Print roll contents - fwrite ($bf,full_tag("ID",6,false,$att_rol->id)); - fwrite ($bf,full_tag("USERID",6,false,$att_rol->userid)); - fwrite ($bf,full_tag("HOUR",6,false,$att_rol->hour)); - fwrite ($bf,full_tag("STATUS",6,false,$att_rol->status)); - fwrite ($bf,full_tag("NOTES",6,false,$att_rol->notes)); - //End roll - $status =fwrite ($bf,end_tag("ROLL",5,true)); - } - //Write end tag - $status =fwrite ($bf,end_tag("ROLLS",4,true)); - } - return $status; - } - - ////Return an array of info (name,value) - function attendance_check_backup_mods($course,$user_data=false,$backup_unique_code) { - //First the course data - $info[0][0] = get_string("modulenameplural","attendance"); - if ($ids = attendance_ids ($course)) { - $info[0][1] = count($ids); - } else { - $info[0][1] = 0; - } - - //Now, if requested, the user_data - if ($user_data) { - $info[1][0] = get_string("entries"); - if ($ids = attendance_roll_ids_by_course ($course)) { - $info[1][1] = count($ids); - } else { - $info[1][1] = 0; - } - } - return $info; - } - - - - - - - // INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE - - //Returns an array of attendances id - function attendance_ids ($course) { - - global $CFG; - - return get_records_sql ("SELECT a.id, a.course - FROM {$CFG->prefix}attendance a - WHERE a.course = '$course'"); - } - - //Returns an array of attendance_rolls id - function attendance_roll_ids_by_course ($course) { - - global $CFG; - - return get_records_sql ("SELECT r.id , r.dayid - FROM {$CFG->prefix}attendance_roll r, - {$CFG->prefix}attendance a - WHERE a.course = '$course' AND - r.dayid = a.id"); - } -?> diff --git a/mod/attendance/config.html b/mod/attendance/config.html deleted file mode 100644 index e77f225c92b..00000000000 --- a/mod/attendance/config.html +++ /dev/null @@ -1,143 +0,0 @@ -attendance_dynsection)) { - $CFG->attendance_dynsection = ''; - } - if (!isset($CFG->attendance_default_hours)) { - $CFG->attendance_default_hours = ''; - } - if (!isset($CFG->attendance_tardies_per_absence)) { - $CFG->attendance_tardies_per_absence = ''; - } - if (!isset($CFG->attendance_hours_in_full_report)) { - $CFG->attendance_hours_in_full_report = ''; - } - if (!isset($CFG->attendance_default_student_status)) { - $CFG->attendance_default_student_status = ''; - } - if (!isset($CFG->attendance_autoattend)) { - $CFG->attendance_autoattend = ''; - } - if (!isset($CFG->attendance_grade)) { - $CFG->attendance_grade = ''; - } - if (!isset($CFG->attendance_maxgrade)) { - $CFG->attendance_maxgrade = ''; - } -?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
attendance_dynsection: - attendance_dynsection, ""); ?> - - -
attendance_default_hours: - attendance_default_hours, ""); ?> - - -
attendance_tardies_per_absence: - attendance_tardies_per_absence, "none","","0"); ?> - - -
attendance_hours_in_full_report: - attendance_tardies_per_absence, ""); ?> - - -
attendance_default_student_status: - attendance_default_student_status == 1) {$r2c="checked";} - elseif ($CFG->attendance_default_student_status == 2) {$r3c="checked";} - else {$r1c="checked";} - $radio1=""; - $radio2=""; - $radio3=""; - echo "\n"; - echo "\n"; - echo "
". - $radio1.$P."". - $radio2.$T."". - $radio3.$A."
\n"; -?> -
- -
attendance_autoattend: - attendance_autoattend, ""); ?> - - -
attendance_grade: - attendance_grade, ""); ?> - - -
attendance_maxgrade: - attendance_maxgrade, ""); ?> - - -
- " />
- -
diff --git a/mod/attendance/db/mysql.php b/mod/attendance/db/mysql.php deleted file mode 100644 index 98ade3fe343..00000000000 --- a/mod/attendance/db/mysql.php +++ /dev/null @@ -1,37 +0,0 @@ -prefix}attendance` ADD `edited` TINYINT( 1 ) DEFAULT '0' NOT NULL;"); - execute_sql("UPDATE `{$CFG->prefix}attendance` set `edited` = 1;"); - } - - if ($oldversion < 2003092500) { - execute_sql("ALTER TABLE `{$CFG->prefix}attendance` ADD `autoattend` TINYINT( 1 ) DEFAULT '0' NOT NULL;"); - } - - if ($oldversion < 2004050301) { - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'view', 'attendance', 'name');"); - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'viewall', 'attendance', 'name');"); - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'viewweek', 'attendance', 'name');"); - } - - if ($oldversion < 2004111200) { - execute_sql("ALTER TABLE {$CFG->prefix}attendance DROP INDEX course;",false); - execute_sql("ALTER TABLE {$CFG->prefix}attendance_roll DROP INDEX dayid;",false); - execute_sql("ALTER TABLE {$CFG->prefix}attendance_roll DROP INDEX userid;",false); - - modify_database('','ALTER TABLE prefix_attendance ADD INDEX course (course);'); - modify_database('','ALTER TABLE prefix_attendance_roll ADD INDEX dayid (dayid);'); - modify_database('','ALTER TABLE prefix_attendance_roll ADD INDEX userid (userid);'); - } - - return true; -} - -?> diff --git a/mod/attendance/db/mysql.sql b/mod/attendance/db/mysql.sql deleted file mode 100755 index 8526c7f2389..00000000000 --- a/mod/attendance/db/mysql.sql +++ /dev/null @@ -1,39 +0,0 @@ -# -# 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', - edited tinyint(1) NOT NULL default '0', - autoattend tinyint(1) NOT NULL default '0', - PRIMARY KEY (id), - KEY `course` (`course`) -) 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), - KEY `dayid` (`dayid`), - KEY `userid` (`userid`) -) TYPE=MyISAM; -INSERT INTO prefix_log_display VALUES ('attendance', 'view', 'attendance', 'name'); -INSERT INTO prefix_log_display VALUES ('attendance', 'view', 'attendance', 'name'); -INSERT INTO prefix_log_display VALUES ('attendance', 'viewall', 'attendance', 'name'); - diff --git a/mod/attendance/db/oci8po.php b/mod/attendance/db/oci8po.php deleted file mode 100755 index 451707bdbd6..00000000000 --- a/mod/attendance/db/oci8po.php +++ /dev/null @@ -1,22 +0,0 @@ - - diff --git a/mod/attendance/db/oci8po.sql b/mod/attendance/db/oci8po.sql deleted file mode 100755 index 31a63c4a9db..00000000000 --- a/mod/attendance/db/oci8po.sql +++ /dev/null @@ -1,75 +0,0 @@ -rem -rem Table structure for table prefix_attendance -rem - -drop TABLE prefix_attendance; -CREATE TABLE prefix_attendance ( - id number(10) primary key, - name varchar2(255) default '' not null, - course number(10) default '0' not null, - day number(10) default '0' not null, - hours number(1) default '0' not null, - roll number(1) default '0' not null, - notes varchar2(64) default '' not null, - timemodified number(10) default '0' not null, - dynsection number(1) default '0' not null, - edited number(1) default '0' not null, - autoattend number(1) default '0' not null -); - -drop sequence p_attendance_seq; -create sequence p_attendance_seq; - -create or replace trigger p_attendance_trig - before insert on prefix_attendance - referencing new as new_row - for each row - begin - select p_attendance_seq.nextval into :new_row.id from dual; - end; -. -/ - -insert into prefix_attendance (name,course,day,hours,roll,notes,timemodified,dynsection,edited) values ('1',1,1,1,1,'1',1,1,1,1); -insert into prefix_attendance (name,course,day,hours,roll,notes,timemodified,dynsection,edited) values ('2',2,2,2,2,'2',2,2,2,2); -insert into prefix_attendance (name,course,day,hours,roll,notes,timemodified,dynsection,edited) values ('3',3,3,3,3,'3',3,3,3,3); -insert into prefix_attendance (name,course,day,hours,roll,notes,timemodified,dynsection,edited) values ('4',4,4,4,4,'4',4,4,4,4); - -select * from prefix_attendance order by 1,2; - - -rem -rem Table structure for table prefix_attendance_roll -rem - -drop TABLE prefix_attendance_roll; -CREATE TABLE prefix_attendance_roll ( - id number(11) primary key, - dayid number(10) default '0' not null, - userid number(11) default '0' not null, - hour number(1) default '0' not null, - status number(11) default '0' not null, - notes varchar2(64) default '' not null -); - -drop sequence p_attendance_roll_seq; -create sequence p_attendance_roll_seq; - -create or replace trigger p_attendance_roll_trig - before insert on prefix_attendance_roll - referencing new as new_row - for each row - begin - select p_attendance_roll_seq.nextval into :new_row.id from dual; - end; -. -/ - -insert into prefix_attendance_roll (dayid,userid,hour,status,notes) values (1,1,1,1,'1'); -insert into prefix_attendance_roll (dayid,userid,hour,status,notes) values (2,2,2,2,'2'); -insert into prefix_attendance_roll (dayid,userid,hour,status,notes) values (3,3,3,3,'3'); -insert into prefix_attendance_roll (dayid,userid,hour,status,notes) values (4,4,4,4,'4'); - -col format format 99 -select * from prefix_attendance_roll order by 1,2; - diff --git a/mod/attendance/db/postgres7.php b/mod/attendance/db/postgres7.php deleted file mode 100644 index b518d872c29..00000000000 --- a/mod/attendance/db/postgres7.php +++ /dev/null @@ -1,46 +0,0 @@ -prefix}attendance set edited = 1;"); - } - if ($oldversion < 2003092500) { - table_column("attendance", "", "autoattend", "integer", 2, "unsigned", "0", "not null"); - } - - if ($oldversion < 2004050301) { - - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'view', 'attendance', 'name');"); - - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'viewall', 'attendance', 'name');"); - - modify_database("", "INSERT INTO {$CFG->prefix}log_display VALUES ('attendance', 'viewweek', 'attendance', 'name');"); - - } - - - - if ($oldversion < 2004111200) { - execute_sql("DROP INDEX {$CFG->prefix}attendance_course_idx;",false); - execute_sql("DROP INDEX {$CFG->prefix}attendance_roll_dayid_idx;",false); - execute_sql("DROP INDEX {$CFG->prefix}attendance_roll_userid_idx;",false); - - modify_database('','CREATE INDEX prefix_attendance_course_idx ON prefix_attendance (course);'); - modify_database('','CREATE INDEX prefix_attendance_roll_dayid_idx ON prefix_attendance_roll (dayid);'); - modify_database('','CREATE INDEX prefix_attendance_roll_userid_idx ON prefix_attendance_roll (userid);'); - } - - return true; -} - -?> diff --git a/mod/attendance/db/postgres7.sql b/mod/attendance/db/postgres7.sql deleted file mode 100644 index b9d0180c935..00000000000 --- a/mod/attendance/db/postgres7.sql +++ /dev/null @@ -1,42 +0,0 @@ -# -# Table structure for table `prefix_attendance` -# - -CREATE TABLE prefix_attendance ( - id SERIAL8, - name varchar(255) NOT NULL default '', - course int8 NOT NULL default '0', - day int8 NOT NULL default '0', - hours int2 NOT NULL default '0', - roll int2 NOT NULL default '0', - notes varchar(64) NOT NULL default '', - timemodified int8 NOT NULL default '0', - dynsection int2 NOT NULL default '0', - edited int2 NOT NULL default '0', - autoattend int2 NOT NULL default '0', - PRIMARY KEY(id) -); - -CREATE INDEX prefix_attendance_course_idx ON prefix_attendance (course); - -# -# Table structure for table `prefix_attendance_roll` -# - -CREATE TABLE prefix_attendance_roll ( - id SERIAL8, - dayid int4 NOT NULL default '0', - userid int8 NOT NULL default '0', - hour int2 NOT NULL default '0', - status int4 NOT NULL default '0', - notes varchar(64) NOT NULL default '', - PRIMARY KEY (id) -); - -CREATE INDEX prefix_attendance_roll_dayid_idx ON prefix_attendance_roll (dayid); -CREATE INDEX prefix_attendance_roll_userid_idx ON prefix_attendance_roll (userid); - -INSERT INTO prefix_log_display VALUES ('attendance', 'view', 'attendance', 'name'); -INSERT INTO prefix_log_display VALUES ('attendance', 'view', 'attendance', 'name'); -INSERT INTO prefix_log_display VALUES ('attendance', 'viewall', 'attendance', 'name'); - diff --git a/mod/attendance/db/schema.php b/mod/attendance/db/schema.php deleted file mode 100755 index 313cfb5f550..00000000000 --- a/mod/attendance/db/schema.php +++ /dev/null @@ -1,29 +0,0 @@ -debug = true; -$server = "false"; -$user = "scott"; -$password = "tiger"; -$db->Connect(false, $user, $password); -$rs = $db->Execute('select * from dept'); -print "
"; 
-print_r($rs->GetRows()); 
-print "
"; -rs2html($rs,'border=2 cellpadding=3',array('Deptno','DName','Loc')); -$dict = NewDataDictionary($db); -$rs = $db->Execute('drop table attendance'); -$schema = new adoSchema($db); -$rs = $db->Execute('drop table attendance_roll'); -$schema = new adoSchema($db); -$sql = $schema->ParseSchema("schema.xml"); -$result = $schema->ExecuteSchema( $sql ); -$sql = "insert into attendance(id,name,course,day,hours,roll,notes,timemodified,dynsection,edited,autoattend) values (2,'2',2,2,2,2,'2',2,2,2,2)"; -$rs = $db->Execute($sql); -$rs = $db->Execute('select * from attendance'); -rs2html($rs,'border=2 cellpadding=3',array('id','name','course','day','hours','roll','notes','timemodified','dynsection','edited','autoattend')); -?> - diff --git a/mod/attendance/db/schema.xml b/mod/attendance/db/schema.xml deleted file mode 100755 index 6df629e3fdd..00000000000 --- a/mod/attendance/db/schema.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - Insert 1 row for testing only...comment out later - - insert into attendance(id,name,course,day,hours,roll,notes,timemodified,dynsection,edited,autoattend) values (1,'1',1,1,1,1,'1',1,1,1,1) - - - insert into attendance(id,name,course,day,hours,roll,notes,timemodified,dynsection,edited,autoattend) values (1,'1',1,1,1,1,'1',1,1,1,1) - - - insert into attendance(id,name,course,day,hours,roll,notes,timemodified,dynsection,edited,autoattend) values (1,'1',1,1,1,1,'1',1,1,1,1) - - -
- diff --git a/mod/attendance/icon.gif b/mod/attendance/icon.gif deleted file mode 100644 index 5157566d1f8..00000000000 Binary files a/mod/attendance/icon.gif and /dev/null differ diff --git a/mod/attendance/index.php b/mod/attendance/index.php deleted file mode 100644 index ceafb7e817d..00000000000 --- a/mod/attendance/index.php +++ /dev/null @@ -1,80 +0,0 @@ -id, "attendance", "viewall", "index.php?id=$course->id", ""); - - -/// Get all required strings - - $strattendances = get_string("modulenameplural", "attendance"); - $strattendance = get_string("modulename", "attendance"); - - -/// Print the header - - print_header_simple($strattendance, "", "$strattendances", "", "", true, "", navmenu($course)); - -/// Get all the appropriate data - - if (! $attendances = get_all_instances_in_course("attendance", $course)) { - notice("There are no attendances", "../../course/view.php?id=$course->id"); - die; - } - -/// Print the list of instances (your module will probably extend this) - - $timenow = time(); - $strname = get_string("name"); - $strweek = get_string("week"); - $strtopic = get_string("topic"); - - if ($course->format == "weeks") { - $table->head = array ($strweek, $strname); - $table->align = array ("CENTER", "LEFT"); - } else if ($course->format == "topics") { - $table->head = array ($strtopic, $strname); - $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT"); - } else { - $table->head = array ($strname); - $table->align = array ("LEFT", "LEFT", "LEFT"); - } - - if ($attendances) foreach ($attendances as $attendance) { - if (!$attendance->visible) { - //Show dimmed if the mod is hidden - $link = "coursemodule\">$attendance->name"; - } else { - //Show normal if the mod is visible - $link = "coursemodule\">$attendance->name"; - } - - if ($course->format == "weeks" or $course->format == "topics") { - $table->data[] = array ($attendance->section, $link); - } else { - $table->data[] = array ($link); - } - } - - echo "
"; - - print_table($table); - -/// Finish the page - - print_footer($course); - -?> diff --git a/mod/attendance/lib.php b/mod/attendance/lib.php deleted file mode 100755 index 1d8aa0ca180..00000000000 --- a/mod/attendance/lib.php +++ /dev/null @@ -1,602 +0,0 @@ -instance = attendance_add_instance($mod)) { - error("Could not add a new instance of $mod->modulename"); return 0; - } - // course_modules and course_sections each contain a reference - // to each other, so we have to update one of them twice. - - if (! $mod->coursemodule = add_course_module($mod) ) { - error("Could not add a new course module"); return 0; - } - if (! $sectionid = add_mod_to_section($mod) ) { - error("Could not add the new course module to that section"); return 0; - } - if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) { - error("Could not update the course module with the correct section"); return 0; - } - add_to_log($mod->course, "course", "add mod", - "../mod/$mod->modulename/view.php?id=$mod->coursemodule", - "$mod->modulename $mod->instance"); - rebuild_course_cache($mod->course); - -} - -function attendance_add_instance($attendance) { - 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->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->dynsection) { - 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"; - } -} - // insert the main record first - return $attendance->id = insert_record("attendance", $attendance); -} - - -function attendance_update_instance($attendance) { - global $mod; - $attendance->edited = 1; - $attendance->timemodified = time(); -// $attendance->oldid=$attendance->id; - $attendance->id = $attendance->instance; - $attendance->dynsection = !empty($attendance->dynsection) ? 1 : 0; - $attendance->autoattend = !empty($attendance->autoattend) ? 1 : 0; - $attendance->grade = !empty($attendance->grade) ? 1 : 0; - - $attendance->day = make_timestamp($attendance->theyear, - $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->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 - 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->hour=$pieces[2]; - $attrec->status=$val; - // clear out any old records for the student - 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); - } - } // 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; -} - -function attendance_delete_instance($id) { - if (! $attendance = get_record("attendance", "id", "$id")) { - return false; - } - - $result = true; - - /// delete all the rolls for the day - delete_records("attendance_roll", "dayid", "$attendance->id"); - - if (! delete_records("attendance", "id", "$attendance->id")) { - $result = false; - } - - return $result; -} - -function attendance_user_outline($course, $user, $mod, $attendance) { -/// Return a small object with summary information about what a -/// user has done with a given particular instance of this module -/// Used for user activity reports. -/// $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); - - // 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 = "";} - // 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"; - return $return; -} - -function attendance_user_complete($course, $user, $mod, $attendance) { -/// Print a detailed representation of what a user has done with -/// a given particular instance of this module, for user activity reports. - // get the attendance record for that day and user - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - - $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 - - $grid = array(); - if ($attrecs) { foreach ($attrecs as $attrec) { $grid[$attrec->hour]=$attrec->status; } } - echo "\n"; - // echo out the table header - for($j=1;$j<=$attendance->hours;$j++) { - echo "\n"; - } - echo ""; - for($j=1;$j<=$attendance->hours;$j++) { - // set the attendance defaults for each student - if (isset($grid[$j])) { - $status = (($grid[$j] == 1) ? $T : $A); - } else {$status=$P;} - echo "\n"; - } /// for loop - echo "
Hour:".$j."
Status:".$status."
\n"; - - - return true; -} - - -function attendance_cron () { -/// Function to be run periodically according to the moodle cron -/// This function searches for things that need to be done, such -/// as sending out mail, toggling flags etc ... - 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")) { - return true; - } - $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 ($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 - } // if the attendance roll is for today - } // for each attendance in the system - return true; -} // function cron - - -function attendance_grades($attendanceid) { -/// Must return an array of grades for a given instance of this module, -/// indexed by user. It also returns a maximum allowed grade. - $attendance = get_record("attendance", "id", $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 - } // if students - $return->maxgrade = $attendance->maxgrade; - } else { // if attendance->grade == "1" - $return = NULL; - }// else for if attendance->grade == "1" - return $return; -} - -/** -* Returns user records for all users who have DATA in a given attendance instance -* -* This function is present only for the backup routines. It won't return meaningful data -* for an attendance roll because it only returns records for users who have been counted as -* tardy or absent in the rolls for a single attendance instance, since these are the only -* records I store in the database - for brevity's sake of course. -* -* @param int $attendanceid the id of the attendance record we're looging for student data from -* @return (object)recordset associative array of records containing the student records we wanted -*/ -function attendance_get_participants($attendanceid) { -//Returns the users with data in one attendance -//(users with records in attendance_roll, students) - - global $CFG; - - //Get students - $students = get_records_sql("SELECT DISTINCT u.id, u.id - FROM {$CFG->prefix}user u, - {$CFG->prefix}attendance_roll a - WHERE a.dayid = '$attendanceid' and - u.id = a.userid"); - - //Return students array (it contains an array of unique users) - return ($students); -} - - -////////////////////////////////////////////////////////////////////////////////////// -/// Any other attendance functions go here. Each of them must have a name that -/// starts with attendance_ - -/** -* get a list of all students enrolled in a given course - modified version -* -* THIS IS JUST THE GET_COURSE_STUDENTS FUNCTION WITH THE INCLUSION OF THE -* 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 - 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"; - if ($courseid == SITEID) { - $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 $select s.userid = u.id AND u.deleted = '0' - ORDER BY $sort"); -} - - -/** -* Find total absences based on number of tardies per absence -* -* 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! -*/ -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; } -} - -/** -* Find total absences based on number of tardies per absence and put it in a string -* -* Given a number of tardies and absences, determine the total -* 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! -*/ -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.""; - } -} - -/** -* get a list of records from a table with multiple criteria -* -* This one is different from the datalib.php one (called get_records) in the sense that it -* allows for multiple criteria to be easily supplied as parameters, but doesn't -* give the ability to specify sort, fields, or limits -* -*/ -function attendance_get_records($table, $field1="", $value1="", $field2="", $value2="", $field3="", $value3="", $sort="", $fields="*", $limitfrom="", $limitnum="") { - - global $CFG; - - if ($field1) { - $select = "WHERE $field1 = '$value1'"; - if ($field2) { - $select .= " AND $field2 = '$value2'"; - if ($field3) { - $select .= " AND $field3 = '$value3'"; - } - } - } else { - $select = ""; - } - - if ($limitfrom !== "") { - switch ($CFG->dbtype) { - case "mysql": - $limit = "LIMIT $limitfrom,$limitnum"; - break; - case "postgres7": - $limit = "LIMIT $limitnum OFFSET $limitfrom"; - break; - default: - $limit = "LIMIT $limitnum,$limitfrom"; - } - } else { - $limit = ""; - } - - if ($sort != "") { - $sort = "ORDER BY $sort"; - } - - return get_records_sql("SELECT $fields FROM $CFG->prefix$table $select $sort $limit"); -} - -/** -* Return all attendance records that are in the same section as the instance specified -* -* This function uses course_modules, modules, and attendance tables together to determine -* 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 -*/ -function get_attendance_for_section($instance, $courseid) { - global $CFG; - // first, get the section for the instance specified - $sql = "SELECT cm.section - FROM {$CFG->prefix}course_modules cm, - {$CFG->prefix}modules md, - {$CFG->prefix}attendance a - WHERE cm.course = '$courseid' AND - cm.deleted = '0' AND - cm.instance = a.id AND - md.name = 'attendance' AND - md.id = cm.module AND - a.id = '$instance'"; - $sectarray = get_record_sql($sql); -// echo "
$sql \n
"; - $section = $sectarray->section; -/* -select cm.section from -mdl_course_modules cm, mdl_modules md, mdl_attendance m -where cm.course = '7' AND cm.deleted = '0' AND cm.instance = m.id -AND md.name = 'attendance' AND md.id = cm.module AND m.id = '119'; -*/ - // then get all the attendance instances in that section - $sql = "SELECT a.* - FROM {$CFG->prefix}course_modules cm, - {$CFG->prefix}modules md, - {$CFG->prefix}attendance a - WHERE cm.course = '$courseid' AND - cm.deleted = '0' AND - cm.section = '$section' AND - md.name = 'attendance' AND - md.id = cm.module AND - a.id = cm.instance order by a.day ASC"; -// echo "
$sql \n
"; - return get_records_sql($sql); -/* -select m.* from mdl_course_modules cm, mdl_modules md, mdl_attendance m -where cm.course = '7' AND cm.deleted = '0' AND cm.section = '85' -AND md.name = 'attendance' AND md.id = cm.module AND m.id = cm.instance; -*/ -} - -/** -* Return all attendance records that are in the same 7 day span as the instance specified -* -* This function uses the course and attendance tables together to find all the attendance -* records that are for days within the same week span as the instance specified. The week is -* determined based NOT on calendar week, but instead on the week span as it occurs in a -* weekly formatted course - I find this by starting with the startdate of the course and -* then skipping ahead by weeks til I find the range that fits the instance, then I use that -* range as min and max to query the attendance table for all the other records. Note that this -* 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 -*/ -function get_attendance_for_week($id, $courseid) { - global $CFG; - if (! $attendance = get_record("attendance", "id", $id)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $courseid)) { - error("Course module is incorrect"); - } - // the offset is for weeks that don't start on Monday - $day = $attendance->day; - // determine the week range for the select, based on the day - for ($maxday=$course->startdate;$day>$maxday;$maxday=$maxday+604800) - {;}$minday = $maxday-608400; - $sql = "SELECT * FROM {$CFG->prefix}attendance - WHERE course = '$courseid' AND day<$maxday AND day>=$minday order by day ASC;"; -// echo "
$sql \n
"; - return get_records_sql($sql); -} - -/** -* Finds the beginning of the day for the date specified -* -* 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 -*/ -function attendance_find_today($d) { -// $da = getdate($d); - $damon = gmdate("m",$d); - $daday = gmdate("d",$d); - $dayear = gmdate("Y",$d); - // now return midnight of that day - // return mktime(0,0,0,$da["mon"], $da["mday"], $da["year"]); - return gmmktime(0,0,0,$damon, $daday, $dayear); -} - -/** -* Finds the beginning of the day following the date specified -* -* 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 -*/ -function attendance_find_tomorrow($d) { - // add 24 hours to the current time - to solve end of month date issues - return attendance_find_today($d+86400); -} - - -?> diff --git a/mod/attendance/mod.html b/mod/attendance/mod.html deleted file mode 100755 index 4fbb1d33275..00000000000 --- a/mod/attendance/mod.html +++ /dev/null @@ -1,220 +0,0 @@ - - - - - -dirroot/mod/attendance/lib.php"); - $nohtmleditorneeded = true; - //require_once("lib.php") - -if (empty($form->dynsection)) { - $form->dynsection = 0; -} -if (empty($form->autoattend)) { - $form->autoattend = 0; -} -if (empty($form->grade)) { - $form->grade = 0; -} -if (empty($form->maxgrade)) { - $form->maxgrade = 0; -} - -// error_reporting(E_ALL); - // if we're adding a new instance -if (empty($form->id)) { - if (isset($CFG->attendance_dynsection) && ($CFG->attendance_dynsection == "1")) { $form->dynsection = 1; } - if (isset($CFG->attendance_autoattend) && ($CFG->attendance_autoattend == "1")) { $form->autoattend = 1; } - if (isset($CFG->attendance_grade) && ($CFG->attendance_grade == "1")) { $form->grade = 1; } - $form->maxgrade = isset($CFG->attendance_maxgrade)?$CFG->attendance_maxgrade:0; - $form->hours = isset($CFG->attendance_default_hours)?$CFG->attendance_default_hours:1; - $form->day = time(); - $form->notes = ""; -} - ?> -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: - " /> -
:day) ?>
: -dynsection", ""); - helpbutton("dynsection", get_string("dynamicsection","attendance"), "attendance"); -?> - -
: - -autoattend", ""); - helpbutton("autoattend", get_string("autoattend","attendance"), "attendance"); -?> - - -
:hours, "1","","1") ?> - -
: -grade", ""); - helpbutton("grade", get_string("gradevalue","attendance"), "attendance"); -?> - -
:maxgrade, "0","","0"); - helpbutton("maxgrade", get_string("maxgradevalue","attendance"), "attendance"); -?>
- - -id)) { - // get the list of attendance records for all hours of the given day and - // put it in the array for use in the attendance table - $rolls = get_records("attendance_roll", "dayid", $form->id); - if ($rolls) { - foreach ($rolls as $roll) { - $sroll[$roll->userid][$roll->hour]->status=$roll->status; - $sroll[$roll->userid][$roll->hour]->notes=$roll->notes; - } - } - // get the list of students along with student ID field -// get back array of stdclass objects in sorted order, with members: -// id, username,firstname,lastname,maildisplay,mailformat,email,city,country, -// lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber - // build the table for attendance roll - // this is the wrapper table - echo "". - "
"; - // this is the main table - echo ""; -if ($form->hours >1) { - echo "\n"; - for($i=1;$i<=$form->hours;$i++) { - echo "\n"; - } - echo "\n"; -} // if more than one hour for each day - echo "\n"; - echo "\n"; - echo "\n"; - $P=get_string("presentshort","attendance"); - $T=get_string("tardyshort","attendance"); - $A=get_string("absentshort","attendance"); - // generate the headers for the attendance hours - for($i=1;$i<=$form->hours;$i++) { - echo "\n"; - echo "\n"; - echo "\n"; - } - echo "\n"; - $table->head = array("Last Name","First Name","ID", - get_string("presentlong","attendance"), - get_string("tardylong","attendance"), - get_string("absentlong","attendance")); - $table->align = array("left", "left", "left", "center","center","center"); - $table->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap"); - $table->width = "80"; - - $students = attendance_get_course_students($form->course, "u.lastname ASC"); - $i=0; - if ($students) foreach ($students as $student) { - echo "\n"; - echo "\n"; - echo "\n"; - for($j=1;$j<=$form->hours;$j++) { - // set the attendance defaults for each student - $r1c=$r2c=$r3c=" "; - $rollstatus = (($form->edited==0)?$CFG->attendance_default_student_status: - ((isset($sroll[$student->id][$j]->status)?$sroll[$student->id][$j]->status:0))); - if ($rollstatus==1) {$r2c="checked=\"checked\"";} - elseif ($rollstatus==2) {$r3c="checked=\"checked\"";} - else {$r1c="checked=\"checked\"";} - $radio1="id."_".$j."\" value=\"0\" ".$r1c." />"; - $radio2="id."_".$j."\" value=\"1\" ".$r2c." />"; - $radio3="id."_".$j."\" value=\"2\" ".$r3c." />"; - echo "\n"; - echo "\n"; - echo "\n"; - } // for loop - echo "\n"; -// $radio1="id."\" value=\"0\" checked=\"checked\" />"; -// $radio2="id."\" value=\"1\" />"; -// $radio3="id."\" value=\"2\" />"; -// $table->data[$i]=array($student->lastname, $student->firstname, -// $student->idnumber, $radio1,$radio2,$radio3); -// $i++; - } - // doing the table manually now -// print_table($table); - // ending for both the tables - echo "
". - "Hours:". - "$i
Last NameFirst NameID".$P."".$T."".$A."
".$student->lastname."".$student->firstname."".$student->idnumber."".$radio1."".$radio2."".$radio3."
\n"; -} // if ($form->id) -?> - - - - - - - - - -
-course . "&section=".$form->section ."\">" . get_string("addmultiple","attendance") . "

"; -?> -" /> -" /> -
-
diff --git a/mod/attendance/restorelib.php b/mod/attendance/restorelib.php deleted file mode 100644 index 316c5c8ff0e..00000000000 --- a/mod/attendance/restorelib.php +++ /dev/null @@ -1,137 +0,0 @@ -id) - // | - // | - // | - // attendance_roll - // (UL,pk->id, fk->dayid) - // - // Meaning: pk->primary key field of the table - // fk->foreign key to link with parent - // nt->nested field (recursive data) - // CL->course level info - // UL->user level info - // files->table may have files) - // - //----------------------------------------------------------- - - //This function executes all the restore procedure about this mod - function attendance_restore_mods($mod,$restore) { - - global $CFG; - - $status = true; - - //Get record from backup_ids - $data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id); - - if ($data) { - //Now get completed xmlized object - $info = $data->info; - //traverse_xmlize($info); //Debug - //print_object ($GLOBALS['traverse_array']); //Debug - //$GLOBALS['traverse_array']=""; //Debug - - //Now, build the ATTENDANCE record structure - $attendance->course = $restore->course_id; - $attendance->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); - $attendance->day = backup_todb($info['MOD']['#']['DAY']['0']['#']); - $attendance->hours = backup_todb($info['MOD']['#']['HOURS']['0']['#']); - $attendance->roll = backup_todb($info['MOD']['#']['ROLL']['0']['#']); - $attendance->notes = backup_todb($info['MOD']['#']['NOTES']['0']['#']); - $attendance->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); - $attendance->dynsection = backup_todb($info['MOD']['#']['DYNSECTION']['0']['#']); - $attendance->edited = backup_todb($info['MOD']['#']['EDITED']['0']['#']); - $attendance->autoattend = backup_todb($info['MOD']['#']['AUTOATTEND']['0']['#']); - - //The structure is equal to the db, so insert the attendance - $newid = insert_record ("attendance",$attendance); - - //Do some output - echo "
  • ".get_string("modulename","attendance")." \"".$attendance->name."\"
  • "; - backup_flush(300); - - if ($newid) { - //We have the newid, update backup_ids - backup_putid($restore->backup_unique_code,$mod->modtype, - $mod->id, $newid); - //Now check if want to restore user data and do it. - if ($restore->mods['attendance']->userinfo) { - //Restore attendance_roll - $status = attendance_roll_restore_mods ($newid,$info,$restore); - } - } else { - $status = false; - } - } else { - $status = false; - } - - return $status; - } - - //This function restores the attendance_roll - function attendance_roll_restore_mods($attendance_id,$info,$restore) { - - global $CFG; - - $status = true; - - //Get the rolls array - $rolls = $info['MOD']['#']['ROLLS']['0']['#']['ROLL']; - - //Iterate over rolls - for($i = 0; $i < sizeof($rolls); $i++) { - $rol_info = $rolls[$i]; - //traverse_xmlize($rol_info); //Debug - //print_object ($GLOBALS['traverse_array']); //Debug - //$GLOBALS['traverse_array']=""; //Debug - - //We'll need this later!! - $oldid = backup_todb($sub_info['#']['ID']['0']['#']); - $olduserid = backup_todb($sub_info['#']['USERID']['0']['#']); - - //Now, build the ATTENDANCE_ROLL record structure - $roll->dayid = $attendance_id; - $roll->userid = backup_todb($rol_info['#']['USERID']['0']['#']); - $roll->hour = backup_todb($rol_info['#']['HOUR']['0']['#']); - $roll->status = backup_todb($rol_info['#']['STATUS']['0']['#']); - $roll->notes = backup_todb($rol_info['#']['NOTES']['0']['#']); - - //We have to recode the userid field - $user = backup_getid($restore->backup_unique_code,"user",$roll->userid); - if ($user) { - $roll->userid = $user->new_id; - } - - //The structure is equal to the db, so insert the attendance_roll - $newid = insert_record ("attendance_roll",$roll); - - //Do some output - if (($i+1) % 50 == 0) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
    "; - } - backup_flush(300); - } - - if ($newid) { - //We have the newid, update backup_ids - backup_putid($restore->backup_unique_code,"attendance_roll",$oldid, - $newid); - } else { - $status = false; - } - } - - return $status; - } - -?> diff --git a/mod/attendance/teacheredit.php b/mod/attendance/teacheredit.php deleted file mode 100755 index 30f66e5418b..00000000000 --- a/mod/attendance/teacheredit.php +++ /dev/null @@ -1,233 +0,0 @@ - - - - - -dirroot/course/lib.php"); - //require_once("lib.php") - - -// this is code from course/mod.php - - if (! $cm = get_record("course_modules", "id", $_GET['update'])) { - error("This course module doesn't exist"); - } - - if (! $course = get_record("course", "id", $cm->course)) { - error("This course doesn't exist"); - } - - if (!isteacher($course->id)) { - error("You can't modify this record!"); - } - - if (! $module = get_record("modules", "id", $cm->module)) { - error("This module doesn't exist"); - } - - if (! $form = get_record($module->name, "id", $cm->instance)) { - error("The required instance of this module doesn't exist"); - } - - if (! $cw = get_record("course_sections", "id", $cm->section)) { - error("This course section doesn't exist"); - } - - if (isset($return)) { - $SESSION->returnpage = "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id"; - } - - $form->coursemodule = $cm->id; - $form->section = $cm->section; // The section ID - $form->course = $course->id; - $form->module = $module->id; - $form->modulename = $module->name; - $form->instance = $cm->instance; - $form->mode = "update"; - - $sectionname = get_string("name$course->format"); - $fullmodulename = strtolower(get_string("modulename", $module->name)); - - if ($form->section) { - $heading->what = $fullmodulename; - $heading->in = "$sectionname $cw->section"; - $pageheading = get_string("updatingain", "moodle", $heading); - } else { - $pageheading = get_string("updatinga", "moodle", $fullmodulename); - } - - - - - $streditinga = get_string("editinga", "moodle", $fullmodulename); - $strmodulenameplural = get_string("modulenameplural", $module->name); - - if ($module->name == "label") { - $focuscursor = ""; - } else { - $focuscursor = "form.name"; - } - - if ($course->category) { - print_header("$course->shortname: $streditinga", "$course->fullname", - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> - wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural -> - $streditinga", $focuscursor, "", false); - } else { - print_header("$course->shortname: $streditinga", "$course->fullname", - "$streditinga", $focuscursor, "", false); - } - - $icon = "modpixpath/$module->name/icon.gif\" alt=\"\" /> "; - - print_heading_with_help($pageheading, "mods", $module->name, $icon); - print_simple_box_start('center'); - - - -// this information is included below instead -// include_once($modform); - - - - - - -// error_reporting(E_ALL); - // if we're adding a new instance -if (empty($form->id)) { - if (isset($CFG->attendance_dynsection) && ($CFG->attendance_dynsection == "1")) { $form->dynsection = 1; } - if (isset($CFG->attendance_autoattend) && ($CFG->attendance_autoattend == "1")) { $form->autoattend = 1; } - if (isset($CFG->attendance_grade) && ($CFG->attendance_grade == "1")) { $form->grade = 1; } - $form->maxgrade = isset($CFG->attendance_maxgrade)?$CFG->attendance_maxgrade:0; - $form->hours = isset($CFG->attendance_default_hours)?$CFG->attendance_default_hours:1; - $form->day = time(); - $form->notes = ""; -} - ?> -
    wwwroot/course/mod.php"; ?>"> -
    -" /> -" /> - -id)) { - // get the list of attendance records for all hours of the given day and - // put it in the array for use in the attendance table - $rolls = get_records("attendance_roll", "dayid", $form->id); - if ($rolls) { - foreach ($rolls as $roll) { - $sroll[$roll->userid][$roll->hour]->status=$roll->status; - $sroll[$roll->userid][$roll->hour]->notes=$roll->notes; - } - } - // get the list of students along with student ID field -// get back array of stdclass objects in sorted order, with members: -// id, username,firstname,lastname,maildisplay,mailformat,email,city,country, -// lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber - // build the table for attendance roll - // this is the wrapper table - echo "". - "
    "; - // this is the main table - echo ""; - if ($form->hours >1) { - echo "\n"; - for($i=1;$i<=$form->hours;$i++) { - echo "\n"; - } - echo "\n"; - } // if more than one hour for each day - echo "\n"; - echo "\n"; - echo "\n"; - $P=get_string("presentshort","attendance"); - $T=get_string("tardyshort","attendance"); - $A=get_string("absentshort","attendance"); - // generate the headers for the attendance hours - for($i=1;$i<=$form->hours;$i++) { - echo "\n"; - echo "\n"; - echo "\n"; - } - echo "\n"; - $table->head = array("Last Name","First Name","ID", - get_string("presentlong","attendance"), - get_string("tardylong","attendance"), - get_string("absentlong","attendance")); - $table->align = array("left", "left", "left", "center","center","center"); - $table->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap"); - $table->width = "80"; - - $students = attendance_get_course_students($form->course, "u.lastname ASC"); - $i=0; - if ($students) foreach ($students as $student) { - echo "\n"; - echo "\n"; - echo "\n"; - for($j=1;$j<=$form->hours;$j++) { - // set the attendance defaults for each student - $r1c=$r2c=$r3c=" "; - $rollstatus = (($form->edited==0)?$CFG->attendance_default_student_status: - ((isset($sroll[$student->id][$j]->status)?$sroll[$student->id][$j]->status:0))); - if ($rollstatus==1) {$r2c="checked";} - elseif ($rollstatus==2) {$r3c="checked";} - else {$r1c="checked";} - $radio1="id."_".$j."\" value=\"0\" ".$r1c." />"; - $radio2="id."_".$j."\" value=\"1\" ".$r2c." />"; - $radio3="id."_".$j."\" value=\"2\" ".$r3c." />"; - echo "\n"; - echo "\n"; - echo "\n"; - } // for loop - echo "\n"; -// $radio1="id."\" value=\"0\" checked>"; -// $radio2="id."\" value=\"1\">"; -// $radio3="id."\" value=\"2\">"; -// $table->data[$i]=array($student->lastname, $student->firstname, -// $student->idnumber, $radio1,$radio2,$radio3); -// $i++; - } - // doing the table manually now -// print_table($table); - // ending for both the tables - echo "
    ". - "Hours:". - "$i
    Last NameFirst NameID".$P."".$T."".$A."
    ".$student->lastname."".$student->firstname."".$student->idnumber."".$radio1."".$radio2."".$radio3."
    \n"; -} // if ($form->id) -?> - - - - - - - - -
    -course . "&section=".$form->section ."\">Add multiple rolls

    "; -?> -" /> -" /> -
    -
    - - - - - diff --git a/mod/attendance/version.php b/mod/attendance/version.php deleted file mode 100644 index eecfc993b96..00000000000 --- a/mod/attendance/version.php +++ /dev/null @@ -1,12 +0,0 @@ -version = 2005021600; // The current module version (Date: YYYYMMDDXX) -$module->requires = 2005021600; // Requires this Moodle version -$module->cron = 3600; // Period for cron to check this module (secs) - -?> diff --git a/mod/attendance/view.php b/mod/attendance/view.php deleted file mode 100644 index 4e03aad93e2..00000000000 --- a/mod/attendance/view.php +++ /dev/null @@ -1,178 +0,0 @@ -dirroot/mod/attendance/lib.php"); teachered -// error_reporting(E_ALL); - optional_variable($id); // Course Module ID, or - optional_variable($a); // attendance ID - if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { - error("Course Module ID was incorrect"); - } - if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); - } - if (! $attendance = get_record("attendance", "id", $cm->instance)) { - error("Course module is incorrect"); - } - } else { - if (! $attendance = get_record("attendance", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $attendance->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id)) { - error("Course Module ID was incorrect"); - } - } - - require_login($course->id, true, $cm); - - add_to_log($course->id, "attendance", "view", "view.php?id=$cm->id", $attendance->id, $cm->id); - -/// Print the page header - - $strattendances = get_string("modulenameplural", "attendance"); - $strattendance = get_string("modulename", "attendance"); - $strteacheredit = get_string("teacheredit", "attendance"); - - print_header_simple($attendance->name, "", - "id>$strattendances -> $attendance->name", - "", "", true, update_module_button($cm->id, $course->id, $strattendance), - navmenu($course, $cm)); - -/// Print the main part of the page - - // adaptation of mod code to view code needs this: - $form = $attendance; - - if (isteacher($course->id)) { - $rolls = get_records("attendance_roll", "dayid", $form->id); - } else if (!$cm->visible) { - notice(get_string("activityiscurrentlyhidden")); - print_footer($course); exit; - } else if (isstudent($course->id)) { // visible and a student - $rolls = get_records("attendance_roll", "dayid", $form->id, "userid", $USER->id); - } else { - notice(get_string("noviews", "attendance")); - print_footer($course); exit; - } - if ($rolls) { - foreach ($rolls as $roll) { - $sroll[$roll->userid][$roll->hour]->status=$roll->status; - $sroll[$roll->userid][$roll->hour]->notes=$roll->notes; - } - } else { - $sroll = array(); //just to set default value - } - - // get the list of attendance records for all hours of the given day and - // put it in the array for use in the attendance table - $strviewall = get_string("viewall", "attendance"); - $strviewweek = get_string("viewweek", "attendance"); - echo '"; - - // this is the wrapper table - echo ""; - echo "
    "; - // this is the main table - echo ""; -// print the date headings at the top of the table - echo "\n"; - // put notes for the date in the date heading - $notes = ($form->notes != "") ? ":
    ".$form->notes : ""; - echo "\n"; - echo (($form->hours > 1) ? "\n" : ""); - echo "\n"; -// print the second level headings with name and possibly hour numbers - echo "\n"; - echo "\n"; - echo "\n"; - // generate the headers for the attendance hours - if ($form->hours > 1) { - for($i=1;$i<=$form->hours;$i++) { - echo "\n"; - } - echo "\n"; } - echo "\n"; - // get the list of students along with student ID field - // get back array of stdclass objects in sorted order, with members: - // id, username,firstname,lastname,maildisplay,mailformat,email,city,country, - // lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber - if (isteacher($course->id)){ - $students = attendance_get_course_students($form->course, "u.lastname ASC"); - } else { // must be a student - $students[0] = $USER; - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - - - if ($students) foreach ($students as $student) { - echo "\n"; - echo "\n"; - $studentid=(($student->idnumber != "") ? $student->idnumber : " "); - echo "\n"; - $abs=$tar=0; - for($j=1;$j<=$form->hours;$j++) { - // set the attendance defaults for each student - if (isset ($sroll[$student->id][$j]->status) && $sroll[$student->id][$j]->status == 1 ) {$status=$T;$tar++;} - elseif (isset ($sroll[$student->id][$j]->status) && $sroll[$student->id][$j]->status == 2 ) {$status=$A;$abs++;} - else {$status=$P;} - echo "\n"; - } /// for loop - if ($form->hours > 1) { - $tot=attendance_tally_overall_absences_fraction($abs,$tar); - echo "\n"; - } - } - /// ending for the table - echo "
    ". - " hours. "\" nowrap class=\"generaltableheader\">". - userdate($form->day,get_string("strftimedateshort")).$notes." 
    Last NameFirst NameID".$i."total"; - } else { echo " 
    ".$student->lastname."".$student->firstname."".$studentid."".$status."".$tot."
    \n"; - - - /// print the miscellaneous settings information before the attendance roll - echo "
    ". - "
    "; -// this is the main table - echo ""; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; - echo"\n"; - if ($form->grade == "1") { - echo"\n"; - echo"\n"; - } - echo "
    ". - get_string("dynsectionshort","attendance").":". - (($form->dynsection=="1")?"Yes":"No")."
    ". - get_string("autoattendshort","attendance").":". - (($form->autoattend=="1")?"Yes":"No")."
    ". - get_string("gradeshort","attendance").":". - (($form->grade=="1")?"Yes":"No")."
    ". - get_string("maxgradeshort","attendance").":". - $form->maxgrade."
    \n"; - -/// Finish the page - print_footer($course); - -?> diff --git a/mod/attendance/viewall.php b/mod/attendance/viewall.php deleted file mode 100644 index 385417b0c70..00000000000 --- a/mod/attendance/viewall.php +++ /dev/null @@ -1,530 +0,0 @@ -dirroot/mod/attendance/lib.php"); -/// error_reporting(E_ALL); - - optional_variable($id); // Course Module ID, or - optional_variable($a); // attendance ID - -/// populate the appropriate objects - if ($id) { - if (! $course = get_record("course", "id", $id)) { - error("Course is misconfigured"); - } - if (! $attendances = get_records("attendance", "course", $id, "day ASC ")) { - error("Course module is incorrect"); - } - } else { - if (! $attendance = get_record("attendance", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $attendance->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id)) { - error("Course Module ID was incorrect"); - } - if (! $attendances = get_records("attendance", "course", $cm->course)) { - error("Course module is incorrect"); - } - } - - require_login($course->id); - - add_to_log($course->id, "attendance", "viewall", "viewall.php?id=$course->id"); - - -/// Print the main part of the page -if ($attendances) { - if ( isstudent($course->id) && !isteacher($course->id)) { - attendance_print_header(); - notice(get_string("noviews", "attendance")); - print_footer($course); exit; - } - - -/// create an array of all the attendance objects for the entire course - $numatt=0; - $numhours=0; - 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; - $atts[$numatt]->attendance=$attendance; - // tally the hours for possible paging of the report - $numhours=$numhours+$attendance->hours; - // get the list of attendance records for all hours of the given day and - // put it in the array for use in the attendance table - if (isstudent($course->id) && !isteacher($course->id)) { - $rolls = get_records("attendance_roll", "dayid", $form->id, "userid", $USER->id); - } else { // must be a teacher - $rolls = get_records("attendance_roll", "dayid", $attendance->id); - } - if ($rolls) { - foreach ($rolls as $roll) { - $atts[$numatt]->sroll[$roll->userid][$roll->hour]->status=$roll->status; - $atts[$numatt]->sroll[$roll->userid][$roll->hour]->notes=$roll->notes; - } - } - $numatt++; - } - - -// -// -// IF REQUESTING A DATA FILE DOWNLOAD, GENERATE IT INSTEAD OF THE HTML PAGE, SEND IT, AND EXIT -// -// - -if ($download == "xls") { - require_once("$CFG->libdir/excel/Worksheet.php"); - require_once("$CFG->libdir/excel/Workbook.php"); - // HTTP headers - attendance_HeaderingExcel($course->shortname."_Attendance.xls"); - // Creating a workbook - $workbook = new Workbook("-"); - // Creating the first worksheet - $myxls =& $workbook->add_worksheet('Attendance'); - - // print the date headings at the top of the table - // for each day of attendance - $myxls->write_string(3,0,get_string("lastname")); - $myxls->write_string(3,1,get_string("firstname")); - $myxls->write_string(3,2,get_string("idnumber")); - $pos=3; -if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { - // put notes for the date in the date heading - $myxls->write_string(1,$pos,userdate($atts[$k]->attendance->day,"%m/%0d")); - $myxls->set_column($pos,$pos,5); - $myxls->write_string(2,$pos,$atts[$k]->attendance->notes); - for ($i=1;$i<=$atts[$k]->attendance->hours;$i++) { - $myxls->write_number(3,$pos,$i); - $myxls->set_column($pos,$pos,1); - $pos++; - } - } -} // if dlsub==all - $myxls->write_string(3,$pos,get_string("total")); - $myxls->set_column($pos,$pos,5); - -/// generate the attendance rolls for the body of the spreadsheet - if (isstudent($course->id) && !isteacher($course->id)) { - $students[0] = $USER; - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - $row=4; - 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 : " "); - $myxls->write_string($row,2,$studentid); - $pos=3; - if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { // for each day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - $myxls->write_string($row,$pos,$status); - $pos++; - } /// for loop - } - } - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_decimal($abs,$tar); - $myxls->write_number($row,$pos,$tot); - $row++; - } - $workbook->close(); - - exit; -} - - -if ($download == "txt") { - - header("Content-Type: application/download\n"); - header("Content-Disposition: attachment; filename=\"".$course->shortname."_Attendance.txt\""); - -/// Print names of all the fields - - echo get_string("firstname")."\t".get_string("lastname") . "\t". get_string("idnumber"); - -if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { - // put notes for the date in the date heading - echo "\t" . userdate($atts[$k]->attendance->day,"%m/%0d"); - echo (($atts[$k]->attendance->notes != "")?" ".$atts[$k]->attendance->notes:""); - for ($i=2;$i<=$atts[$k]->attendance->hours;$i++) { echo "\t$i"; } - } -} // if dlsub==all - echo "\t". get_string("total") . "\n"; - -/// generate the attendance rolls for the body of the spreadsheet - if (isstudent($course->id) && !isteacher($course->id)) { - $students[0] = $USER; - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - $row=3; - if ($students) foreach ($students as $student) { - echo $student->lastname; - echo "\t".$student->firstname; - $studentid=(($student->idnumber != "") ? $student->idnumber : " "); - echo "\t". $studentid; - if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { // for each day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - echo "\t".$status; - } /// for loop - } - } - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_decimal($abs,$tar); - echo "\t".$tot."\n"; - $row++; - } - exit; -} - - - -// -// -// FIGURE OUT THE PAGING LAYOUT FOR THE DATA BASED ON STATUS, PAGE NUMBER REQUESTED, ETC -// -// - -// A LOOP FOR CREATING SINGLE-USER VERSION OF THE REPORT OR A ONE-PAGE REPORT - if (isstudent($course->id) && !isteacher($course->id)) { - $onepage=true; - $multipage=false; - } else if (!(isset($onepage))){ - $onepage=false; - $multipage=true; - } else if ($onepage) { - $multipage=false; - } else { // if onepage is set to false - $multilpage=true; - } - -// adjust the width for the report for students - - if (($onetable) || ($CFG->attendance_hours_in_full_report == 0)) { - $hoursinreport = 100+$numhours; - } else if (isstudent($course->id) && !isteacher($course->id)) { - $hoursinreport = $CFG->attendance_hours_in_full_report + 15; - } else { - $hoursinreport = $CFG->attendance_hours_in_full_report; - } -while (($multipage || $onepage) && (!$endonepage)) { - // this makes for a one iteration loop for multipage - if ($multipage) {$onepage = false; $multipage = false; $endonepage=false;} - - - if ($numhours>=$hoursinreport) { - if (!isset($pagereport)) { - // $pagereport is used to determine whether the report needs to be paged at all - $pagereport=true; - $endatt=0; - $page=1; - } - // find the last hour to have on this page of the report - // go to the next (or first) page -// $endatt++; -// $startatt=$endatt; - $curpage=1; - $endatt=0; - for($curpage=1;true;$curpage++) { // the for loop is broken from the inside - $pagehours=$atts[$endatt]->attendance->hours; - $startatt=$endatt; - while(($pagehours<=$hoursinreport)) { - if ($endatt>=$numatt) { break 2; } // end the page number calculations and trigger the end of a multi-page report! - $endatt++; - $pagehours=$pagehours+$atts[$endatt]->attendance->hours; - } - // if this is the page we're on, save the info - if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; } - } // hopefully at this point, startatt and endatt are set correctly for the current page - if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; } else { - $endatt=$endatt_target; $startatt=$startatt_target; } - $maxpages = $curpage; - } else {$pagereport=false;} - - $minatt=($pagereport ? $startatt : 0); - $maxatt=($pagereport ? $endatt : $numatt); - - if ((!$pagereport) || ($page == $maxpages)) {$endonepage = true;} // end a one page display - - - - - - -// -// -// ALL PRELIMINARY STUFF DONE - MAKE THE MEAT OF THE PAGE -// -// - attendance_print_header(); - -// print other links at top of page - $strviewone = get_string("viewone", "attendance"); - $strviewtable = get_string("viewtable", "attendance"); - $strviewmulti = get_string("viewmulti", "attendance"); - $strviewweek = get_string("viewweek", "attendance"); - if ($onepage) { // one page for all tables - echo "

    id."\">"; - echo "$strviewmulti
    "; - echo "id."&onetable=1\">"; - echo "$strviewtable
    "; - echo "attendance->id."\">"; - echo "$strviewweek

    "; - } else if ($onetable) { // one table for all - echo "

    id."\">"; - echo "$strviewmulti
    "; - echo "id."&onepage=1\">"; - echo "$strviewone
    "; - echo "attendance->id."\">"; - echo "$strviewweek

    "; - } else { // multiple pages - echo "

    id."&onepage=1\">"; - echo "$strviewone
    "; - echo "id."&onetable=1\">"; - echo "$strviewtable
    "; - echo "attendance->id."\">"; - echo "$strviewweek

    "; - - } - - if (!$onepage) { - - attendance_print_pagenav(); - } - // build the table for attendance roll - // this is the wrapper table - echo "". - "
    "; - // this is the main table - echo ""; - if (isteacher($course->id)) { - echo "\n"; - } -// $minpage=0;$maxpage=$numatt; - // print the date headings at the top of the table - // for each day of attendance - for($k=$minatt;$k<$maxatt;$k++) { - // put notes for the date in the date heading - $notes = ($atts[$k]->attendance->notes != "") ? ":
    ".$atts[$k]->attendance->notes : ""; - $auto = ($atts[$k]->attendance->autoattend == 1) ? "(".get_string("auto","attendance").")" : ""; - echo "\n"; - } - // if we're at the end of the report - if ($maxatt==$numatt || !$pagereport) { - echo "\n"; - } - echo "\n"; - // print the second level headings with name and possibly hour numbers - if (isteacher($course->id)) { - echo "\n"; - echo "\n"; - echo "\n"; - } - // generate the headers for the attendance hours - for($k=$minatt;$k<$maxatt;$k++) { - if ($atts[$k]->attendance->hours > 1) { - for($i=1;$i<=$atts[$k]->attendance->hours;$i++) { - echo "\n"; - } - } else { echo "\n"; } - } - // if we're at the end of the report - if ($maxatt==$numatt || !$pagereport) { - echo ""; - } - echo "\n"; - - // get the list of students along with student ID field - // get back array of stdclass objects in sorted order, with members: - // id, username,firstname,lastname,maildisplay,mailformat,email,city,country, - // lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber - - - if (isstudent($course->id) && !isteacher($course->id)) { - $students[0] = $USER; - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - if ($students) foreach ($students as $student) { - if (isteacher($course->id)) { - echo "\n"; - echo "\n"; - $studentid=(($student->idnumber != "") ? $student->idnumber : " "); - echo "\n"; - } - for($k=$minatt;$k<$maxatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - echo "\n"; - } /// for loop - } - if ($maxatt==$numatt || !$pagereport) { - // tally total attendances for the students - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_fraction($abs,$tar); - echo "\n"; - } - } // foreach - /// doing the table manually now - /// print_table($table); - /// ending for the table - echo "
    ". - " attendance->hours. "\" nowrap class=\"generaltableheader\">". - "attendance->cmid."\">".userdate($atts[$k]->attendance->day,"%m/%0d")."".$auto. - $notes." 
    Last NameFirst NameID".$i." total
    ".$student->lastname."".$student->firstname."".$studentid."".$status."".$tot."
    \n"; - -if ($onepage) {$page++; echo "

    \n"; } -} // while loop for multipage/one page printing - - if (!$onepage) { attendance_print_pagenav(); } - - - echo "
    "; - echo "
    "; - if (($numhours-4) > 255) { - echo "
    "; - } else { - $options["id"] = "$course->id"; - $options["download"] = "xls"; - $options["dlsub"] = "all"; - print_single_button("viewall.php", $options, get_string("downloadexcelfull", "attendance")); - } - echo "
    "; - $options["id"] = "$course->id"; - $options["download"] = "xls"; - $options["dlsub"] = "totals"; - print_single_button("viewall.php", $options, get_string("downloadexceltotals", "attendance")); - echo ""; - $options["download"] = "txt"; - $options["dlsub"] = "all"; - print_single_button("viewall.php", $options, get_string("downloadtextfull", "attendance")); - echo ""; - $options["dlsub"] = "totals"; - print_single_button("viewall.php", $options, get_string("downloadtexttotals", "attendance")); - echo "
    "; - - -} else { error("There are no attendance rolls in this course.");} // for no attendance rolls -/// Finish the page - - - print_footer($course); - -function attendance_print_header() { - global $course, $cm; - - /// Print the page header - - $strattendances = get_string("modulenameplural", "attendance"); - $strattendance = get_string("modulename", "attendance"); - $strallattendance = get_string("allmodulename", "attendance"); - print_header_simple("$strallattendance", "", - "id>$strattendances -> $strallattendance", - "", "", true, " ", - navmenu($course, $cm)); -} - -function attendance_print_pagenav() { - global $pagereport, $minatt, $maxatt, $course, $page, $numatt, $maxpages; - if ($pagereport) { - $of = get_string('of','attendance'); - $pg = get_string('page'); - - echo "
    ". - "
    "; - // this is the main table - echo ""; - echo ""; - if ($minatt!=0) { - echo "\n"; - } else { - echo "\n"; - } - echo "\n"; - if ($maxatt!=$numatt) { - echo ""; - } else { - echo "\n"; - } - echo "
    ". - "id ."&pagereport=1&page=1\"><< \n". - "id ."&pagereport=1&page=".($page-1)."\"><<< <". - "$pg $page $of $maxpages". - "id ."&pagereport=1&page=". ($page+1)."\">> ". - "id ."&pagereport=1&page=$maxpages\">>>> >>
    \n"; - } -} - -function attendance_HeaderingExcel($filename) { - header("Content-type: application/vnd.ms-excel"); - header("Content-Disposition: attachment; filename=$filename" ); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); - header("Pragma: public"); -} - -?> - -http://www.alpine-usa.com/company_info/press_release/010804_ipad.html diff --git a/mod/attendance/viewweek.php b/mod/attendance/viewweek.php deleted file mode 100644 index ed51b553655..00000000000 --- a/mod/attendance/viewweek.php +++ /dev/null @@ -1,537 +0,0 @@ -dirroot/mod/attendance/lib.php"); -/// error_reporting(E_ALL); - - optional_variable($id); // Course Module ID, or - optional_variable($a); // attendance ID - -/// populate the appropriate objects - if ($id) { - if (! $attendance = get_record("attendance", "id", $id)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $attendance->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("attendance", $attendance->id, $course->id)) { - error("Course Module ID was incorrect"); - } - if ($scope == "section") { - if (! $attendances = get_attendance_for_section($attendance->id, $course->id)) { - error("Course module is incorrect"); - } - } else { - if (! $attendances = get_attendance_for_week($attendance->id, $course->id)) { - error("Course module is incorrect"); - } - } - } - - require_login($course->id); - - add_to_log($course->id, "attendance", "viewweek", "viewweek.php?scope=".$scope."&id=$course->id"); - - -if ($attendances) { - if ( !(isteacher($course->id) || isstudent($course->id)) ) { - attendance_print_header(); - notice(get_string("noviews", "attendance")); - print_footer($course); exit; - } - - - - -/// create an array of all the attendance objects for the week - $numatt=0; - $numhours=0; - 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; - $atts[$numatt]->attendance=$attendance; - // tally the hours for possible paging of the report - $numhours=$numhours+$attendance->hours; - // get the list of attendance records for all hours of the given day and - // put it in the array for use in the attendance table - if (isstudent($course->id)) { - $rolls = get_records("attendance_roll", "dayid", $form->id, "userid", $USER->id); - } else { // must be a teacher - $rolls = get_records("attendance_roll", "dayid", $attendance->id); - } - if ($rolls) { - foreach ($rolls as $roll) { - $atts[$numatt]->sroll[$roll->userid][$roll->hour]->status=$roll->status; - $atts[$numatt]->sroll[$roll->userid][$roll->hour]->notes=$roll->notes; - } - } - $numatt++; - } - - -// -// -// IF REQUESTING A DATA FILE DOWNLOAD, GENERATE IT INSTEAD OF THE HTML PAGE, SEND IT, AND EXIT -// -// - - -if ($download == "xls") { - require_once("$CFG->libdir/excel/Worksheet.php"); - require_once("$CFG->libdir/excel/Workbook.php"); - // HTTP headers - attendance_HeaderingExcel($course->shortname."_Attendance_Week.xls"); - // Creating a workbook - $workbook = new Workbook("-"); - // Creating the first worksheet - $myxls =& $workbook->add_worksheet('Weekly Attendance'); - - // print the date headings at the top of the table - // for each day of attendance - $myxls->write_string(3,0,get_string("lastname")); - $myxls->write_string(3,1,get_string("firstname")); - $myxls->write_string(3,2,get_string("idnumber")); - $pos=3; -if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { - // put notes for the date in the date heading - $myxls->write_string(1,$pos,userdate($atts[$k]->attendance->day,"%m/%0d")); - $myxls->set_column($pos,$pos,5); - $myxls->write_string(2,$pos,$atts[$k]->attendance->notes); - for ($i=1;$i<=$atts[$k]->attendance->hours;$i++) { - $myxls->write_number(3,$pos,$i); - $myxls->set_column($pos,$pos,1); - $pos++; - } - } -} // if dlsub==all - $myxls->write_string(3,$pos,get_string("total")); - $myxls->set_column($pos,$pos,5); - -/// generate the attendance rolls for the body of the spreadsheet - if (isstudent($course->id)) { - $students[0] = $USER; - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - $row=4; - 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 : " "); - $myxls->write_string($row,2,$studentid); - $pos=3; - if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { // for each day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - $myxls->write_string($row,$pos,$status); - $pos++; - } /// for loop - } - } - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_decimal($abs,$tar); - $myxls->write_number($row,$pos,$tot); - $row++; - } - $workbook->close(); - - exit; -} - -if ($download == "txt") { - - header("Content-Type: application/download\n"); - header("Content-Disposition: attachment; filename=\"".$course->shortname."_Attendance_Week.txt\""); - -/// Print names of all the fields - - echo get_string("firstname")."\t".get_string("lastname") . "\t". get_string("idnumber"); - -if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { - // put notes for the date in the date heading - echo "\t" . userdate($atts[$k]->attendance->day,"%m/%0d"); - echo (($atts[$k]->attendance->notes != "")?" ".$atts[$k]->attendance->notes:""); - for ($i=2;$i<=$atts[$k]->attendance->hours;$i++) { echo "\t$i"; } - } -} // if dlsub==all - echo "\t". get_string("total") . "\n"; - -/// generate the attendance rolls for the body of the spreadsheet - if (isstudent($course->id)) { - $students[0] = get_user_info_from_db("id", $USER->id); - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - $row=3; - if ($students) foreach ($students as $student) { - echo $student->lastname; - echo "\t".$student->firstname; - $studentid=(($student->idnumber != "") ? $student->idnumber : " "); - echo "\t". $studentid; - if ($dlsub== "all") { - for($k=0;$k<$numatt;$k++) { // for each day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - echo "\t".$status; - } /// for loop - } - } - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_decimal($abs,$tar); - echo "\t".$tot."\n"; - $row++; - } - exit; -} - - - -// -// -// FIGURE OUT THE PAGING LAYOUT FOR THE DATA BASED ON STATUS, PAGE NUMBER REQUESTED, ETC -// -// - - - - if (isstudent($course->id)) { - $onepage=true; - $multipage=false; - } else if (!(isset($onepage))){ - $onepage=false; - $multipage=true; - } else if ($onepage) { - $multipage=false; - } else { // if onepage is set to false - $multilpage=true; - } - -// adjust the width for the report for students - - if (($onetable) || ($CFG->attendance_hours_in_full_report == 0)) { - $hoursinreport = 100+$numhours; - } else if (isstudent($course->id)) { - $hoursinreport = $CFG->attendance_hours_in_full_report + 15; - } else { - $hoursinreport = $CFG->attendance_hours_in_full_report; - } -while (($multipage || $onepage) && (!$endonepage)) { - // this makes for a one iteration loop for multipage - $multipage = false; - - - if ($numhours>=$hoursinreport) { - if (!isset($pagereport)) { - // $pagereport is used to determine whether the report needs to be paged at all - $pagereport=true; - $endatt=0; - $page=1; - } - // find the last hour to have on this page of the report - // go to the next (or first) page -// $endatt++; -// $startatt=$endatt; - $curpage=1; - $endatt=0; - for($curpage=1;true;$curpage++) { // the for loop is broken from the inside - $pagehours=$atts[$endatt]->attendance->hours; - $startatt=$endatt; - while(($pagehours<$hoursinreport)) { - if ($endatt>=$numatt) { break 2; } // end the page number calculations and trigger the end of a multi-page report! - $endatt++; - $pagehours=$pagehours+$atts[$endatt]->attendance->hours; - } - // if this is the page we're on, save the info - if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; } - } // hopefully at this point, startatt and endatt are set correctly for the current page - if ($curpage == $page) {$endatt_target = $endatt; $startatt_target = $startatt; } else { - $endatt=$endatt_target; $startatt=$startatt_target; } - $maxpages = $curpage; - } else {$pagereport=false;} - - $minatt=($pagereport ? $startatt : 0); - $maxatt=($pagereport ? $endatt : $numatt); - - if ((!$pagereport) || ($page == $maxpages)) {$endonepage = true;} // end a one page display - -// -// -// ALL PRELIMINARY STUFF DONE - MAKE THE MEAT OF THE PAGE -// -// - attendance_print_header(); - - -// print other links at top of page - $strviewsection = get_string("viewsection", "attendance"); - $strviewweek = get_string("viewweek", "attendance"); - $strviewall = get_string("viewall", "attendance"); - $strviewone = get_string("viewone", "attendance"); - $strviewtable = get_string("viewtable", "attendance"); - $strviewmulti = get_string("viewmulti", "attendance"); - - - echo "

    id."\">"; - echo "$strviewall
    "; - if ($onepage) { // one page for all tables - echo ""; - echo "$strviewmulti
    "; - echo ""; - echo "$strviewtable
    "; - } else if ($onetable) { // one table for all - echo ""; - echo "$strviewmulti
    "; - echo ""; - echo "$strviewone
    "; - } else { // multiple pages - echo ""; - echo "$strviewone
    "; - echo ""; - echo "$strviewtable
    "; - } - if ($scope=="week") { // week view for scope - echo ""; - echo "$strviewsection

    "; - } else { // section view for scope - echo ""; - echo "$strviewweek

    "; - } - - - if (!$onepage) { - - attendance_print_pagenav(); - } - - - - // build the table for attendance roll - // this is the wrapper table - echo "". - "
    "; - // this is the main table - echo ""; - if (isteacher($course->id)) { - echo "\n"; - } -// $minpage=0;$maxpage=$numatt; - // print the date headings at the top of the table - // for each day of attendance - for($k=$minatt;$k<$maxatt;$k++) { - // put notes for the date in the date heading - $notes = ($atts[$k]->attendance->notes != "") ? ":
    ".$atts[$k]->attendance->notes : ""; - $auto = ($atts[$k]->attendance->autoattend == 1) ? "(".get_string("auto","attendance").")" : ""; - echo "\n"; - } - // if we're at the end of the report - if ($maxatt==$numatt || !$pagereport) { - echo "\n"; - } - echo "\n"; - // print the second level headings with name and possibly hour numbers - if (isteacher($course->id)) { - echo "\n"; - echo "\n"; - echo "\n"; - } - // generate the headers for the attendance hours - for($k=$minatt;$k<$maxatt;$k++) { - if ($atts[$k]->attendance->hours > 1) { - for($i=1;$i<=$atts[$k]->attendance->hours;$i++) { - echo "\n"; - } - } else { echo "\n"; } - } - // if we're at the end of the report - if ($maxatt==$numatt || !$pagereport) { - echo ""; - } - echo "\n"; - - // get the list of students along with student ID field - // get back array of stdclass objects in sorted order, with members: - // id, username,firstname,lastname,maildisplay,mailformat,email,city,country, - // lastaccess,lastlogin,picture (picture is null, 0, or 1), idnumber - - - if (isstudent($course->id)) { - $students[0] = get_user_info_from_db("id", $USER->id); - } else { // must be a teacher - $students = attendance_get_course_students($attendance->course, "u.lastname ASC"); - } - $i=0; - $A = get_string("absentshort","attendance"); - $T = get_string("tardyshort","attendance"); - $P = get_string("presentshort","attendance"); - if ($students) foreach ($students as $student) { - if (isteacher($course->id)) { - echo "\n"; - echo "\n"; - $studentid=(($student->idnumber != "") ? $student->idnumber : " "); - echo "\n"; - } - for($k=$minatt;$k<$maxatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {$status=$T;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {$status=$A;} - else {$status=$P;} - echo "\n"; - } /// for loop - } - if ($maxatt==$numatt || !$pagereport) { - // tally total attendances for the students - $abs=$tar=0; - for($k=0;$k<$numatt;$k++) { // for eacj day of attendance for the student - for($j=1;$j<=$atts[$k]->attendance->hours;$j++) { - // set the attendance defaults for each student - if ($atts[$k]->sroll[$student->id][$j]->status == 1) {;$tar++;} - elseif ($atts[$k]->sroll[$student->id][$j]->status == 2) {;$abs++;} - } /// for loop - } // outer for for each day of attendance - $tot=attendance_tally_overall_absences_fraction($abs,$tar); - echo "\n"; - } - } // foreach - /// doing the table manually now - /// print_table($table); - /// ending for the table - echo "
    ". - " attendance->hours. "\" nowrap class=\"generaltableheader\">". - "attendance->cmid."\">".userdate($atts[$k]->attendance->day,"%m/%0d")."".$auto. - $notes." 
    Last NameFirst NameID".$i." total
    ".$student->lastname."".$student->firstname."".$studentid."".$status."".$tot."
    \n"; - -if ($onepage) {$page++; echo "

    \n"; } -} // while loop for multipage/one page printing - - if (!$onepage) { attendance_print_pagenav(); } - - - echo "
    "; - echo "
    "; - if (($numhours-4) > 255) { - echo "
    "; - } else { - $options["id"] = "$id"; - $options["download"] = "xls"; - $options["dlsub"] = "all"; - print_single_button("viewweek.php", $options, get_string("downloadexcelfull", "attendance")); - } - echo "
    "; - $options["id"] = "$id"; - $options["download"] = "xls"; - $options["dlsub"] = "totals"; - print_single_button("viewweek.php", $options, get_string("downloadexceltotals", "attendance")); - echo ""; - $options["download"] = "txt"; - $options["dlsub"] = "all"; - print_single_button("viewweek.php", $options, get_string("downloadtextfull", "attendance")); - echo ""; - $options["dlsub"] = "totals"; - print_single_button("viewweek.php", $options, get_string("downloadtexttotals", "attendance")); - echo "
    "; - - - - - } else { error("There are no attendance rolls in this course.");} // for no attendance rolls -/// Finish the page - print_footer($course); - - -function attendance_print_pagenav() { - global $pagereport, $minatt, $maxatt, $course, $page, $numatt, $maxpages, $attendance,$scope,$id; - if ($pagereport) { - $of = get_string('of','attendance'); - $pg = get_string('page'); - - echo "
    ". - "
    "; - // this is the main table - echo ""; - echo ""; - if ($minatt!=0) { - echo "\n"; - } else { - echo "\n"; - } - echo "\n"; - if ($maxatt!=$numatt) { - echo ""; - } else { - echo "\n"; - } - echo "
    ". - "< \n"; - "<<<< <". - "$pg $page $of $maxpages". - "> ". - ">>> >>
    \n"; - } -} - -function attendance_print_header() { - global $course, $cm; - - -/// Print the page header - - $strattendances = get_string("modulenameplural", "attendance"); - $strattendance = get_string("modulename", "attendance"); - $strweekattendance = get_string("weekmodulename", "attendance"); - print_header_simple("$strallattendance", "", - "id>$strattendances -> $strweekattendance", - "", "", true, " ", - navmenu($course, $cm)); -} - -function attendance_HeaderingExcel($filename) { - header("Content-type: application/vnd.ms-excel"); - header("Content-Disposition: attachment; filename=$filename" ); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); - header("Pragma: public"); -} - -?>