This repository was archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprint.php
126 lines (103 loc) · 3.63 KB
/
print.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?PHP // $Id: view.php,v 1.25 2004/08/22 14:38:38 gustav_delius Exp $
require_once("../../config.php");
require_once("lib.php");
$strregistrations = get_string("modulenameplural", "registration");
$strregistration = get_string("modulename", "registration");
$strorder = get_string("order", "registration");
$strfirstname = get_string("firstname");
$strlastname = get_string("lastname");
$strdatetext = get_string("datetext", "registration");
$strclosed = get_string("closed", "registration");
$strfull = get_string("full", "registration");
$stranswer = get_string("answer", "registration");
$stranswercancel = get_string("answercancel", "registration");
$strpoints = get_string("points", "registration");
$strnote = get_string("note", "registration");
$stridnumber = get_string("idnumber");
$id = optional_param('id', 0, PARAM_INT); // Course Module ID
//optional_variable($id);// Course Module ID
$version = optional_param('version', 0, PARAM_INT); // print names?
//optional_variable($a);// registration ID
if (! $registration = $DB->get_record("registration", array('id'=>$id)))
print_error("courseincorrect","registration");
if (! $course = $DB->get_record("course", array('id'=>$registration->course)))
print_error("coursemisconfigured","registration");
if (! $cm = get_coursemodule_from_instance("registration", $registration->id, $course->id))
print_error("courseidincorrect","registration");
require_course_login($course);
$context = context_course::instance($course->id);
require_capability('mod/registration:viewlist', $context);
$ismyteacher = has_capability('mod/registration:grade', $context);
$ismystudent = has_capability('mod/registration:view', $context);
if (!empty($CFG->registration_hide_idnumber))
$version = 2;
echo '<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" media="all">
* {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 10pt;}
h1 {font-size: 12pt; text-align: center;};
.generalbox {border: 1px solid;}
.generaltableheader {border: 1px solid;}
.generaltablecell {border: 1px solid;}
</style>
</head>
<body>
';
$strduedate = userdate($registration->timedue);
echo '<h1>'.$course->fullname.": ".$strduedate.'</h1>
<div style="text-align: center; margin: 10px;">'.$registration->name.'</div>
';
$table = new html_table();
$table->attributes['style']="margin-left:auto; margin-right:auto;";
$table->head[] = $strorder;
$table->align[] = "center";
if (empty($CFG->registration_hide_idnumber) && $version<2)
{
$table->head[] = $stridnumber;
$table->align[] = "center";
}
if ($version>0)
{
$table->head[] = $strfirstname;
$table->head[] = $strlastname;
}
if($ismyteacher && $registration->grade)
{
$table->head[] = $strpoints;
$table->align[] = "center";
}
$table->head[] =$strnote;
$table->align[] = "left";
$grades = make_grades_menu($registration->grade);
$students = $DB->get_records("registration_submissions",array('registration'=>$cm->instance));
$i = 0;
if (!$students) $students = array();
foreach ($students as $data)
{
$person = $DB->get_record("user",array('id'=>$data->userid));
$line = array();
$line[] = ++$i;
if (empty($CFG->registration_hide_idnumber) && $version<2)
{
$line[] = $person->idnumber;
}
if ($version>0)
{
$line[] = $person->firstname;
$line[] = $person->lastname;
}
if($ismyteacher && $registration->grade)
{
$line[] = $grades[$data->grade];
}
$line[] = $data->comment;
$table->data[] =$line;
}
echo html_writer::table($table);
echo "
</body>
</html>
";
?>