Example #1
0
 * @copyright  2015 UC Regents
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->libdir . '/moodlelib.php';
$id = required_param('id', PARAM_INT);
// Course_module ID.
if ($id) {
    $cm = get_coursemodule_from_id('zoom', $id, 0, false, MUST_EXIST);
    $course = get_course($cm->course);
    $zoom = $DB->get_record('zoom', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
    error('You must specify a course_module ID');
}
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
require_capability('mod/zoom:view', $context);
// Check whether user had a grade. If no, then assign full credits to him or her.
$gradelist = grade_get_grades($course->id, 'mod', 'zoom', $cm->instance, $USER->id);
// Assign full credits for user who has no grade yet, if this meeting is gradable
// (i.e. the grade type is not "None").
if (!empty($gradelist->items) && empty($gradelist->items[0]->grades[$USER->id]->grade)) {
    $grademax = $gradelist->items[0]->grademax;
    $grades = array('rawgrade' => $grademax, 'userid' => $USER->id, 'usermodified' => $USER->id, 'dategraded' => '', 'feedbackformat' => '', 'feedback' => '');
    zoom_grade_item_update($zoom, $grades);
}
// Redirect user to join zoom meeting.
$joinurl = new moodle_url($zoom->join_url, array('uname' => fullname($USER)));
redirect($joinurl);
Example #2
0
/**
 * Update zoom grades in the gradebook
 *
 * Needed by {@link grade_update_mod_grades()}.
 *
 * @param stdClass $zoom instance object with extra cmidnumber and modname property
 * @param int $userid update grade of specific user only, 0 means all participants
 */
function zoom_update_grades(stdClass $zoom, $userid = 0)
{
    global $CFG;
    require_once $CFG->libdir . '/gradelib.php';
    // Populate array of grade objects indexed by userid.
    if ($zoom->grade == 0) {
        zoom_grade_item_update($zoom);
    } else {
        if ($userid != 0) {
            $grade = grade_get_grades($zoom->course, 'mod', 'zoom', $zoom->id, $userid)->items[0]->grades[$userid];
            $grade->userid = $userid;
            if ($grade->grade == -1) {
                $grade->grade = null;
            }
            zoom_grade_item_update($zoom, $grade);
        } else {
            if ($userid == 0) {
                $context = context_course::instance($zoom->course);
                $enrollusersid = array_keys(get_enrolled_users($context));
                $grades = grade_get_grades($zoom->course, 'mod', 'zoom', $zoom->id, $enrollusersid)->items[0]->grades;
                foreach ($grades as $k => $v) {
                    $grades[$k]->userid = $k;
                    if ($v->grade == -1) {
                        $grades[$k]->grade = null;
                    }
                }
                zoom_grade_item_update($zoom, $grades);
            } else {
                zoom_grade_item_update($zoom);
            }
        }
    }
}