error("Course Module ID was incorrect"); } if (!($problemstatement = get_record("problemstatement", "id", $cm->instance))) { error("Problemstatement ID was incorrect"); } if (!($course = get_record("course", "id", $problemstatement->course))) { error("Course is misconfigured"); } if (!($user = get_record("user", "id", $userid))) { error("User is misconfigured"); } require_login($course->id, false, $cm); if ($USER->id != $user->id && !has_capability('mod/problemstatement:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { error("You can not view this problemstatement"); } $problemstatementinstance = new problemstatement($cm->id, $problemstatement, $cm, $course); if ($submission = $problemstatementinstance->get_submission($user->id)) { print_header(fullname($user, true) . ': ' . $problemstatement->name); print_simple_box_start('center', '', '', '', 'generalbox', 'dates'); echo '<table>'; if ($problemstatement->timedue) { echo '<tr><td class="c0">' . get_string('duedate', 'problemstatement') . ':</td>'; echo ' <td class="c1">' . userdate($problemstatement->timedue) . '</td></tr>'; } echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>'; echo ' <td class="c1">' . userdate($submission->timemodified); /// Decide what to count //if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_WORDS) { echo ' (' . get_string('numwords', '', count_words($submission->programtext)) . ')</td></tr>'; //} else if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_LETTERS) { echo ' (' . get_string('numletters', '', count_letters($submission->programtext)) . ')</td></tr>';
} } else { if (!($problemstatement = get_record("problemstatement", "id", $a))) { error("Course module is incorrect"); } if (!($course = get_record("course", "id", $problemstatement->course))) { error("Course is misconfigured"); } if (!($cm = get_coursemodule_from_instance("problemstatement", $problemstatement->id, $course->id))) { error("Course Module ID was incorrect"); } } require_login($course->id); add_to_log($course->id, "problemstatement", "view", "view.php?id={$cm->id}", "{$problemstatement->id}"); /// Print the page header if ($course->category) { $navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->"; } else { $navigation = ''; } $strproblemstatements = get_string("modulenameplural", "problemstatement"); $strproblemstatement = get_string("modulename", "problemstatement"); print_header("{$course->shortname}: {$problemstatement->name}", "{$course->fullname}", "{$navigation} <a href=index.php?id={$course->id}>{$strproblemstatements}</a> -> {$problemstatement->name}", "", "", true, update_module_button($cm->id, $course->id, $strproblemstatement), navmenu($course, $cm)); /// Print the main part of the page //echo "YOUR CODE GOES HERE"; require "{$CFG->dirroot}/mod/problemstatement/problemstatement.class.php"; $problemstatementinstance = new problemstatement($cm->id, $problemstatement, $cm, $course); $problemstatementinstance->view(); // Actually display the problemstatement! /// Finish the page //print_footer($course);