Пример #1
0
function workshop_grades($workshopid)
{
    /// Must return an array of grades, indexed by user, and a max grade.
    /// only returns grades once assessment has started
    /// returns nothing if workshop is not graded
    global $CFG;
    $return = null;
    if ($workshop = get_record("workshop", "id", $workshopid)) {
        if ($workshop->assessmentstart < time() and $workshop->gradingstrategy) {
            if ($students = workshop_get_students($workshop)) {
                foreach ($students as $student) {
                    if ($workshop->wtype) {
                        $gradinggrade = workshop_gradinggrade($workshop, $student);
                    } else {
                        // ignore grading grades for simple assignments
                        $gradinggrade = 0;
                    }
                    $bestgrade = 0;
                    if ($submissions = workshop_get_user_submissions($workshop, $student)) {
                        foreach ($submissions as $submission) {
                            if (!$submission->late) {
                                $grade = workshop_submission_grade($workshop, $submission);
                            } else {
                                $grade = 0.01;
                            }
                            if ($grade > $bestgrade) {
                                $bestgrade = $grade;
                            }
                        }
                    }
                    $return->grades[$student->id] = $gradinggrade + $bestgrade;
                }
            }
        }
        // set maximum grade if graded
        if ($workshop->gradingstrategy) {
            if ($workshop->wtype) {
                $return->maxgrade = $workshop->grade + $workshop->gradinggrade;
            } else {
                // ignore grading grades for simple assignemnts
                $return->maxgrade = $workshop->grade;
            }
        }
    }
    return $return;
}
Пример #2
0
             $data[] = workshop_print_submission_title($workshop, $submission) . " <a href=\"submissions.php?action=adminamendtitle&amp;id={$cm->id}&amp;sid={$submission->id}\">" . "<img src=\"{$CFG->pixpath}/t/edit.gif\" " . 'class="iconsmall" alt="' . get_string('amendtitle', 'workshop') . '" /></a>' . " <a href=\"submissions.php?action=confirmdelete&amp;id={$cm->id}&amp;sid={$submission->id}\">" . "<img src=\"{$CFG->pixpath}/t/delete.gif\" " . 'class="iconsmall" alt="' . get_string('delete', 'workshop') . '" /></a>';
             $sortdata['title'] = $submission->title;
             $data[] = userdate($submission->timecreated, get_string('datestr', 'workshop'));
             $sortdata['date'] = $submission->timecreated;
             if (($tmp = workshop_print_submission_assessments($workshop, $submission, "teacher")) == '&nbsp;') {
                 $data[] = '<a href="assess.php?id=' . $cm->id . '&amp;sid=' . $submission->id . '">' . get_string('assess', 'workshop') . '</a>';
                 $sortdata['tassmnt'] = -1;
             } else {
                 $data[] = $tmp;
                 $sortdata['tassmnt'] = 1;
                 // GWD still have to fix this
             }
             if ($workshop->wtype) {
                 $data[] = workshop_print_submission_assessments($workshop, $submission, "student");
             }
             $grade = workshop_submission_grade($workshop, $submission);
             $data[] = $grade;
             $sortdata['sgrade'] = $grade;
             if ($workshop->wtype) {
                 $data[] = number_format($gradinggrade + $grade, 1);
                 $sortdata['ograde'] = $gradinggrade + $grade;
             }
             $tablesort->data[] = $data;
             $tablesort->sortdata[] = $sortdata;
         }
     }
 }
 function workshop_sortfunction($a, $b)
 {
     global $sort, $dir;
     if ($dir == 'ASC') {
Пример #3
0
function workshop_print_league_table($workshop)
{
    // print an order table of (student) submissions showing teacher's and student's assessments
    if (!($course = get_record("course", "id", $workshop->course))) {
        error("Print league table: Course is misconfigured");
    }
    if (!($cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course))) {
        error("Course Module ID was incorrect");
    }
    // set $groupid if workshop is in SEPARATEGROUPS mode
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        $groupid = get_current_group($course->id);
    } else {
        $groupid = 0;
    }
    $nentries = $workshop->showleaguetable;
    if ($workshop->anonymous and workshop_is_student($workshop)) {
        $table->head = array(get_string("title", "workshop"), get_string("teacherassessments", "workshop", $course->teacher), get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop"));
        $table->align = array("left", "center", "center", "center");
        $table->size = array("*", "*", "*", "*");
    } else {
        // show names
        $table->head = array(get_string("title", "workshop"), get_string("name"), get_string("teacherassessments", "workshop", $course->teacher), get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop"));
        $table->align = array("left", "left", "center", "center", "center");
        $table->size = array("*", "*", "*", "*", "*");
    }
    $table->cellpadding = 2;
    $table->cellspacing = 0;
    if ($submissions = workshop_get_student_submissions($workshop)) {
        foreach ($submissions as $submission) {
            if ($groupid) {
                // check submission's group
                if (!groups_is_member($groupid, $submission->userid)) {
                    continue;
                    // skip this submission
                }
            }
            $grades[$submission->id] = workshop_submission_grade($workshop, $submission);
        }
        arsort($grades);
        // largest grade first
        reset($grades);
        $n = 1;
        while (list($submissionid, $grade) = each($grades)) {
            if (!($submission = get_record("workshop_submissions", "id", $submissionid))) {
                error("Print league table: submission not found");
            }
            if (!($user = get_record("user", "id", $submission->userid))) {
                error("Print league table: user not found");
            }
            if ($workshop->anonymous and workshop_is_student($workshop)) {
                $table->data[] = array(workshop_print_submission_title($workshop, $submission), workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
            } else {
                $table->data[] = array(workshop_print_submission_title($workshop, $submission), fullname($user), workshop_print_submission_assessments($workshop, $submission, "teacher"), workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
            }
            $n++;
            if ($n > $nentries) {
                break;
            }
        }
        print_heading(get_string("leaguetable", "workshop"));
        print_table($table);
        workshop_print_key($workshop);
    }
}