Browse Source

Merge branch 'v2.3' of github.com:andreev-artem/moodle_mod_attforblock into MDL_19

Conflicts:
	attendances.php
	attsettings.php
	backuplib.php
	db/install.xml
	db/upgrade.php
	export.php
	lib.php
	locallib.php
	manage.php
	report.php
	restorelib.php
MOODLE_23_STABLE
Luis Ramon Lopez 14 years ago
parent
commit
23336d8c99
  1. 72
      CHANGES
  2. 121
      attendances.php
  3. 10
      attsettings.php
  4. 6
      backuplib.php
  5. 68
      db/install.xml
  6. 29
      db/upgrade.php
  7. 4
      export.php
  8. 7
      export_form.php
  9. 15
      lang/en/attforblock.php
  10. 39
      lang/es/attforblock.php
  11. 2
      lang/es/help/attforblock/createmultiplesessions.html
  12. 2
      lang/es/help/attforblock/report.html
  13. 2
      lang/es/help/attforblock/updateattendance.html
  14. 10
      lang/ru_utf8/attforblock.php
  15. 36
      lib.php
  16. 84
      locallib.php
  17. 33
      manage.php
  18. 16
      report.php
  19. 12
      restorelib.php
  20. 5
      sessions.php
  21. 19
      styles.php
  22. 4
      version.php

72
CHANGES

@ -1,3 +1,75 @@
2011-01-18 lrlopez
* attendances.php: styles.php:
Implemented copy attendance data from same-day sessions.
Fixed fast session dropdown list end time inaccuracy.
Enhanced session dropdown list.
* lang/: en_utf8/attforblock.php, es_utf8/attforblock.php:
Added new strings for the copy dropdown menus.
2011-01-18 lrlopez
* attendances.php: styles.php:
Implemented fast session switching for same-day sessions.
Fixed some XHTML compliance tags (more coming)
* lang/: en_utf8/attforblock.php, es_utf8/attforblock.php:
Added new strings for the dropdown menus.
2011-01-16 lrlopez
* export.php: export_form.php:
* lang/: en_utf8/attforblock.php: es_utf8/attforblock.php:
Added "Start of period" into export tab and two new strings for
the new fields on the form.
2011-01-15 lrlopez
* db/install.xml:
Bugs fixed.
* attendances.php: locallib.php: manage.php:
Fixed some minor bugs and code readibility issues. Now, in grid view
mode, statuses are always next to their radio buttons.
2010-12-30 - 2011-01-04 lrlopez
* lang/: es_utf8/attforblock.php:
Updated and fixed Spanish translation (Enrique Robredo)
* styles.php:
Fixed yui-calendar CSS modifying global CSS behaviour.
* manage.php:
Added an option for choosing between show session duration or show end
time in session list.
* db/: install.xml: upgrade.php: version.php:
* attsettings.php: lib.php: locallib.php: manage.php: report.php:
Added support to allow more than one attendance in the same course.
* sessions.php:
Fixed DST bug (adding multiple sessions could generate invalid start
times if any DST change occur in-between)
* attendances.php:
Implemented display modes (list and grid)
* lang/: en_utf8/attforblock.php, es_utf8/attforblock.php:
Added new strings for the new display modes
2010-07-10 - 2010-09-17 andreev.artem 2010-07-10 - 2010-09-17 andreev.artem
Implemented ability to add two types of sessions: common and group Implemented ability to add two types of sessions: common and group

121
attendances.php

@ -16,6 +16,7 @@
$grouptype = required_param('grouptype', PARAM_INT); $grouptype = required_param('grouptype', PARAM_INT);
$group = optional_param('group', -1, PARAM_INT); // Group to show $group = optional_param('group', -1, PARAM_INT); // Group to show
$sort = optional_param('sort','lastname', PARAM_ALPHA); $sort = optional_param('sort','lastname', PARAM_ALPHA);
$copyfrom = optional_param('copyfrom', -1, PARAM_INT);
if (! $cm = $DB->get_record('course_modules', array('id'=>$id))) { if (! $cm = $DB->get_record('course_modules', array('id'=>$id))) {
error('Course Module ID was incorrect'); error('Course Module ID was incorrect');
@ -38,7 +39,7 @@
print_error('badcontext'); print_error('badcontext');
} }
$statlist = implode(',', array_keys( (array)get_statuses($course->id) )); $statlist = implode(',', array_keys( (array)get_statuses($attforblock->id) ));
if ($form = data_submitted()) { if ($form = data_submitted()) {
$students = array(); // stores students ids $students = array(); // stores students ids
$formarr = (array)$form; $formarr = (array)$form;
@ -103,6 +104,58 @@
$groupmode = groups_get_activity_groupmode($cm); $groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true); $currentgroup = groups_get_activity_group($cm, true);
// get the viewmode & grid columns
$attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id);'course', $course->id);
$view = optional_param('view', -1, PARAM_INT);
if ($view != -1) {
set_user_preference("attforblock_viewmode", $view);
}
else {
$view = get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW);
}
$gridcols = optional_param('gridcols', -1, PARAM_INT);
if ($gridcols != -1) {
set_user_preference("attforblock_gridcolumns", $gridcols);
}
else {
$gridcols = get_user_preferences("attforblock_gridcolumns",5);
}
echo '<table class="controls" cellspacing="0"><tr>'; //echo '<center>';
$options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock'));
$dataurl = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols";
if ($group!=-1) {
$dataurl = $dataurl . "&group=$group";
}
$today = usergetmidnight($sessdata->sessdate);
$select = "sessdate>=? AND sessdate<? AND attendanceid=?";
$tomorrow = $today + 86400;
$todaysessions = $DB->get_records_select('attendance_sessions', $select, array($today, $tomorrow, $cm->instance), 'sessdate ASC');
$optionssesions = array();
if (count($todaysessions)>1) {
echo '<td class="right"><label for="fastsessionmenu_jump">'. get_string('jumpto','attforblock') . "&nbsp;</label>";
foreach($todaysessions as $sessdatarow) {
$descr = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdatarow->duration, get_string('strftimehm', 'attforblock'));
if ($sessdatarow->description) {
$descr = $sessdatarow->description . ' ('.$descr.')';
}
$optionssessions[$sessdatarow->id] = $descr;
}
popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, '');
echo "<td/><tr/><tr>";
}
$dataurl .= "&sessionid=$sessionid";
echo '<td class="right"><label for="viewmenu_jump">'. get_string('viewmode','attforblock') . "&nbsp;</label>";
popup_form("$dataurl&view=", $options, 'viewmenu', $view, '');
if ($view == SORTEDGRIDVIEW) {
$options = array (1 => '1 '.get_string('column','attforblock'),'2 '.get_string('columns','attforblock'),'3 '.get_string('columns','attforblock'),
'4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'),
'7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'),
'10 '.get_string('columns','attforblock'));
$dataurl .= "&view=$view";
popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, '');
}
echo '</td></tr></table>';//</center>';
if ($grouptype === 0) { if ($grouptype === 0) {
if ($currentgroup) { if ($currentgroup) {
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false);
@ -124,14 +177,23 @@
$table->data[][] = '<b>'.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')). $table->data[][] = '<b>'.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')).
', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"</b>'; ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"</b>';
print_table($table); print_table($table);
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
$i = 3; $i = 3;
foreach($statuses as $st) { foreach($statuses as $st) {
switch($view) {
case SORTEDLISTVIEW:
$tabhead[] = "<a href=\"javascript:select_all_in('TD', 'cell c{$i}', null);\"><u>$st->acronym</u></a>"; $tabhead[] = "<a href=\"javascript:select_all_in('TD', 'cell c{$i}', null);\"><u>$st->acronym</u></a>";
break;
case SORTEDGRIDVIEW:
$tabhead[] = "<a href=\"javascript:select_all_in('INPUT', '". $st->acronym . "', null);\"><u>$st->acronym</u></a>";
break;
}
$i++; $i++;
} }
if ($view == SORTEDLISTVIEW) {
$tabhead[] = get_string('remarks','attforblock'); $tabhead[] = get_string('remarks','attforblock');
}
$firstname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=firstname\">".get_string('firstname').'</a>'; $firstname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=firstname\">".get_string('firstname').'</a>';
$lastname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=lastname\">".get_string('lastname').'</a>'; $lastname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=lastname\">".get_string('lastname').'</a>';
@ -143,6 +205,9 @@
if ($students) { if ($students) {
unset($table); unset($table);
switch($view) {
case SORTEDLISTVIEW: // sorted list
$table->width = '0%'; $table->width = '0%';
$table->head[] = '#'; $table->head[] = '#';
$table->align[] = 'center'; $table->align[] = 'center';
@ -170,10 +235,46 @@
$table->data[$student->id][] = "<a href=\"view.php?id=$id&amp;student={$student->id}\">".((!$att && $update) ? '<font color="red"><b>' : '').fullname($student).((!$att && $update) ? '</b></font>' : '').'</a>'; $table->data[$student->id][] = "<a href=\"view.php?id=$id&amp;student={$student->id}\">".((!$att && $update) ? '<font color="red"><b>' : '').fullname($student).((!$att && $update) ? '</b></font>' : '').'</a>';
foreach($statuses as $st) { foreach($statuses as $st) {
@$table->data[$student->id][] = '<input name="student'.$student->id.'" type="radio" value="'.$st->id.'" '.($st->id == $att->statusid ? 'checked' : '').'>'; $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom;
$att = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id));
$currentstatusid = $att===false ? -1 : $att->statusid;
@$table->data[$student->id][] = '<input name="student'.$student->id.'" type="radio" value="'.$st->id.'" '.($st->id == $currentstatusid ? 'checked' : '').'>';
} }
$table->data[$student->id][] = '<input type="text" name="remarks'.$student->id.'" size="" value="'.($att ? $att->remarks : '').'">'; $table->data[$student->id][] = '<input type="text" name="remarks'.$student->id.'" size="" value="'.($att ? $att->remarks : '').'">';
} }
break;
case SORTEDGRIDVIEW: // sorted grid
$table->width = '0%';
$data = '';
foreach ($tabhead as $hd) {
$data = $data . $hd . '&nbsp';
}
print_heading($data,'center');
$i = 0;
// sanity check
$gridcols = $gridcols < 1 ? 1 : $gridcols;
for ($i=0; $i<$gridcols; $i++) {
$table->head[] = '&nbsp;';
$table->align[] = 'center';
$table->size[] = '110px';
}
$i = 0;
foreach($students as $student) {
$i++;
$copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom;
$att = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id));
$currentstatusid = $att===false ? -1 : $att->statusid;
$data = "<span class='userinfobox' style='font-size:80%;border:none'>" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "<br/>" . fullname($student) . "<br/></span>";//, $returnstring=false, $link=true, $target='');
foreach($statuses as $st) {
$data = $data . '<nobr><input name="student'.$student->id.'" type="radio" class="' . $st->acronym . '" value="'.$st->id.'" '.($st->id == $currentstatusid ? 'checked' : '').'>' . $st->acronym . "</nobr> ";
}
$table->data[($i-1) / ($gridcols)][] = $data;
}
break;
}
echo '<form name="takeattendance" method="post" action="attendances.php">'; echo '<form name="takeattendance" method="post" action="attendances.php">';
print_table($table); print_table($table);
@ -181,9 +282,17 @@
echo '<input type="hidden" name="sessionid" value="'.$sessionid.'">'; echo '<input type="hidden" name="sessionid" value="'.$sessionid.'">';
echo '<input type="hidden" name="grouptype" value="'.$grouptype.'">'; echo '<input type="hidden" name="grouptype" value="'.$grouptype.'">';
echo '<input type="hidden" name="formfrom" value="editsessvals">'; echo '<input type="hidden" name="formfrom" value="editsessvals">';
echo '<center><input type="submit" name="esv" value="'.get_string('ok').'"></center>'; echo '<center><input type="submit" name="esv" value="'.get_string('save','attforblock').'"></center>';
echo '</form>'; echo '</form>';
} else {
if (count($todaysessions)>1) {
echo '<br/><table class="controls" cellspacing="0"><tr><td class="center">';
echo '<label for="copysessionmenu_jump">'. get_string('copyfrom','attforblock') . "&nbsp;</label>";
popup_form("$dataurl&copyfrom=", $optionssessions, 'copysessionmenu', $sessionid, '');
echo '</td></tr></table>';
}
} else {
print_heading(get_string('nothingtodisplay'), 'center'); print_heading(get_string('nothingtodisplay'), 'center');
} }

