MDL-14945
[moodle-linuxchix.git] / mod / workshop / viewassessment.php
blob81648b2c044505312c19117646188b96e0b242de
1 <?php // $Id$
3 require("../../config.php");
4 require("lib.php");
5 require("locallib.php");
7 $aid = required_param('aid', PARAM_INT); // Assessment ID
8 $allowcomments = optional_param('allowcomments', false, PARAM_BOOL);
9 $redirect = optional_param('redirect', '', PARAM_URL);
10 $frameset = optional_param('frameset', '', PARAM_ALPHA);
12 if (! $assessment = get_record("workshop_assessments", "id", $aid)) {
13 error("Assessment id is incorrect");
15 if (! $submission = get_record('workshop_submissions', 'id', $assessment->submissionid)) {
16 error("Incorrect submission id");
18 if (! $workshop = get_record("workshop", "id", $submission->workshopid)) {
19 error("Submission is incorrect");
21 if (! $course = get_record("course", "id", $workshop->course)) {
22 error("Workshop is misconfigured");
24 if (! $cm = get_coursemodule_from_instance("workshop", $workshop->id, $course->id)) {
25 error("No coursemodule found");
28 if (!$redirect) {
29 $redirect = htmlentities($_SERVER["HTTP_REFERER"].'#sid='.$submission->id);
32 require_login($course->id, false, $cm);
34 $strworkshops = get_string("modulenameplural", "workshop");
35 $strworkshop = get_string("modulename", "workshop");
36 $strassess = get_string("viewassessment", "workshop");
38 /// Now check whether we need to display a frameset
40 if (empty($frameset)) {
41 if ( get_string('thisdirection') == 'rtl' ) {
42 $direction = ' dir="rtl"';
43 } else {
44 $direction = ' dir="ltr"';
46 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
47 echo "<html $direction>\n";
48 echo "<head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
49 echo "<title>{$course->shortname}: ".format_string($workshop->name,true)."</title></head>\n";
50 echo "<frameset rows=\"90%,*\" border=\"10\">";
51 echo " <frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;allowcomments=$allowcomments&amp;frameset=top&amp;redirect=$redirect\" border=\"10\" />";
52 echo " <frame src=\"viewassessment.php?id=$id&amp;aid=$aid&amp;allowcomments=$allowcomments&amp;frameset=bottom&amp;redirect=$redirect\" />";
53 echo "</frameset>";
54 echo "</html>";
55 exit;
58 /// top frame with the navigation bar and the assessment form
60 if ($frameset == "top") {
61 $navigation = build_navigation($strassess, $cm);
62 print_header_simple(format_string($workshop->name), "", $navigation,
63 "", '', true);
65 // show assessment but don't allow changes
66 workshop_print_assessment($workshop, $assessment, false, $allowcomments);
68 if (workshop_is_teacher($workshop) and !workshop_is_teacher($workshop, $assessment->userid)) {
69 print_heading_with_help(get_string("gradeassessment", "workshop"), "gradingassessments", "workshop");
70 include('assessment_grading_form.html');
72 print_continue($redirect);
73 print_footer($course);
74 exit;
77 /// print bottom frame with the submission
78 // removed <base target="_parent" /> as it does not validate
79 print_header('', '', '', '', '');
80 $title = '"'.$submission->title.'" ';
81 if (workshop_is_teacher($workshop)) {
82 $title .= ' '.get_string('by', 'workshop').' '.workshop_fullname($submission->userid, $course->id);
84 print_heading($title);
85 workshop_print_submission($workshop, $submission);
86 print_footer('none');