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);
$navigation = "";
if ($course->category) {
$navigation = "id\">$course->shortname ->";
}
$strworkshops = get_string("modulenameplural", "workshop");
$strworkshop = get_string("modulename", "workshop");
$strassessments = get_string("assessments", "workshop");
// ... print the header and...
print_header("$course->shortname: $workshop->name", "$course->fullname",
"$navigation id>$strworkshops ->
id\">$workshop->name -> $strassessments",
"", "", true);
//...get the action
require_variable($action);
/*************** add comment to assessment (by author, assessor or teacher) ***************************/
if ($action == 'addcomment') {
print_heading_with_help(get_string("addacomment", "workshop"), "addingacomment", "workshop");
// get assessment record
if (!$assessmentid = $_REQUEST['aid']) { // comes from link or hidden form variable
error("Assessment id not given");
}
$assessment = get_record("workshop_assessments", "id", $assessmentid);
if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
error("Submission not found");
}
?>
\n";
echo "
".get_string("assessment", "workshop"). "
\n";
workshop_print_assessment($workshop, $assessment);
}
/******************* admin confirm delete ************************************/
elseif ($action == 'adminconfirmdelete' ) {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (empty($_GET['aid'])) {
error("Admin confirm delete: assessment id missing");
}
notice_yesno(get_string("confirmdeletionofthisitem","workshop", get_string("assessment", "workshop")),
"assessments.php?action=admindelete&id=$cm->id&aid=$_GET[aid]", "submissions.php?action=adminlist&id=$cm->id");
}
/******************* admin delete ************************************/
elseif ($action == 'admindelete' ) {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (empty($_GET['aid'])) {
error("Admin delete: submission id missing");
}
print_string("deleting", "workshop");
// first delete all the associated records...
delete_records("workshop_comments", "assessmentid", $_GET['aid']);
delete_records("workshop_grades", "assessmentid", $_GET['aid']);
// ...now delete the assessment...
delete_records("workshop_assessments", "id", $_GET['aid']);
print_continue("submissions.php?id=$cm->id&action=adminlist");
}
/*********************** admin list of asssessments (of a submission) (by teachers)**************/
elseif ($action == 'adminlist') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (empty($_GET['sid'])) {
error ("Workshop asssessments: adminlist called with no sid");
}
$submission = get_record("workshop_submissions", "id", $_GET['sid']);
workshop_print_assessments_for_admin($workshop, $submission);
print_continue("submissions.php?action=adminlist&a=$workshop->id");
}
/*********************** admin list of asssessments by a student (used by teachers only )******************/
elseif ($action == 'adminlistbystudent') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
if (empty($_GET['userid'])) {
error ("Workshop asssessments: adminlistbystudent called with no userid");
}
$user = get_record("user", "id", $_GET['userid']);
workshop_print_assessments_by_user_for_admin($workshop, $user);
print_continue("submissions.php?action=adminlist&a=$workshop->id");
}
/*************** agree (to) assessment (by student) ***************************/
elseif ($action == 'agreeassessment') {
$timenow = time();
// assessment id comes from link or hidden form variable
if (!$assessment = get_record("workshop_assessments", "id", $_REQUEST['aid'])) {
error("Assessment : agree assessment failed");
}
//save time of agreement
set_field("workshop_assessments", "timeagreed", $timenow, "id", $assessment->id);
echo "".get_string("savedok", "workshop")." \n";
add_to_log($course->id, "workshop", "agree", "assessments.php?action=viewassessment&id=$cm->id&aid=$assessment->id", "$assessment->id");
print_continue("view.php?id=$cm->id");
}
/*************** Assess submission (by teacher or student) ***************************/
elseif ($action == 'assesssubmission') {
require_variable($sid);
optional_variable($allowcomments);
if (!isset($allowcomments)) {
$allowcomments = false;
}
if (! $submission = get_record("workshop_submissions", "id", $sid)) {
error("Assess submission is misconfigured - no submission record!");
}
// there can be an assessment record (for teacher submissions), if there isn't...
if (!$assessment = 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
$assessment->workshopid = $workshop->id;
$assessment->submissionid = $submission->id;
$assessment->userid = $USER->id;
$assessment->grade = -1; // set impossible grade
$assessment->timecreated = $yearfromnow;
$assessment->timegraded = 0;
$assessment->timeagreed = 0;
$assessment->resubmission = 0;
if (!$assessment->id = insert_record("workshop_assessments", $assessment)) {
error("Could not insert workshop assessment!");
}
}
print_heading_with_help(get_string("assessthissubmission", "workshop"), "grading", "workshop");
// show assessment and allow changes
workshop_print_assessment($workshop, $assessment, true, $allowcomments, $_SERVER["HTTP_REFERER"]);
}
/*************** display grading form (viewed by student) *********************************/
elseif ($action == 'displaygradingform') {
print_heading_with_help(get_string("specimenassessmentform", "workshop"), "specimen", "workshop");
workshop_print_assessment($workshop); // called with no assessment
print_continue("view.php?a=$workshop->id");
}
/*************** edit comment on assessment (by author, assessor or teacher) ***************************/
elseif ($action == 'editcomment') {
print_heading_with_help(get_string("editacomment", "workshop"), "editingacomment", "workshop");
// get the comment record...
if (!$comment = get_record("workshop_comments", "id", $_GET['cid'])) {
error("Edit Comment: Comment not found");
}
if (!$assessment = get_record("workshop_assessments", "id", $comment->assessmentid)) {
error("Edit Comment: Assessment not found");
}
if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
error("Edit Comment: Submission not found");
}
?>
\n";
workshop_print_assessment($workshop, $assessment);
}
/*********************** edit assessment elements (for teachers) ***********************/
elseif ($action == 'editelements') {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
}
$count = count_records("workshop_grades", "workshop", $workshop->id);
if ($workshop->phase > 1 and $count) {
notify(get_string("warningonamendingelements", "workshop"));
}
// set up heading, form and table
print_heading_with_help(get_string("editingassessmentelements", "workshop"), "elements", "workshop");
?>
id)) {
error("Only teachers can look at this page");
}
// set up coment scale
for ($i=COMMENTSCALE; $i>=0; $i--) {
$num[$i] = $i;
}
print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
// get assessment record
if (!$assessmentid = $_GET['aid']) {
error("Assessment id not given");
}
$assessment = get_record("workshop_assessments", "id", $assessmentid);
if (!$submission = get_record("workshop_submissions", "id", $assessment->submissionid)) {
error("Submission not found");
}
// get the teacher's assessment first
if ($teachersassessment = workshop_get_submission_assessment($submission, $USER)) {
echo "