10
attsettings.php

@ -20,7 +20,10 @@
error("Course module is incorrect"); error("Course module is incorrect");
} }
} }
$attforblockrecord = $DB->get_record('attforblock',array('course'=>$course->id)); //$attforblockrecord = get_record('attforblock','course',$course->id);
if (! $attforblockrecord = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
error("Course module is incorrect");
}
require_login($course->id); require_login($course->id);
@ -45,7 +48,7 @@
if (!empty($action)) { if (!empty($action)) {
switch ($action) { switch ($action) {
case 'delete': case 'delete':
if (!$rec = $DB->get_record('attendance_statuses', array('courseid'=> $course->id, 'id'=> $stid))) { if (!$rec = $DB->get_record('attendance_statuses', array('attendanceid'=> $$attforblockrecord->id, 'id'=> $stid))) {
print_error('notfoundstatus', 'attforblock', "attsettings.php?id=$id"); print_error('notfoundstatus', 'attforblock', "attsettings.php?id=$id");
} }
if ($DB->count_records('attendance_log', array('statusid'=> $stid))) { if ($DB->count_records('attendance_log', array('statusid'=> $stid))) {
@ -84,6 +87,7 @@
if (!empty($newacronym) && !empty($newdescription)) { if (!empty($newacronym) && !empty($newdescription)) {
unset($rec); unset($rec);
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->attendanceid = $attforblock->id;
$rec->acronym = $newacronym; $rec->acronym = $newacronym;
$rec->description = $newdescription; $rec->description = $newdescription;
$rec->grade = $newgrade; $rec->grade = $newgrade;
@ -113,7 +117,7 @@
get_string('action')); get_string('action'));
$table->align = array('center', 'center', 'center', 'center', 'center', 'center'); $table->align = array('center', 'center', 'center', 'center', 'center', 'center');
//$table->size = array('1px', '1px', '*', '1px', '1px', '1px'); //$table->size = array('1px', '1px', '*', '1px', '1px', '1px');
$statuses = get_statuses($course->id, false); $statuses = get_statuses($attforblockrecord->id, false);
$deltitle = get_string('delete'); $deltitle = get_string('delete');
foreach($statuses as $st) foreach($statuses as $st)
{ {

6
backuplib.php

@ -100,7 +100,7 @@
$status = true; $status = true;
$datas = $DB->get_records('attendance_sessions', array('courseid'=> $attforblock->course)); $datas = $DB->get_records('attendance_sessions', array('attendanceid'=> $attforblock->id));
if ($datas) { if ($datas) {
//Write start tag //Write start tag
$status =fwrite ($bf,start_tag('SESSIONS',4,true)); $status =fwrite ($bf,start_tag('SESSIONS',4,true));
@ -139,7 +139,7 @@
$status = true; $status = true;
$datas = $DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course)); $datas = $DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id));
//If there is levels //If there is levels
if ($datas) { if ($datas) {
//Write start tag //Write start tag
@ -173,7 +173,7 @@
$status = true; $status = true;
$sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $attforblock->course)); $sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id));
$sesslist = implode(',', array_keys($sessions)); $sesslist = implode(',', array_keys($sessions));
$datas = $DB->get_records_list('attendance_log', array('sessionid'=> $sesslist)); $datas = $DB->get_records_list('attendance_log', array('sessionid'=> $sesslist));
//If there is levels //If there is levels

68
db/install.xml

@ -6,10 +6,10 @@
<TABLES> <TABLES>
<TABLE NAME="attforblock" COMMENT="Module for support Attendances" NEXT="attendance_sessions"> <TABLE NAME="attforblock" COMMENT="Module for support Attendances" NEXT="attendance_sessions">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" COMMENT="id of the table, please edit me" NEXT="course"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="name"/> <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="course" NEXT="grade"/> <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" COMMENT="This is maximum grade for instance" PREVIOUS="name"/> <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" ENUM="false" COMMENT="This is maximum grade for instance" PREVIOUS="name"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attforblock"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attforblock"/>
@ -20,35 +20,37 @@
</TABLE> </TABLE>
<TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table retrofitted from MySQL" PREVIOUS="attforblock" NEXT="attendance_log"> <TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table retrofitted from MySQL" PREVIOUS="attforblock" NEXT="attendance_log">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="courseid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="groupid"/> <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="sessdate"/> <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="attendanceid"/>
<FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="groupid" NEXT="duration"/> <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="sessdate"/>
<FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sessdate" NEXT="lasttaken"/> <FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="attendanceid" NEXT="duration"/>
<FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="duration" NEXT="lasttakenby"/> <FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="sessdate" NEXT="lasttaken"/>
<FIELD NAME="lasttakenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="lasttaken" NEXT="timemodified"/> <FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="duration" NEXT="lasttakenby"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="lasttakenby" NEXT="description"/> <FIELD NAME="lasttakenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lasttaken" NEXT="timemodified"/>
<FIELD NAME="description" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="timemodified"/> <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="lasttakenby" NEXT="description"/>
<FIELD NAME="description" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_sessions"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_sessions"/>
</KEYS> </KEYS>
<INDEXES> <INDEXES>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="groupid"/> <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="groupid"/>
<INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="courseid" NEXT="sessdate"/> <INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="courseid" NEXT="attendanceid"/>
<INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="groupid"/> <INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" PREVIOUS="groupid" NEXT="sessdate"/>
<INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="attendanceid"/>
</INDEXES> </INDEXES>
</TABLE> </TABLE>
<TABLE NAME="attendance_log" COMMENT="attendance_log table retrofitted from MySQL" PREVIOUS="attendance_sessions" NEXT="attendance_statuses"> <TABLE NAME="attendance_log" COMMENT="attendance_log table retrofitted from MySQL" PREVIOUS="attendance_sessions" NEXT="attendance_statuses">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="sessionid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="sessionid"/>
<FIELD NAME="sessionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="studentid"/> <FIELD NAME="sessionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="studentid"/>
<FIELD NAME="studentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sessionid" NEXT="statusid"/> <FIELD NAME="studentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="sessionid" NEXT="statusid"/>
<FIELD NAME="statusid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="link with attendance_status table" PREVIOUS="studentid" NEXT="statusset"/> <FIELD NAME="statusid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="link with attendance_status table" PREVIOUS="studentid" NEXT="statusset"/>
<FIELD NAME="statusset" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" PREVIOUS="statusid" NEXT="timetaken"/> <FIELD NAME="statusset" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="statusid" NEXT="timetaken"/>
<FIELD NAME="timetaken" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="When attendance of this student was taken" PREVIOUS="statusset" NEXT="takenby"/> <FIELD NAME="timetaken" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="When attendance of this student was taken" PREVIOUS="statusset" NEXT="takenby"/>
<FIELD NAME="takenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timetaken" NEXT="remarks"/> <FIELD NAME="takenby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timetaken" NEXT="remarks"/>
<FIELD NAME="remarks" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="takenby"/> <FIELD NAME="remarks" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="takenby"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_log"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_log"/>
@ -61,20 +63,22 @@
</TABLE> </TABLE>
<TABLE NAME="attendance_statuses" COMMENT="attendance_statuses table retrofitted from MySQL" PREVIOUS="attendance_log"> <TABLE NAME="attendance_statuses" COMMENT="attendance_statuses table retrofitted from MySQL" PREVIOUS="attendance_log">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="courseid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="acronym"/> <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="attendanceid"/>
<FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" PREVIOUS="courseid" NEXT="description"/> <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="acronym"/>
<FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="acronym" NEXT="grade"/> <FIELD NAME="acronym" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="attendanceid" NEXT="description"/>
<FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="visible"/> <FIELD NAME="description" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="acronym" NEXT="grade"/>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="grade" NEXT="deleted"/> <FIELD NAME="grade" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="visible"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="visible"/> <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="grade" NEXT="deleted"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_settings"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance_settings"/>
</KEYS> </KEYS>
<INDEXES> <INDEXES>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="visible"/> <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="attendanceid"/>
<INDEX NAME="visible" UNIQUE="false" FIELDS="visible" PREVIOUS="courseid" NEXT="deleted"/> <INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" PREVIOUS="courseid" NEXT="visible"/>
<INDEX NAME="visible" UNIQUE="false" FIELDS="visible" PREVIOUS="attendanceid" NEXT="deleted"/>
<INDEX NAME="deleted" UNIQUE="false" FIELDS="deleted" PREVIOUS="visible"/> <INDEX NAME="deleted" UNIQUE="false" FIELDS="deleted" PREVIOUS="visible"/>
</INDEXES> </INDEXES>
</TABLE> </TABLE>

29
db/upgrade.php

@ -236,7 +236,34 @@ function xmldb_attforblock_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2010070900, 'attforblock'); upgrade_mod_savepoint(true, 2010070900, 'attforblock');
} }
return true; if ($oldversion < 2010123003) {
$table = new xmldb_table('attendance_sessions');
$field = new xmldb_field('attendanceid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid');
$dbman->add_field($table, $field);
$index = new xmldb_table('attendanceid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid'));
$dbman->add_index($table, $index);
$sql = "UPDATE {attendance_sessions} AS ses,{attforblock} AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid";
$dbman->execute($sql);
$table = new xmldb_table('attendance_statuses');
$field = new xmldb_field('attendanceid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid');
$dbman->add_field($table, $field);
$index = new xmldb_index('attendanceid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid'));
$dbman->add_index($table, $index);
$sql = "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid";
execute($sql);
}
return $result;
} }
?> ?>

