Skip to content

Commit

Permalink
CCLE-5258 - bug fix and add code for grading all enroll students
Browse files Browse the repository at this point in the history
  • Loading branch information
nbawzl2004 committed Jul 24, 2015
1 parent 6d93189 commit 6a67453
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
24 changes: 19 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,28 @@ function zoom_update_grades(stdClass $zoom, $userid = 0) {

// Populate array of grade objects indexed by userid.
$grademax = grade_get_grades($zoom->course, 'mod', 'zoom', $zoom->id)->items[0]->grademax;
$grades = array('rawgrade' => $grademax,
'userid' => $USER->id,
'usermodified' => $USER->id,
if ($userid != 0) {
$grades = array('rawgrade' => $grademax,
'userid' => $userid,
'usermodified' => $userid,
'dategraded' => '',
'feedbackformat' => '',
'feedback' => '');

grade_update('mod/zoom', $zoom->course, 'mod', 'zoom', $zoom->id, 0, $grades);
grade_update('mod/zoom', $zoom->course, 'mod', 'zoom', $zoom->id, 0, $grades);
} else {
// Assign full credits for all users.
$context = context_course::instance($zoom->course);
$enrollusers = get_enrolled_users($context);
foreach ($enrollusers as $user) {
$grades = array('rawgrade' => $grademax,
'userid' => $user->id,
'usermodified' => $USER->id,
'dategraded' => '',
'feedbackformat' => '',
'feedback' => '');
grade_update('mod/zoom', $zoom->course, 'mod', 'zoom', $zoom->id, 0, $grades);
}
}
}

/* File API */
Expand Down
18 changes: 7 additions & 11 deletions loadmeeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@

require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir . '/gradelib.php');
require_once($CFG->libdir . '/moodlelib.php');

$id = optional_param('id', 0, PARAM_INT); // Course_module ID.
$id = required_param('id', PARAM_INT); // Course_module ID.
if ($id) {
$cm = get_coursemodule_from_id('zoom', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$course = get_course($cm->course);
$zoom = $DB->get_record('zoom', array('id' => $cm->instance), '*', MUST_EXIST);
} else if ($n) {
$zoom = $DB->get_record('zoom', array('id' => $n), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $zoom->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('zoom', $zoom->id, $course->id, false, MUST_EXIST);
} else {
error('You must specify a course_module ID or an instance ID');
error('You must specify a course_module ID');
}

require_login($course, true, $cm);
Expand All @@ -52,10 +49,9 @@
$gradelist = grade_get_grades($course->id, 'mod', 'zoom', $cm->instance, $USER->id);
// Assign full credits for user who has no grade yet.
if (empty($gradelist->items[0]->grades[$USER->id]->grade)) {
zoom_update_grades($zoom, 0);
zoom_update_grades($zoom, $USER->id);
}

// Redirect user to join zoom meeting.
$joinurl = new moodle_url($zoom->join_url, array('uname' => $USER->firstname.' '.$USER->lastname));
redirect($joinurl);
exit();
$joinurl = new moodle_url($zoom->join_url, array('uname' => fullname($USER)));
redirect($joinurl);

0 comments on commit 6a67453

Please sign in to comment.