Beispiel #1
0
 $units = array_slice($units, $startindex, $limit);
 // First set the tbody to have the info for the theader
 $activities = "";
 $unitdetails = "";
 // Just show the registers of one page
 foreach ($units as $unit) {
     // Get the next value of the array
     $row = array();
     if (!($unitname = $DB->get_field_select('rcommon_books_units', 'name', "bookid={$rcontent->bookid} AND id={$unit->unitid}", null, 'name'))) {
         $unitname = $unit->unitid;
     }
     $row[] = $unitname;
     $timetracks = rcontent_get_attempt_runtime($rcontent->id, $user, $attempt, $unit->unitid, '', $unit->starttime);
     $row[] = $timetracks->start;
     $row[] = $timetracks->finish;
     $grade = rcontent_grade_user_attempt($rcontent->id, $user, $attempt, $unit->unitid, '', '', $unit->starttime);
     // Take status value from the 1st position of the array
     if (!empty($grade->status[0])) {
         $row[] = get_string($grade->status[0], 'rcontent');
     } else {
         $row[] = "";
     }
     $row[] = $grade->grade . ' ' . $grade->range;
     $row[] = $grade->comments;
     $conditions = array('rcontentid' => $rcontent->id, 'userid' => $user, 'attempt' => $attempt, 'unitid' => $unit->unitid, 'activityid' => 0);
     $unitdetails = $DB->get_records('rcontent_grades_details', $conditions, 'id');
     if ($unitdetails) {
         $row[] = '<a href="' . $baseurl . '&b=' . $unit->unitid . '&user='******'&attempt=' . $attempt . '&action=details">' . get_string('viewdetails', 'rcontent') . '</a>';
     } else {
         $row[] = "";
     }
Beispiel #2
0
/**
 * Check the score of the request user for the request activity
 * @param $rcontent int -> ID of the activity
 * @param $userid int -> ID of the user
 * @param $time int -> datetime
 * @return int -> the score for that user
 */
function rcontent_grade_user($rcontent, $userid, $from = '')
{
    global $DB;
    // Take the global grade for the given activity
    $sql = "userid={$userid} AND rcontentid={$rcontent->id} AND unitid={$rcontent->unitid} AND activityid={$rcontent->activityid}";
    if (!($grade = $DB->get_records_select('rcontent_grades', $sql))) {
        return 0;
    }
    $grade = current($grade);
    $lastattempt = rcontent_get_last_attempt($rcontent->id, $userid);
    if ($grade->maxattempts != 0 && $lastattempt >= $grade->maxattempts) {
        $lastattempt = $grade->maxattempts;
    }
    switch ($rcontent->whatgrade) {
        case RCONTENT_FIRSTATTEMPT:
            $grade = rcontent_grade_user_attempt($rcontent->id, $userid, 1, $grade->unitid, $grade->activityid);
            if ($from != 'gradebook') {
                return $grade->justgrade . ' ' . $grade->range;
            } else {
                return $grade->justgrade;
            }
            break;
        case RCONTENT_LASTATTEMPT:
            $grade = rcontent_grade_user_attempt($rcontent->id, $userid, $lastattempt, $grade->unitid, $grade->activityid);
            if ($from != 'gradebook') {
                return $grade->justgrade . ' ' . $grade->range;
            } else {
                return $grade->justgrade;
            }
            break;
        case RCONTENT_HIGHESTATTEMPT:
            $maxscore = 0;
            $attempttime = 0;
            for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
                $attemptgrade = rcontent_grade_user_attempt($rcontent->id, $userid, $attempt, $grade->unitid, $grade->activityid);
                $maxscore = $attemptgrade->justgrade > $maxscore ? $attemptgrade->justgrade : $maxscore;
            }
            if ($from != 'gradebook') {
                return $maxscore . ' ' . $attemptgrade->range;
            } else {
                return $attemptgrade->justgrade;
            }
            break;
        case RCONTENT_AVERAGEATTEMPT:
            $sumscore = 0;
            for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
                $attemptgrade = rcontent_grade_user_attempt($rcontent->id, $userid, $attempt, $grade->unitid, $grade->activityid);
                $sumscore += $attemptgrade->justgrade;
            }
            if ($lastattempt > 0) {
                $score = $sumscore / $lastattempt;
            } else {
                $score = 0;
            }
            if ($from != 'gradebook') {
                return $score . ' ' . $attemptgrade->range;
            } else {
                return $attemptgrade->justgrade;
            }
            break;
    }
}
Beispiel #3
0
// Activity Id
// Filter by status, get parameter with the filterby
$filterby = optional_param('filterby', '', PARAM_RAW);
$heading = '';
$url = new moodle_url('/mod/rcontent/report.php', array('id' => $id));
// Base URL
$PAGE->set_title($rcontent->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_url($url);
$contextmodule = context_module::instance($cm->id);
if (!$contextmodule) {
    $contextmodule = context_system::instance();
}
require_capability('mod/rcontent:updatescore', $contextmodule);
// Add parameter idgrade to the loader data
if (!($grade = rcontent_grade_user_attempt($rcontent->id, $userid, $attempt, $unitid, $activityid, $update))) {
    notice('Grade not found');
}
$user = $DB->get_record('user', array('id' => $userid));
$userdata = rcontent_get_user_data($userid);
$toform = new stdClass();
$toform->rcontentid = $rcontent->id;
$toform->id = $cm->id;
$toform->user = $user->id;
$toform->attempt = $attempt;
$toform->duration = rcontent_get_ellapsed_time($grade->totaltime);
$toform->gradeid = $grade->id;
$toform->grade = $grade->justgrade;
$toform->comment_editor['text'] = $grade->justcomments;
$toform->comment_editor['format'] = FORMAT_HTML;
$mform = new mod_rcontent_grade_form(null, array($rcontent, $toform, null), 'post', '', array('class' => 'gradeform'));