2004-09-12 21:43:59 +00:00
|
|
|
<?php // $Id$
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
/// Library of extra functions and module workshop
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*** Functions for the workshop module ******
|
|
|
|
|
|
|
|
workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="",
|
|
|
|
$nothingvalue="0", $return=false) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_compare_assessments($workshop, $assessment1, $assessment2) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_count_all_submissions_for_assessment($workshop, $user) {
|
2004-11-12 17:28:07 +00:00
|
|
|
workshop_count_assessments($submission) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_count_comments($assessment) {
|
|
|
|
workshop_count_peer_assessments($workshop, $user) {
|
|
|
|
workshop_count_self_assessments($workshop, $user) {
|
|
|
|
workshop_count_student_submissions($workshop) {
|
|
|
|
workshop_count_student_submissions_for_assessment($workshop, $user) {
|
2004-11-12 17:28:07 +00:00
|
|
|
workshop_count_teacher_assessments($courseid, $submission) {
|
|
|
|
workshop_count_teacher_assessments_by_user($workshop, $user) {
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_count_teacher_submissions($workshop) {
|
|
|
|
workshop_count_teacher_submissions_for_assessment($workshop, $user) {
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_count_ungraded_assessments($workshop) { --->in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_count_ungraded_assessments_student($workshop) {
|
|
|
|
workshop_count_ungraded_assessments_teacher($workshop) {
|
|
|
|
workshop_count_user_assessments($worshop, $user, $type = "all") { $type is all, student or teacher
|
|
|
|
workshop_count_user_submissions($workshop, $user) {
|
|
|
|
|
|
|
|
workshop_delete_submitted_files($workshop, $submission) {
|
|
|
|
workshop_delete_user_files($workshop, $user, $exception) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_file_area($workshop, $submission) { ---> in lib.php
|
|
|
|
workshop_file_area_name($workshop, $submission) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-11-12 17:28:07 +00:00
|
|
|
workshop_get_all_teacher_assessments($workshop) {
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_get_assessments($submission, $all = '') { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_get_comments($assessment) {
|
|
|
|
workshop_get_participants($workshopid) {
|
|
|
|
workshop_get_student_assessments($workshop, $user) {
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_get_student_submission($workshop, $user) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_get_student_submission_assessments($workshop) {
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_get_student_submissions($workshop) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_get_submission_assessment($submission, $user) {
|
2004-11-12 17:28:07 +00:00
|
|
|
workshop_get_teacher_assessments($courseid, $submission) {
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_get_teacher_submission_assessments($workshop) {
|
|
|
|
workshop_get_teacher_submissions($workshop) {
|
|
|
|
workshop_get_ungraded_assessments($workshop) {
|
|
|
|
workshop_get_unmailed_assessments($cutofftime) {
|
|
|
|
workshop_get_unmailed_marked_assessments($cutofftime) {
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_get_user_assessments($workshop, $user) { ---> in lib.php
|
|
|
|
workshop_get_user_submissions($workshop, $user) { ---> in lib.php
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_get_users_done($workshop) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_grade_assessments($workshop) { ---> in lib.php
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_list_all_submissions($workshop) {
|
|
|
|
workshop_list_all_ungraded_assessments($workshop) {
|
|
|
|
workshop_list_assessed_submissions($workshop, $user) {
|
|
|
|
workshop_list_peer_assessments($workshop, $user) {
|
|
|
|
workshop_list_student_submissions($workshop, $user) {
|
|
|
|
workshop_list_submissions_for_admin($workshop, $order) {
|
2004-11-12 17:28:07 +00:00
|
|
|
workshop_list_teacher_assessments_by_user($workshop, $user) {
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_list_teacher_submissions($workshop) {
|
|
|
|
workshop_list_unassessed_student_submissions($workshop, $user) {
|
|
|
|
workshop_list_unassessed_teacher_submissions($workshop, $user) {
|
|
|
|
workshop_list_ungraded_assessments($workshop, $stype) {
|
|
|
|
workshop_list_user_submissions($workshop, $user) {
|
|
|
|
|
|
|
|
|
|
|
|
workshop_print_assessment($workshop, $assessment, $allowchanges, $showcommentlinks, $returnto)
|
|
|
|
workshop_print_assessments_by_user_for_admin($workshop, $user) {
|
|
|
|
workshop_print_assessments_for_admin($workshop, $submission) {
|
|
|
|
workshop_print_assignment_info($cm, $workshop) {
|
|
|
|
workshop_print_difference($time) {
|
|
|
|
workshop_print_feedback($course, $submission) {
|
|
|
|
workshop_print_league_table($workshop) {
|
|
|
|
workshop_print_submission_assessments($workshop, $submission, $type) {
|
|
|
|
workshop_print_submission_title($workshop, $user) {
|
|
|
|
workshop_print_tabbed_table($table) {
|
|
|
|
workshop_print_time_to_deadline($time) {
|
|
|
|
workshop_print_upload_form($workshop) {
|
|
|
|
workshop_print_user_assessments($workshop, $user) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_submission_grade($submission) { ---> in lib.php
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_test_user_assessments($workshop, $user) {
|
|
|
|
***************************************/
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="",
|
|
|
|
$nothingvalue="0", $return=false) {
|
|
|
|
/// Given an array of value, creates a popup menu to be part of a form
|
|
|
|
/// $options["value"]["label"]
|
|
|
|
|
|
|
|
if ($nothing == "choose") {
|
|
|
|
$nothing = get_string("choose")."...";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($script) {
|
|
|
|
$javascript = "onChange=\"$script\"";
|
|
|
|
} else {
|
|
|
|
$javascript = "";
|
|
|
|
}
|
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
$output = "<select name=$name $javascript>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($nothing) {
|
2004-09-14 20:39:28 +00:00
|
|
|
$output .= " <option value=\"$nothingvalue\"\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($nothingvalue == $selected) {
|
2004-09-14 20:39:28 +00:00
|
|
|
$output .= " selected=\"selected\"";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
$output .= ">$nothing</option>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
if (!empty($options)) {
|
|
|
|
foreach ($options as $value => $label) {
|
2004-09-14 20:39:28 +00:00
|
|
|
$output .= " <option value=\"$value\"";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($value == $selected) {
|
2004-09-14 20:39:28 +00:00
|
|
|
$output .= " selected=\"selected\"";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
// stop zero label being replaced by array index value
|
|
|
|
// if ($label) {
|
2004-09-12 21:43:59 +00:00
|
|
|
// $output .= ">$label</option>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
// } else {
|
2004-09-12 21:43:59 +00:00
|
|
|
// $output .= ">$value</option>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
// }
|
2004-09-12 21:43:59 +00:00
|
|
|
$output .= ">$label</option>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
$output .= "</select>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_copy_assessment($assessment, $submission, $withfeedback = false) {
|
|
|
|
// adds a copy of the given assessment for the submission specified to the workshop_assessments table.
|
|
|
|
// The grades and optionally the comments are added to the workshop_grades table. Returns the new
|
|
|
|
// assessment object. The owner of the assessment is not changed.
|
|
|
|
|
|
|
|
$yearfromnow = time() + 365 * 86400;
|
|
|
|
$newassessment->workshopid = $assessment->workshopid;
|
|
|
|
$newassessment->submissionid = $submission->id;
|
|
|
|
$newassessment->userid = $assessment->userid;
|
|
|
|
$newassessment->timecreated = $yearfromnow;
|
|
|
|
$newassessment->grade = $assessment->grade;
|
|
|
|
if ($withfeedback) {
|
|
|
|
$newassessment->generalcomment = addslashes($assessment->generalcomment);
|
|
|
|
$newassessment->teachercomment = addslashes($assessment->teachercomment);
|
|
|
|
}
|
|
|
|
if (!$newassessment->id = insert_record("workshop_assessments", $newassessment)) {
|
|
|
|
error("Copy Assessment: Could not insert workshop assessment!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($grades = get_records("workshop_grades", "assessmentid", $assessment->id)) {
|
|
|
|
foreach ($grades as $grade) {
|
2004-09-09 18:47:07 +00:00
|
|
|
unset($grade->id); // clear id, insert record now seems to believe it!
|
2004-06-18 09:24:20 +00:00
|
|
|
if (!$withfeedback) {
|
|
|
|
$grade->feedback = '';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$grade->feedback = addslashes($grade->feedback);
|
|
|
|
}
|
|
|
|
$grade->assessmentid = $newassessment->id;
|
|
|
|
if (!$grade->id = insert_record("workshop_grades", $grade)) {
|
|
|
|
error("Copy Assessment: Could not insert workshop grade!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($withfeedback) {
|
|
|
|
// remove the slashes from comments as the new assessment record might be used,
|
|
|
|
// currently this function is only called in upload which does not!
|
|
|
|
$newassessment->generalcomment = stripslashes($assessment->generalcomment);
|
|
|
|
$newassessment->teachercomment = stripslashes($assessment->teachercomment);
|
|
|
|
}
|
|
|
|
return $newassessment;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_all_submissions_for_assessment($workshop, $user) {
|
|
|
|
// looks at all submissions and deducts the number which has been assessed by this user
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = get_records_select("workshop_submissions", "workshopid = $workshop->id AND
|
|
|
|
timecreated > 0")) {
|
|
|
|
$n =count($submissions);
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
$n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_comments($assessment) {
|
|
|
|
// Return the number of comments for this assessment provided they are newer than the assessment,
|
|
|
|
return count_records_select("workshop_comments", "(assessmentid = $assessment->id) AND
|
|
|
|
timecreated > $assessment->timecreated");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_peer_assessments($workshop, $user) {
|
|
|
|
// returns the number of assessments made by students on user's submissions
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
// ignore teacher assessments
|
|
|
|
if (!isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_self_assessments($workshop, $user) {
|
|
|
|
// returns the number of assessments made by user on their own submissions
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "userid = $user->id AND
|
|
|
|
submissionid = $submission->id")) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_student_submissions($workshop) {
|
|
|
|
global $CFG;
|
2004-08-22 14:38:47 +00:00
|
|
|
|
|
|
|
// make sure it works on the site course
|
|
|
|
$select = "s.course = '$workshop->course' AND";
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($workshop->course == SITEID) {
|
2004-08-22 14:38:47 +00:00
|
|
|
$select = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
|
2004-06-18 09:24:20 +00:00
|
|
|
{$CFG->prefix}user_students u
|
2004-08-22 14:38:47 +00:00
|
|
|
WHERE $select s.userid = u.userid
|
2004-06-18 09:24:20 +00:00
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND timecreated > 0");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_student_submissions_for_assessment($workshop, $user) {
|
|
|
|
global $CFG;
|
2004-09-07 16:17:32 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
$timenow = time();
|
2004-09-07 16:17:32 +00:00
|
|
|
if (groupmode($course, $cm) == SEPARATEGROUPS) {
|
|
|
|
$groupid = get_current_group($course->id);
|
|
|
|
} else {
|
|
|
|
$groupid = 0;
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_student_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// check group membership, if necessary
|
|
|
|
if ($groupid) {
|
|
|
|
// check user's group
|
|
|
|
if (!ismember($groupid, $submission->userid)) {
|
|
|
|
continue; // skip this user
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
// check if submission is cold
|
|
|
|
if (($submission->timecreated + $CFG->maxeditingtime) > $timenow) {
|
|
|
|
continue; // skip this submission
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
// has any teacher assessed this submission?
|
|
|
|
if (!workshop_count_teacher_assessments($course->id, $submission)) {
|
2004-09-07 16:17:32 +00:00
|
|
|
$n++;
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
return $n;
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
2004-11-12 17:28:07 +00:00
|
|
|
function workshop_count_teacher_assessments($courseid, $submission) {
|
|
|
|
// Return count of (cold) teacher assessments of a submission
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
$timenow = time();
|
|
|
|
return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_assessments a,
|
|
|
|
{$CFG->prefix}user_teachers u
|
|
|
|
WHERE u.course = $courseid
|
|
|
|
AND a.userid = u.userid
|
|
|
|
AND a.submissionid = $submission->id
|
|
|
|
AND $timenow > (a.timecreated + $CFG->maxeditingtime)");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_teacher_assessments_by_user($workshop, $user) {
|
2004-06-18 09:24:20 +00:00
|
|
|
// returns the number of assessments made by teachers on user's submissions
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
// count only teacher assessments
|
|
|
|
if (isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_teacher_submissions($workshop) {
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return count_records_sql("SELECT count(*) FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_teachers u
|
|
|
|
WHERE u.course = $workshop->course
|
|
|
|
AND s.userid = u.userid
|
|
|
|
AND s.workshopid = $workshop->id");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_teacher_submissions_for_assessment($workshop, $user) {
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
$n =count($submissions);
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
$n -= count_records("workshop_assessments", "submissionid", $submission->id, "userid", $user->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_ungraded_assessments_student($workshop) {
|
|
|
|
// function returns the number of ungraded assessments by students of STUDENT submissions
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_student_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if ($assessment->timegraded == 0) {
|
|
|
|
// ignore teacher assessments
|
|
|
|
if (!isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_ungraded_assessments_teacher($workshop) {
|
|
|
|
// function returns the number of ungraded assessments by students of TEACHER submissions
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
$timenow = time();
|
|
|
|
$n = 0;
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if ($assessment->timegraded == 0) {
|
|
|
|
// ignore teacher assessments
|
|
|
|
if (!isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
// must have created a little time ago
|
|
|
|
if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_user_assessments($workshop, $user, $stype = "all") {
|
|
|
|
// returns the number of assessments allocated/made by a user, all of them, or just those
|
|
|
|
// for the student or teacher submissions. The student's self assessments are included in the count.
|
|
|
|
// The maxeditingtime is NOT taken into account here also, allocated assessments which have not yet
|
|
|
|
// been done are counted as well
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
if ($assessments = workshop_get_user_assessments($workshop, $user)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
switch ($stype) {
|
|
|
|
case "all" :
|
|
|
|
$n++;
|
|
|
|
break;
|
|
|
|
case "student" :
|
|
|
|
$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
|
|
|
|
if (isstudent($workshop->course, $submission->userid)) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "teacher" :
|
|
|
|
$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
|
|
|
|
if (isteacher($workshop->course, $submission->userid)) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_user_assessments_done($workshop, $user) {
|
|
|
|
// returns the number of assessments actually done by a user
|
|
|
|
// the student's self assessments are included in the count
|
|
|
|
// the maxeditingtime is NOT taken into account here
|
|
|
|
|
|
|
|
$n = 0;
|
|
|
|
$timenow = time();
|
|
|
|
if ($assessments = workshop_get_user_assessments($workshop, $user)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if ($assessment->timecreated < $timenow) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_count_user_submissions($workshop, $user) {
|
|
|
|
// returns the number of (real) submissions make by this user
|
|
|
|
return count_records_select("workshop_submissions", "workshopid = $workshop->id AND
|
|
|
|
userid = $user->id AND timecreated > 0");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_delete_submitted_files($workshop, $submission) {
|
|
|
|
// Deletes the files in the workshop area for this submission
|
|
|
|
|
|
|
|
if ($basedir = workshop_file_area($workshop, $submission)) {
|
|
|
|
if ($files = get_directory_list($basedir)) {
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if (unlink("$basedir/$file")) {
|
|
|
|
notify("Existing file '$file' has been deleted!");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
notify("Attempt to delete file $basedir/$file has failed!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_delete_user_files($workshop, $user, $exception) {
|
|
|
|
// Deletes all the user files in the workshop area for a user
|
|
|
|
// EXCEPT for any file named $exception
|
|
|
|
|
|
|
|
if (!$submissions = workshop_get_submissions($workshop, $user)) {
|
|
|
|
notify("No submissions!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($basedir = workshop_file_area($workshop, $submission)) {
|
|
|
|
if ($files = get_directory_list($basedir)) {
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if ($file != $exception) {
|
|
|
|
unlink("$basedir/$file");
|
|
|
|
notify("Existing file '$file' has been deleted!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-12 17:28:07 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_all_teacher_assessments($workshop) {
|
|
|
|
// Return all teacher assessments, ordered by timecreated, oldest first
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_assessments a,
|
|
|
|
{$CFG->prefix}user_teachers u
|
|
|
|
WHERE u.course = $workshop->course
|
|
|
|
AND a.userid = u.userid
|
|
|
|
AND a.workshopid = $workshop->id
|
|
|
|
ORDER BY a.timecreated");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_comments($assessment) {
|
|
|
|
// Return all comments for this assessment provided they are newer than the assessment,
|
|
|
|
// and ordered oldest first, newest last
|
|
|
|
return get_records_select("workshop_comments", "(assessmentid = $assessment->id) AND
|
|
|
|
timecreated > $assessment->timecreated",
|
|
|
|
"timecreated DESC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_student_assessments($workshop, $user) {
|
|
|
|
// Return all assessments on the student submissions by a user, order by youngest first, oldest last
|
|
|
|
global $CFG;
|
2004-08-22 14:38:47 +00:00
|
|
|
|
|
|
|
// make sure it works on the site course
|
|
|
|
$select = "u.course = '$workshop->course' AND";
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($workshop->course == SITEID) {
|
2004-08-22 14:38:47 +00:00
|
|
|
$select = '';
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_students u,
|
|
|
|
{$CFG->prefix}workshop_assessments a
|
2004-08-22 14:38:47 +00:00
|
|
|
WHERE $select s.userid = u.userid
|
2004-06-18 09:24:20 +00:00
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND a.submissionid = s.id
|
|
|
|
AND a.userid = $user->id
|
|
|
|
ORDER BY a.timecreated DESC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_student_submission_assessments($workshop) {
|
|
|
|
// Return all assessments on the student submissions, order by youngest first, oldest last
|
|
|
|
global $CFG;
|
2004-08-22 14:38:47 +00:00
|
|
|
|
|
|
|
// make sure it works on the site course
|
|
|
|
$select = "u.course = '$workshop->course' AND";
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($workshop->course == SITEID) {
|
2004-08-22 14:38:47 +00:00
|
|
|
$select = '';
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a
|
2004-08-22 14:38:47 +00:00
|
|
|
WHERE $select s.userid = u.userid
|
2004-06-18 09:24:20 +00:00
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND a.submissionid = s.id
|
|
|
|
ORDER BY a.timecreated DESC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_submission_assessment($submission, $user) {
|
|
|
|
// Return the user's assessment for this submission (cold or warm, not hot)
|
|
|
|
|
|
|
|
$timenow = time();
|
|
|
|
return get_record_select("workshop_assessments", "submissionid = $submission->id AND
|
|
|
|
userid = $user->id AND timecreated < $timenow");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
2004-11-12 17:28:07 +00:00
|
|
|
function workshop_get_teacher_assessments($courseid, $submission) {
|
|
|
|
// Return teacher assessments of a submission, ordered by timecreated, oldest first
|
2004-09-27 14:41:17 +00:00
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_assessments a,
|
|
|
|
{$CFG->prefix}user_teachers u
|
2004-11-12 17:28:07 +00:00
|
|
|
WHERE u.course = $courseid
|
2004-09-27 14:41:17 +00:00
|
|
|
AND a.userid = u.userid
|
2004-11-12 17:28:07 +00:00
|
|
|
AND a.submissionid = $submission->id
|
2004-09-27 14:41:17 +00:00
|
|
|
ORDER BY a.timecreated");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_teacher_submission_assessments($workshop) {
|
|
|
|
// Return all assessments on the teacher submissions, order by youngest first, oldest last
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_teachers u, {$CFG->prefix}workshop_assessments a
|
|
|
|
WHERE u.course = $workshop->course
|
|
|
|
AND s.userid = u.userid
|
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND a.submissionid = s.id
|
|
|
|
ORDER BY a.timecreated DESC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_teacher_submissions($workshop) {
|
|
|
|
// Return all teacher submissions, ordered by title
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
return get_records_sql("SELECT s.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_teachers u
|
|
|
|
WHERE u.course = $workshop->course
|
|
|
|
AND s.userid = u.userid
|
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
ORDER BY s.title");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_ungraded_assessments($workshop) {
|
|
|
|
global $CFG;
|
|
|
|
// Return all assessments which have not been graded or just graded
|
2004-09-27 14:41:17 +00:00
|
|
|
$cutofftime = time() - $CFG->maxeditingtime;
|
2004-06-18 09:24:20 +00:00
|
|
|
return get_records_select("workshop_assessments", "workshopid = $workshop->id AND (timegraded = 0 OR
|
|
|
|
timegraded > $cutofftime)", "timecreated");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_ungraded_assessments_student($workshop) {
|
|
|
|
global $CFG;
|
|
|
|
// Return all assessments which have not been graded or just graded of student's submissions
|
2004-08-22 14:38:47 +00:00
|
|
|
|
|
|
|
// make sure it works on the site course
|
|
|
|
$select = "u.course = '$workshop->course' AND";
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($workshop->course == SITEID) {
|
2004-08-22 14:38:47 +00:00
|
|
|
$select = '';
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$cutofftime = time() - $CFG->maxeditingtime;
|
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_students u, {$CFG->prefix}workshop_assessments a
|
2004-08-22 14:38:47 +00:00
|
|
|
WHERE $select s.userid = u.userid
|
2004-06-18 09:24:20 +00:00
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND a.submissionid = s.id
|
|
|
|
AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
|
|
|
|
AND a.timecreated < $cutofftime
|
|
|
|
ORDER BY a.timecreated ASC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_ungraded_assessments_teacher($workshop) {
|
|
|
|
global $CFG;
|
|
|
|
// Return all assessments which have not been graded or just graded of teacher's submissions
|
|
|
|
|
|
|
|
$cutofftime =time() - $CFG->maxeditingtime;
|
|
|
|
return get_records_sql("SELECT a.* FROM {$CFG->prefix}workshop_submissions s,
|
|
|
|
{$CFG->prefix}user_teachers u, {$CFG->prefix}workshop_assessments a
|
|
|
|
WHERE u.course = $workshop->course
|
|
|
|
AND s.userid = u.userid
|
|
|
|
AND s.workshopid = $workshop->id
|
|
|
|
AND a.submissionid = s.id
|
|
|
|
AND (a.timegraded = 0 OR a.timegraded > $cutofftime)
|
|
|
|
AND a.timecreated < $cutofftime
|
|
|
|
ORDER BY a.timecreated ASC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_user_assessments_done($workshop, $user) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// Return all the user's assessments, oldest first, newest last (warm and cold ones only)
|
2004-06-18 09:24:20 +00:00
|
|
|
// ignores maxeditingtime
|
|
|
|
$timenow = time();
|
|
|
|
return get_records_select("workshop_assessments", "workshopid = $workshop->id AND userid = $user->id
|
|
|
|
AND timecreated < $timenow",
|
2004-09-07 16:17:32 +00:00
|
|
|
"timecreated ASC");
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_get_users_done($workshop) {
|
|
|
|
global $CFG;
|
2004-08-22 14:38:47 +00:00
|
|
|
|
|
|
|
// make sure it works on the site course
|
|
|
|
$select = "s.course = '$workshop->course' AND";
|
2004-08-29 14:15:40 +00:00
|
|
|
if ($workshop->course == SITEID) {
|
2004-08-22 14:38:47 +00:00
|
|
|
$select = '';
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
return get_records_sql("SELECT u.*
|
|
|
|
FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s,
|
|
|
|
{$CFG->prefix}workshop_submissions a
|
2004-08-22 14:38:47 +00:00
|
|
|
WHERE $select s.user = u.id
|
2004-06-18 09:24:20 +00:00
|
|
|
AND u.id = a.user AND a.workshop = '$workshop->id'
|
|
|
|
ORDER BY a.timemodified DESC");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_all_submissions($workshop, $user) {
|
|
|
|
// list the teacher sublmissions first
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
$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;
|
|
|
|
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($submission->userid == $user->id) {
|
|
|
|
$comment = get_string("ownwork", "workshop")."; ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$comment = "";
|
|
|
|
}
|
|
|
|
// has user already assessed this submission
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $user->id")) {
|
|
|
|
$curtime = time();
|
|
|
|
if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">"
|
2004-09-12 21:43:59 +00:00
|
|
|
.get_string("view", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
// has teacher graded user's assessment?
|
|
|
|
if ($assessment->timegraded) {
|
|
|
|
if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
|
|
|
|
$comment .= get_string("gradedbyteacher", "workshop", $course->teacher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // there's still time left to edit...
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // user has not graded this submission
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
|
|
|
|
$comment);
|
|
|
|
}
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center><p><b>".get_string("studentsubmissions", "workshop", $course->student).
|
2004-09-12 22:29:44 +00:00
|
|
|
"</b></center><br />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
unset($table);
|
|
|
|
$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;
|
|
|
|
|
|
|
|
if ($submissions = workshop_get_student_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($submission->userid == $user->id) {
|
|
|
|
$comment = get_string("ownwork", "workshop")."; ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$comment = "";
|
|
|
|
}
|
|
|
|
// has user already assessed this submission
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $user->id")) {
|
|
|
|
$curtime = time();
|
|
|
|
if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
// has teacher graded on user's assessment?
|
|
|
|
if ($assessment->timegraded) {
|
|
|
|
if (($curtime - $assessment->timegraded) > $CFG->maxeditingtime) {
|
|
|
|
$comment .= get_string("gradedbyteacher", "workshop", $course->teacher)."; ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$otherassessments = workshop_get_assessments($submission);
|
|
|
|
if (count($otherassessments) > 1) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$comment .= "<a href=\"assessments.php?action=viewallassessments&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("viewotherassessments", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // there's still time left to edit...
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // user has not assessed this submission
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
|
|
|
|
$comment);
|
|
|
|
}
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_all_ungraded_assessments($workshop) {
|
|
|
|
// lists all the assessments for comment by teacher
|
|
|
|
global $CFG;
|
2004-09-07 16:17:32 +00:00
|
|
|
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
|
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
$timenow = time();
|
|
|
|
|
|
|
|
if ($assessments = workshop_get_ungraded_assessments($workshop)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (!isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=gradeassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=gradeassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("gradeassessment", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
|
|
|
userdate($assessment->timecreated), $action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_assessed_submissions($workshop, $user) {
|
|
|
|
// list the submissions that have been assessed by this user and are COLD
|
2004-09-27 14:41:17 +00:00
|
|
|
global $CFG, $USER;
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
$timenow = time();
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
$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;
|
|
|
|
|
|
|
|
if ($assessments = workshop_get_student_assessments($workshop, $user)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
$comment = "";
|
|
|
|
$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
|
|
|
|
// the assessment may be in three states:
|
|
|
|
// 1. "hot", just created but not completed (timecreated is in the future)
|
|
|
|
// 2. "warm" just created and still capable of being edited, and
|
|
|
|
// 3. "cold" after the editing time
|
2004-09-07 16:17:32 +00:00
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment->timecreated < ($timenow - $CFG->maxeditingtime)) { // it's cold
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($workshop->agreeassessments) {
|
|
|
|
if (!$assessment->timeagreed) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id&".
|
2004-09-07 16:17:32 +00:00
|
|
|
"allowcomments=$workshop->agreeassessments\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("reassess", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
2004-09-27 14:41:17 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id&".
|
|
|
|
"allowcomments=false\">".get_string("view", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-09-27 14:41:17 +00:00
|
|
|
// if it been graded allow student to re-assess, except if it's a self assessment
|
|
|
|
if ($assessment->timegraded and !($USER->id == $assessment->userid)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("reassess", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment->timecreated < $timenow) { // only show the date if it's in the past (future dates cause confusion
|
|
|
|
$comment = get_string("assessedon", "workshop", userdate($assessment->timecreated));
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
else {
|
|
|
|
$comment = '';
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($submission->userid == $user->id) { // self assessment?
|
|
|
|
$comment .= "; ".get_string("ownwork", "workshop"); // just in case they don't know!
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
// has assessment been graded?
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
|
2004-09-29 21:28:55 +00:00
|
|
|
if ($workshop->gradingstrategy) { // supress grading grade if not graded
|
|
|
|
$comment .= "; ".get_string("thegradeforthisassessmentis", "workshop",
|
2004-09-07 16:17:32 +00:00
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0)).
|
|
|
|
" / $workshop->gradinggrade";
|
2004-09-29 21:28:55 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
// if peer agreements show whether agreement has been reached
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($workshop->agreeassessments) {
|
|
|
|
if ($assessment->timeagreed) {
|
|
|
|
$comment .= "; ".get_string("assessmentwasagreedon", "workshop",
|
|
|
|
userdate($assessment->timeagreed));
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
else {
|
|
|
|
$comment .= "; ".get_string("assessmentnotyetagreed", "workshop");
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
|
|
|
|
$comment);
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
else {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center>".get_string("noassessmentsdone", "workshop")."</center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_peer_assessments($workshop, $user) {
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
$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 user's submissions
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
// get the assessments
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
// assessments by students only and exclude any self assessments
|
|
|
|
if (isstudent($workshop->course, $assessment->userid) and
|
|
|
|
($assessment->userid != $user->id)) {
|
|
|
|
$timenow = time();
|
|
|
|
if (($timenow - $assessment->timecreated) > $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id&".
|
2004-06-18 09:24:20 +00:00
|
|
|
"allowcomments=$workshop->agreeassessments\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
$comment = get_string("assessedon", "workshop", userdate($assessment->timecreated));
|
|
|
|
$grade = number_format($assessment->grade * $workshop->grade / 100, 1);
|
2004-09-29 21:28:55 +00:00
|
|
|
if ($workshop->gradingstrategy) { // supress grade if not graded
|
|
|
|
$comment .= "; ".get_string("gradeforsubmission", "workshop").
|
|
|
|
": $grade / $workshop->grade";
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($assessment->timegraded) {
|
|
|
|
if (!$assessment->gradinggrade) {
|
|
|
|
// it's a bad assessment
|
|
|
|
$comment .= "; ".get_string("thisisadroppedassessment", "workshop");
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
if (isteacher($workshop->course, $assessment->userid) and $workshop->teacherweight) {
|
|
|
|
$comment .= "; ".get_string("thisisadroppedassessment", "workshop");
|
|
|
|
}
|
|
|
|
// if peer agreements show whether agreement has been reached
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($workshop->agreeassessments) {
|
|
|
|
if ($assessment->timeagreed) {
|
|
|
|
$comment .= "; ".get_string("assessmentwasagreedon", "workshop",
|
|
|
|
userdate($assessment->timeagreed));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$comment .= "; ".get_string("assessmentnotyetagreed", "workshop");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
|
|
|
$action, $comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
else {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center>".get_string("noassessmentsdone", "workshop")."</center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_self_assessments($workshop, $user) {
|
|
|
|
// list user's submissions for the user to assess
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
$timenow = time();
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
$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 user's submissions
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
2004-09-27 14:41:17 +00:00
|
|
|
$comment = get_string("ownwork", "workshop"); // just in case they don't know!
|
2004-06-18 09:24:20 +00:00
|
|
|
if (!$assessment = get_record_select("workshop_assessments", "submissionid = $submission->id AND
|
|
|
|
userid = $user->id")) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
2004-09-27 14:41:17 +00:00
|
|
|
} else {
|
|
|
|
// may still be warm
|
|
|
|
if (($assessment->timecreated + $CFG->maxeditingtime) > $timenow) {
|
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
|
|
|
get_string("reassess", "workshop")."</a>";
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($table->data)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p><center><b>".get_string("pleaseassessyoursubmissions", "workshop", $course->student).
|
2004-09-12 22:29:44 +00:00
|
|
|
"</b></center><br />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
print_table($table);
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
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;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
|
|
|
|
$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;
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// check group membership, if necessary
|
|
|
|
if ($groupid) {
|
|
|
|
// check user's group
|
|
|
|
if (!ismember($groupid, $submission->userid)) {
|
|
|
|
continue; // skip this submission
|
|
|
|
}
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// 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 (isstudent($workshop->course, $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
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
|
|
|
}
|
|
|
|
elseif ($assessment->timecreated > ($timenow - $CFG->maxeditingtime)) { // there's still time left to edit...
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($table->data)) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p><center><b>".get_string("pleaseassessthesestudentsubmissions", "workshop", $course->student).
|
2004-09-12 22:29:44 +00:00
|
|
|
"</b></center><br />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
else {
|
2004-09-12 22:29:44 +00:00
|
|
|
echo "<p><center><b>".get_string("nosubmissionsavailableforassessment", "workshop")."</b></center><br />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_submissions_for_admin($workshop, $order) {
|
|
|
|
// list the teacher sublmissions first
|
|
|
|
global $CFG, $USER;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
if (groupmode($course, $cm) == SEPARATEGROUPS) {
|
|
|
|
$groupid = get_current_group($course->id);
|
|
|
|
} else {
|
|
|
|
$groupid = 0;
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
|
|
|
|
workshop_print_assignment_info($workshop);
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (isteacheredit($course->id)) {
|
|
|
|
// list any teacher submissions
|
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
|
|
|
|
get_string("action", "workshop"));
|
|
|
|
$table->align = array ("left", "left", "left");
|
|
|
|
$table->size = array ("*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
|
2004-09-07 16:17:32 +00:00
|
|
|
get_string("amendtitle", "workshop")."</a>";
|
|
|
|
// has user already assessed this submission
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $USER->id")) {
|
|
|
|
$curtime = time();
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment->timecreated > $curtime) { // it's a "hanging" assessment
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
elseif (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">"
|
2004-06-18 09:24:20 +00:00
|
|
|
.get_string("reassess", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
else { // there's still time left to edit...
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
else { // user has not graded this submission
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-07 16:17:32 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=adminlist&id=$cm->id&sid=$submission->id\">".
|
2004-09-07 16:17:32 +00:00
|
|
|
get_string("listassessments", "workshop")."</a>";
|
|
|
|
}
|
2004-10-17 15:53:19 +00:00
|
|
|
if (isteacheredit($course->id)) {
|
|
|
|
$action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
|
|
|
|
get_string("delete", "workshop")."</a>";
|
|
|
|
}
|
2004-09-29 16:52:24 +00:00
|
|
|
$table->data[] = array("<a href=\"submissions.php?action=editsubmission&id=$cm->id&sid=$submission->id\">$submission->title</a>", $course->teacher, $action);
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
print_heading(get_string("studentsubmissions", "workshop", $course->teacher), "center");
|
|
|
|
print_table($table);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// list student assessments
|
|
|
|
// Get all the students...
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($users = get_course_students($course->id, "u.lastname, u.firstname")) {
|
2004-06-18 09:24:20 +00:00
|
|
|
$timenow = time();
|
|
|
|
unset($table);
|
|
|
|
$table->head = array(get_string("name"), get_string("title", "workshop"), get_string("action", "workshop"));
|
|
|
|
$table->align = array ("left", "left", "left");
|
|
|
|
$table->size = array ("*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
2004-11-12 17:28:07 +00:00
|
|
|
$nassessments = 0;
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($users as $user) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// check group membership, if necessary
|
|
|
|
if ($groupid) {
|
|
|
|
// check user's group
|
|
|
|
if (!ismember($groupid, $user->id)) {
|
|
|
|
continue; // skip this user
|
|
|
|
}
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// list the assessments which have been done (exclude the hot ones)
|
|
|
|
if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
|
|
|
|
$title ='';
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
|
|
|
|
error("Workshop_list_submissions_for_admin: Submission record not found!");
|
|
|
|
}
|
|
|
|
$title .= $submission->title;
|
2004-09-27 14:41:17 +00:00
|
|
|
if ($workshop->agreeassessments and !$assessment->timeagreed and
|
|
|
|
isstudent($workshop->course, $submission->userid)) { // agreements for student work only
|
|
|
|
$title .= " <<".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")>> ";
|
|
|
|
} elseif ($assessment->timegraded) {
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($assessment->gradinggrade) {
|
|
|
|
// a good assessment
|
|
|
|
$title .= " {".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")} ";
|
|
|
|
} else {
|
|
|
|
// a poor assessment
|
2004-09-27 14:41:17 +00:00
|
|
|
$title .= " <".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).")> ";
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// not yet graded
|
2004-09-27 14:41:17 +00:00
|
|
|
$title .= " {".number_format($assessment->grade * $workshop->grade / 100, 0)." ((".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0)."))} ";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
if ($realassessments = workshop_count_user_assessments_done($workshop, $user)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=adminlistbystudent&id=$cm->id&userid=$user->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("liststudentsassessments", "workshop")." ($realassessments)</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
2004-06-18 09:24:20 +00:00
|
|
|
$action ="";
|
|
|
|
}
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
$nassessments++;
|
2004-08-17 05:19:21 +00:00
|
|
|
$table->data[] = array(fullname($user), $title, $action);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
2004-11-12 17:28:07 +00:00
|
|
|
print_heading(get_string("studentassessments", "workshop", $course->student)." [$nassessments]");
|
2004-09-07 16:17:32 +00:00
|
|
|
print_table($table);
|
|
|
|
workshop_print_key($workshop);
|
|
|
|
// grading grade analysis
|
|
|
|
unset($table);
|
|
|
|
$table->head = array (get_string("count", "workshop"), get_string("mean", "workshop"),
|
|
|
|
get_string("standarddeviation", "workshop"), get_string("maximum", "workshop"),
|
|
|
|
get_string("minimum", "workshop"));
|
|
|
|
$table->align = array ("center", "center", "center", "center", "center");
|
|
|
|
$table->size = array ("*", "*", "*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
if ($groupid) {
|
|
|
|
$stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean,
|
|
|
|
STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max
|
|
|
|
FROM {$CFG->prefix}groups_members g, {$CFG->prefix}workshop_assessments a
|
|
|
|
WHERE g.groupid = $groupid AND a.userid = g.userid AND a.timegraded > 0
|
|
|
|
AND a.workshopid = $workshop->id");
|
|
|
|
} else { // no group/all participants
|
|
|
|
$stats = get_record_sql("SELECT COUNT(*) as count, AVG(gradinggrade) AS mean,
|
|
|
|
STDDEV(gradinggrade) AS stddev, MIN(gradinggrade) AS min, MAX(gradinggrade) AS max
|
|
|
|
FROM {$CFG->prefix}workshop_assessments a
|
|
|
|
WHERE a.timegraded > 0 AND a.workshopid = $workshop->id");
|
|
|
|
}
|
|
|
|
$table->data[] = array($stats->count, number_format($stats->mean * $workshop->gradinggrade / 100, 1),
|
|
|
|
number_format($stats->stddev * $workshop->gradinggrade /100, 1),
|
|
|
|
number_format($stats->max * $workshop->gradinggrade / 100, 1),
|
|
|
|
number_format($stats->min* $workshop->gradinggrade / 100, 1));
|
|
|
|
print_heading(get_string("gradinggrade", "workshop")." ".get_string("analysis", "workshop"));
|
2004-06-18 09:24:20 +00:00
|
|
|
print_table($table);
|
2004-09-27 14:41:17 +00:00
|
|
|
echo "<p align=\"center\"><a href=\"assessments.php?id=$cm->id&action=regradestudentassessments\">".
|
|
|
|
get_string("regradestudentassessments", "workshop")."</a> ";
|
|
|
|
helpbutton("regrading", get_string("regradestudentassessments", "workshop"), "workshop");
|
|
|
|
echo "</p>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now the sudent submissions
|
|
|
|
unset($table);
|
|
|
|
switch ($order) {
|
|
|
|
case "title" :
|
2004-09-16 17:13:57 +00:00
|
|
|
$table->head = array("<a href=\"submissions.php?action=adminlist&id=$cm->id&order=name\">".
|
2004-09-28 15:49:49 +00:00
|
|
|
get_string("submittedby", "workshop")."</a>", get_string("title", "workshop"),
|
|
|
|
get_string("submitted", "workshop"), get_string("action", "workshop"));
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
case "name" :
|
|
|
|
$table->head = array (get_string("submittedby", "workshop"),
|
2004-09-16 17:13:57 +00:00
|
|
|
"<a href=\"submissions.php?action=adminlist&id=$cm->id&order=title\">".
|
2004-09-28 15:49:49 +00:00
|
|
|
get_string("title", "workshop")."</a>", get_string("submitted", "workshop"),
|
|
|
|
get_string("action", "workshop"));
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-09-28 15:49:49 +00:00
|
|
|
$table->align = array ("left", "left", "left", "left");
|
|
|
|
$table->size = array ("*", "*", "*", "*");
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
2004-11-12 17:28:07 +00:00
|
|
|
|
|
|
|
$nsubmissions = 0;
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($submissions = workshop_get_student_submissions($workshop, $order)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if (!$user = get_record("user", "id", $submission->userid)) {
|
|
|
|
error("workshop_list_submissions_for_admin: failure to get user record");
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
// check group membership, if necessary
|
|
|
|
if ($groupid) {
|
|
|
|
// check user's group
|
|
|
|
if (!ismember($groupid, $user->id)) {
|
|
|
|
continue; // skip this user
|
|
|
|
}
|
|
|
|
}
|
2004-09-28 15:49:49 +00:00
|
|
|
$datesubmitted = userdate($submission->timecreated);
|
|
|
|
if ($submission->late) {
|
|
|
|
$datesubmitted = "<font color=\"red\">".$datesubmitted."</font>";
|
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"submissions.php?action=adminamendtitle&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("amendtitle", "workshop")."</a>";
|
|
|
|
// has teacher already assessed this submission
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $USER->id")) {
|
|
|
|
$curtime = time();
|
|
|
|
if (($curtime - $assessment->timecreated) > $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("reassess", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
else { // there's still time left to edit...
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // user has not assessed this submission
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
if ($nassessments = workshop_count_assessments($submission)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"assessments.php?action=adminlist&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("listassessments", "workshop")." ($nassessments)</a>";
|
|
|
|
}
|
2004-09-28 15:49:49 +00:00
|
|
|
if ($submission->late) {
|
|
|
|
$action .= " | <a href=\"submissions.php?action=adminlateflag&id=$cm->id&sid=$submission->id\">".
|
|
|
|
get_string("clearlateflag", "workshop")."</a>";
|
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
$action .= " | <a href=\"submissions.php?action=adminconfirmdelete&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("delete", "workshop")."</a>";
|
2004-11-12 17:28:07 +00:00
|
|
|
$nsubmissions++;
|
2004-09-07 16:17:32 +00:00
|
|
|
$table->data[] = array("$user->firstname $user->lastname", $submission->title.
|
|
|
|
" (".get_string("grade").": ".workshop_submission_grade($workshop, $submission)." ".
|
|
|
|
workshop_print_submission_assessments($workshop, $submission, "teacher").
|
2004-09-28 15:49:49 +00:00
|
|
|
" ".workshop_print_submission_assessments($workshop, $submission, "student").")", $datesubmitted,
|
|
|
|
$action);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
print_heading(get_string("studentsubmissions", "workshop", $course->student)." [$nsubmissions]", "center");
|
2004-06-18 09:24:20 +00:00
|
|
|
print_table($table);
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_print_key($workshop);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
2004-11-12 17:28:07 +00:00
|
|
|
function workshop_list_teacher_assessments_by_user($workshop, $user) {
|
2004-06-18 09:24:20 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
$timenow = time();
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$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 user's submissions
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
// get the assessments
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (isteacher($workshop->course, $assessment->userid)) { // assessments by teachers only
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
// has teacher commented on teacher's assessment? shouldn't happen but leave test in
|
|
|
|
if ($assessment->timegraded and ($timenow - $assessment->timegraded > $CFG->maxeditingtime)) {
|
|
|
|
$comment = get_string("gradedbyteacher", "workshop", $course->teacher);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$comment = userdate($assessment->timecreated);
|
|
|
|
}
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
else {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center>".get_string("noassessmentsdone", "workshop")."</center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_teacher_submissions($workshop, $user) {
|
|
|
|
global $CFG;
|
2004-09-27 14:41:17 +00:00
|
|
|
|
|
|
|
// set threshold on re-assessments
|
|
|
|
$reassessthreshold = 80;
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$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
|
|
|
|
$nassessed = count_records_select("workshop_assessments", "workshopid = $workshop->id
|
|
|
|
AND userid = $user->id");
|
|
|
|
if ($nassessed < $workshop->ntassessments) {
|
|
|
|
// if user has not assessed enough, set up "future" assessment records for this user for the teacher submissions...
|
|
|
|
// ... first count the number of assessments for each teacher submission...
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
srand ((float)microtime()*1000000); // initialise random number generator
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
$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, 99) / 100;
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// ...put the submissions with the lowest number of assessments first...
|
|
|
|
asort($nassessments);
|
|
|
|
reset($nassessments);
|
|
|
|
foreach ($nassessments as $submissionid => $n) { // break out of loop when we allocated enough assessments...
|
|
|
|
$submission = get_record("workshop_submissions", "id", $submissionid);
|
|
|
|
// ... provided the user has NOT already assessed that 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 of 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("Could not insert workshop assessment!");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$nassessed++;
|
|
|
|
if ($nassessed >= $workshop->ntassessments) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// now list user's assessments (but only list those which come from teacher 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_teacher_submissions: unable to get submission");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// submission from a teacher?
|
|
|
|
if (isteacher($workshop->course, $submission->userid)) {
|
|
|
|
$comment = '';
|
2004-09-07 16:17:32 +00:00
|
|
|
// user assessment has two states: record created but not assessed (date created in the future);
|
|
|
|
// assessed but always available for re-assessment
|
|
|
|
if ($assessment->timecreated > $timenow) { // user needs to assess this submission
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
elseif ($assessment->timegraded and ($assessment->gradinggrade < $reassessthreshold)) {
|
|
|
|
// allow student to improve on their assessment once it's been graded and is below threshold
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("reassess", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
2004-09-27 14:41:17 +00:00
|
|
|
// allow student just to see their assessment if it hasn't been graded (or above threshold)
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("view", "workshop")."</a>";
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
|
|
|
// see if the assessment is graded
|
|
|
|
if ($assessment->timegraded) {
|
2004-09-29 21:28:55 +00:00
|
|
|
// show grading grade (supressed if workshop not graded)
|
|
|
|
if ($workshop->gradingstrategy) {
|
|
|
|
$comment = get_string("thegradeforthisassessmentis", "workshop",
|
2004-09-07 16:17:32 +00:00
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 1))." / ".
|
|
|
|
$workshop->gradinggrade;
|
2004-09-29 21:28:55 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
} elseif ($assessment->timecreated < $timenow) {
|
|
|
|
$comment = get_string("awaitinggradingbyteacher", "workshop", $course->teacher);
|
|
|
|
}
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
print_table($table);
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_unassessed_student_submissions($workshop, $user) {
|
|
|
|
// list the student submissions not assessed by this user
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
$timenow = time();
|
2004-09-07 16:17:32 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groupmode($course, $cm) == SEPARATEGROUPS) {
|
|
|
|
$groupid = get_current_group($course->id);
|
|
|
|
} else {
|
|
|
|
$groupid = 0;
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
|
2004-09-27 14:41:17 +00:00
|
|
|
get_string("submitted", "workshop"), get_string("action", "workshop"), get_string("comment", "workshop"));
|
|
|
|
$table->align = array ("left", "left", "left", "left", "left");
|
|
|
|
$table->size = array ("*", "*", "*", "*", "*");
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
if ($submissions = workshop_get_student_submissions($workshop, 'time')) { // oldest first
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($submissions as $submission) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// check group membership, if necessary
|
|
|
|
if ($groupid) {
|
|
|
|
// check user's group
|
|
|
|
if (!ismember($groupid, $submission->userid)) {
|
|
|
|
continue; // skip this user
|
|
|
|
}
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
// see if submission is cold
|
|
|
|
if (($submission->timecreated +$CFG->maxeditingtime) > $timenow) {
|
|
|
|
continue; // skip this submission
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$comment = "";
|
2004-09-27 14:41:17 +00:00
|
|
|
$timegap = get_string("ago", "workshop", format_time($submission->timecreated - $timenow));
|
2004-06-18 09:24:20 +00:00
|
|
|
// see if user already graded this assessment
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $user->id")) {
|
|
|
|
if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
|
|
|
|
// last chance salon
|
|
|
|
$submissionowner = get_record("user", "id", $submission->userid);
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
2004-09-27 14:41:17 +00:00
|
|
|
fullname($submissionowner), $timegap, $action, $comment);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
else {
|
|
|
|
// no assessment by this user, if no other teacher has assessed submission then list it
|
|
|
|
if (!workshop_count_teacher_assessments($course->id, $submission)) {
|
|
|
|
$submissionowner = get_record("user", "id", $submission->userid);
|
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
|
|
|
get_string("assess", "workshop")."</a>";
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
|
|
|
fullname($submissionowner), $timegap, $action, $comment);
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_unassessed_teacher_submissions($workshop, $user) {
|
|
|
|
// list the teacher submissions not assessed by this user
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("action", "workshop"),
|
|
|
|
get_string("comment", "workshop"));
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
$comment = "";
|
|
|
|
// see if user already graded this assessment
|
|
|
|
if ($assessment = get_record_select("workshop_assessments", "submissionid = $submission->id
|
|
|
|
AND userid = $user->id")) {
|
|
|
|
$timenow = time();
|
|
|
|
if (($timenow - $assessment->timecreated < $CFG->maxeditingtime)) {
|
|
|
|
// last chance salon
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // no assessment
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=assesssubmission&id=$cm->id&sid=$submission->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("assess", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action, $comment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_ungraded_assessments($workshop, $stype) {
|
2004-09-07 16:17:32 +00:00
|
|
|
// lists all the assessments of student submissions for grading by teacher
|
2004-06-18 09:24:20 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("submittedby", "workshop"),
|
|
|
|
get_string("assessor", "workshop"), get_string("timeassessed", "workshop"), get_string("action", "workshop"));
|
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("*", "*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
$timenow = time();
|
|
|
|
|
|
|
|
switch ($stype) {
|
|
|
|
case "student" :
|
|
|
|
$assessments = workshop_get_ungraded_assessments_student($workshop);
|
|
|
|
break;
|
|
|
|
case "teacher" :
|
|
|
|
$assessments = workshop_get_ungraded_assessments_teacher($workshop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ($assessments) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (!isteacher($workshop->course, $assessment->userid)) { // don't let teacher grade their own assessments
|
|
|
|
if (($timenow - $assessment->timegraded) < $CFG->maxeditingtime) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=gradeassessment&id=$cm->id&stype=$stype&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-16 17:13:57 +00:00
|
|
|
$action = "<a href=\"assessments.php?action=gradeassessment&id=$cm->id&stype=$stype&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("grade", "workshop")."</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
$submission = get_record("workshop_submissions", "id", $assessment->submissionid);
|
|
|
|
$submissionowner = get_record("user", "id", $submission->userid);
|
|
|
|
$assessor = get_record("user", "id", $assessment->userid);
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
2004-08-17 05:19:21 +00:00
|
|
|
fullname($submissionowner), fullname($assessor), userdate($assessment->timecreated), $action);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->data)) {
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_list_user_submissions($workshop, $user) {
|
|
|
|
global $CFG;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$timenow = time();
|
|
|
|
$table->head = array (get_string("title", "workshop"), get_string("action", "workshop"),
|
|
|
|
get_string("submitted", "assignment"), get_string("assessments", "workshop"));
|
|
|
|
$table->align = array ("LEFT", "LEFT", "LEFT", "LEFT");
|
|
|
|
$table->size = array ("*", "*", "*", "*");
|
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
|
|
|
if ($submissions = workshop_get_user_submissions($workshop, $user)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
// allow user to delete a submission if it's warm
|
|
|
|
if ($submission->timecreated > ($timenow - $CFG->maxeditingtime)) {
|
2004-09-27 14:41:17 +00:00
|
|
|
$action = "<a href=\"submissions.php?action=editsubmission&id=$cm->id&sid=$submission->id\">".
|
|
|
|
get_string("edit", "workshop")."</a> | ".
|
|
|
|
"<a href=\"submissions.php?action=userconfirmdelete&id=$cm->id&sid=$submission->id\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("delete", "workshop")."</a>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$action = '';
|
|
|
|
}
|
2004-09-28 15:49:49 +00:00
|
|
|
$datesubmitted = userdate($submission->timecreated);
|
|
|
|
if ($submission->late) {
|
|
|
|
$datesubmitted = "<font color=\"red\">".$datesubmitted."</font>";
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$n = count_records_select("workshop_assessments", "submissionid = $submission->id AND
|
|
|
|
timecreated < ($timenow - $CFG->maxeditingtime)");
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), $action,
|
2004-09-28 15:49:49 +00:00
|
|
|
$datesubmitted, $n);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_assessment($workshop, $assessment = false, $allowchanges = false,
|
|
|
|
$showcommentlinks = false, $returnto = '') {
|
|
|
|
// $allowchanges added 14/7/03
|
|
|
|
// $returnto added 28/8/03
|
|
|
|
global $CFG, $THEME, $USER, $WORKSHOP_SCALES, $WORKSHOP_EWEIGHTS;
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
$timenow = time();
|
|
|
|
|
|
|
|
// reset the internal flags
|
|
|
|
if ($assessment) {
|
|
|
|
$showgrades = false;
|
|
|
|
}
|
|
|
|
else { // if no assessment, i.e. specimen grade form always show grading scales
|
|
|
|
$showgrades = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($assessment) {
|
|
|
|
// set the internal flag is necessary
|
|
|
|
if ($allowchanges or !$workshop->agreeassessments or !$workshop->hidegrades or
|
|
|
|
$assessment->timeagreed) {
|
|
|
|
$showgrades = true;
|
|
|
|
}
|
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<center><table border=\"1\" width=\"30%\"><tr>
|
|
|
|
<td align=\"center\" bgcolor=\"$THEME->cellcontent\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
|
|
|
|
error ("Workshop_print_assessment: Submission record not found");
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
echo workshop_print_submission($workshop, $submission);
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "</td></tr></table><br clear=\"all\" />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
// see if this is a pre-filled assessment for a re-submission...
|
|
|
|
if ($assessment->resubmission) {
|
|
|
|
// ...and print an explaination
|
|
|
|
print_heading(get_string("assessmentofresubmission", "workshop"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// print agreement time if the workshop requires peer agreement
|
|
|
|
if ($workshop->agreeassessments and $assessment->timeagreed) {
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p>".get_string("assessmentwasagreedon", "workshop", userdate($assessment->timeagreed));
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// first print any comments on this assessment
|
|
|
|
if ($comments = workshop_get_comments($assessment)) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<table cellpadding=\"2\" border=\"1\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
$firstcomment = TRUE;
|
|
|
|
foreach ($comments as $comment) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\"><td bgcolor=\"$THEME->cellheading2\"><p><b>".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("commentby","workshop")." ";
|
|
|
|
if (isteacher($workshop->course, $comment->userid)) {
|
|
|
|
echo $course->teacher;
|
|
|
|
}
|
|
|
|
elseif ($assessment->userid == $comment->userid) {
|
|
|
|
print_string("assessor", "workshop");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print_string("authorofsubmission", "workshop");
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " ".get_string("on", "workshop", userdate($comment->timecreated))."</b></p></td></tr><tr><td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
echo text_to_html($comment->comments)." \n";
|
|
|
|
// add the links if needed
|
|
|
|
if ($firstcomment and $showcommentlinks and !$assessment->timeagreed) {
|
|
|
|
// show links depending on who doing the viewing
|
|
|
|
$firstcomment = FALSE;
|
|
|
|
if (isteacher($workshop->course, $USER->id) and ($comment->userid != $USER->id)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<p align=\"right\"><a href=\"assessments.php?action=addcomment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("reply", "workshop")."</a>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
elseif (($comment->userid ==$USER->id) and (($timenow - $comment->timecreated) < $CFG->maxeditingtime)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<p align=\"right\"><a href=\"assessments.php?action=editcomment&id=$cm->id&cid=$comment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("edit", "workshop")."</a>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($USER->id == $submission->userid) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo " | <a href=\"assessments.php?action=agreeassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("agreetothisassessment", "workshop")."</a>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (($comment->userid != $USER->id) and (($USER->id == $assessment->userid) or
|
|
|
|
($USER->id == $submission->userid))) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<p align=\"right\"><a href=\"assessments.php?action=addcomment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("reply", "workshop")."</a>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($USER->id == $submission->userid) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo " | <a href=\"assessments.php?action=agreeassessment&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 21:43:59 +00:00
|
|
|
get_string("agreetothisassessment", "workshop")."</a>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</table>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// only show the grade if grading strategy > 0 and the grade is positive
|
|
|
|
if ($showgrades and $workshop->gradingstrategy and $assessment->grade >= 0) {
|
2004-09-20 14:59:41 +00:00
|
|
|
echo "<center><b>".get_string("thegradeis", "workshop").": ".
|
|
|
|
number_format($assessment->grade * $workshop->grade / 100, 2)." (".
|
2004-09-14 20:39:28 +00:00
|
|
|
get_string("maximumgrade")." ".number_format($workshop->grade, 0).")</b></center><br clear=\"all\" />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
// now print the grading form with the grading grade if any
|
2004-06-18 09:24:20 +00:00
|
|
|
// FORM is needed for Mozilla browsers, else radio bttons are not checked
|
|
|
|
?>
|
|
|
|
<form name="assessmentform" method="post" action="assessments.php">
|
2004-09-12 14:41:49 +00:00
|
|
|
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
|
|
|
|
<input type="hidden" name="aid" value="<?php echo $assessment->id ?>" />
|
|
|
|
<input type="hidden" name="action" value="updateassessment" />
|
|
|
|
<input type="hidden" name="returnto" value="<?php echo $returnto ?>" />
|
2004-11-12 17:28:07 +00:00
|
|
|
<input type="hidden" name="elementno" value="" />
|
|
|
|
<input type="hidden" name="stockcommentid" value="" />
|
2004-06-18 09:24:20 +00:00
|
|
|
<center>
|
2004-09-14 20:39:28 +00:00
|
|
|
<table cellpadding="2" border="1">
|
2004-06-18 09:24:20 +00:00
|
|
|
<?php
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"><center><b>".get_string("assessment", "workshop").
|
2004-06-18 09:24:20 +00:00
|
|
|
"</b></center></td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
// get the assignment elements...
|
|
|
|
$elementsraw = get_records("workshop_elements", "workshopid", $workshop->id, "elementno ASC");
|
|
|
|
if (count($elementsraw) < $workshop->nelements) {
|
|
|
|
print_string("noteonassignmentelements", "workshop");
|
|
|
|
}
|
|
|
|
if ($elementsraw) {
|
|
|
|
foreach ($elementsraw as $element) {
|
|
|
|
$elements[] = $element; // to renumber index 0,1,2...
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$elements = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($assessment) {
|
|
|
|
// get any previous grades...
|
|
|
|
if ($gradesraw = get_records_select("workshop_grades", "assessmentid = $assessment->id", "elementno")) {
|
|
|
|
foreach ($gradesraw as $grade) {
|
|
|
|
$grades[] = $grade; // to renumber index 0,1,2...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// setup dummy grades array
|
|
|
|
for($i = 0; $i < count($elementsraw); $i++) { // gives a suitable sized loop
|
|
|
|
$grades[$i]->feedback = get_string("yourfeedbackgoeshere", "workshop");
|
|
|
|
$grades[$i]->grade = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine what sort of grading
|
|
|
|
switch ($workshop->gradingstrategy) {
|
|
|
|
case 0: // no grading
|
|
|
|
// now print the form
|
|
|
|
for ($i=0; $i < count($elements); $i++) {
|
|
|
|
$iplus1 = $i+1;
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>".text_to_html($elements[$i]->description);
|
|
|
|
echo "</td></tr>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($allowchanges) {
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($grades[$i]->feedback)) {
|
|
|
|
echo $grades[$i]->feedback;
|
|
|
|
}
|
|
|
|
echo "</textarea>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo text_to_html($grades[$i]->feedback);
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
|
|
|
|
// if active and the teacher show stock comments...
|
|
|
|
if ($allowchanges and isteacher($course->id, $USER->id)) {
|
|
|
|
echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
|
|
|
|
get_string("addcomment", "workshop")."\"
|
|
|
|
onclick=\"document.assessmentform.action.value='addstockcomment';
|
|
|
|
document.assessmentform.elementno.value=$i;document.assessmentform.submit();\" /> \n";
|
|
|
|
helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
|
|
|
|
echo "</td><td>\n";
|
|
|
|
if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
|
|
|
|
AND elementno = $i", "id")) { // show comments in fixed order (oldest first)
|
|
|
|
foreach ($stockcomments as $stockcomment) {
|
|
|
|
echo "<a onclick=\"document.assessmentform.feedback_$i.value+=' '+'$stockcomment->comments';\"><<$stockcomment->comments>></a>\n";
|
|
|
|
if (isteacheredit($course->id, $USER->id)) {
|
|
|
|
echo " <a onclick=\"document.assessmentform.action.value='removestockcomment';document.assessmentform.stockcommentid.value=$stockcomment->id;document.assessmentform.submit();\"> <small><i><--".get_string("delete","workshop")."</i></small></a>\n";
|
|
|
|
}
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // accumulative grading
|
|
|
|
// now print the form
|
|
|
|
for ($i=0; $i < count($elements); $i++) {
|
|
|
|
$iplus1 = $i+1;
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>".text_to_html($elements[$i]->description);
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<p align=\"right\"><font size=\"1\">".get_string("weight", "workshop").": ".
|
2004-09-12 21:43:59 +00:00
|
|
|
number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
|
|
|
|
echo "</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($showgrades) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td valign=\"top\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
// get the appropriate scale
|
|
|
|
$scalenumber=$elements[$i]->scale;
|
|
|
|
$SCALE = (object)$WORKSHOP_SCALES[$scalenumber];
|
|
|
|
switch ($SCALE->type) {
|
|
|
|
case 'radio' :
|
|
|
|
// show selections highest first
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center><b>$SCALE->start</b> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
|
|
|
|
$checked = false;
|
|
|
|
if (isset($grades[$i]->grade)) {
|
|
|
|
if ($j == $grades[$i]->grade) {
|
|
|
|
$checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // there's no previous grade so check the lowest option
|
|
|
|
if ($j == 0) {
|
|
|
|
$checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($checked) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> \n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> \n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <b>$SCALE->end</b></center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
case 'selection' :
|
|
|
|
unset($numbers);
|
|
|
|
for ($j = $SCALE->size; $j >= 0; $j--) {
|
|
|
|
$numbers[$j] = $j;
|
|
|
|
}
|
|
|
|
if (isset($grades[$i]->grade)) {
|
|
|
|
choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
choose_from_menu($numbers, "grade[$i]", 0, "");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($allowchanges) {
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($grades[$i]->feedback)) {
|
|
|
|
echo $grades[$i]->feedback;
|
|
|
|
}
|
|
|
|
echo "</textarea>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo text_to_html($grades[$i]->feedback);
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
|
|
|
|
// if active and the teacher show stock comments...
|
|
|
|
if ($allowchanges and isteacher($course->id, $USER->id)) {
|
|
|
|
echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
|
|
|
|
get_string("addcomment", "workshop")."\"
|
|
|
|
onclick=\"document.assessmentform.action.value='addstockcomment';
|
|
|
|
document.assessmentform.elementno.value=$i;document.assessmentform.submit();\" /> \n";
|
|
|
|
helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
|
|
|
|
echo "</td><td>\n";
|
|
|
|
if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
|
|
|
|
AND elementno = $i", "id")) { // get comments in a fixed order - oldest first
|
|
|
|
foreach ($stockcomments as $stockcomment) {
|
|
|
|
echo "<a onclick=\"document.assessmentform.feedback_$i.value+=' '+'$stockcomment->comments';\"><<$stockcomment->comments>></a>\n";
|
|
|
|
if (isteacheredit($course->id, $USER->id)) {
|
|
|
|
echo " <a onclick=\"document.assessmentform.action.value='removestockcomment';document.assessmentform.stockcommentid.value=$stockcomment->id;document.assessmentform.submit();\"> <small><i><--".get_string("delete","workshop")."</i></small></a>\n";
|
|
|
|
}
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // error banded grading
|
|
|
|
// now run through the elements
|
|
|
|
$negativecount = 0;
|
|
|
|
for ($i=0; $i < count($elements) - 1; $i++) {
|
|
|
|
$iplus1 = $i+1;
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("element","workshop")." $iplus1:</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>".text_to_html($elements[$i]->description);
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<p align=\"right\"><font size=\"1\">".get_string("weight", "workshop").": ".
|
2004-09-12 21:43:59 +00:00
|
|
|
number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."</font>\n";
|
|
|
|
echo "</td></tr>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("grade"). ":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td valign=\"top\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
// get the appropriate scale - yes/no scale (0)
|
|
|
|
$SCALE = (object) $WORKSHOP_SCALES[0];
|
|
|
|
switch ($SCALE->type) {
|
|
|
|
case 'radio' :
|
|
|
|
// show selections highest first
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<center><b>$SCALE->start</b> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
for ($j = $SCALE->size - 1; $j >= 0 ; $j--) {
|
|
|
|
$checked = false;
|
|
|
|
if (isset($grades[$i]->grade)) {
|
|
|
|
if ($j == $grades[$i]->grade) {
|
|
|
|
$checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // there's no previous grade so check the lowest option
|
|
|
|
if ($j == 0) {
|
|
|
|
$checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($checked) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" checked=\"checked\" /> \n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\" /> \n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <b>$SCALE->end</b></center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
case 'selection' :
|
|
|
|
unset($numbers);
|
|
|
|
for ($j = $SCALE->size; $j >= 0; $j--) {
|
|
|
|
$numbers[$j] = $j;
|
|
|
|
}
|
|
|
|
if (isset($grades[$i]->grade)) {
|
|
|
|
choose_from_menu($numbers, "grade[$i]", $grades[$i]->grade, "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
choose_from_menu($numbers, "grade[$i]", 0, "");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($allowchanges) {
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($grades[$i]->feedback)) {
|
|
|
|
echo $grades[$i]->feedback;
|
|
|
|
}
|
|
|
|
echo "</textarea>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (isset($grades[$i]->feedback)) {
|
|
|
|
echo text_to_html($grades[$i]->feedback);
|
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
|
|
|
|
// if active and the teacher show stock comments...
|
|
|
|
if ($allowchanges and isteacher($course->id, $USER->id)) {
|
|
|
|
echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
|
|
|
|
get_string("addcomment", "workshop")."\"
|
|
|
|
onclick=\"document.assessmentform.action.value='addstockcomment';
|
|
|
|
document.assessmentform.elementno.value=$i;document.assessmentform.submit();\" /> \n";
|
|
|
|
helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
|
|
|
|
echo "</td><td>\n";
|
|
|
|
if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
|
|
|
|
AND elementno = $i", "id")) { // get comments in a fixed order - oldest first
|
|
|
|
foreach ($stockcomments as $stockcomment) {
|
|
|
|
echo "<a onclick=\"document.assessmentform.feedback_$i.value+=' '+'$stockcomment->comments';\"><<$stockcomment->comments>></a>\n";
|
|
|
|
if (isteacheredit($course->id, $USER->id)) {
|
|
|
|
echo " <a onclick=\"document.assessmentform.action.value='removestockcomment';document.assessmentform.stockcommentid.value=$stockcomment->id;document.assessmentform.submit();\"> <small><i><--".get_string("delete","workshop")."</i></small></a>\n";
|
|
|
|
}
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
|
|
}
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (empty($grades[$i]->grade)) {
|
|
|
|
$negativecount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// print the number of negative elements
|
2004-09-12 21:43:59 +00:00
|
|
|
// echo "<tr><td>".get_string("numberofnegativeitems", "workshop")."</td><td>$negativecount</td></tr>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
// echo "<tr valign=\"top\">\n";
|
|
|
|
// echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</table></center>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
// now print the grade table
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<p><center><b>".get_string("gradetable","workshop")."</b></center>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<center><table cellpadding=\"5\" border=\"1\"><tr><td align=\"CENTER\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("numberofnegativeresponses", "workshop");
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td><td>". get_string("suggestedgrade", "workshop")."</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
for ($j = 100; $j >= 0; $j--) {
|
|
|
|
$numbers[$j] = $j;
|
|
|
|
}
|
|
|
|
for ($i=0; $i<=$workshop->nelements; $i++) {
|
|
|
|
if ($i == $negativecount) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<tr><td align=\"CENTER\"><img src=\"$CFG->pixpath/t/right.gif\" alt=\"\" /> $i</td><td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr><td align=\"CENTER\">$i</td><td align=\"CENTER\">{$elements[$i]->maxscore}</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</table></center>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td><b>".get_string("optionaladjustment",
|
2004-09-12 21:43:59 +00:00
|
|
|
"workshop")."</b></td><td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
unset($numbers);
|
|
|
|
for ($j = 20; $j >= -20; $j--) {
|
|
|
|
$numbers[$j] = $j;
|
|
|
|
}
|
|
|
|
if (isset($grades[$workshop->nelements]->grade)) {
|
|
|
|
choose_from_menu($numbers, "grade[$workshop->nelements]", $grades[$workshop->nelements]->grade, "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
choose_from_menu($numbers, "grade[$workshop->nelements]", 0, "");
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // criteria grading
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\"><b>". get_string("criterion","workshop")."</b></td>\n";
|
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\"><b>".get_string("select", "workshop")."</b></td>\n";
|
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\"><b>".get_string("suggestedgrade", "workshop")."</b></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
// find which criteria has been selected (saved in the zero element), if any
|
|
|
|
if (isset($grades[0]->grade)) {
|
|
|
|
$selection = $grades[0]->grade;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$selection = 0;
|
|
|
|
}
|
|
|
|
// now run through the elements
|
|
|
|
for ($i=0; $i < count($elements); $i++) {
|
|
|
|
$iplus1 = $i+1;
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>$iplus1</td><td>".text_to_html($elements[$i]->description)."</td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($selection == $i) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" checked=\"checked\" /></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[0]\" value=\"$i\" /></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<td align=\"center\">{$elements[$i]->maxscore}</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</table></center>\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<p><center><table cellpadding=\"5\" border=\"1\"><tr><td><b>".get_string("optionaladjustment",
|
2004-09-12 21:43:59 +00:00
|
|
|
"workshop")."</b></td><td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
unset($numbers);
|
|
|
|
for ($j = 20; $j >= -20; $j--) {
|
|
|
|
$numbers[$j] = $j;
|
|
|
|
}
|
|
|
|
if (isset($grades[1]->grade)) {
|
|
|
|
choose_from_menu($numbers, "grade[1]", $grades[1]->grade, "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
choose_from_menu($numbers, "grade[1]", 0, "");
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // rubric grading
|
|
|
|
// now run through the elements...
|
|
|
|
for ($i=0; $i < count($elements); $i++) {
|
|
|
|
$iplus1 = $i+1;
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo "<td align=\"right\"><b>".get_string("element", "workshop")." $iplus1:</b></td>\n";
|
|
|
|
echo "<td>".text_to_html($elements[$i]->description).
|
|
|
|
"<p align=\"right\"><font size=\"1\">".get_string("weight", "workshop").": ".
|
|
|
|
number_format($WORKSHOP_EWEIGHTS[$elements[$i]->weight], 2)."</font></td></tr>\n";
|
|
|
|
echo "<tr valign=\"top\">\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\" align=\"center\"><b>".get_string("select", "workshop").
|
|
|
|
"</b></td>\n";
|
|
|
|
echo " <td bgcolor=\"$THEME->cellheading2\"><b>". get_string("criterion","workshop").
|
|
|
|
"</b></td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($grades[$i])) {
|
|
|
|
$selection = $grades[$i]->grade;
|
2004-11-12 17:28:07 +00:00
|
|
|
} else {
|
2004-06-18 09:24:20 +00:00
|
|
|
$selection = 0;
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// ...and the rubrics
|
|
|
|
if ($rubricsraw = get_records_select("workshop_rubrics", "workshopid = $workshop->id AND
|
|
|
|
elementno = $i", "rubricno ASC")) {
|
|
|
|
unset($rubrics);
|
|
|
|
foreach ($rubricsraw as $rubic) {
|
|
|
|
$rubrics[] = $rubic; // to renumber index 0,1,2...
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
for ($j=0; $j<5; $j++) {
|
|
|
|
if (empty($rubrics[$j]->description)) {
|
|
|
|
break; // out of inner for loop
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($selection == $j) {
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\"
|
|
|
|
checked=\"checked\" /></td>\n";
|
|
|
|
} else {
|
|
|
|
echo " <td align=\"center\"><input type=\"RADIO\" name=\"grade[$i]\" value=\"$j\"
|
|
|
|
/></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
echo "<td>".text_to_html($rubrics[$j]->description)."</td>\n";
|
|
|
|
}
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("feedback").":</b></p></td>\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($allowchanges) {
|
2004-11-12 17:28:07 +00:00
|
|
|
echo " <textarea name=\"feedback_$i\" rows=\"3\" cols=\"75\" wrap=\"virtual\">\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
if (isset($grades[$i]->feedback)) {
|
|
|
|
echo $grades[$i]->feedback;
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
echo "</textarea>\n";
|
|
|
|
} else {
|
2004-06-18 09:24:20 +00:00
|
|
|
echo text_to_html($grades[$i]->feedback);
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
|
|
|
|
// if active and the teacher show stock comments...
|
|
|
|
if ($allowchanges and isteacher($course->id, $USER->id)) {
|
|
|
|
echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
|
|
|
|
get_string("addcomment", "workshop")."\"
|
|
|
|
onclick=\"document.assessmentform.action.value='addstockcomment';
|
|
|
|
document.assessmentform.elementno.value=$i;document.assessmentform.submit();\" /> \n";
|
|
|
|
helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
|
|
|
|
echo "</td><td>\n";
|
|
|
|
if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
|
|
|
|
AND elementno = $i", "id")) { // show comments in fixed (creation) order
|
|
|
|
foreach ($stockcomments as $stockcomment) {
|
|
|
|
echo "<a onclick=\"document.assessmentform.feedback_$i.value+=' '+'$stockcomment->comments';\"><<$stockcomment->comments>></a>\n";
|
|
|
|
if (isteacheredit($course->id, $USER->id)) {
|
|
|
|
echo " <a onclick=\"document.assessmentform.action.value='removestockcomment';document.assessmentform.stockcommentid.value=$stockcomment->id;document.assessmentform.submit();\"> <small><i><--".get_string("delete","workshop")."</i></small></a>\n";
|
|
|
|
}
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
break;
|
|
|
|
} // end of outer switch
|
|
|
|
|
2004-11-12 17:28:07 +00:00
|
|
|
// now get the general comment (present in all types)
|
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
switch ($workshop->gradingstrategy) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 4 : // no grading, accumulative and rubic
|
|
|
|
echo " <td align=\"right\"><p><b>". get_string("generalcomment", "workshop").":</b></p></td>\n";
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
echo " <td align=\"right\"><p><b>".get_string("generalcomment", "workshop")."/<br />".
|
|
|
|
get_string("reasonforadjustment", "workshop").":</b></p></td>\n";
|
|
|
|
}
|
|
|
|
echo " <td>\n";
|
|
|
|
if ($allowchanges) {
|
|
|
|
echo " <textarea name=\"generalcomment\" rows=\"5\" cols=\"75\" wrap=\"virtual\">\n";
|
|
|
|
if (isset($assessment->generalcomment)) {
|
|
|
|
echo $assessment->generalcomment;
|
|
|
|
}
|
|
|
|
echo "</textarea>\n";
|
|
|
|
} else {
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment) {
|
|
|
|
if (isset($assessment->generalcomment)) {
|
|
|
|
echo text_to_html($assessment->generalcomment);
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
} else {
|
2004-06-18 09:24:20 +00:00
|
|
|
print_string("yourfeedbackgoeshere", "workshop");
|
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
// if active and the teacher show stock comments...
|
|
|
|
if ($allowchanges and isteacher($course->id, $USER->id)) {
|
|
|
|
echo "<tr><td valign=\"top\" align=\"right\"><input type=\"button\" value=\"".
|
|
|
|
get_string("addcomment", "workshop")."\"
|
|
|
|
onclick=\"document.assessmentform.action.value='addstockcomment';
|
|
|
|
document.assessmentform.elementno.value=99;document.assessmentform.submit();\" /> \n";
|
|
|
|
helpbutton("addcommenttobank", get_string("addcomment", "workshop"), "workshop");
|
|
|
|
echo "</td><td>\n";
|
|
|
|
if ($stockcomments = get_records_select("workshop_stockcomments", "workshopid = $workshop->id
|
|
|
|
AND elementno = 99", "id")) { // show in the same order (oldest at the top)
|
|
|
|
foreach ($stockcomments as $stockcomment) {
|
|
|
|
echo "<a onclick=\"document.assessmentform.generalcomment.value+=' '+'$stockcomment->comments';\"><<$stockcomment->comments>></a>\n";
|
|
|
|
if (isteacheredit($course->id, $USER->id)) {
|
|
|
|
echo " <a onclick=\"document.assessmentform.action.value='removestockcomment';document.assessmentform.stockcommentid.value=$stockcomment->id;document.assessmentform.submit();\"> <small><i><--".get_string("delete","workshop")."</i></small></a>\n";
|
|
|
|
}
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "<tr valign=\"top\">\n";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo " <td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
$timenow = time();
|
2004-09-07 16:17:32 +00:00
|
|
|
// now show the grading grade if available...
|
|
|
|
if ($assessment->timegraded) {
|
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo " <td align=\"right\"><p><b>";
|
|
|
|
if (isteacher($course->id, $assessment->userid)) {
|
|
|
|
print_string("gradeforstudentsassessment", "workshop", $course->teacher);
|
|
|
|
} else {
|
|
|
|
print_string("gradeforstudentsassessment", "workshop", $course->student);
|
|
|
|
}
|
|
|
|
echo ":</b></p></td><td>\n";
|
|
|
|
echo number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0);
|
2004-06-18 09:24:20 +00:00
|
|
|
echo " </td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
echo "<tr valign=\"top\">\n";
|
|
|
|
echo "<td colspan=\"2\" bgcolor=\"$THEME->cellheading2\"> </td>\n";
|
|
|
|
echo "</tr>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
// ...and close the table, show submit button if needed...
|
|
|
|
echo "</table>\n";
|
|
|
|
if ($assessment) {
|
|
|
|
if ($allowchanges) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<input type=\"submit\" value=\"".get_string("savemyassessment", "workshop")."\" />\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
// ...if user is author, assessment not agreed, there's no comments, the showcommentlinks flag is set and
|
|
|
|
// it's not self assessment then show some buttons!
|
|
|
|
if (($submission->userid == $USER->id) and !$assessment->timeagreed and !$comments and $showcommentlinks and
|
|
|
|
$submission->userid != $assessment->userid) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<input type=\"button\" value=\"".get_string("agreetothisassessment", "workshop")."\"
|
2004-09-12 14:41:49 +00:00
|
|
|
onclick=\"document.assessmentform.action.value='agreeassessment';document.assessmentform.submit();\" />\n";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<input type=\"submit\" value=\"".get_string("disagreewiththisassessment", "workshop")."\"
|
2004-09-12 14:41:49 +00:00
|
|
|
onclick=\"document.assessmentform.action.value='addcomment';document.assessmentform.submit();\" />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "</center>";
|
|
|
|
echo "</form>\n";
|
2004-11-12 17:28:07 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_assessments_by_user_for_admin($workshop, $user) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($assessments as $assessment) {
|
2004-08-17 05:19:21 +00:00
|
|
|
echo "<p><center><b>".get_string("assessmentby", "workshop", fullname($user))."</b></center></p>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_print_assessment($workshop, $assessment);
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<p align=\"right\"><a href=\"assessments.php?action=adminconfirmdelete&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 14:41:49 +00:00
|
|
|
get_string("delete", "workshop")."</a></p><hr />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_assessments_for_admin($workshop, $submission) {
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessments =workshop_get_assessments($submission)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (!$user = get_record("user", "id", $assessment->userid)) {
|
|
|
|
error (" workshop_print_assessments_for_admin: unable to get user record");
|
|
|
|
}
|
2004-08-17 05:19:21 +00:00
|
|
|
echo "<p><center><b>".get_string("assessmentby", "workshop", fullname($user))."</b></center></p>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
workshop_print_assessment($workshop, $assessment);
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<p align=\"right\"><a href=\"assessments.php?action=adminconfirmdelete&id=$cm->id&aid=$assessment->id\">".
|
2004-09-12 14:41:49 +00:00
|
|
|
get_string("delete", "workshop")."</a></p><hr />\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_assignment_info($workshop) {
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
// print standard assignment heading
|
|
|
|
$strdifference = format_time($workshop->deadline - time());
|
|
|
|
if (($workshop->deadline - time()) < 0) {
|
|
|
|
$strdifference = "<font color=\"red\">$strdifference</font>";
|
|
|
|
}
|
|
|
|
$strduedate = userdate($workshop->deadline)." ($strdifference)";
|
|
|
|
print_simple_box_start("center");
|
|
|
|
print_heading($workshop->name, "center");
|
|
|
|
print_simple_box_start("center");
|
|
|
|
echo "<b>".get_string("duedate", "assignment")."</b>: $strduedate<br />";
|
2004-09-07 16:17:32 +00:00
|
|
|
$grade = $workshop->gradinggrade + $workshop->grade;
|
|
|
|
echo "<b>".get_string("maximumgrade")."</b>: $grade<br />";
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "<b>".get_string("detailsofassessment", "workshop")."</b>:
|
2004-09-16 17:13:57 +00:00
|
|
|
<a href=\"assessments.php?id=$cm->id&action=displaygradingform\">".
|
2004-06-18 09:24:20 +00:00
|
|
|
get_string("specimenassessmentform", "workshop")."</a><br />";
|
|
|
|
print_simple_box_end();
|
|
|
|
echo "<br />";
|
|
|
|
echo format_text($workshop->description, $workshop->format);
|
|
|
|
print_simple_box_end();
|
|
|
|
echo "<br />";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_difference($time) {
|
|
|
|
if ($time < 0) {
|
|
|
|
$timetext = get_string("late", "assignment", format_time($time));
|
2004-09-14 20:39:28 +00:00
|
|
|
return " (<font color=\"red\">$timetext</font>)";
|
2004-06-18 09:24:20 +00:00
|
|
|
} else {
|
|
|
|
$timetext = get_string("early", "assignment", format_time($time));
|
|
|
|
return " ($timetext)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_feedback($course, $submission) {
|
|
|
|
global $CFG, $THEME, $RATING;
|
|
|
|
|
|
|
|
if (! $teacher = get_record("user", "id", $submission->teacher)) {
|
|
|
|
error("Weird workshop error");
|
|
|
|
}
|
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "\n<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\"><tr><td bgcolor=#888888>";
|
|
|
|
echo "\n<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" valign=\"top\">";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "\n<tr>";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "\n<td rowspan=\"3\" bgcolor=\"$THEME->body\" width=\"35\" valign=\"top\">";
|
2004-06-18 09:24:20 +00:00
|
|
|
print_user_picture($teacher->id, $course->id, $teacher->picture);
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td>";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<td nowrap=\"nowrap\" width=\"100%\" bgcolor=\"$THEME->cellheading\">".fullname($teacher);
|
|
|
|
echo " <font size=\"2\"><i>".userdate($submission->timemarked)."</i>";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</tr>";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "\n<tr><td width=\"100%\" bgcolor=\"$THEME->cellcontent\">";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<p align=\"right\"><font size=\"-1\"><i>";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($submission->grade) {
|
|
|
|
echo get_string("grade").": $submission->grade";
|
|
|
|
} else {
|
|
|
|
echo get_string("nograde");
|
|
|
|
}
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</i></font></p>";
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
echo text_to_html($submission->assessorcomment);
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</td></tr></table>";
|
|
|
|
echo "</td></tr></table>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_key($workshop) {
|
|
|
|
// print an explaination of the grades
|
|
|
|
|
|
|
|
if (!$course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Print key: course not found");
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
echo "<div align=\"center\">\n";
|
|
|
|
echo "<p><small>{} ".get_string("assessmentby", "workshop", $course->student)."; \n";
|
|
|
|
echo "[] ".get_string("assessmentby", "workshop", $course->teacher)."; \n";
|
|
|
|
echo "<> ".get_string("assessmentdropped", "workshop").";\n";
|
|
|
|
if ($workshop->agreeassessments) echo "<<>> ".get_string("assessmentnotyetagreed", "workshop").";\n";
|
|
|
|
echo "<br />() ".get_string("gradegiventoassessment", "workshop")."; \n";
|
|
|
|
echo "(()) ".get_string("assessmentnotyetgraded", "workshop").".\n";
|
|
|
|
echo "<br />".get_string("gradesforsubmissionsare", "workshop", $workshop->grade)."; \n";
|
|
|
|
echo get_string("gradesforassessmentsare", "workshop", $workshop->gradinggrade).".</small></p>\n";
|
|
|
|
echo "</div>\n";
|
2004-09-07 16:17:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
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");
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$nentries = $workshop->showleaguetable;
|
|
|
|
if ($workshop->anonymous and isstudent($course->id)) {
|
|
|
|
$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 ("*", "*", "*", "*");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
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 ("*", "*", "*", "*", "*");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$table->cellpadding = 2;
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($submissions = workshop_get_student_submissions($workshop)) {
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($submissions as $submission) {
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($groupid) {
|
|
|
|
// check submission's group
|
|
|
|
if (!ismember($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");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if (!$user = get_record("user", "id", $submission->userid)) {
|
|
|
|
error("Print league table: user not found");
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($workshop->anonymous and isstudent($course->id)) {
|
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_print_submission_assessments($workshop, $submission, "teacher"),
|
|
|
|
workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
else {
|
2004-08-17 05:19:21 +00:00
|
|
|
$table->data[] = array(workshop_print_submission_title($workshop, $submission), fullname($user),
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_print_submission_assessments($workshop, $submission, "teacher"),
|
|
|
|
workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
$n++;
|
|
|
|
if ($n > $nentries) {
|
|
|
|
break;
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
print_heading(get_string("leaguetable", "workshop"));
|
|
|
|
print_table($table);
|
2004-09-07 16:17:32 +00:00
|
|
|
workshop_print_key($workshop);
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_submission($workshop, $submission) {
|
|
|
|
// prints the submission with optional attachments
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
print_simple_box(format_text($submission->description), 'center');
|
|
|
|
if ($workshop->nattachments) {
|
|
|
|
$n = 1;
|
|
|
|
echo "<table align=\"center\">\n";
|
|
|
|
$filearea = workshop_file_area_name($workshop, $submission);
|
|
|
|
if ($basedir = workshop_file_area($workshop, $submission)) {
|
|
|
|
if ($files = get_directory_list($basedir)) {
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$icon = mimeinfo("icon", $file);
|
|
|
|
if ($CFG->slasharguments) {
|
|
|
|
$ffurl = "file.php/$filearea/$file";
|
|
|
|
} else {
|
|
|
|
$ffurl = "file.php?file=/$filearea/$file";
|
|
|
|
}
|
|
|
|
echo "<tr><td><b>".get_string("attachment", "workshop")." $n:</b> \n";
|
|
|
|
echo "<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\"
|
|
|
|
border=\"0\" alt=\"File\" />".
|
|
|
|
" <a target=\"uploadedfile\" href=\"$CFG->wwwroot/$ffurl\">$file</a></td></tr>";
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_submission_assessments($workshop, $submission, $type) {
|
2004-11-12 17:28:07 +00:00
|
|
|
global $USER;
|
2004-06-18 09:24:20 +00:00
|
|
|
// Returns the teacher or peer grade and a hyperlinked list of grades for this submission
|
2004-09-07 16:17:32 +00:00
|
|
|
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
$str = '';
|
|
|
|
if ($assessments = workshop_get_assessments($submission)) {
|
|
|
|
switch ($type) {
|
2004-11-12 17:28:07 +00:00
|
|
|
case "teacher" :
|
|
|
|
// students can see teacher assessments only if the release date has passed
|
|
|
|
$timenow = time();
|
|
|
|
if (isteacher($workshop->course, $USER->id) or ($timenow > $workshop->releasegrades)) {
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (isteacher($workshop->course, $assessment->userid)) {
|
|
|
|
$str .= "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">";
|
|
|
|
if ($assessment->timegraded) {
|
|
|
|
if ($assessment->gradinggrade) {
|
|
|
|
$str .= "[".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
|
|
|
|
")]</a> ";
|
|
|
|
} else {
|
|
|
|
$str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0).
|
|
|
|
" (0)></a> ";
|
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
2004-11-12 17:28:07 +00:00
|
|
|
$str .= "[".number_format($assessment->grade *$workshop->grade / 100, 0);
|
|
|
|
if ($workshop->wtype) { // print null grade if there are student assessments
|
|
|
|
$str .= " ((".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100,
|
|
|
|
0)."))";
|
|
|
|
}
|
|
|
|
$str .= "]</a> ";
|
2004-09-28 15:49:49 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "student" :
|
|
|
|
foreach ($assessments as $assessment) {
|
|
|
|
if (isstudent($workshop->course, $assessment->userid)) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$str .= "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">";
|
2004-09-27 14:41:17 +00:00
|
|
|
if ($workshop->agreeassessments and !$assessment->timeagreed and
|
|
|
|
isstudent($workshop->course, $submission->userid)) { // agreement on student work only
|
|
|
|
$str .= "<<".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
|
|
|
|
")>></a> ";
|
|
|
|
} elseif ($assessment->timegraded) {
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($assessment->gradinggrade) {
|
|
|
|
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
|
|
|
|
")}</a> ";
|
|
|
|
} else {
|
|
|
|
$str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0).
|
|
|
|
" (0)></a> ";
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
} else {
|
2004-09-27 14:41:17 +00:00
|
|
|
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." ((".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0)."))}</a> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$str) {
|
|
|
|
$str = " "; // be kind to Mozilla browsers!
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_submission_title($workshop, $submission) {
|
|
|
|
// Arguments are objects
|
|
|
|
|
2004-09-27 14:41:17 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
if (!$submission->timecreated) { // a "no submission"
|
|
|
|
return $submission->title;
|
2004-09-08 06:43:57 +00:00
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
return "<a href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\">$submission->title</a>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_tabbed_heading($tabs) {
|
|
|
|
// Prints a tabbed heading where one of the tabs highlighted.
|
|
|
|
// $tabs is an object with several properties.
|
|
|
|
// $tabs->names is an array of tab names
|
|
|
|
// $tabs->urls is an array of links
|
|
|
|
// $tabs->align is an array of column alignments (defaults to "center")
|
|
|
|
// $tabs->size is an array of column sizes
|
|
|
|
// $tabs->wrap is an array of "nowrap"s or nothing
|
|
|
|
// $tabs->highlight is an index (zero based) of "active" heading .
|
|
|
|
// $tabs->width is an percentage of the page (defualts to 80%)
|
|
|
|
// $tabs->cellpadding padding on each cell (defaults to 5)
|
|
|
|
|
|
|
|
global $CFG, $THEME;
|
|
|
|
|
|
|
|
if (isset($tabs->names)) {
|
|
|
|
foreach ($tabs->names as $key => $name) {
|
|
|
|
if (!empty($tabs->urls[$key])) {
|
|
|
|
$url =$tabs->urls[$key];
|
|
|
|
if ($tabs->highlight == $key) {
|
|
|
|
$tabcontents[$key] = "<b>$name</b>";
|
|
|
|
} else {
|
|
|
|
$tabcontents[$key] = "<a class= \"dimmed\" href=\"$url\"><b>$name</b></a>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$tabcontents[$key] = "<b>$name</b>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($tabs->width)) {
|
|
|
|
$tabs->width = "80%";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($tabs->cellpadding)) {
|
|
|
|
$tabs->cellpadding = "5";
|
|
|
|
}
|
|
|
|
|
|
|
|
// print_simple_box_start("center", "$table->width", "#ffffff", 0);
|
|
|
|
echo "<table width=\"$tabs-width\" border=\"0\" valign=\"top\" align=\"center\" ";
|
|
|
|
echo " cellpadding=\"$tabs->cellpadding\" cellspacing=\"0\" class=\"generaltable\">\n";
|
|
|
|
|
|
|
|
if (!empty($tabs->names)) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td class=\"generaltablecell\">".
|
2004-09-14 20:39:28 +00:00
|
|
|
"<img width=\"10\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($tabcontents as $key => $tab) {
|
|
|
|
if (isset($align[$key])) {
|
|
|
|
$alignment = "align=\"$align[$key]\"";
|
|
|
|
} else {
|
|
|
|
$alignment = "align=\"center\"";
|
|
|
|
}
|
|
|
|
if (isset($size[$key])) {
|
|
|
|
$width = "width=\"$size[$key]\"";
|
|
|
|
} else {
|
|
|
|
$width = "";
|
|
|
|
}
|
|
|
|
if (isset($wrap[$key])) {
|
|
|
|
$wrapping = "no wrap";
|
|
|
|
} else {
|
|
|
|
$wrapping = "";
|
|
|
|
}
|
|
|
|
if ($key == $tabs->highlight) {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<td valign=\"top\" class=\"generaltabselected\" $alignment $width $wrapping bgcolor=\"$THEME->cellheading2\">$tab</td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
} else {
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<td valign=\"top\" class=\"generaltab\" $alignment $width $wrapping bgcolor=\"$THEME->cellheading\">$tab</td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
echo "<td class=\"generaltablecell\">".
|
2004-09-14 20:39:28 +00:00
|
|
|
"<img width=\"10\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
|
|
|
} else {
|
|
|
|
echo "<tr><td>No names specified</td></tr>\n";
|
|
|
|
}
|
|
|
|
// bottom stripe
|
|
|
|
$ncells = count($tabs->names)*2 +1;
|
|
|
|
$height = 2;
|
|
|
|
echo "<tr><td colspan=\"$ncells\" bgcolor=\"$THEME->cellheading2\">".
|
2004-09-14 20:39:28 +00:00
|
|
|
"<img height=\"$height\" src=\"$CFG->wwwroot/pix/spacer.gif\" alt=\"\" /></td></tr>\n";
|
2004-06-18 09:24:20 +00:00
|
|
|
echo "</table>\n";
|
|
|
|
// print_simple_box_end();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function workshop_print_time_to_deadline($time) {
|
|
|
|
if ($time < 0) {
|
|
|
|
$timetext = get_string("afterdeadline", "workshop", format_time($time));
|
2004-09-14 20:39:28 +00:00
|
|
|
return " (<font color=\"red\">$timetext</font>)";
|
2004-06-18 09:24:20 +00:00
|
|
|
} else {
|
|
|
|
$timetext = get_string("beforedeadline", "workshop", format_time($time));
|
|
|
|
return " ($timetext)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_upload_form($workshop) {
|
2004-09-15 00:03:04 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
if (! $course = get_record("course", "id", $workshop->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
2004-09-27 14:41:17 +00:00
|
|
|
$usehtmleditor = can_use_html_editor();
|
2004-06-18 09:24:20 +00:00
|
|
|
|
2004-09-14 20:39:28 +00:00
|
|
|
echo "<div align=\"center\">";
|
2004-09-20 14:59:41 +00:00
|
|
|
echo "<form enctype=\"multipart/form-data\" method=\"POST\" action=\"upload.php\">";
|
2004-09-14 20:39:28 +00:00
|
|
|
echo " <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />";
|
2004-09-27 14:41:17 +00:00
|
|
|
echo "<table celpadding=\"5\" border=\"1\" align=\"center\">\n";
|
|
|
|
// now get the submission
|
|
|
|
echo "<tr valign=\"top\"><td><b>". get_string("title", "workshop").":</b>\n";
|
|
|
|
echo "<input type=\"text\" name=\"title\" size=\"60\" maxlength=\"100\" value=\"\" />\n";
|
|
|
|
echo "</td></tr><tr><td><b>".get_string("submission", "workshop").":</b><br />\n";
|
|
|
|
print_textarea($usehtmleditor, 25,70, 630, 400, "description");
|
|
|
|
use_html_editor("description");
|
|
|
|
echo "</td></tr><tr><td>\n";
|
|
|
|
if ($workshop->nattachments) {
|
|
|
|
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
|
|
|
for ($i=0; $i < $workshop->nattachments; $i++) {
|
|
|
|
$iplus1 = $i + 1;
|
|
|
|
$tag[$i] = get_string("attachment", "workshop")." $iplus1:";
|
|
|
|
}
|
|
|
|
upload_print_form_fragment($workshop->nattachments,null,$tag,false,null,$course->maxbytes,
|
|
|
|
$workshop->maxbytes,false);
|
|
|
|
}
|
|
|
|
echo "</td></tr></table>\n";
|
|
|
|
echo " <input type=\"submit\" name=\"save\" value=\"".get_string("submitassignment","workshop")."\" />";
|
2004-09-12 21:43:59 +00:00
|
|
|
echo "</form>";
|
|
|
|
echo "</div>";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_print_user_assessments($workshop, $user) {
|
|
|
|
// Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
|
|
|
|
|
2004-09-07 16:17:32 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
|
|
|
|
$n = count($assessments);
|
2004-09-07 16:17:32 +00:00
|
|
|
$str = "$n : ";
|
2004-06-18 09:24:20 +00:00
|
|
|
foreach ($assessments as $assessment) {
|
2004-09-16 17:13:57 +00:00
|
|
|
$str .= "<a href=\"assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id\">";
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($assessment->timegraded) {
|
2004-09-07 16:17:32 +00:00
|
|
|
if ($assessment->gradinggrade) {
|
|
|
|
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0). " (".
|
|
|
|
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100).")}</a> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
} else {
|
2004-09-07 16:17:32 +00:00
|
|
|
$str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0)." (0)></a> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-07 16:17:32 +00:00
|
|
|
} else {
|
|
|
|
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (-)}</a> ";
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$str ="0";
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function workshop_test_user_assessments($workshop, $user) {
|
|
|
|
// see if user has assessed required number of assessments of teachers submissions...
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
$result = true;
|
|
|
|
$n = 0;
|
|
|
|
$timenow =time();
|
|
|
|
if ($submissions = workshop_get_teacher_submissions($workshop)) {
|
|
|
|
foreach ($submissions as $submission) {
|
|
|
|
if ($assessment = workshop_get_submission_assessment($submission, $user)) {
|
|
|
|
// ...the date stamp on the assessment should be in the past
|
|
|
|
if ($assessment->timecreated < $timenow) {
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
}
|
2004-09-08 06:43:57 +00:00
|
|
|
}
|
2004-06-18 09:24:20 +00:00
|
|
|
if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
}
|
2004-09-08 06:43:57 +00:00
|
|
|
return $result;
|
2004-06-18 09:24:20 +00:00
|
|
|
}
|
2004-09-08 06:43:57 +00:00
|
|
|
|
2004-06-18 09:24:20 +00:00
|
|
|
|
|
|
|
?>
|