Beispiel #1
0
/**
 * Find the activity detail grade for a given user and attempt
 * @param int $rcontent
 * @param int $userid
 * @param int $attempt
 * @param int $time
 * @return string grade(mingrade/maxgrade)
 */
function rcontent_grade_details_user_attempt($id, $rcontentid, $userid, $attempt = 1, $time = false, $unitid = '', $activityid = '')
{
    global $DB;
    $return = new stdClass();
    $return->grade = "";
    $return->range = "";
    $return->maxattemps = "";
    $return->weight = "";
    $return->url = "";
    $return->description = "";
    $return->totalweight = "";
    $grade = $DB->get_record('rcontent_grades_details', array('id' => $id));
    if ($grade) {
        $return->grade = $grade->grade;
        $return->range = "({$grade->mingrade}-{$grade->maxgrade})";
        $return->maxattempts = '(' . $grade->maxattempts . ')';
        $return->weight = $grade->weight;
        if (!empty($grade->urlviewresults)) {
            $return->url = rcontent_get_urlviewresults_link($grade->urlviewresults);
        }
        if (!empty($grade->description)) {
            if (strlen($grade->description) > 30) {
                $return->description = '<span title="' . $grade->description . '">' . substr($grade->description, 0, 27) . '...</span>';
            } else {
                $return->description = $grade->description;
            }
        }
        // Take the sumweight for the parent
        $paramssql = array('userid' => $userid, 'rcontentid' => $rcontentid, 'attempt' => $attempt);
        $paramssql['unitid'] = $unitid != '' ? $unitid : 0;
        $paramssql['activityid'] = $activityid != '' ? $activityid : 0;
        if ($totalweight = $DB->get_records('rcontent_grades', $paramssql)) {
            foreach ($totalweight as $tw) {
                $return->totalweight = '(' . $tw->sumweights . ')';
            }
        }
    }
    return $return;
}
Beispiel #2
0
 // Show grade
 $row[] = '<div id="rcontent_grade_' . $at->userid . '_' . $at->id . '">' . round($at->grade, 2) . '</div>';
 // Set grade range
 $range = "({$at->mingrade}-{$at->maxgrade})";
 // Show comments
 $comments = '<div id="rcontent_comments_' . $at->userid . '_' . $at->id . '">';
 if (strlen($at->comments) > 30) {
     $comments .= '<span title="' . $at->comments . '">' . substr($at->comments, 0, 27) . '...</span>';
 } else {
     $comments .= $at->comments;
 }
 $comments .= '</div>';
 $row[] = $comments;
 $href = "";
 if ($at->urlviewresults != "" && $canviewresults) {
     $href = rcontent_get_urlviewresults_link($at->urlviewresults);
 }
 // Show update activity link
 if ($canupdatescore) {
     $href .= ' | ' . rcontent_get_uploadscore_link($id, $at->userid, $at->attempt, $at->id);
 }
 if (!empty($href)) {
     $row[] = $href;
     $showhreffield = true;
 }
 $table->data[] = $row;
 $rowclass = "";
 if ($at->attempt == $attempt) {
     $rowclass = 'selected';
 }
 // If original status is POR_CORREGIR set background to red