get_string('notgraded', 'workshop'),
1 => get_string('accumulative', 'workshop'),
2 => get_string('errorbanded', 'workshop'),
3 => get_string('criterion', 'workshop'),
4 => get_string('rubric', 'workshop') );
$WORKSHOP_SHOWGRADES = array (0 => get_string('dontshowgrades', 'workshop'),
1 => get_string('showgrades', 'workshop') );
$WORKSHOP_SCALES = array(
0 => array( 'name' => get_string('scaleyes', 'workshop'), 'type' => 'radio',
'size' => 2, 'start' => get_string('yes'), 'end' => get_string('no')),
1 => array( 'name' => get_string('scalepresent', 'workshop'), 'type' => 'radio',
'size' => 2, 'start' => get_string('present', 'workshop'),
'end' => get_string('absent', 'workshop')),
2 => array( 'name' => get_string('scalecorrect', 'workshop'), 'type' => 'radio',
'size' => 2, 'start' => get_string('correct', 'workshop'),
'end' => get_string('incorrect', 'workshop')),
3 => array( 'name' => get_string('scalegood3', 'workshop'), 'type' => 'radio',
'size' => 3, 'start' => get_string('good', 'workshop'),
'end' => get_string('poor', 'workshop')),
4 => array( 'name' => get_string('scaleexcellent4', 'workshop'), 'type' => 'radio',
'size' => 4, 'start' => get_string('excellent', 'workshop'),
'end' => get_string('verypoor', 'workshop')),
5 => array( 'name' => get_string('scaleexcellent5', 'workshop'), 'type' => 'radio',
'size' => 5, 'start' => get_string('excellent', 'workshop'),
'end' => get_string('verypoor', 'workshop')),
6 => array( 'name' => get_string('scaleexcellent7', 'workshop'), 'type' => 'radio',
'size' => 7, 'start' => get_string('excellent', 'workshop'),
'end' => get_string('verypoor', 'workshop')),
7 => array( 'name' => get_string('scale10', 'workshop'), 'type' => 'selection',
'size' => 10),
8 => array( 'name' => get_string('scale20', 'workshop'), 'type' => 'selection',
'size' => 20),
9 => array( 'name' => get_string('scale100', 'workshop'), 'type' => 'selection',
'size' => 100));
//////////////////////////////////////////////////////////////////////////////////////
/*** Functions for the workshop module ******
workshop_choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="",
$nothingvalue="0", $return=false) {
workshop_compare_assessments($workshop, $assessment1, $assessment2) { ---> in lib.php
workshop_count_all_submissions_for_assessment($workshop, $user) {
workshop_count_assessments($submission) { ---> in lib.php
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) {
workshop_count_teacher_assessments($courseid, $submission) {
workshop_count_teacher_assessments_by_user($workshop, $user) {
workshop_count_teacher_submissions($workshop) {
workshop_count_teacher_submissions_for_assessment($workshop, $user) {
workshop_count_ungraded_assessments($workshop) { --->in lib.php
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) {
workshop_file_area($workshop, $submission) { ---> in lib.php
workshop_file_area_name($workshop, $submission) { ---> in lib.php
workshop_get_all_teacher_assessments($workshop) {
workshop_get_assessments($submission, $all = '') { ---> in lib.php
workshop_get_comments($assessment) {
workshop_get_participants($workshopid) {
workshop_get_student_assessments($workshop, $user) {
workshop_get_student_submission($workshop, $user) { ---> in lib.php
workshop_get_student_submission_assessments($workshop) {
workshop_get_student_submissions($workshop) { ---> in lib.php
workshop_get_submission_assessment($submission, $user) {
workshop_get_teacher_assessments($courseid, $submission) {
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) {
workshop_get_user_assessments($workshop, $user) { ---> in lib.php
workshop_get_user_submissions($workshop, $user) { ---> in lib.php
workshop_get_users_done($workshop) {
workshop_grade_assessments($workshop) { ---> in lib.php
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) {
workshop_list_teacher_assessments_by_user($workshop, $user) {
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_calculate_phase($workshop, $style='') {
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_time_to_deadline($time) {
workshop_print_upload_form($workshop) {
workshop_print_user_assessments($workshop, $user) {
workshop_submission_grade($submission) { ---> in lib.php
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 = "";
}
$output = "
\n";
workshop_print_assessment($workshop, $assessment);
echo "id&aid=$assessment->id\">".
get_string("delete", "workshop")."
\n";
}
}
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_assignment_info($workshop) {
global $CFG;
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
print_heading(format_string($workshop->name), "center");
print_simple_box_start("center");
// print phase and date info
$string = ''.get_string('currentphase', 'workshop').': '.workshop_phase($workshop).'
';
$dates = array(
'submissionstart' => $workshop->submissionstart,
'submissionend' => $workshop->submissionend,
'assessmentstart' => $workshop->assessmentstart,
'assessmentend' => $workshop->assessmentend
);
foreach ($dates as $type => $date) {
if ($date) {
$strdifference = format_time($date - time());
if (($date - time()) < 0) {
$strdifference = "$strdifference";
}
$string .= ''.get_string($type, 'workshop').': '.userdate($date)." ($strdifference)
";
}
}
echo $string;
$grade = $workshop->gradinggrade + $workshop->grade;
echo "
".get_string("maximumgrade").": $grade ";
// print link to specimen assessment form
echo "(id&action=displaygradingform\">".
get_string("specimenassessmentform", "workshop")."";
// print edit icon
if (workshop_is_teacheredit($workshop) and $workshop->nelements) {
echo " id&action=editelements\">".
"pixpath/t/edit.gif\" ".
'class="iconsmall" alt="'.get_string('amendassessmentelements', 'workshop').'" />';
}
echo ")
";
print_simple_box_end();
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_difference($time) {
if ($time < 0) {
$timetext = get_string("late", "assignment", format_time($time));
return " ($timetext)";
} else {
$timetext = get_string("early", "assignment", format_time($time));
return " ($timetext)";
}
}
//////////////////////////////////////////////////////////////////////////////////////
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");
}
echo "\n";
echo "
{} ".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 "
() ".get_string("automaticgradeforassessment", "workshop")."; \n";
echo "[] ".get_string("teachergradeforassessment", "workshop", $course->teacher).".\n";
echo "
".get_string("gradesforsubmissionsare", "workshop", $workshop->grade)."; \n";
echo get_string("gradesforassessmentsare", "workshop", $workshop->gradinggrade).".
\n";
echo "
\n";
return;
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_league_table($workshop) {
// print an order table of (student) submissions showing teacher's and student's assessments
if (! $course = get_record("course", "id", $workshop->course)) {
error("Print league table: Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
error("Course Module ID was incorrect");
}
// set $groupid if workshop is in SEPARATEGROUPS mode
if (groupmode($course, $cm) == SEPARATEGROUPS) {
$groupid = get_current_group($course->id);
} else {
$groupid = 0;
}
$nentries = $workshop->showleaguetable;
if ($workshop->anonymous and workshop_is_student($workshop)) {
$table->head = array (get_string("title", "workshop"),
get_string("teacherassessments", "workshop", $course->teacher),
get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop"));
$table->align = array ("left", "center", "center", "center");
$table->size = array ("*", "*", "*", "*");
}
else { // show names
$table->head = array (get_string("title", "workshop"), get_string("name"),
get_string("teacherassessments", "workshop", $course->teacher),
get_string("studentassessments", "workshop", $course->student), get_string("overallgrade", "workshop"));
$table->align = array ("left", "left", "center", "center", "center");
$table->size = array ("*", "*", "*", "*", "*");
}
$table->cellpadding = 2;
$table->cellspacing = 0;
if ($submissions = workshop_get_student_submissions($workshop)) {
foreach ($submissions as $submission) {
if ($groupid) {
// check submission's group
if (!groups_is_member($groupid, $submission->userid)) {
continue; // skip this submission
}
}
$grades[$submission->id] = workshop_submission_grade($workshop, $submission);
}
arsort($grades); // largest grade first
reset($grades);
$n = 1;
while (list($submissionid, $grade) = each($grades)) {
if (!$submission = get_record("workshop_submissions", "id", $submissionid)) {
error("Print league table: submission not found");
}
if (!$user = get_record("user", "id", $submission->userid)) {
error("Print league table: user not found");
}
if ($workshop->anonymous and workshop_is_student($workshop)) {
$table->data[] = array(workshop_print_submission_title($workshop, $submission),
workshop_print_submission_assessments($workshop, $submission, "teacher"),
workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
}
else {
$table->data[] = array(workshop_print_submission_title($workshop, $submission), fullname($user),
workshop_print_submission_assessments($workshop, $submission, "teacher"),
workshop_print_submission_assessments($workshop, $submission, "student"), $grade);
}
$n++;
if ($n > $nentries) {
break;
}
}
print_heading(get_string("leaguetable", "workshop"));
print_table($table);
workshop_print_key($workshop);
}
}
//////////////////////////////////////////////////////////////////////////////////////
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 "\n";
$filearea = workshop_file_area_name($workshop, $submission);
if ($basedir = workshop_file_area($workshop, $submission)) {
if ($files = get_directory_list($basedir)) {
require_once($CFG->libdir .'/filelib.php');
foreach ($files as $file) {
$icon = mimeinfo("icon", $file);
$ffurl = get_file_url("$filearea/$file");
echo "".get_string("attachment", "workshop")." $n: \n";
// removed target=\"uploadedfile\" as it does not validate
// MDL-7861
echo "pixpath/f/$icon\" class=\"icon\" alt=\"".get_string('file')."\" />".
" $file |
";
$n++;
}
}
}
echo "
\n";
}
return;
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_submission_assessments($workshop, $submission, $type) {
global $USER, $CFG;
// Returns the teacher or peer grade and a hyperlinked list of grades for this submission
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
error("Course Module ID was incorrect");
}
$str = '';
// get the assessments in grade order, highest first
if ($assessments = workshop_get_assessments($submission, "", "grade DESC")) {
if ($type == 'teacher' or $type == 'all') {
// students can see teacher assessments only if the release date has passed
$timenow = time();
if (workshop_is_teacher($workshop, $USER->id) or ($timenow > $workshop->releasegrades)) {
foreach ($assessments as $assessment) {
if (workshop_is_teacher($workshop, $assessment->userid)) {
if ($type == 'all') {
$str .= workshop_fullname($assessment->userid, $workshop->course).': ';
}
$str .= "id\">"
. "[".number_format($assessment->grade *$workshop->grade / 100, 0)."]";
if (workshop_is_teacher($workshop, $USER->id)) {
$str .= ' id&sid=$submission->id\">pixpath/t/edit.gif\" ".
' class="iconsmall" alt="'.get_string('reassess', 'workshop').'" />';
$str .= ' id&aid=$assessment->id\">pixpath/t/delete.gif\" ".
' class="iconsmall" alt="'.get_string('delete', 'workshop').'" />
';
}
}
}
}
}
if ($type == 'student' or $type == 'all') {
foreach ($assessments as $assessment) {
if (workshop_is_student($workshop, $assessment->userid)) {
if ($type == 'all') {
$str .= workshop_fullname($assessment->userid, $workshop->course).': ';
}
$str .= "id\">";
if ($workshop->agreeassessments and !$assessment->timeagreed and
workshop_is_student($workshop, $submission->userid)) { // agreement on student work only
$str .= "<<".number_format($assessment->grade * $workshop->grade / 100, 0)." (".
number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
")>> ";
} elseif ($assessment->timegraded) {
if ($assessment->gradinggrade) {
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
if ($assessment->teachergraded) {
$str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
"]} ";
} else {
$str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0).
")} ";
}
} else {
$str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0).
" (0)> ";
}
} else {
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)."} ";
}
$str .= '
';
}
}
}
}
if (!$str) {
$str = " "; // be kind to Mozilla browsers!
}
return $str;
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_submission_title($workshop, $submission) {
// Arguments are objects
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
error("Course Module ID was incorrect");
}
if (!$submission->timecreated) { // a "no submission"
return $submission->title;
}
return "id\" href=\"submissions.php?id=$cm->id&action=showsubmission&sid=$submission->id\">$submission->title";
}
function workshop_print_time_to_deadline($time) {
if ($time < 0) {
$timetext = get_string("afterdeadline", "workshop", format_time($time));
return " ($timetext)";
} else {
$timetext = get_string("beforedeadline", "workshop", format_time($time));
return " ($timetext)";
}
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_upload_form($workshop) {
global $CFG;
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");
}
$usehtmleditor = can_use_html_editor();
echo "";
}
//////////////////////////////////////////////////////////////////////////////////////
function workshop_print_user_assessments($workshop, $user, &$gradinggrade) {
// Returns the number of assessments and a hyperlinked list of grading grades for the assessments made by this user
if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course)) {
error("Course Module ID was incorrect");
}
$gradinggrade = 0;
$n = 0;
$str = '';
if ($assessments = workshop_get_user_assessments_done($workshop, $user)) {
foreach ($assessments as $assessment) {
$gradinggrade += $assessment->gradinggrade;
$n++;
$str .= "id\">";
if ($assessment->timegraded) {
if ($assessment->gradinggrade) {
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0);
if ($assessment->teachergraded) {
$str .= " [".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100)."]} ";
} else {
$str .= " (".number_format($assessment->gradinggrade * $workshop->gradinggrade / 100).")} ";
}
} else {
$str .= "<".number_format($assessment->grade * $workshop->grade / 100, 0)." (0)> ";
}
} else {
$str .= "{".number_format($assessment->grade * $workshop->grade / 100, 0)." (-)} ";
}
$str .= '
';
}
}
else {
$str ="0";
}
if ($n = max($n, $workshop->ntassessments + $workshop->nsassessments)) {
$gradinggrade = number_format($gradinggrade/$n * $workshop->gradinggrade / 100, 1);
}
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++;
}
}
}
if ($n < min($workshop->ntassessments, workshop_count_teacher_submissions($workshop))) {
$result = false;
}
}
return $result;
}
?>