/
user.php
261 lines (201 loc) · 11.3 KB
/
user.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Prints a particular instance of scormfull
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package mod
* @subpackage scormfull
* @copyright 2011 Your Name
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/// (Replace scormfull with the name of your module and remove this line)
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
require_once(dirname(__FILE__).'/Computationtime.php');
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
$n = optional_param('n', 0, PARAM_INT); // scormfull instance ID - it should be named as the first character of the module
if ($id) {
$cm = get_coursemodule_from_id('scormfull', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$scormfull = $DB->get_record('scormfull', array('id' => $cm->instance), '*', MUST_EXIST);
$quiz = $DB->get_record('quiz', array("id"=>$scormfull->quid), '*', MUST_EXIST);
}else if ($n) {
$quiz = $DB->get_record('quiz', array('id' => $n), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);
$sql="SELECT * FROM {$CFG->prefix}scormfull WHERE course=$course->id AND quid= $quiz->id";
$scormfull=$DB->get_records_sql($sql);
foreach($scormfull as $value)
{
$scormfull=$value;
}
} else {
error('You must specify a course_module ID or an scormfull ID');
}
require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, "scormfull", "user", "user.php?id=$cm->id", "$scormfull->id");
/// Print the page header
$PAGE->set_url('/mod/scormfull/user.php', array('id' => $cm->id));
$PAGE->set_title(format_string($scormfull->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
// Output starts here
echo $OUTPUT->header();
/// Finish the page
echo $OUTPUT->heading($scormfull->name);
if ($scormfull->intro) { // Conditions to show the intro can change to look for own settings or whatever
echo $OUTPUT->box(format_module_intro('scormfull', $scormfull, $cm->id), 'generalbox mod_introbox', 'scormfullintro');
}
$struen_name = get_string('struen_name','scormfull');
$strthreshold_boo = get_string('threshold_boo','scormfull');
$Thresholdvalue = get_string('Thresholdvalue','scormfull');
$scrom_name = get_string('scrom_name','scormfull');
$starnopass = get_string('starnopass','scormfull');
$connected_exam = get_string('connected_exam','scormfull');
$strsetvalue = get_string('strsetvalue','scormfull');
$cssting = get_string('curriculum_standards_setting','scormfull');
$hours_of_the_event = get_string('hours_of_the_event','scormfull');
$through_standard_assessment = get_string('through_standard_assessment','scormfull');
$scorm_quiz_score = get_string('scorm_quiz_score','scormfull');
$text_test_pass = get_string('text_test_pass','scormfull');
$test_scores = get_string('test_scores','scormfull');
$not_been_exam = get_string('not_been_exam','scormfull');
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($course->format == 'weeks') {
$table->head = array ($struen_name, $strthreshold_boo,$Thresholdvalue,$hours_of_the_event,$through_standard_assessment);
$table->align = array ('center', 'left','left', 'left','left', 'left');
} else if ($course->format == 'topics') {
$table->head = array ($struen_name, $strthreshold_boo,$Thresholdvalue,$hours_of_the_event,$through_standard_assessment);
$table->align = array ('center', 'left', 'left', 'left','left', 'left');
} else {
$table->head = array ($struen_name, $strthreshold_boo,$Thresholdvalue,$hours_of_the_event,$through_standard_assessment);
$table->align = array ('left', 'left', 'left', 'left','left', 'left');
}
$table2 = new html_table();
$table2->attributes['class'] = 'generaltable mod_index';
$table3 = new html_table();
$table3->attributes['class'] = 'generaltable mod_index';
$table3->head = array ($struen_name, $strthreshold_boo,$test_scores,$text_test_pass);
$table3->align = array ('center', 'left','left', 'left');
$table2->head = array ($strsetvalue);
$table2->align = array ('center', 'left');
if(! $scormfull->threshold)
{
$table2->data[] = array (($course->fullname.get_string('Courses_all_scrom_courses','scormfull')));
if (! $scormdata = $DB->get_records("scorm", array("course"=>$course->id))) {
error("The scorm with id $cm->instance corresponding to this scormfull $id is missing");
}
$sql="SELECT count(*) as allcount FROM {$CFG->prefix}scorm_scoes ss ,{$CFG->prefix}scorm sc WHERE ss.scorm=sc.id And sc.course=$course->id AND ss.scormtype = 'sco'";
$all_count=$DB->get_records_sql($sql);
$user_grades_array=(get_quiz_grades($quiz->id));
foreach($all_count as $value)
{
$all_count=$value->allcount;
}
$sum=0;
$calculation_results_sum=0;
foreach($scormdata as $value)
{
$sql="SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified
FROM {$CFG->prefix}scorm_scoes_track st
WHERE st.scormid =$value->id and (value='completed' or value='suspend') and st.userid=$USER->id group by st.scoid";
$getcount=$DB->get_records_sql($sql);
if(!empty($getcount))
{
$sum=$sum+count($getcount);
}
$calculation_results=calculateInteTime(integrate_log($scormfull,$USER->id,$value->id));
$calculation_results_sum=$calculation_results_sum+$calculation_results;
}
$getvalue=round($sum/$all_count, 2);
if($getvalue>=1)
{
$getvalue=1;
}
$setjudg= get_string('starnopass','scormfull');
$threshold_judg= get_string('starnopass','scormfull');
if($getvalue>=((int)$scormfull->thresholdvalue/100))
{
$setjudg= get_string('strpass','scormfull');
$threshold_judg=!$scormfull->report_add ? get_string('strpass','scormfull') : ($calculation_results_sum>=$scormfull->report_value ? get_string('strpass','scormfull') : get_string('starnopass','scormfull'));
}
$table->data[] = array (("<a href=\"$CFG->wwwroot/user/view.php?id={$USER->id}&course=$course->id\">"."{$USER->lastname}{$USER->firstname}</a><br />"),$setjudg,(($getvalue*100)."%"),$calculation_results_sum,!$scormfull->report_add ? "-" : ($calculation_results_sum>=$scormfull->report_value ? get_string('strpass','scormfull'): get_string('starnopass','scormfull')));
$table3->data[] = array (("<a href=\"$CFG->wwwroot/user/view.php?id={$USER->id}&course=$course->id\">"."{$USER->lastname}{$USER->firstname}</a><br />"),$threshold_judg,(!empty($user_grades_array[$USER->id])) ? $user_grades_array[$USER->id]->grade : $not_been_exam,(!empty($user_grades_array[$USER->id])) ? (($user_grades_array[$USER->id]->grade) >= ($scormfull->quid_score)) ? get_string('strpass','scormfull') : get_string('starnopass','scormfull') : "-");
$table2->data[] = array (("$connected_exam : ".$quiz->name));
$table2->data[] = array (("$Thresholdvalue : ".$scormfull->thresholdvalue."%"));
}else
{
if (! $scorm = $DB->get_record("scorm", array("id"=>$scormfull->threshold))) {
error("The scorm with id $cm->instance corresponding to this scormfull $scormfull->threshold is missing");
}
$table2->data[] = array (("$scrom_name : ".$scorm->name));
$sql="SELECT COUNT(*) as count
FROM {$CFG->prefix}scorm_scoes sss
WHERE sss.scorm = $scormfull->threshold
AND sss.scormtype = 'sco'";
$sco_count=0;
$get_countarray=$DB->get_records_sql($sql);
foreach($get_countarray as $value)
{
$sco_count=$value->count;
}
$sql="SELECT st.id,st.userid,st.scormid,st.scoid,st.attempt,st.element,st.value,st.timemodified
FROM {$CFG->prefix}scorm_scoes_track st
WHERE st.scormid =$scormfull->threshold and (value='completed' or value='suspend') and st.userid=$USER->id group by st.scoid";
$getqudata=$DB->get_records_sql($sql);
$user_grades_array=(get_quiz_grades($quiz->id));
$calculation_results=calculateInteTime(integrate_log($scormfull,$USER->id));
if(!empty($getqudata))
{
$getvalue=round(count($getqudata)/$sco_count, 2);
}
if($getvalue>=1)
{
$getvalue=1;
}
$setjudg= get_string('starnopass','scormfull');
$threshold_judg= get_string('starnopass','scormfull');
if($getvalue>=((int)$scormfull->thresholdvalue/100))
{
$setjudg= get_string('strpass','scormfull');
$threshold_judg=!$scormfull->report_add ? get_string('strpass','scormfull') : ($calculation_results>=$scormfull->report_value ? get_string('strpass','scormfull') : get_string('starnopass','scormfull'));
}
// $table->data[] = array (($USER->lastname.$USER->firstname),$setjudg,(($getvalue*100)."%"));
$table->data[] = array (("<a href=\"$CFG->wwwroot/user/view.php?id={$USER->id}&course=$course->id\">"."{$USER->lastname}{$USER->firstname}</a><br />"),$setjudg,(($getvalue*100)."%"), $calculation_results,!$scormfull->report_add ? "-" :($calculation_results>=$scormfull->report_value ? get_string('strpass','scormfull'): get_string('starnopass','scormfull')));
$table3->data[] = array (("<a href=\"$CFG->wwwroot/user/view.php?id={$USER->id}&course=$course->id\">"."{$USER->lastname}{$USER->firstname}</a><br />"),$threshold_judg,(!empty($user_grades_array[$USER->id])) ? $user_grades_array[$USER->id]->grade : $not_been_exam,(!empty($user_grades_array[$USER->id])) ? (($user_grades_array[$USER->id]->grade) >= ($scormfull->quid_score)) ? get_string('strpass','scormfull') : get_string('starnopass','scormfull') : "-");
$table2->data[] = array (("$connected_exam : ".$quiz->name));
$table2->data[] = array (("$Thresholdvalue : ".$scormfull->thresholdvalue."%"));
}
if(!$scormfull->report_add)
{
$report_data=get_string('Not_joined_the_settings','scormfull');
}else{
$report_data="{$scormfull->report_value}".get_string('hours_txt','scormfull');
}
$table2->data[] = array (("$cssting : ".$report_data));
$table2->data[] = array (("$scorm_quiz_score : ".$scormfull->quid_score));
echo html_writer::table($table2);
echo "<p></p>";
echo html_writer::table($table);
echo "<p></p>";
echo html_writer::table($table3);
// Finish the page
echo $OUTPUT->footer();