course)) { error("Course is misconfigured"); } if (! $workshop = get_record("workshop", "id", $cm->instance)) { error("Course module is incorrect"); } require_login($course->id, false, $cm); $strworkshops = get_string("modulenameplural", "workshop"); $strworkshop = get_string("modulename", "workshop"); $strsubmissions = get_string("submissions", "workshop"); // ... print the header and... print_header_simple("$workshop->name", "", "id\">$strworkshops -> id\">$workshop->name -> $strsubmissions", "", "", true); //...get the action or set up an suitable default optional_variable($action); if (empty($action)) { $action = "listallsubmissions"; } /******************* admin amend title ************************************/ elseif ($action == 'adminamendtitle' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (empty($_GET['sid'])) { error("Admin Amend Title: submission id missing"); } $submission = get_record("workshop_submissions", "id", $_GET['sid']); print_heading(get_string("amendtitle", "workshop")); ?>
\n"; print_heading("framename}\" href=\"view.php?id=$cm->id#sid=$submission->id\">".get_string("cancel").""); } /******************* admin clear late (flag) ************************************/ elseif ($action == 'adminclearlate' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (empty($_GET['sid'])) { error("Admin clear late flag: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { error("Admin clear late flag: can not get submission record"); } if (set_field("workshop_submissions", "late", 0, "id", $_GET['sid'])) { print_heading(get_string("clearlateflag", "workshop")." ".get_string("ok")); } add_to_log($course->id, "workshop", "late flag cleared", "view.php?id=$cm->id", "submission $submission->id"); redirect("view.php?id=$cm->id"); } /******************* confirm delete ************************************/ elseif ($action == 'confirmdelete' ) { if (empty($_GET['sid'])) { error("Confirm delete: submission id missing"); } $sid = $_GET['sid']; notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("submission", "workshop")), "submissions.php?action=delete&id=$cm->id&sid=$sid", "view.php?id=$cm->id#sid=$sid"); } /******************* delete ************************************/ elseif ($action == 'delete' ) { if (empty($_GET['sid'])) { error("Delete: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { error("Admin delete: can not get submission record"); } // students are only allowed to delete their own submission and only up to the deadline if (!(isteacher($course->id) or (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend) and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) { error("You are not authorized to delete this submission"); } print_string("deleting", "workshop"); // first get any assessments... if ($assessments = workshop_get_assessments($submission, 'ALL')) { foreach($assessments as $assessment) { // ...and all the associated records... delete_records("workshop_comments", "assessmentid", $assessment->id); delete_records("workshop_grades", "assessmentid", $assessment->id); echo "."; } // ...now delete the assessments... delete_records("workshop_assessments", "submissionid", $submission->id); } // ...and the submission record... delete_records("workshop_submissions", "id", $submission->id); // ..and finally the submitted file workshop_delete_submitted_files($workshop, $submission); redirect("view.php?id=$cm->id"); } /******************* admin (confirm) late flag ************************************/ elseif ($action == 'adminlateflag' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (empty($_GET['sid'])) { error("Admin confirm late flag: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { error("Admin confirm late flag: can not get submission record"); } notice_yesno(get_string("clearlateflag","workshop")."?", "submissions.php?action=adminclearlate&id=$cm->id&sid=$_GET[sid]", "view.php?id=$cm->id"); } /******************* list all submissions ************************************/ elseif ($action == 'adminlist' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (empty($_GET['order'])) { $order = "name"; } else { $order = $_GET['order']; } workshop_list_submissions_for_admin($workshop, $order); print_continue("view.php?id=$cm->id"); } /******************* admin update title ************************************/ elseif ($action == 'adminupdatetitle' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } if (empty($_POST['sid'])) { error("Admin Update Title: submission id missing"); } if (set_field("workshop_submissions", "title", $_POST['title'], "id", $_POST['sid'])) { print_heading(get_string("amendtitle", "workshop")." ".get_string("ok")); } print_continue("view.php?id=$cm->id"); } /******************* confirm remove attachments ************************************/ elseif ($action == 'confirmremoveattachments' ) { if (empty($_GET['sid'])) { error("Admin confirm delete: submission id missing"); } if (!$submission = get_record("workshop_submissions", "id", $_GET['sid'])) { error("Admin delete: can not get submission record"); } notice_yesno(get_string("confirmremoveattachments","workshop"), "submissions.php?action=removeattachments&id=$cm->id&sid=$_GET[sid]", "view.php?id=$cm->id"); } /******************* edit submission ************************************/ elseif ($action == 'editsubmission' ) { if (empty($_GET['sid'])) { error("Edit submission: submission id missing"); } $usehtmleditor = can_use_html_editor(); $submission = get_record("workshop_submissions", "id", $_GET['sid']); print_heading(get_string("editsubmission", "workshop")); if ($submission->userid <> $USER->id) { error("Edit submission: Userids do not match"); } if (($submission->timecreated < ($timenow - $CFG->maxeditingtime)) and ($workshop->assessmentstart < $timenow)) { error(get_string('notallowed', 'workshop')); } ?> \n"; } /******************* list all submissions ************************************/ elseif ($action == 'listallsubmissions' ) { if (!$users = get_course_students($course->id)) { print_heading(get_string("nostudentsyet")); print_footer($course); exit; } print_heading(get_string("listofallsubmissions", "workshop").":", "CENTER"); workshop_list_all_submissions($workshop, $USER); print_continue("view.php?id=$cm->id"); } /******************* list for assessment student (submissions) ************************************/ elseif ($action == 'listforassessmentstudent' ) { if (!$users = get_course_students($course->id)) { print_heading(get_string("nostudentsyet")); print_footer($course); exit; } workshop_list_unassessed_student_submissions($workshop, $USER); print_continue("view.php?id=$cm->id"); } /******************* list for assessment teacher (submissions) ************************************/ elseif ($action == 'listforassessmentteacher' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } workshop_list_unassessed_teacher_submissions($workshop, $USER); print_continue("view.php?id=$cm->id"); } /******************* remove (all) attachments ************************************/ elseif ($action == 'removeattachments' ) { $form = data_submitted(); if (empty($form->sid)) { error("Update submission: submission id missing"); } $submission = get_record("workshop_submissions", "id", $form->sid); // students are only allowed to remove their own attachments and only up to the deadline if (!(isteacher($course->id) or (($USER->id = $submission->userid) and ($timenow < $workshop->submissionend) and (($timenow < $workshop->assessmentstart) or ($timenow < $submission->timecreated + $CFG->maxeditingtime))))) { error("You are not authorized to delete these attachments"); } // amend title... just in case they were modified // check existence of title if (empty($form->title)) { notify(get_string("notitlegiven", "workshop")); } else { set_field("workshop_submissions", "title", $form->title, "id", $submission->id); set_field("workshop_submissions", "description", trim($form->description), "id", $submission->id); } print_string("removeallattachments", "workshop"); workshop_delete_submitted_files($workshop, $submission); add_to_log($course->id, "workshop", "removeattachments", "view.php?id=$cm->id", "submission $submission->id"); print_continue("view.php?id=$cm->id#sid=$submission->id"); } /******************* show submission ************************************/ elseif ($action == 'showsubmission' ) { if (empty($_GET['sid'])) { error("Show submission: submission id missing"); } $submission = get_record("workshop_submissions", "id", $_GET['sid']); $title = '"'.$submission->title.'" '; if (isteacher($course->id)) { $title .= get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id); } print_heading($title); echo '