course)) {
error("Course is misconfigured");
}
if (! $workshop = get_record("workshop", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else {
if (! $workshop = get_record("workshop", "id", $a)) {
error("Course module is incorrect");
}
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");
}
}
require_login($course->id);
// ...log activity...
add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
if ($course->category) {
$navigation = "id\">$course->shortname ->";
}
$strworkshops = get_string("modulenameplural", "workshop");
$strworkshop = get_string("modulename", "workshop");
// ...display header...
print_header("$course->shortname: $workshop->name", "$course->fullname",
"$navigation id>$strworkshops -> $workshop->name",
"", "", true, update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
// ...and if necessary set default action
optional_variable($action);
if (isteacher($course->id)) {
if (empty($action)) { // no action specified, either go straight to elements page else the admin page
// has the assignment any elements
if (count_records("workshop_elements", "workshopid", $workshop->id)) {
$action = "teachersview";
}
else {
redirect("assessments.php?action=editelements&id=$cm->id");
}
}
}
elseif (!isguest()) { // it's a student then
if (!$cm->visible) {
notice(get_string("activityiscurrentlyhidden"));
}
switch ($workshop->phase) {
case 0 :
case 1 : $action = 'notavailable'; break;
case 2 : $action = 'studentsview'; break;
case 3 : $action = 'notavailable'; break;
case 4 : $action = 'displayfinalgrade';
}
}
else { // it's a guest, oh no!
$action = 'notavailable';
}
/*********************** close workshop for student assessments and submissions (move to phase 3) (for teachers)**/
if ($action == 'closeworkshop') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
// move phase along
if ($workshop->phase == 2) { // force phase to open workshop
set_field("workshop", "phase", 3, "id", "$workshop->id");
echo "
";
echo "".get_string("submissions", "workshop")." | ";
if ($useteachersgrades) {
echo "".get_string("teachersassessment", "workshop")." | ";
}
if ($usepeergrades) {
echo "".get_string("studentsassessment", "workshop")." | ";
}
echo "".get_string("assessmentsdone", "workshop")." | ";
if ($usebiasgrades) {
echo "".get_string("gradeforbias", "workshop")." | ";
}
if ($usereliabilitygrades) {
echo "".get_string("gradeforreliability", "workshop")." | ";
}
if ($usegradinggrades) {
echo "".get_string("gradeforassessments", "workshop")." | ";
}
echo "".get_string("overallgrade", "workshop")." |
\n";
// now the weights
echo "".get_string("weights", "workshop")." | ";
if ($useteachersgrades) {
echo "$workshop_FWEIGHTS[$teacherweight] | \n";
}
if ($usepeergrades) {
echo "$workshop_FWEIGHTS[$peerweight] | \n";
}
echo " | \n";
if ($usebiasgrades) {
echo "$workshop_FWEIGHTS[$biasweight] | \n";
}
if ($usereliabilitygrades) {
echo "$workshop_FWEIGHTS[$reliabilityweight] | \n";
}
if ($usegradinggrades) {
echo "$workshop_FWEIGHTS[$gradingweight] | \n";
}
echo " |
\n";
foreach ($submissions as $submission) {
echo "".workshop_print_submission_title($workshop, $submission)." | \n";
if ($useteachersgrades) {
echo "".workshop_print_submission_assessments($workshop, $submission, "teacher")." | ";
}
if ($usepeergrades) {
echo "".workshop_print_submission_assessments($workshop, $submission, "student")." | ";
}
echo "".workshop_print_user_assessments($workshop, $USER)." | ";
if ($usebiasgrades) {
echo "$submission->biasgrade | ";
}
if ($usereliabilitygrades) {
echo "$submission->reliabilitygrade | ";
}
if ($usegradinggrades) {
echo "$submission->gradinggrade | ";
}
echo "$submission->finalgrade |
\n";
}
}
echo "
\n";
print_string("allgradeshaveamaximumof", "workshop", $workshop->grade);
print_continue("view.php?a=$workshop->id");
}
/*********************** make final grades available (for teachers only)**************/
elseif ($action == 'makefinalgradesavailable') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if ($workshop->phase == 3) { // is this at the expected phase?
set_field("workshop", "phase", 4, "id", "$workshop->id");
echo "".get_string("movedtophase", "workshop", 4)."\n";
}
else {
echo "".get_string("assignmentnotinthecorrectphase", "workshop")."\n";
}
print_continue("view.php?a=$workshop->id");
add_to_log($course->id, "workshop", "display grades", "view.php?a=$workshop->id", "$workshop->id");
}
/*********************** make final grades unavailable (for teachers only)**************/
elseif ($action == 'makefinalgradesunavailable') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if ($workshop->phase == 4) { // is this at the expected phase?
set_field("workshop", "phase", 3, "id", "$workshop->id");
echo "".get_string("movedtophase", "workshop", 3)."\n";
}
else {
echo "".get_string("assignmentnotinthecorrectphase", "workshop")."\n";
}
print_continue("view.php?a=$workshop->id");
add_to_log($course->id, "workshop", "hide grades", "view.php?a=$workshop->id", "$workshop->id");
}
/*********************** assignment not available (for students)***********************/
elseif ($action == 'notavailable') {
echo "".get_string("notavailable", "workshop")."\n";
}
/*********************** open workshop for student assessments and submissions (move to phase 2) (for teachers)**/
elseif ($action == 'openworkshop') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
// move phase along
if (!($workshop->phase == 2)) { // force phase to open workshop
set_field("workshop", "phase", 2, "id", "$workshop->id");
echo "".get_string("movedtophase", "workshop", 2)."\n";
}
print_continue("view.php?id=$cm->id");
add_to_log($course->id, "workshop", "open", "view.php?a=$workshop->id", "$workshop->id");
}
/*********************** set up assignemnt (move back to phase 1) (for teachers)***********************/
elseif ($action == 'setupassignment') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if ($workshop->phase == 2) { // phase must be correct
set_field("workshop", "phase", 1, "id", "$workshop->id");
echo "".get_string("movedtophase", "workshop", 1)."\n";
}
else {
echo "".get_string("assignmentnotinthecorrectphase", "workshop")."\n";
}
print_continue("view.php?a=$workshop->id");
}
/*********************** student's view could be in 1 of 4 stages ***********************/
elseif ($action == 'studentsview') {
// print standard assignment heading
$strdifference = format_time($workshop->deadline - time());
if (($workshop->deadline - time()) < 0) {
$strdifference = "$strdifference";
}
$strduedate = userdate($workshop->deadline)." ($strdifference)";
print_simple_box_start("CENTER");
print_heading($workshop->name, "CENTER");
print_simple_box_start("CENTER");
echo "".get_string("duedate", "assignment").": $strduedate
";
echo "".get_string("maximumgrade").": $workshop->grade
";
echo "".get_string("detailsofassessment", "workshop").":
id&action=displaygradingform\">".
get_string("specimenassessmentform", "workshop")."
";
print_simple_box_end();
echo "
";
echo format_text($workshop->description, $workshop->format);
print_simple_box_end();
echo "
";
// in Stage 1? - assess teacher's submissions to a satisfactory level
if (!workshop_test_user_assessments($workshop, $USER)) {
print_heading(get_string("pleaseassesstheseexamplesfromtheteacher", "workshop", $course->teacher));
print_heading(get_string("theseasessmentsaregradedbytheteacher", "workshop", $course->teacher), "center", 5);
workshop_list_teacher_submissions($workshop, $USER);
}
// in stage 2? - submit own first attempt
else {
if ($workshop->ntassessments) { // display message if student had to assess the teacher's examples
print_heading("id\">".
get_string("assessmentsareok", "workshop")."");
}
if (!workshop_get_user_submissions($workshop, $USER)) {
// print upload form
print_heading(get_string("submitassignment", "assignment").":");
workshop_print_upload_form($workshop);
}
// in stage 3? - grade other student's submissions, resubmit and list all submissions
else {
// list any assessments by teachers
if (workshop_count_teacher_assessments($workshop, $USER)) {
print_heading(get_string("assessmentsby", "workshop", $course->teachers));
workshop_list_teacher_assessments($workshop, $USER);
}
// if student assessments show any to assess...
if ($workshop->nsassessments) { // if there are student assessments display them...
workshop_list_student_submissions($workshop, $USER);
// ..and any they have already done...
print_heading(get_string("yourassessments", "workshop"));
workshop_list_assessed_submissions($workshop, $USER);
// ... and show peer assessments
if (workshop_count_peer_assessments($workshop, $USER)) {
print_heading(get_string("assessmentsby", "workshop", $course->students));
workshop_list_peer_assessments($workshop, $USER);
}
}
// list previous submissions
print_heading(get_string("submissions", "workshop"));
workshop_list_user_submissions($workshop, $USER);
echo "
";
if ($workshop->resubmit) {
// if resubmissions allowed print upload form
print_heading(get_string("submitassignment", "assignment").":");
workshop_print_upload_form($workshop);
echo "
";
}
print_heading("id\">".
get_string("listofallsubmissions", "workshop"));
}
}
}
/*********************** submission of assignment by a student/teacher ***********************/
elseif ($action == 'submitassignment') {
$strdifference = format_time($workshop->deadline - time());
if (($workshop->deadline - time()) < 0) {
$strdifference = "$strdifference";
}
$strduedate = userdate($workshop->deadline)." ($strdifference)";
print_simple_box_start("CENTER");
print_heading($workshop->name, "CENTER");
print_simple_box_start("CENTER");
echo "".get_string("duedate", "assignment").": $strduedate
";
echo "".get_string("maximumgrade").": $workshop->grade
";
echo "".get_string("detailsofassessment", "workshop").":
id&action=displayelements\">".
get_string("specimenassessmentform", "workshop")."
";
print_simple_box_end();
echo "
";
echo format_text($workshop->description, $workshop->format);
print_simple_box_end();
echo "
";
workshop_list_teacher_submissions($workshop, $USER);
echo "
";
echo "
";
workshop_list_student_submissions($workshop, $USER);
echo "
";
echo "
";
// list previous submissions
workshop_list_user_submissions($workshop, $USER);
echo "
";
// print upload form
print_heading(get_string("submitassignment", "assignment").":", "CENTER");
workshop_print_upload_form($workshop);
}
/*********************** teacher's view - display admin page (current phase options) ************/
elseif ($action == 'teachersview') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
print_heading_with_help(get_string("managingassignment", "workshop"), "managing", "workshop");
echo "\n";
switch ($workshop->phase) {
case 0:
case 1: // set up assignment
echo "".get_string("phase1", "workshop")."";
echo "
id&action=editelements\">".
get_string("amendassessmentelements", "workshop")."
";
echo "id&action=submitassignment\">".
get_string("submitexampleassignment", "workshop")."";
echo "
id&action=listforassessmentteacher\">".
get_string("teachersubmissionsforassessment", "workshop",
workshop_count_teacher_submissions_for_assessment($workshop, $USER)).
"
\n";
echo "id&action=openworkshop\">".
get_string("moveonto", "workshop")." ".get_string("phase2", "workshop", $course->student)."
";
break;
case 2: // submissions and assessments
echo "".get_string("phase2", "workshop", $course->student)."";
echo "id&action=listungradedteachersubmissions\">".
get_string("ungradedassessmentsofteachersubmissions", "workshop", workshop_count_ungraded_assessments_teacher($workshop))."\n";
echo "
id&action=listungradedstudentsubmissions\">".
get_string("ungradedassessmentsofstudentsubmissions", "workshop", workshop_count_ungraded_assessments_student($workshop))."\n";
echo "
id&action=listforassessmentstudent\">".
get_string("studentsubmissionsforassessment", "workshop", workshop_count_student_submissions_for_assessment($workshop, $USER)).
"\n";
echo "
id&action=closeworkshop\">".
get_string("moveonto", "workshop")." ".get_string("phase3", "workshop")."
";
echo "[".get_string("deadlineis", "workshop", userdate($workshop->deadline))."]
\n";
echo "id&action=setupassignment\">(".
get_string("returnto", "workshop")." ".get_string("phase1", "workshop").")
";
break;
case 3: // calculate final grades
echo "".get_string("phase3", "workshop")."";
echo "id&action=listungradedstudentsubmissions\">".
get_string("ungradedassessmentsofstudentsubmissions", "workshop", workshop_count_ungraded_assessments_student($workshop))."\n";
echo "
id&action=listforassessmentstudent\">".
get_string("studentsubmissionsforassessment", "workshop", workshop_count_student_submissions_for_assessment($workshop, $USER)).
"\n";
echo "
id&action=displayfinalweights\">".
get_string("calculationoffinalgrades", "workshop")."
";
echo "id&action=makefinalgradesavailable\">".
get_string("moveonto", "workshop")." ".get_string("phase4", "workshop")."
";
echo "id&action=openworkshop\">(".
get_string("returnto", "workshop")." ".get_string("phase2", "workshop", $course->student).")
";
break;
case 4: // show final grades
echo "".get_string("phase4", "workshop")."";
echo "id&action=displayfinalgrades\">".
get_string("displayoffinalgrades", "workshop")."
";
echo "id&action=makefinalgradesunavailable\">(".
get_string("returnto", "workshop")." ".get_string("phase3", "workshop").")
";
}
echo "id&action=adminlist\">".
get_string("listofallsubmissions", "workshop")."
\n";
}
/*************** no man's land **************************************/
else {
error("Fatal Error: Unknown Action: ".$action."\n");
}
print_footer($course);
?>