-
Notifications
You must be signed in to change notification settings - Fork 0
/
getgrades.php
66 lines (52 loc) · 2.64 KB
/
getgrades.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
<?php
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
require_once(dirname(__FILE__) . '/sort_grade_form.php');
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
$cm = get_coursemodule_from_id('sort', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$sort = $DB->get_record('sort', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
//Get users enrolled in the course.
$enrols = $DB->get_records('enrol',array('courseid' => $course->id));
$enrolids = array_keys($enrols);
$enrolments = $DB->get_records_list('user_enrolments','enrolid', $enrolids);
$userids = array();
foreach ($enrolments as $enrolment) {
$userids[] = $enrolment->userid;
}
$users = $DB->get_records_list('user','id', $userids);
// Get counts of sort records for each student and apply them to the $users array
$problems = $DB->get_records('sort_problem', array('sid' => $sort->id));
$studentworks = $DB->get_records_list('sort_studentwork', 'pid', array_keys($problems));
$classifications = $DB->get_records_list('sort_classification', 'swid', array_keys($studentworks));
$mform = new sort_grade_form("/mod/sort/setgrades.php?id={$cm->id}", array('problems' => $problems, 'studentworks' => $studentworks, 'classifications' => $classifications, 'users' => $users));
if ($results = $mform->get_data()) {
}
add_to_log($course->id, 'sort', 'view', "setgrades.php?id={$cm->id}", $sort->name, $cm->id);
$PAGE->set_url('/mod/sort/setgrades.php', array('id' => $cm->id));
$PAGE->set_title(format_string('Setting Grades for ' . $sort->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
$PAGE->requires->css('/mod/sort/css/sort.css');
echo $OUTPUT->header();
foreach ($classifications as $classification) {
if (isset($users[$classification->uid])) {
$users[$classification->uid]->classifications +=1;
if (!is_null($classification->commenttext)) {
$users[$classification->uid]->comments += 1;
}
}
}
foreach ($users as $user) {
echo '<div class="sort-grade-user-box">';
echo "<h3 class='sort-grade-user-box-header'>$user->username</h3>";
echo "# of Classifications: $user->classifications";
echo "<br /># of Comments: $user->comments";
echo '</div>';
}
echo "<div class='sort-action-links'>";
echo "<span><a href='/grade/report/grader/index.php?id=$course->id'>Back to the Course Grading Page</a></span>";
echo "</div>";
echo $OUTPUT->footer();