4
export.php

@ -75,7 +75,7 @@
$i = 0; $i = 0;
$data->table = array(); $data->table = array();
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
foreach($students as $student) { foreach($students as $student) {
if (isset($fromform->ident['id'])) { if (isset($fromform->ident['id'])) {
$data->table[$i][] = $student->id; $data->table[$i][] = $student->id;
@ -92,7 +92,7 @@
$data->table[$i][] = '-'; $data->table[$i][] = '-';
} }
} }
$data->table[$i][] = get_percent($student->id, $course).'%'; $data->table[$i][] = get_percent($student->id, $course, $attforblock).'%';
$i++; $i++;
} }

7
export_form.php

@ -59,9 +59,14 @@ class mod_attforblock_export_form extends moodleform {
// $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); // $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true);
// $mform->addGroup($durtime, 'durtime', get_string('duration','attforblock'), array(' '), true); // $mform->addGroup($durtime, 'durtime', get_string('duration','attforblock'), array(' '), true);
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall','attforblock'), get_string('yes'));
$mform->setDefault('includeallsessions', true);
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes')); $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes'));
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod','attforblock'));
$mform->setDefault('sessionstartdate', $course->startdate);
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked');
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock')); $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock'));
$mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked'); $mform->disabledIf('sessionenddate', 'includeallsessions', 'checked');
$mform->addElement('select', 'format', get_string('format'), $mform->addElement('select', 'format', get_string('format'),
array('excel' => get_string('downloadexcel','attforblock'), array('excel' => get_string('downloadexcel','attforblock'),

15
lang/en/attforblock.php

@ -39,13 +39,17 @@ $string['caltoday'] = 'Today';
$string['calweekdays'] = ' \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"'; $string['calweekdays'] = ' \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"';
$string['changeduration'] = 'Change duration'; $string['changeduration'] = 'Change duration';
$string['changesession'] = 'Change session'; $string['changesession'] = 'Change session';
$string['column'] = 'column';
$string['columns'] = 'columns';
$string['commonsession'] = 'Common'; $string['commonsession'] = 'Common';
$string['commonsessions'] = 'Common'; $string['commonsessions'] = 'Common';
$string['countofselected'] = 'Count of selected'; $string['countofselected'] = 'Count of selected';
$string['copyfrom'] = 'Copy attendance data from';
$string['createmultiplesessions'] = 'Create multiple sessions'; $string['createmultiplesessions'] = 'Create multiple sessions';
$string['createonesession'] = 'Create one session for the course'; $string['createonesession'] = 'Create one session for the course';
$string['days'] = 'Day'; $string['days'] = 'Day';
$string['defaults'] = 'Defaults'; $string['defaults'] = 'Defaults';
$string['defaultdisplaymode'] = 'Default display mode';
$string['delete'] = 'Delete'; $string['delete'] = 'Delete';
$string['deletelogs'] = 'Delete attendance data'; $string['deletelogs'] = 'Delete attendance data';
$string['deleteselected'] = 'Delete selected'; $string['deleteselected'] = 'Delete selected';
@ -55,20 +59,25 @@ $string['deletingsession'] = 'Deleting session for the course';
$string['deletingstatus'] = 'Deleting status for the course'; $string['deletingstatus'] = 'Deleting status for the course';
$string['description'] = 'Description'; $string['description'] = 'Description';
$string['display'] = 'Display'; $string['display'] = 'Display';
$string['displaymode'] = 'Display mode';
$string['downloadexcel'] = 'Download in Excel format'; $string['downloadexcel'] = 'Download in Excel format';
$string['downloadooo'] = 'Download in OpenOffice format'; $string['downloadooo'] = 'Download in OpenOffice format';
$string['downloadtext'] = 'Download in text format'; $string['downloadtext'] = 'Download in text format';
$string['duration'] = 'Duration'; $string['duration'] = 'Duration';
$string['editsession'] = 'Edit Session'; $string['editsession'] = 'Edit Session';
$string['endtime'] = 'Session end time';
$string['endofperiod'] = 'End of period'; $string['endofperiod'] = 'End of period';
$string['errorgroupsnotselected'] = 'Select one or more groups'; $string['errorgroupsnotselected'] = 'Select one or more groups';
$string['errorinaddingsession'] = 'Error in adding session'; $string['errorinaddingsession'] = 'Error in adding session';
$string['erroringeneratingsessions'] = 'Error in generating sessions '; $string['erroringeneratingsessions'] = 'Error in generating sessions ';
$string['gridcolumns'] = 'Grid columns';
$string['groupsession'] = 'Group'; $string['groupsession'] = 'Group';
$string['hiddensessions'] = 'Hidden sessions'; $string['hiddensessions'] = 'Hidden sessions';
$string['identifyby'] = 'Identify student by'; $string['identifyby'] = 'Identify student by';
$string['includeall'] = 'Select all sessions';
$string['includenottaken'] = 'Include not taken sessions'; $string['includenottaken'] = 'Include not taken sessions';
$string['indetail'] = 'In detail...'; $string['indetail'] = 'In detail...';
$string['jumpto'] = 'Jump to';
$string['moduledescription'] = 'You can add only one module Attendance per course.<br />Removal of this module will not entail removal of the data!'; $string['moduledescription'] = 'You can add only one module Attendance per course.<br />Removal of this module will not entail removal of the data!';
$string['modulename'] = 'Attendance'; $string['modulename'] = 'Attendance';
$string['modulenameplural'] = 'Attendances'; $string['modulenameplural'] = 'Attendances';
@ -94,6 +103,7 @@ $string['report'] = 'Report';
$string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!'; $string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!';
$string['resetstatuses'] = 'Reset statuses to default'; $string['resetstatuses'] = 'Reset statuses to default';
$string['restoredefaults'] = 'Restore defaults'; $string['restoredefaults'] = 'Restore defaults';
$string['save'] = 'Save attendance';
$string['session'] = 'Session'; $string['session'] = 'Session';
$string['sessionadded'] = 'Session successfully added'; $string['sessionadded'] = 'Session successfully added';
$string['sessionalreadyexists'] = 'Session already exists for this date'; $string['sessionalreadyexists'] = 'Session already exists for this date';
@ -111,6 +121,10 @@ $string['sessiontypeshort'] = 'Type';
$string['sessionupdated'] = 'Session successfully updated'; $string['sessionupdated'] = 'Session successfully updated';
$string['settings'] = 'Settings'; $string['settings'] = 'Settings';
$string['showdefaults'] = 'Show defaults'; $string['showdefaults'] = 'Show defaults';
$string['showduration'] = 'Show duration';
$string['sortedgrid'] = 'Sorted grid';
$string['sortedlist'] = 'Sorted list';
$string['startofperiod'] = 'Start of period';
$string['status'] = 'Status'; $string['status'] = 'Status';
$string['statusdeleted'] = 'Status deleted'; $string['statusdeleted'] = 'Status deleted';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';
@ -126,6 +140,7 @@ $string['update'] = 'Update';
$string['variable'] = 'variable'; $string['variable'] = 'variable';
$string['variablesupdated'] = 'Variables successfully updated'; $string['variablesupdated'] = 'Variables successfully updated';
$string['versionforprinting'] = 'version for printing'; $string['versionforprinting'] = 'version for printing';
$string['viewmode'] = 'View mode';
$string['week'] = 'week(s)'; $string['week'] = 'week(s)';
$string['weeks'] = 'Weeks'; $string['weeks'] = 'Weeks';
$string['youcantdo'] = 'You can\'t do anything'; $string['youcantdo'] = 'You can\'t do anything';

39
lang/es/attforblock.php

@ -3,12 +3,12 @@
$string['all'] = 'Todas'; $string['all'] = 'Todas';
$string['Aacronym'] = 'A'; $string['Aacronym'] = 'I';
$string['Afull'] = 'Ausente'; $string['Afull'] = 'Falta injustificada';
$string['Eacronym'] = 'E'; $string['Eacronym'] = 'J';
$string['Efull'] = 'Excusa'; $string['Efull'] = 'Falta justificada';
$string['Lacronym'] = 'T'; $string['Lacronym'] = 'R';
$string['Lfull'] = 'Tarde'; $string['Lfull'] = 'Retraso';
$string['Pacronym'] = 'P'; $string['Pacronym'] = 'P';
$string['Pfull'] = 'Presente'; $string['Pfull'] = 'Presente';
$string['acronym'] = 'Acrónimo'; $string['acronym'] = 'Acrónimo';
@ -24,8 +24,8 @@ $string['attendancepercent'] = 'Porcentaje';
$string['attendancereport'] = 'Informe de Asistencia'; $string['attendancereport'] = 'Informe de Asistencia';
$string['attendancesuccess'] = 'Asistencia tomada con éxito'; $string['attendancesuccess'] = 'Asistencia tomada con éxito';
$string['attendanceupdated'] = 'Asistencia actualizada con éxito'; $string['attendanceupdated'] = 'Asistencia actualizada con éxito';
$string['attforblock:changeattendances'] = 'Cambiar asistencias'; $string['attforblock:changeattendances'] = 'Cambiar Asistencias';
$string['attforblock:changepreferences'] = 'Cambiar Preferencias'; $string['attforblock:changepreferences'] = 'Cambiar preferencias';
$string['attforblock:export'] = 'Exportar Informes'; $string['attforblock:export'] = 'Exportar Informes';
$string['attforblock:manageattendances'] = 'Gestionar Asistencias'; $string['attforblock:manageattendances'] = 'Gestionar Asistencias';
$string['attforblock:takeattendances'] = 'Tomar Asistencias'; $string['attforblock:takeattendances'] = 'Tomar Asistencias';
@ -39,13 +39,17 @@ $string['caltoday'] = 'Hoy';
$string['calweekdays'] = '\"Do\", \"Lu\", \"Ma\", \"Mi\", \"Ju\", \"Vi\", \"Sá\"'; $string['calweekdays'] = '\"Do\", \"Lu\", \"Ma\", \"Mi\", \"Ju\", \"Vi\", \"Sá\"';
$string['changeduration'] = 'Cambiar duración'; $string['changeduration'] = 'Cambiar duración';
$string['changesession'] = 'Cambiar Sesión'; $string['changesession'] = 'Cambiar Sesión';
$string['column'] = 'columna';
$string['columns'] = 'columnas';
$string['commonsession'] = 'Común'; $string['commonsession'] = 'Común';
$string['commonsessions'] = 'Comunes'; $string['commonsessions'] = 'Comunes';
$string['countofselected'] = 'Recuento de selección'; $string['countofselected'] = 'Recuento de selección';
$string['copyfrom'] = 'Copiar asistencia desde';
$string['createmultiplesessions'] = 'Crear varias sesiones'; $string['createmultiplesessions'] = 'Crear varias sesiones';
$string['createonesession'] = 'Crear una sesión para el curso'; $string['createonesession'] = 'Crear una sesión para el curso';
$string['days'] = 'Hoy'; $string['days'] = 'Hoy';
$string['defaults'] = 'Por Defecto'; $string['defaults'] = 'Por Defecto';
$string['defaultdisplaymode'] = 'Visualización por defecto';
$string['delete'] = 'Eliminar'; $string['delete'] = 'Eliminar';
$string['deletelogs'] = 'Eliminar datos de asistencia'; $string['deletelogs'] = 'Eliminar datos de asistencia';
$string['deleteselected'] = 'Eliminar selección'; $string['deleteselected'] = 'Eliminar selección';
@ -55,20 +59,25 @@ $string['deletingsession'] = 'Eliminando Sesión para el Curso/Asignatura';
$string['deletingstatus'] = 'Eliminando estatus del curso'; $string['deletingstatus'] = 'Eliminando estatus del curso';
$string['description'] = 'Descripción'; $string['description'] = 'Descripción';
$string['display'] = 'Mostrar'; $string['display'] = 'Mostrar';
$string['downloadexcel'] = 'Descargar en Formato Excell'; $string['displaymode'] = 'Modo de visualización';
$string['downloadexcel'] = 'Descargar en Formato Excel';
$string['downloadooo'] = 'Descargar en Formato OpenOffice'; $string['downloadooo'] = 'Descargar en Formato OpenOffice';
$string['downloadtext'] = 'Descargar en Formato de Texto'; $string['downloadtext'] = 'Descargar en Formato de Texto';
$string['duration'] = 'Duración'; $string['duration'] = 'Duración';
$string['editsession'] = 'Editar Sesión'; $string['editsession'] = 'Editar Sesión';
$string['endofperiod'] = 'Fin del periodo'; $string['endofperiod'] = 'Fecha final';
$string['endtime'] = 'Hora de finalización';
$string['errorgroupsnotselected'] = 'Elija uno o más grupos'; $string['errorgroupsnotselected'] = 'Elija uno o más grupos';
$string['errorinaddingsession'] = 'Error añadiendo Sesión'; $string['errorinaddingsession'] = 'Error añadiendo Sesión';
$string['erroringeneratingsessions'] = 'Error generando sesión'; $string['erroringeneratingsessions'] = 'Error generando sesión';
$string['gridcolumns'] = 'Columnas de la rejilla';
$string['groupsession'] = 'Grupal'; $string['groupsession'] = 'Grupal';
$string['hiddensessions'] = 'Sesiones ocultas'; $string['hiddensessions'] = 'Sesiones ocultas';
$string['identifyby'] = 'Identificar estudiantes por'; $string['identifyby'] = 'Identificar estudiantes por';
$string['includeall'] = 'Seleccionar todas las sesiones';
$string['includenottaken'] = 'Incluir sesiones no registradas'; $string['includenottaken'] = 'Incluir sesiones no registradas';
$string['indetail'] = 'En Detalle...'; $string['indetail'] = 'En detalle...';
$string['jumpto'] = 'Saltar a';
$string['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.<br>Si se elimina esta actividad, los datos de la base de datos no se verán afectados, así que reaparecerán en caso de volver a agregar nuevamente la actividad.'; $string['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.<br>Si se elimina esta actividad, los datos de la base de datos no se verán afectados, así que reaparecerán en caso de volver a agregar nuevamente la actividad.';
$string['modulename'] = 'Asistencia'; $string['modulename'] = 'Asistencia';
$string['modulenameplural'] = 'Asistencias'; $string['modulenameplural'] = 'Asistencias';
@ -95,6 +104,7 @@ $string['report'] = 'Informe';
$string['resetdescription'] = 'Recuerde que eliminando los datos de la asistencia provocará el borrado de información en la base de datos. Usted puede ocultar sesiones anteriores cambiando la fecha de inicio del curso en la zona de administración.'; $string['resetdescription'] = 'Recuerde que eliminando los datos de la asistencia provocará el borrado de información en la base de datos. Usted puede ocultar sesiones anteriores cambiando la fecha de inicio del curso en la zona de administración.';
$string['resetstatuses'] = 'Reinicar la configuración por defecto'; $string['resetstatuses'] = 'Reinicar la configuración por defecto';
$string['restoredefaults'] = 'Restarurar valores por defecto'; $string['restoredefaults'] = 'Restarurar valores por defecto';
$string['save'] = 'Guardar asistencia';
$string['session'] = 'Sesión'; $string['session'] = 'Sesión';
$string['sessionadded'] = 'Sesión añadida con éxito'; $string['sessionadded'] = 'Sesión añadida con éxito';
$string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada'; $string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada';
@ -111,9 +121,13 @@ $string['sessiontype'] = 'Tipo de sesión';
$string['sessiontypeshort'] = 'Tipo'; $string['sessiontypeshort'] = 'Tipo';
$string['sessionupdated'] = 'Sesión actualizada con éxito'; $string['sessionupdated'] = 'Sesión actualizada con éxito';
$string['settings'] = 'Configuración'; $string['settings'] = 'Configuración';
$string['showduration'] = 'Mostrar duración';
$string['showdefaults'] = 'Mostrar opciones por defecto'; $string['showdefaults'] = 'Mostrar opciones por defecto';
$string['sortedgrid'] = 'Rejilla alfabética';
$string['sortedlist'] = 'Lista alfabética';
$string['startofperiod'] = 'Fecha de comienzo';
$string['status'] = 'Estado'; $string['status'] = 'Estado';
$string['statusdeleted'] = 'Estatus eliminado'; $string['statusdeleted'] = 'Estado eliminado';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';
$string['strftimedmy'] = '%%d.%%m.%%Y'; $string['strftimedmy'] = '%%d.%%m.%%Y';
$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; $string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M';
@ -127,6 +141,7 @@ $string['update'] = 'Actualizar';
$string['variable'] = 'variable'; $string['variable'] = 'variable';
$string['variablesupdated'] = 'Variables actualizadas con éxito'; $string['variablesupdated'] = 'Variables actualizadas con éxito';
$string['versionforprinting'] = 'versión para Imprimir'; $string['versionforprinting'] = 'versión para Imprimir';
$string['viewmode'] = 'Visualización';
$string['week'] = 'semana(s)'; $string['week'] = 'semana(s)';
$string['weeks'] = 'Semanal'; $string['weeks'] = 'Semanal';
$string['youcantdo'] = 'Usted no puede hacer nada'; $string['youcantdo'] = 'Usted no puede hacer nada';

2
lang/es/help/attforblock/createmultiplesessions.html

@ -2,7 +2,7 @@
<p align="left"><strong>Crear Múltiples Sesiones</strong></p> <p align="left"><strong>Crear Múltiples Sesiones</strong></p>
<p align="left">Esta función le permite crear múltiples sesiones en un único paso. <br /> <p align="left">Esta función le permite crear múltiples sesiones en un único paso. <br />
<strong>Fecha de Inicio de Sesión</strong>: seleccione la fecha de inicio de su curso<F2> asignatura <strong>Fecha de Inicio de Sesión</strong>: seleccione la fecha de inicio de su curso o asignatura
(el primer día de clase).<br><strong>Fecha de Fin de Sesión</strong>: indique aquí el último día de clase (el primer día de clase).<br><strong>Fecha de Fin de Sesión</strong>: indique aquí el último día de clase
(el último día en que usted quiera tomar asistencia). <br /> (el último día en que usted quiera tomar asistencia). <br />
<strong>Días de Sesión</strong>: Seleccione los días de la semana en los que tenga clase.<br /> <strong>Días de Sesión</strong>: Seleccione los días de la semana en los que tenga clase.<br />

2
lang/es/help/attforblock/report.html

@ -2,4 +2,4 @@
<p align="left"><strong>Informe</strong></p> <p align="left"><strong>Informe</strong></p>
<p align="justify">Modifique la forma en que se visualizan los datos de asistencia ajustando los parámetros. Los datos también pueden ser <p align="justify">Modifique la forma en que se visualizan los datos de asistencia ajustando los parámetros. Los datos también pueden ser
descargados para una visualización sin conexión y analizarlos mediante el menú desplegable de &quot;Informe&quot; descargados para una visualización sin conexión y analizarlos mediante el menú desplegable de &quot;Informe&quot;
que puede encontrar en la pestaña "exportar".</p><br><br><strong>Informe individual:</strong> Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).</p> que puede encontrar en la pestaña "exportar".<br><br><strong>Informe individual:</strong> Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).</p>

2
lang/es/help/attforblock/updateattendance.html

@ -1,3 +1,3 @@
<p align="center"><b>Asistencia</b></p> <p align="center"><b>Asistencia</b></p>
<p align="left"><strong>Actualizar asistencia</strong></p> <p align="left"><strong>Actualizar asistencia</strong></p>
<p align="left">Desde aquí podrá marcar los datos de asistencia de su grupo de estudiantes. Puede hacerlo individualmente o en bloque. Para asignar a todos sus alumnos el mismo valor, puede seleccionar la letra que figura en el encabezado de cada columna (P, J, T...) y luego modificar individualmente algún dato concreto. Al final del listado encontrará el botón "ok" (puede acceder rápidamente pulsando la tecla Fin de su teclado) que grabará los resultados. Puede modificar los valores en cualquier momento accediendo nuevamente la asistencia de este día/hora. Junto a cada registro encontrará una caja de texto que le permitirá anotar observaciones personalizadas para cada estudiante.</p><br><br><strong>Informe individual:</strong> Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).</p> <p align="left">Desde aquí podrá marcar los datos de asistencia de su grupo de estudiantes. Puede hacerlo individualmente o en bloque. Para asignar a todos sus alumnos el mismo valor, puede seleccionar la letra que figura en el encabezado de cada columna (P, J, T...) y luego modificar individualmente algún dato concreto. Al final del listado encontrará el botón "ok" (puede acceder rápidamente pulsando la tecla Fin de su teclado) que grabará los resultados. Puede modificar los valores en cualquier momento accediendo nuevamente la asistencia de este día/hora. Junto a cada registro encontrará una caja de texto que le permitirá anotar observaciones personalizadas para cada estudiante.<br><br><strong>Informe individual:</strong> Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).</p>

10
lang/ru_utf8/attforblock.php

@ -38,9 +38,12 @@ $string['caltoday'] = 'Сегодня';
$string['calweekdays'] = ' \"Вс\", \"Пн\", \"Вт\", \"Ср\", \"Чт\", \"Пт\", \"Сб\"'; $string['calweekdays'] = ' \"Вс\", \"Пн\", \"Вт\", \"Ср\", \"Чт\", \"Пт\", \"Сб\"';
$string['changeduration'] = 'Изменить продолжительность'; $string['changeduration'] = 'Изменить продолжительность';
$string['changesession'] = 'Изменить занятие'; $string['changesession'] = 'Изменить занятие';
$string['column'] = 'колонка';
$string['columns'] = 'колонок';
$string['commonsession'] = 'Общее'; $string['commonsession'] = 'Общее';
$string['commonsessions'] = 'Общие'; $string['commonsessions'] = 'Общие';
$string['countofselected'] = 'Выбрано занятий'; $string['countofselected'] = 'Выбрано занятий';
$string['copyfrom'] = 'Копировать данные посещаемости из занятия';
$string['createmultiplesessions'] = 'Создать несколько занятий'; $string['createmultiplesessions'] = 'Создать несколько занятий';
$string['createonesession'] = 'Создать одно занятие для курса'; $string['createonesession'] = 'Создать одно занятие для курса';
$string['days'] = 'День'; $string['days'] = 'День';
@ -64,8 +67,10 @@ $string['erroringeneratingsessions'] = 'Ошибка при создании з
$string['groupsession'] = 'Групповое'; $string['groupsession'] = 'Групповое';
$string['hiddensessions'] = 'Скрытых занятий'; $string['hiddensessions'] = 'Скрытых занятий';
$string['identifyby'] = 'Идентифицировать студентов по'; $string['identifyby'] = 'Идентифицировать студентов по';
$string['includeall'] = 'Выбрать все занятия';
$string['includenottaken'] = 'Включить не прошедшие занятия'; $string['includenottaken'] = 'Включить не прошедшие занятия';
$string['indetail'] = 'Подробнее...'; $string['indetail'] = 'Подробнее...';
$string['jumpto'] = 'Перейти к занятию ';
$string['moduledescription'] = 'Вы можете добавить только один данный модуль в каждый курс.<br />Удаление этого модуля не повлечет удаление данных о посещаемости!'; $string['moduledescription'] = 'Вы можете добавить только один данный модуль в каждый курс.<br />Удаление этого модуля не повлечет удаление данных о посещаемости!';
$string['modulename'] = 'Посещаемость'; $string['modulename'] = 'Посещаемость';
$string['modulenameplural'] = 'Посещаемость'; $string['modulenameplural'] = 'Посещаемость';
@ -89,6 +94,7 @@ $string['period'] = 'Периодичность';
$string['remarks'] = 'Заметка'; $string['remarks'] = 'Заметка';
$string['report'] = 'Отчет'; $string['report'] = 'Отчет';
$string['restoredefaults'] = 'Востановить значения по-умолчанию'; $string['restoredefaults'] = 'Востановить значения по-умолчанию';
$string['save'] = 'Сохранить посещаемость';
$string['session'] = 'Занятие'; $string['session'] = 'Занятие';
$string['sessionadded'] = 'Занятие успешно добавлено'; $string['sessionadded'] = 'Занятие успешно добавлено';
$string['sessionalreadyexists'] = 'В этот день занятие уже существует'; $string['sessionalreadyexists'] = 'В этот день занятие уже существует';
@ -106,6 +112,9 @@ $string['sessiontypeshort'] = 'Тип';
$string['sessionupdated'] = 'Занятие успешно изменено'; $string['sessionupdated'] = 'Занятие успешно изменено';
$string['settings'] = 'Настройки'; $string['settings'] = 'Настройки';
$string['showdefaults'] = 'Показать значения по-умолчанию'; $string['showdefaults'] = 'Показать значения по-умолчанию';
$string['sortedgrid'] = 'Таблица';
$string['sortedlist'] = 'Список';
$string['startofperiod'] = 'Начало периода';
$string['status'] = 'Статус'; $string['status'] = 'Статус';
$string['statusdeleted'] = 'Статус удален'; $string['statusdeleted'] = 'Статус удален';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';
@ -120,6 +129,7 @@ $string['update'] = 'Обновить';
$string['variable'] = 'переменную'; $string['variable'] = 'переменную';
$string['variablesupdated'] = 'Переменные успешно обновлены'; $string['variablesupdated'] = 'Переменные успешно обновлены';
$string['versionforprinting'] = 'версия для печати'; $string['versionforprinting'] = 'версия для печати';
$string['viewmode'] = 'Вид: ';
$string['week'] = 'неделя(и)'; $string['week'] = 'неделя(и)';
$string['weeks'] = 'Неделя'; $string['weeks'] = 'Неделя';
$string['youcantdo'] = 'Вы ничего не можете сделать'; $string['youcantdo'] = 'Вы ничего не можете сделать';

36
lib.php

@ -33,27 +33,27 @@ function attforblock_add_instance($attforblock) {
$attforblock->timemodified = time(); $attforblock->timemodified = time();
if ($att = $DB->get_record('attforblock', array('course'=> $attforblock->course))) { /*if ($att = get_record('attforblock', 'course', $attforblock->course)) {
$modnum = $DB->get_field('modules', 'id', array('name'=> 'attforblock')); $modnum = get_field('modules', 'id', 'name', 'attforblock');
if (!$DB->get_record('course_modules', array('course'=> $attforblock->course, 'module'=> $modnum))) { if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) {
$DB->delete_records('attforblock', array('course'=> $attforblock->course)); delete_records('attforblock', 'course', $attforblock->course);
$attforblock->id = $DB->insert_record('attforblock', $attforblock); $attforblock->id = insert_record('attforblock', $attforblock);
} else { /*} else {
return false; return false;
} }
} else { } else {*/
$attforblock->id = $DB->insert_record('attforblock', $attforblock); $attforblock->id = insert_record('attforblock', $attforblock);
} //}
//Copy statuses for new instance from defaults //Copy statuses for new instance from defaults
if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) { //if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) {
$statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id'); $statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id');
foreach($statuses as $stat) { foreach($statuses as $stat) {
$rec = $stat; $rec = $stat;
$rec->courseid = $attforblock->course; $rec->courseid = $attforblock->course;
$DB->insert_record('attendance_statuses', $rec); $DB->insert_record('attendance_statuses', $rec);
} }
} //}
// attforblock_grade_item_update($attforblock); // attforblock_grade_item_update($attforblock);
// attforblock_update_grades($attforblock); // attforblock_update_grades($attforblock);
@ -177,11 +177,11 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) {
require_once('locallib.php'); require_once('locallib.php');
if (isstudent($course->id, $user->id)) { if (isstudent($course->id, $user->id)) {
if ($sescount = get_attendance($user->id,$course)) { if ($sescount = get_attendance($user->id,$course, $attforblock)) {
$strgrade = get_string('grade'); $strgrade = get_string('grade');
$maxgrade = get_maxgrade($user->id, $course); $maxgrade = get_maxgrade($user->id, $course,$attforblock);
$usergrade = get_grade($user->id, $course); $usergrade = get_grade($user->id, $course,$attforblock);
$percent = get_percent($user->id,$course); $percent = get_percent($user->id,$course, $attforblock);
$result->info = "$strgrade: $usergrade / $maxgrade ($percent%)"; $result->info = "$strgrade: $usergrade / $maxgrade ($percent%)";
} }
} }
@ -241,13 +241,13 @@ function attforblock_get_user_grades($attforblock, $userid=0) {
if ($userid) { if ($userid) {
$result = array(); $result = array();
$result[$userid]->userid = $userid; $result[$userid]->userid = $userid;
$result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100; $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course, $attforblock) / 100;
} else { } else {
if ($students = get_course_students($course->id)) { if ($students = get_course_students($course->id)) {
$result = array(); $result = array();
foreach ($students as $student) { foreach ($students as $student) {
$result[$student->id]->userid = $student->id; $result[$student->id]->userid = $student->id;
$result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100; $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course, $attforblock) / 100;
} }
} }
} }
@ -325,7 +325,7 @@ function attforblock_grade_item_update($attforblock, $grades=NULL) {
}else{ }else{
// MDL-14303 // MDL-14303
$cm = get_coursemodule_from_instance('attforblock', $attforblock->id); $cm = get_coursemodule_from_instance('attforblock', $attforblock->id);
$params = array('itemname'=>$attforblock->name, 'idnumber'=>$cm->id); $params = array('itemname'=>$attforblock->name/*, 'idnumber'=>$attforblock->id*/);
} }
if ($attforblock->grade > 0) { if ($attforblock->grade > 0) {

84
locallib.php

@ -12,6 +12,9 @@ define('WITHOUT_SELECTOR', 0);
define('GROUP_SELECTOR', 1); define('GROUP_SELECTOR', 1);
define('SESSION_TYPE_SELECTOR', 2); define('SESSION_TYPE_SELECTOR', 2);
define('SORTEDLISTVIEW', 0);
define('SORTEDGRIDVIEW', 1);
function show_tabs($cm, $context, $currenttab='sessions') function show_tabs($cm, $context, $currenttab='sessions')
{ {
$toprow = array(); $toprow = array();
@ -46,14 +49,14 @@ function show_tabs($cm, $context, $currenttab='sessions')
//getting settings for course //getting settings for course
function get_statuses($courseid, $onlyvisible = true) function get_statuses($attendanceid, $onlyvisible = true)
{ {
global $DB; global $DB;
if ($onlyvisible) { if ($onlyvisible) {
$result = $DB->get_records_select('attendance_statuses', "courseid = ? AND visible = 1 AND deleted = 0", array( $courseid ), 'grade DESC'); $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid AND visible = 1 AND deleted = 0", 'grade DESC');
} else { } else {
$result = $DB->get_records_select('attendance_statuses', "courseid = ? AND deleted = 0", array( $courseid ), 'grade DESC'); $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid AND deleted = 0", 'grade DESC');
// $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC'); // $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC');
} }
return $result; return $result;
@ -61,24 +64,24 @@ function get_statuses($courseid, $onlyvisible = true)
//gets attendance status for a student, returns count //gets attendance status for a student, returns count
function get_attendance($userid, $course, $statusid=0) function get_attendance($userid, $course, $attendance, $statusid=0)
{ {
global $CFG, $DB; global $CFG, $DB;
$qry = "SELECT count(*) as cnt $qry = "SELECT count(*) as cnt
FROM {attendance_log} al FROM {attendance_log} al
JOIN {attendance_sessions} ats JOIN {attendance_sessions} ats
ON al.sessionid = ats.id ON al.sessionid = ats.id
WHERE ats.courseid = $course->id WHERE ats.attendanceid = :aid
AND ats.sessdate >= $course->startdate AND ats.sessdate >= :cstartdate
AND al.studentid = $userid"; AND al.studentid = :uid";
if ($statusid) { if ($statusid) {
$qry .= " AND al.statusid = $statusid"; $qry .= " AND al.statusid = :sid";
} }
return $DB->count_records_sql($qry); return $DB->count_records_sql($qry, array('aid' => $attendance->id, 'cstartdate' => $course->startdate, 'uid'=>$userid, 'sid'=>$statusid ));
} }
function get_grade($userid, $course) function get_grade($userid, $course, $attendance)
{ {
global $CFG, $DB; global $CFG, $DB;
$logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset
@ -86,11 +89,12 @@ function get_grade($userid, $course)
JOIN {attendance_sessions} s JOIN {attendance_sessions} s
ON l.sessionid = s.id ON l.sessionid = s.id
WHERE l.studentid = :usid WHERE l.studentid = :usid
AND s.attendanceid = :aid
AND s.courseid = :cid AND s.courseid = :cid
AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
$result = 0; $result = 0;
if ($logs) { if ($logs) {
$stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
foreach ($logs as $log) { foreach ($logs as $log) {
$result += $stat_grades[$log->statusid]; $result += $stat_grades[$log->statusid];
} }
@ -110,7 +114,7 @@ function local_array_intersect_key($array1, $array2) {
return $result; return $result;
} }
function get_maxgrade($userid, $course) function get_maxgrade($userid, $course, $attendance)
{ {
global $CFG, $DB; global $CFG, $DB;
$logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset
@ -118,12 +122,13 @@ function get_maxgrade($userid, $course)
JOIN {attendance_sessions} s JOIN {attendance_sessions} s
ON l.sessionid = s.id ON l.sessionid = s.id
WHERE l.studentid = :usid WHERE l.studentid = :usid
AND s.attendanceid = :aid
AND s.courseid = :cid AND s.courseid = :cid
AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
$maxgrade = 0; $maxgrade = 0;
if ($logs) { if ($logs) {
$stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); $stat_grades = records_to_menu(get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
foreach ($logs as $log) { foreach ($logs as $log) {
$ids = array_flip(explode(',', $log->statusset)); $ids = array_flip(explode(',', $log->statusset));
// $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher // $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher
@ -143,11 +148,12 @@ function get_percent_adaptive($userid, $course) // NOT USED
JOIN {attendance_sessions} s JOIN {attendance_sessions} s
ON l.sessionid = s.id ON l.sessionid = s.id
WHERE l.studentid = :usid WHERE l.studentid = :usid
AND s.attendanceid = :aid
AND s.courseid = :cid AND s.courseid = :cid
AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
$result = 0; $result = 0;
if ($logs) { if ($logs) {
$stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
$percent = 0; $percent = 0;
foreach ($logs as $log) { foreach ($logs as $log) {
@ -165,15 +171,15 @@ function get_percent_adaptive($userid, $course) // NOT USED
return sprintf("%0.{$dp}f", $result); return sprintf("%0.{$dp}f", $result);
} }
function get_percent($userid, $course) function get_percent($userid, $course, $attforblock)
{ {
global $CFG; global $CFG;
$maxgrd = get_maxgrade($userid, $course); $maxgrd = get_maxgrade($userid, $course, $attforblock);
if ($maxgrd == 0) { if ($maxgrd == 0) {
$result = 0; $result = 0;
} else { } else {
$result = get_grade($userid, $course) / $maxgrd * 100; $result = get_grade($userid, $course, $attforblock) / $maxgrd * 100;
} }
if ($result < 0) { if ($result < 0) {
$result = 0; $result = 0;
@ -221,20 +227,20 @@ function print_row($left, $right) {
function print_attendance_table($user, $course, $attforblock) { function print_attendance_table($user, $course, $attforblock) {
$complete = get_attendance($user->id, $course); $complete = get_attendance($user->id, $course, $attforblock);
echo '<table border="0" cellpadding="0" cellspacing="0" class="list">'; echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
print_row(get_string('sessionscompleted','attforblock').':', "<strong>$complete</strong>"); print_row(get_string('sessionscompleted','attforblock').':', "<strong>$complete</strong>");
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
foreach($statuses as $st) { foreach($statuses as $st) {
print_row($st->description.': ', '<strong>'.get_attendance($user->id, $course, $st->id).'</strong>'); print_row($st->description.': ', '<strong>'.get_attendance($user->id, $course, $attforblock, $st->id).'</strong>');
} }
if ($attforblock->grade) { if ($attforblock->grade) {
$percent = get_percent($user->id, $course).'&nbsp;%'; $percent = get_percent($user->id, $course, $attforblock).'&nbsp;%';
$grade = get_grade($user->id, $course); $grade = get_grade($user->id, $course, $attforblock);
print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>"); print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>");
print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course)); print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course, $attforblock));
} }
print_row('&nbsp;', '&nbsp;'); print_row('&nbsp;', '&nbsp;');
echo '</table>'; echo '</table>';
@ -263,30 +269,31 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
echo '<font size="+1"><b>'.fullname($user).'</b></font>'; echo '<font size="+1"><b>'.fullname($user).'</b></font>';
if ($course) { if ($course) {
echo '<hr />'; echo '<hr />';
$complete = get_attendance($user->id, $course); $complete = get_attendance($user->id, $course, $attforblock);
if($complete) { if($complete) {
print_attendance_table($user, $course, $attforblock); print_attendance_table($user, $course, $attforblock);
} else { } else {
echo get_string('attendancenotstarted','attforblock'); echo get_string('attendancenotstarted','attforblock');
} }
} else { } else {
$stqry = "SELECT ats.id,ats.courseid $stqry = "SELECT ats.id,ats.courseid AS 'cid',ats.attendanceid AS 'aid'
FROM {attendance_log} al FROM {attendance_log} al
JOIN {attendance_sessions} ats JOIN {attendance_sessions} ats
ON al.sessionid = ats.id ON al.sessionid = ats.id
WHERE al.studentid = {$user->id} WHERE al.studentid = ?
GROUP BY ats.courseid GROUP BY cid
ORDER BY ats.courseid asc"; ORDER BY cid,aid asc";
$recs = $DB->get_records_sql_menu($stqry); $recs = get_records_sql($stqry, array($user->id));
foreach ($recs as $id => $courseid) { foreach ($recs as $rec) {
echo '<hr />'; echo '<hr />';
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="list1">'; echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="list1">';
$nextcourse = $DB->get_record('course', array('id'=> $courseid)); $nextcourse = $DB->get_record('course', array('id'=> $rec['cid']));
echo '<tr><td valign="top"><strong>'.$nextcourse->fullname.'</strong></td>'; $nextattendance = $DB->get_record('attforblock', array('id'=> $rec['aid']));
echo '<tr><td valign="top"><strong>'.$nextcourse->fullname.' - '.$nextattendance->name . '</strong></td>';
echo '<td align="right">'; echo '<td align="right">';
$complete = get_attendance($user->id, $nextcourse); $complete = get_attendance($user->id, $nextcourse, $nextattendance);
if($complete) { if($complete) {
print_attendance_table($user, $nextcourse, $attforblock); print_attendance_table($user, $nextcourse, $nextattendance);
} else { } else {
echo get_string('attendancenotstarted','attforblock'); echo get_string('attendancenotstarted','attforblock');
} }
@ -393,6 +400,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect
$link = $url . "?id=$id" . ($sort ? "&amp;sort=$sort" : "") . ($studentid ? "&amp;student=$studentid" : ""); $link = $url . "?id=$id" . ($sort ? "&amp;sort=$sort" : "") . ($studentid ? "&amp;student=$studentid" : "");
$currentgroup = -1; $currentgroup = -1;
$sessiontypeselector = '';
if ($printselector === GROUP_SELECTOR) { if ($printselector === GROUP_SELECTOR) {
$groupmode = groups_get_activity_groupmode($cm); $groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true); $currentgroup = groups_get_activity_group($cm, true);

33
manage.php

@ -10,7 +10,7 @@
$from = optional_param('from', PARAM_ACTION); $from = optional_param('from', PARAM_ACTION);
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show $view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 0, PARAM_INT); $current = optional_param('current', 0, PARAM_INT);
$showendtime = optional_param('showendtime', get_user_preferences("attforblock_showendtime",0), PARAM_INT);
if (! $cm = $DB->get_record('course_modules', array('id'=> $id))) { if (! $cm = $DB->get_record('course_modules', array('id'=> $id))) {
error('Course Module ID was incorrect'); error('Course Module ID was incorrect');
} }
@ -43,15 +43,17 @@
!has_capability('mod/attforblock:changeattendances', $context)) { !has_capability('mod/attforblock:changeattendances', $context)) {
redirect("view.php?id=$cm->id"); redirect("view.php?id=$cm->id");
} }
set_user_preference("attforblock_showendtime",$showendtime);
//if teacher is coming from block, then check for a session exists for today //if teacher is coming from block, then check for a session exists for today
if($from === 'block') { if($from === 'block') {
$today = time(); // because we compare with database, we don't need to use usertime() $today = time(); // because we compare with database, we don't need to use usertime()
$sql = "SELECT id, groupid, lasttaken $sql = "SELECT id, groupid, lasttaken
FROM {attendance_sessions} FROM {attendance_sessions}
WHERE ? BETWEEN sessdate AND (sessdate + duration) WHERE ? BETWEEN sessdate AND (sessdate + duration)
AND courseid = $course->id"; AND courseid = ? AND attendanceid = ?";
if($atts = $DB->get_records_sql($sql, array($today))) { if($atts = $DB->get_records_sql($sql, array($today, $course->id, $attforblock->id))) {
$size = count($atts); $size = count($atts);
if ($size == 1) { if ($size == 1) {
$att = reset($atts); $att = reset($atts);
@ -76,24 +78,24 @@
print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname); print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
if(!$DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate >= ?", array($course->id, $course->startdate))) { // no session exists for this course if(!$DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate >= ?", array($course->id, $attforblock->id, $course->startdate))) { // no session exists for this course
show_tabs($cm, $context); show_tabs($cm, $context);
print_heading(get_string('nosessionexists','attforblock')); print_heading(get_string('nosessionexists','attforblock'));
$hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate < ?", array($course->id, $course->startdate)); $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate < ?", array($course->id, $attforblock->id, $course->startdate));
echo '<div align="left">'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: fix '--' echo '<div align="left">'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: fix '--'
echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div>'; echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div>';
} else { //sessions generated , display them } else { //sessions generated , display them
add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname); add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname);
show_tabs($cm, $context); show_tabs($cm, $context);
print_sessions_list($course); print_sessions_list($course, $attforblock);
} }
// require_once('lib.php'); // require_once('lib.php');
// $t = attforblock_get_user_grades($attforblock); //////////////////////////////////////////// // $t = attforblock_get_user_grades($attforblock); ////////////////////////////////////////////
print_footer($course); print_footer($course);
function print_sessions_list($course) { function print_sessions_list($course, $attforblock) {
global $CFG, $context, $cm, $current, $view, $id, $DB; global $CFG, $context, $cm, $current, $view, $id, $showendtime, $DB;
$strhours = get_string('hours'); $strhours = get_string('hours');
$strmins = get_string('min'); $strmins = get_string('min');
@ -109,20 +111,20 @@ function print_sessions_list($course) {
$currentgroup = $ret['currentgroup']; $currentgroup = $ret['currentgroup'];
if ($startdate && $enddate) { if ($startdate && $enddate) {
$where = "courseid=:cid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate";
} else { } else {
$where = "courseid=:cid AND sessdate >= :sdate"; $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate";
} }
if ($currentgroup > -1) { if ($currentgroup > -1) {
$where .= " AND groupid=:cgroup"; $where .= " AND groupid=:cgroup";
} }
$qry = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate asc'); $qry = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid' => $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate asc');
$i = 0; $i = 0;
$table->width = '100%'; $table->width = '100%';
//$table->tablealign = 'center'; //$table->tablealign = 'center';
$table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('time'), get_string('duration', 'attforblock'), get_string('description','attforblock'), get_string('actions'), get_string('select')); $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('from'), ($showendtime=='0') ? get_string('duration', 'attforblock') : get_string('to'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
$table->align = array('', '', '', 'right', 'left', 'center', 'center'); $table->align = array('', '', '', 'right', 'left', 'center', 'center');
$table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px'); $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
@ -170,17 +172,18 @@ function print_sessions_list($course) {
$hours = floor($sessdata->duration / HOURSECS); $hours = floor($sessdata->duration / HOURSECS);
$mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS); $mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
$mins = $mins < 10 ? "0$mins" : "$mins"; $mins = $mins < 10 ? "0$mins" : "$mins";
$table->data[$sessdata->id][] = $hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}"; $table->data[$sessdata->id][] = ($showendtime=='0') ? ($hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}") : userdate($sessdata->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock'));;
$table->data[$sessdata->id][] = $desc; $table->data[$sessdata->id][] = $desc;
$table->data[$sessdata->id][] = $actions; $table->data[$sessdata->id][] = $actions;
$table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />'; $table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />';
unset($desc, $actions); unset($desc, $actions);
} }
} }
echo '<div align="center"><div class="generalbox attwidth">'; echo '<div align="center"><div class="generalbox attwidth">';
echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&amp;sessionid={$sessdata->id} echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&amp;sessionid={$sessdata->id}
print_table($table); print_table($table);
$hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate < ?", array($course->id,$course->startdate)); $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate < ?", array($course->id, $attforblock->id, $course->startdate));
echo '<table width="100%"><tr><td valign="top">'; echo '<table width="100%"><tr><td valign="top">';
echo '<div align="left">'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: Change '--' echo '<div align="left">'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: Change '--'
echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div></td>'; echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div></td>';

16
report.php

@ -74,9 +74,9 @@
$currentgroup = $ret['currentgroup']; $currentgroup = $ret['currentgroup'];
if ($startdate && $enddate) { if ($startdate && $enddate) {
$where = "courseid=:cid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate";
} else { } else {
$where = "courseid=:cid AND sessdate >= :sdate"; $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate";
} }
if ($currentgroup) { if ($currentgroup) {
@ -86,12 +86,12 @@
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false);
} }
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
$allstatuses = get_statuses($course->id, false); $allstatuses = get_statuses($attforblock->id, false);
if ($students and if ($students and
($course_sess = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate ASC'))) { ($course_sess = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid'=> $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate ASC'))) {
$firstname = "<a href=\"report.php?id=$id&amp;sort=firstname\">".get_string('firstname').'</a>'; $firstname = "<a href=\"report.php?id=$id&amp;sort=firstname\">".get_string('firstname').'</a>';
$lastname = "<a href=\"report.php?id=$id&amp;sort=lastname\">".get_string('lastname').'</a>'; $lastname = "<a href=\"report.php?id=$id&amp;sort=lastname\">".get_string('lastname').'</a>';
@ -179,11 +179,11 @@
} }
} }
foreach($statuses as $st) { foreach($statuses as $st) {
$table->data[$student->id][] = get_attendance($student->id, $course, $st->id); $table->data[$student->id][] = get_attendance($student->id, $course, $attforblock, $st->id);
} }
if ($attforblock->grade) { if ($attforblock->grade) {
$table->data[$student->id][] = get_grade($student->id, $course).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course); $table->data[$student->id][] = get_grade($student->id, $course, $attforblock).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course, $attforblock);
$table->data[$student->id][] = get_percent($student->id, $course).'%'; $table->data[$student->id][] = get_percent($student->id, $course, $attforblock).'%';
} }
} }
print_table($table); print_table($table);

12
restorelib.php

@ -13,9 +13,9 @@
//Now get completed xmlized object //Now get completed xmlized object
$info = $data->info; $info = $data->info;
if ($DB->count_records('attforblock', array('course'=> $restore->course_id))) { /*if (count_records('attforblock', 'course', $restore->course_id)) {
return false; return false;
} }*/
//Now, build the attforblock record structure //Now, build the attforblock record structure
$attforblock->course = $restore->course_id; $attforblock->course = $restore->course_id;
@ -67,6 +67,7 @@
//Now, build the attforblock_SESSIONS record structure //Now, build the attforblock_SESSIONS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']); $stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']);
$group = restore_group_getid($restore, $stat->groupid); $group = restore_group_getid($restore, $stat->groupid);
if ($group) { if ($group) {
@ -117,6 +118,7 @@
//Now, build the attforblock_STATUS record structure //Now, build the attforblock_STATUS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
$stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
$stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
@ -139,6 +141,7 @@
//Now, build the attforblock_STATUS record structure //Now, build the attforblock_STATUS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
$stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
$stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
@ -159,6 +162,7 @@
foreach($stats as $stat) { foreach($stats as $stat) {
// $stat = $stats[$i]; // $stat = $stats[$i];
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$newid = $DB->insert_record('attendance_statuses', $stat); $newid = $DB->insert_record('attendance_statuses', $stat);
$oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid; $oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid;
// $i++; // $i++;
@ -182,9 +186,9 @@
@$logs = $info['MOD']['#']['ATTFORBLOCK_LOG']['0']['#']['ROWS']; @$logs = $info['MOD']['#']['ATTFORBLOCK_LOG']['0']['#']['ROWS'];
} }
$stats = $DB->get_records_menu('attendance_statuses', array('courseid'=> $restore->course_id)); $stats = $DB->get_records_menu('attendance_statuses', array('attendanceid'=> $new_attforblock_id));
$statslist = implode(',', array_keys($stats)); $statslist = implode(',', array_keys($stats));
$sessions = $DB->get_records('attendance_sessions', 'courseid', $restore->course_id); $sessions = $DB->get_records('attendance_sessions', array('attendanceid'=> $new_attforblock_id));
//Iterate over logs //Iterate over logs
for($i = 0; $i < sizeof($logs); $i++) { for($i = 0; $i < sizeof($logs); $i++) {

5
sessions.php

@ -60,6 +60,7 @@
if (isset($fromform->addmultiply)) { if (isset($fromform->addmultiply)) {
$startdate = $fromform->sessiondate;// + $fromform->stime['hour']*3600 + $fromform->stime['minute']*60; $startdate = $fromform->sessiondate;// + $fromform->stime['hour']*3600 + $fromform->stime['minute']*60;
$starttime = $startdate - usergetmidnight($startdate);
$enddate = $fromform->sessionenddate + ONE_DAY; // because enddate in 0:0am $enddate = $fromform->sessionenddate + ONE_DAY; // because enddate in 0:0am
//get number of days //get number of days
@ -91,7 +92,8 @@
// continue; // continue;
// } // }
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->sessdate = $sdate; $rec->attendanceid = $attforblock->id;
$rec->sessdate = usergetmidnight($sdate) + $starttime;
$rec->duration = $duration; $rec->duration = $duration;
$rec->description = $fromform->sdescription; $rec->description = $fromform->sdescription;
$rec->timemodified = $now; $rec->timemodified = $now;
@ -117,6 +119,7 @@
} else { } else {
// insert one session // insert one session
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->attendanceid = $attforblock->id;
$rec->sessdate = $fromform->sessiondate; $rec->sessdate = $fromform->sessiondate;
$rec->duration = $duration; $rec->duration = $duration;
$rec->description = $fromform->sdescription; $rec->description = $fromform->sdescription;

19
styles.php

@ -26,6 +26,25 @@
width:90%; width:90%;
} }
body#mod-attforblock-attendances table.controls {
width: 100%;
text-align: center;
}
body#mod-attforblock-attendances table.controls tr {
vertical-align: top;
}
body#mod-attforblock-attendances table.controls td.right, body#mod-attforblock-attendances table.controls td.left {
padding-bottom: 4px;
padding-left: 4px;
padding-right: 4px;
padding-top: 4px;
}
body#mod-attforblock-attendances table.controls .right {
text-align: right;
}
/* for IE7*/ /* for IE7*/
.attfiltercontrols td { .attfiltercontrols td {
padding:6px; padding:6px;

4
version.php

@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php /// This fragment is called by moodle_needs_upgrading() and /admin/index.php
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
$module->version = 2010070900; // The current module version (Date: YYYYMMDDXX) $module->version = 2010123003; // The current module version (Date: YYYYMMDDXX)
$module->release = '2.2.0'; $module->release = '2.2.1';
$module->cron = 0; // Period for cron to check this module (secs) $module->cron = 0; // Period for cron to check this module (secs)
?> ?>

Loading…
Cancel
Save