Exemplo n.º 1
0
         workshop_print_upload_form($workshop);
     } else {
         print_heading(get_string("submissionsnolongerallowed", "workshop"));
     }
 } else {
     // is self assessment used in this workshop?
     if ($workshop->includeself) {
         // prints a table if there are any submissions which have not been self assessed yet
         workshop_list_self_assessments($workshop, $USER);
     }
     // if peer assessments are being done then show some  to assess...
     if ($workshop->nsassessments and ($workshop->assessmentstart < $timenow and $workshop->assessmentend > $timenow)) {
         workshop_list_student_submissions($workshop, $USER);
     }
     // ..and any they have already done (and have gone cold)...
     if (workshop_count_user_assessments($workshop, $USER, "student")) {
         print_heading(get_string("yourassessments", "workshop"));
         workshop_list_assessed_submissions($workshop, $USER);
     }
     // list any assessments by teachers
     if (workshop_count_teacher_assessments_by_user($workshop, $USER) and $timenow > $workshop->releasegrades) {
         print_heading(get_string("assessmentsby", "workshop", $course->teachers));
         workshop_list_teacher_assessments_by_user($workshop, $USER);
     }
     // ... and show peer assessments
     if (workshop_count_peer_assessments($workshop, $USER)) {
         print_heading(get_string("assessmentsby", "workshop", $course->students));
         workshop_list_peer_assessments($workshop, $USER);
     }
     // list previous submissions
     print_heading(get_string("yoursubmissions", "workshop"));
Exemplo n.º 2
0
function workshop_list_student_submissions($workshop, $user)
{
    // list available submissions for this user to assess, submissions with the least number
    // of assessments are show first
    global $CFG;
    if (!($cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course))) {
        error("Course Module ID was incorrect");
    }
    if (!($course = get_record("course", "id", $workshop->course))) {
        error("Course is misconfigured");
    }
    $timenow = time();
    // set student's group if workshop is in SEPARATEGROUPS mode
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        $groupid = get_current_group($course->id);
    } else {
        $groupid = 0;
    }
    $table->head = array(get_string("title", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
    $table->align = array("left", "left", "left");
    $table->size = array("*", "*", "*");
    $table->cellpadding = 2;
    $table->cellspacing = 0;
    // get the number of assessments this user has done on student submission, deduct self assessments
    $nassessed = workshop_count_user_assessments($workshop, $user, "student") - workshop_count_self_assessments($workshop, $user);
    // user hasn't been allocated enough, try and get some more
    if ($nassessed < $workshop->nsassessments) {
        // count the number of assessments for each student submission
        if ($submissions = workshop_get_student_submissions($workshop)) {
            // srand ((float)microtime()*1000000); // now done automatically in PHP 4.2.0->
            foreach ($submissions as $submission) {
                // check group membership, if necessary
                if ($groupid) {
                    // check user's group
                    if (!groups_is_member($groupid, $submission->userid)) {
                        continue;
                        // skip this submission
                    }
                }
                // process only cold submissions
                if ($submission->timecreated + $CFG->maxeditingtime > $timenow) {
                    continue;
                }
                $n = count_records("workshop_assessments", "submissionid", $submission->id);
                // ...OK to have zero, we add a small random number to randomise things
                $nassessments[$submission->id] = $n + rand(0, 98) / 100;
            }
            if (isset($nassessments)) {
                // make sure we end up with something to play with
                // put the submissions with the lowest number of assessments first
                asort($nassessments);
                reset($nassessments);
                $nsassessments = $workshop->nsassessments;
                foreach ($nassessments as $submissionid => $n) {
                    // only use those submissions which fall below the allocation threshold
                    if ($n < $workshop->nsassessments + $workshop->overallocation) {
                        $comment = "";
                        $submission = get_record("workshop_submissions", "id", $submissionid);
                        // skip submission if it belongs to this user
                        if ($submission->userid != $user->id) {
                            // add a "hot" assessment record if user has NOT already assessed this submission
                            if (!get_record("workshop_assessments", "submissionid", $submission->id, "userid", $user->id)) {
                                $yearfromnow = time() + 365 * 86400;
                                // ...create one and set timecreated way in the future, this is reset when record is updated
                                unset($assessment);
                                // clear previous version object (if any)
                                $assessment->workshopid = $workshop->id;
                                $assessment->submissionid = $submission->id;
                                $assessment->userid = $user->id;
                                $assessment->grade = -1;
                                // set impossible grade
                                $assessment->timecreated = $yearfromnow;
                                if (!($assessment->id = insert_record("workshop_assessments", $assessment))) {
                                    error("List Student submissions: Could not insert workshop assessment!");
                                }
                                $nassessed++;
                                // is user up to quota?
                                if ($nassessed == $nsassessments) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // now list the student submissions this user has been allocated, list only the hot and warm ones,
    // the cold ones are listed in the "your assessments list" (_list_assessed submissions)
    if ($assessments = workshop_get_user_assessments($workshop, $user)) {
        $timenow = time();
        foreach ($assessments as $assessment) {
            if (!($submission = get_record("workshop_submissions", "id", $assessment->submissionid))) {
                error("workshop_list_student_submissions: unable to get submission");
            }
            // submission from a student?
            if (workshop_is_student($workshop, $submission->userid)) {
                $comment = '';
                // user assessment has three states: record created but not assessed (date created in the future) [hot];
                // just assessed but still editable [warm]; and "static" (may or may not have been graded by teacher, that
                // is shown in the comment) [cold]
                if ($assessment->timecreated > $timenow) {
                    // user needs to assess this submission
                    $action = "<a href=\"assess.php?id={$cm->id}&amp;sid={$submission->id}\">" . get_string("assess", "workshop") . "</a>";
                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                } elseif ($assessment->timecreated > $timenow - $CFG->maxeditingtime) {
                    // there's still time left to edit...
                    $action = "<a href=\"assess.php?id={$cm->id}&amp;sid={$submission->id}\">" . get_string("edit", "workshop") . "</a>";
                    $table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
                }
            }
        }
    }
    if (isset($table->data)) {
        echo "<p><div style=\"text-align:center;\"><b>" . get_string("pleaseassessthesestudentsubmissions", "workshop", $course->student) . "</b></div><br />\n";
        print_table($table);
    } else {
        echo "<p><div style=\"text-align:center;\"><b>" . get_string("nosubmissionsavailableforassessment", "workshop") . "</b></div><br />\n";
    }
}