You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.8 KiB

<?PHP // $Id: view.php,v 1.3.2.2 2009/02/23 19:22:41 dlnsk Exp $
/// This page prints a particular instance of attforblock
/// (Replace attforblock with the name of your module)
require_once("../../config.php");
require_once('locallib.php');
$id = optional_param('id', -1, PARAM_INT); // Course Module ID, or
// $a = optional_param('a', -1, PARAM_INT); // attforblock ID
$studentid = optional_param('student', 0, PARAM_INT);
$printing = optional_param('printing', 0, PARAM_INT);
$mode = optional_param('mode', 'thiscourse', PARAM_ALPHA);
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 0, PARAM_INT);
if ($id) {
if (! $cm = $DB->get_record("course_modules", array("id"=> $id))) {
error("Course Module ID was incorrect");
}
if (! $course = $DB->get_record("course", array("id"=> $cm->course))) {
error("Course is misconfigured");
}
if (! $attforblock = $DB->get_record("attforblock", array("id"=> $cm->instance))) {
error("Course module is incorrect");
}
} else {
error("Module id is incorrect.");
// if (! $attforblock = get_record("attforblock", "id", $a)) {
// error("Course module is incorrect");
// }
// if (! $course = get_record("course", "id", $attforblock->course)) {
// error("Course is misconfigured");
// }
// if (! $cm = get_coursemodule_from_instance("attforblock", $attforblock->id, $course->id)) {
// error("Course Module ID was incorrect");
// }
}
require_login($course->id);
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
print_error('badcontext');
}
if (!$studentid && (has_capability('mod/attforblock:manageattendances', $context) ||
has_capability('mod/attforblock:takeattendances', $context) ||
has_capability('mod/attforblock:changeattendances', $context))) {
redirect("manage.php?id=$cm->id");
}
if (!$studentid && has_capability('mod/attforblock:viewreports', $context)) {
redirect("report.php?id=$cm->id");
}
if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
error("No such user in this course");
}
if ($view)
set_current_view($course->id, $_GET['view']);
else
$view = get_current_view($course->id, 'months');
require_capability('mod/attforblock:view', $context);
$student = false;
if ($studentid) {
if ($studentid == $USER->id or has_capability('mod/attforblock:viewreports', $context)) {
if (!$student = $DB->get_record('user', array('id'=> $studentid) )) {
error("No such user in this course");
}
}
}
// if (empty($student) && has_capability('mod/attforblock:manageattendances', $context)) {
// redirect("manage.php?id=$cm->id");
// }
if ($student) {
$user = $student;
}
if ($printing) {
if ($mode === 'thiscourse') {
print_header('', $course->fullname.' - '.get_string('attendancereport','attforblock'));
print_user_attendaces($user, $cm, $attforblock, $course, 'printing');
} else {
print_header('', get_string('attendancereport','attforblock'));
print_user_attendaces($user, $cm, $attforblock, 0, 'printing');
}
exit();
}
/// Print headers
$navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activityinstance');
$navlinks[] = array('name' => get_string('attendancereport', 'attforblock'), 'link' => null, 'type' => 'title');
$navigation = build_navigation($navlinks);
print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('export', 'quiz'), $course->fullname,
$navigation, "", "", true, "&nbsp;", navmenu($course));
//add info to log
add_to_log($course->id, 'attendance', 'student view', "mod/attforblock/view.php?course=$course->id&amp;student=$USER->id", $USER->lastname.' '.$USER->firstname);
// print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
/// Prints out tabs
$currenttab = $mode;
$studstr = $student ? '&amp;student='.$student->id : '';
$toprow = array();
$toprow[] = new tabobject('thiscourse', "view.php?id=$id&amp;mode=thiscourse{$studstr}",
get_string('thiscourse','attforblock'));
$toprow[] = new tabobject('allcourses', "view.php?id=$id&amp;mode=allcourses{$studstr}",
get_string('allcourses','attforblock'));
print_tabs(array($toprow), $currenttab);
if ($mode === 'thiscourse') {
print_user_attendaces($user, $cm, $attforblock, $course);
} else {
print_user_attendaces($user, $cm, $attforblock);
}
print_footer($course);
?>