diff --git a/attendances.php b/attendances.php index fa2588f..e1fa7ab 100644 --- a/attendances.php +++ b/attendances.php @@ -59,7 +59,7 @@ $i++; } } - $attforblockrecord = $DB->get_record('attforblock', array('course' => $course->id)); + $attforblockrecord = $DB->get_record('attforblock', array('attendanceid' => $attforblock->id)); foreach($students as $student) { if ($log = $DB->get_record('attendance_log', array('sessionid' => $sessionid, 'studentid'=> $student->studentid))) { @@ -79,11 +79,22 @@ } /// Print headers - $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity'); + $url = new moodle_url('/mod/attforblock/manage.php', array('id'=> $id, 'sessionid'=> $sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort, 'copyfrom' => $copyfrom)); + $PAGE->set_url($url); + $PAGE->set_title($course->shortname. ": ".$attforblock->name . ' - ' .get_string('update','attforblock')); + $PAGE->set_heading($course->fullname); + $PAGE->set_focuscontrol(''); + $PAGE->set_cacheable(true); + $PAGE->set_button($OUTPUT->update_module_button($cm->id,'attforblock')); + $PAGE->navbar->add($attforblock->name); + + echo $OUTPUT->header(); + + /*$navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity'); $navlinks[] = array('name' => get_string('update', 'attforblock'), 'link' => null, 'type' => 'activityinstance'); $navigation = build_navigation($navlinks); print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('update','attforblock'), $course->fullname, - $navigation, "", "", true, " ", navmenu($course)); + $navigation, "", "", true, " ", navmenu($course));*/ //check for hack if (!$sessdata = $DB->get_record('attendance_sessions', array('id'=> $sessionid))) { @@ -97,7 +108,7 @@ print_heading(get_string('update','attforblock').' ' .get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname.$help); } else { require_capability('mod/attforblock:takeattendances', $context); - print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname.$help); + echo $OUTPUT->heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname.$help); } /// find out current groups mode @@ -105,7 +116,7 @@ $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); + $attforblockrecord = $DB->get_record('attforblock', array('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); @@ -123,7 +134,7 @@ echo ''; //echo '
'; $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); - $dataurl = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; + $dataurl = "/mod/attforblock/attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { $dataurl = $dataurl . "&group=$group"; } @@ -141,29 +152,32 @@ } $optionssessions[$sessdatarow->id] = $descr; } - popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + //popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'sessionid',$optionssessions, $sessionid); echo "
"; } $dataurl .= "&sessionid=$sessionid"; echo '
"; - popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); + //popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); + echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'view',$options, $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, ''); + //popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, ''); + echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'view'=>$view, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'gridcols',$options, $gridcols); } echo '
';//'; if ($grouptype === 0) { if ($currentgroup) { - $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); + $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', $currentgroup, '', false); } else { - $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); + $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', '', '', false); } } else { - $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $grouptype, '', false); + $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', $grouptype, '', false); } $sort = $sort == 'firstname' ? 'firstname' : 'lastname'; @@ -180,6 +194,7 @@ $statuses = get_statuses($attforblock->id); $i = 3; + $tabhead = array(); foreach($statuses as $st) { switch($view) { case SORTEDLISTVIEW: @@ -269,7 +284,7 @@ $currentstatusid = $att===false ? -1 : $att->statusid; $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); foreach($statuses as $st) { - $data = $data . 'id == $currentstatusid ? 'checked' : '').'>' . $st->acronym . " "; + $data = $data . 'id == $currentstatusid ? 'checked' : '').'> ' . $st->acronym . " "; } $table->data[($i-1) / ($gridcols)][] = $data; } @@ -288,7 +303,8 @@ if (count($todaysessions)>1) { echo '
'; echo '"; - popup_form("$dataurl©from=", $optionssessions, 'copysessionmenu', $sessionid, ''); + //popup_form("$dataurl©from=", $optionssessions, 'copysessionmenu', $sessionid, ''); + echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'copyfrom',$optionssessions, $sessionid); echo '
'; } @@ -301,6 +317,6 @@ echo $st->acronym.' - '.$st->description.'
'; } - print_footer($course); + $OUTPUT->footer($course); ?> diff --git a/db/access.php b/db/access.php index 2e4b6c4..ac53edc 100644 --- a/db/access.php +++ b/db/access.php @@ -40,8 +40,7 @@ $mod_attforblock_capabilities = array( 'legacy' => array( 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -53,8 +52,7 @@ $mod_attforblock_capabilities = array( 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -66,8 +64,7 @@ $mod_attforblock_capabilities = array( 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -79,8 +76,7 @@ $mod_attforblock_capabilities = array( 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( 'teacher' => CAP_ALLOW, - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -91,8 +87,7 @@ $mod_attforblock_capabilities = array( 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -103,8 +98,7 @@ $mod_attforblock_capabilities = array( 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW ) ), @@ -115,8 +109,19 @@ $mod_attforblock_capabilities = array( 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( - 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'editingteacher' => CAP_ALLOW + ) + ), + + + 'mod/attforblock:canbelisted' => array( + + 'riskbitmask' => RISK_PERSONAL, + + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'legacy' => array( + 'student' => CAP_ALLOW ) ) ); diff --git a/db/install.xml b/db/install.xml index 36f9da5..ca2c123 100644 --- a/db/install.xml +++ b/db/install.xml @@ -6,10 +6,10 @@ - - - - + + + + @@ -20,16 +20,16 @@
- - - - - - - - - - + + + + + + + + + + @@ -43,14 +43,14 @@
- - - - - - - - + + + + + + + + @@ -63,14 +63,14 @@
- - - - - - - - + + + + + + + + diff --git a/db/upgrade.php b/db/upgrade.php index 997470f..23d7d88 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -241,11 +241,11 @@ function xmldb_attforblock_upgrade($oldversion=0) { $table = new xmldb_table('attendance_sessions'); $field = new xmldb_field('attendanceid'); - $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid'); + $field->set_attributes(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')); + $index->set_attributes(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"; @@ -254,10 +254,10 @@ function xmldb_attforblock_upgrade($oldversion=0) { $table = new xmldb_table('attendance_statuses'); $field = new xmldb_field('attendanceid'); - $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); + $field->set_attributes(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')); + $index->set_attributes(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"; diff --git a/lang/en/attforblock.php b/lang/en/attforblock.php index 718d49b..656eff6 100644 --- a/lang/en/attforblock.php +++ b/lang/en/attforblock.php @@ -24,6 +24,7 @@ $string['attendancepercent'] = 'Attendance percent'; $string['attendancereport'] = 'Attendance report'; $string['attendancesuccess'] = 'Attendance has been successfully taken'; $string['attendanceupdated'] = 'Attendance successfully updated'; +$string['attforblock:canbelisted'] = 'Appears in the roster'; $string['attforblock:changepreferences'] = 'Changing Preferences'; $string['attforblock:changeattendances'] = 'Changing Attendances'; $string['attforblock:export'] = 'Export Reports'; diff --git a/lang/es/attforblock.php b/lang/es/attforblock.php index 37335de..3953bd1 100644 --- a/lang/es/attforblock.php +++ b/lang/es/attforblock.php @@ -24,6 +24,7 @@ $string['attendancepercent'] = 'Porcentaje'; $string['attendancereport'] = 'Informe de Asistencia'; $string['attendancesuccess'] = 'Asistencia tomada con éxito'; $string['attendanceupdated'] = 'Asistencia actualizada con éxito'; +$string['attforblock:canbelisted'] = 'Aparecer en la lista'; $string['attforblock:changeattendances'] = 'Cambiar Asistencias'; $string['attforblock:changepreferences'] = 'Cambiar preferencias'; $string['attforblock:export'] = 'Exportar Informes'; @@ -128,12 +129,12 @@ $string['sortedlist'] = 'Lista alfabética'; $string['startofperiod'] = 'Fecha de comienzo'; $string['status'] = 'Estado'; $string['statusdeleted'] = 'Estado eliminado'; -$string['strftimedm'] = '%%d.%%m'; -$string['strftimedmy'] = '%%d.%%m.%%Y'; -$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; -$string['strftimedmyw'] = '%%d.%%m.%%y (%%a)'; -$string['strftimehm'] = '%%H:%%M'; -$string['strftimeshortdate'] = '%%d.%%m.%%Y'; +$string['strftimedm'] = '%d.%m'; +$string['strftimedmy'] = '%d.%m.%Y'; +$string['strftimedmyhm'] = '%d.%m.%Y %H.%M'; +$string['strftimedmyw'] = '%d.%m.%y (%a)'; +$string['strftimehm'] = '%H:%M'; +$string['strftimeshortdate'] = '%d.%m.%Y'; $string['studentid'] = 'ID de Estudiante'; $string['takeattendance'] = 'Iniciar Asistencia'; $string['thiscourse'] = 'Este curso'; diff --git a/lib.php b/lib.php index 8d1d883..290c11c 100644 --- a/lib.php +++ b/lib.php @@ -33,17 +33,7 @@ function attforblock_add_instance($attforblock) { $attforblock->timemodified = time(); - /*if ($att = get_record('attforblock', 'course', $attforblock->course)) { - $modnum = get_field('modules', 'id', 'name', 'attforblock'); - if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) { - delete_records('attforblock', 'course', $attforblock->course); - $attforblock->id = insert_record('attforblock', $attforblock); - /*} else { - return false; - } - } else {*/ - $attforblock->id = insert_record('attforblock', $attforblock); - //} + $attforblock->id = $DB->insert_record('attforblock', $attforblock); //Copy statuses for new instance from defaults //if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) { diff --git a/locallib.php b/locallib.php index 8a8e298..fbc8f9a 100644 --- a/locallib.php +++ b/locallib.php @@ -54,9 +54,9 @@ function get_statuses($attendanceid, $onlyvisible = true) global $DB; if ($onlyvisible) { - $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid AND visible = 1 AND deleted = 0", 'grade DESC'); + $result = $DB->get_records_select('attendance_statuses', "attendanceid = :aid AND visible = 1 AND deleted = 0", array('aid' => $attendanceid), 'grade DESC'); } else { - $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid AND deleted = 0", 'grade DESC'); + $result = $DB->get_records_select('attendance_statuses', "attendanceid = :aid AND deleted = 0", array('aid' => $attendanceid), 'grade DESC'); // $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC'); } return $result; @@ -128,7 +128,7 @@ function get_maxgrade($userid, $course, $attendance) $maxgrade = 0; if ($logs) { - $stat_grades = records_to_menu(get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade'); + $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade'); foreach ($logs as $log) { $ids = array_flip(explode(',', $log->statusset)); // $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher @@ -283,7 +283,7 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing WHERE al.studentid = ? GROUP BY cid ORDER BY cid,aid asc"; - $recs = get_records_sql($stqry, array($user->id)); + $recs = $DB->get_records_sql($stqry, array($user->id)); foreach ($recs as $rec) { echo '
'; echo '
'; @@ -537,7 +537,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect function plug_yui_calendar($current) { global $CFG; - + require_js(array('yui_dom-event', 'yui_dragdrop', 'yui_element', 'yui_button', 'yui_container', 'yui_calendar')); echo "