* This is called automatically by {@link load_course()} if the current course
* format = weeks.
*
- * @param array $path An array of keys to the course node in the navigation
- * @param stdClass $modinfo The mod info object for the current course
- * @return bool Returns true
+ * @param navigation_node $navigation The course node
+ * @param array $path An array of keys to the course node
+ * @param stdClass $course The course we are loading the section for
*/
function callback_weeks_load_content(&$navigation, $keys, $course) {
$navigation->add_course_section_generic($keys, $course, get_string('week'), 'week');
* This is called automatically by {@link load_course()} if the current course
* format = weeks and the navigation was requested via AJAX
*
- * @param array $path An array of keys to the course node in the navigation
- * @param stdClass $modinfo The mod info object for the current course
- * @return bool Returns true
+ * @param navigation_node $navigation The course node
+ * @param array $path An array of keys to the course node
+ * @param stdClass $course The course we are loading the section for
+ * @param stdClass $section The section to load
*/
function callback_weeks_load_limited_section(&$navigation, $keys, $course, $section) {
$navigation->limited_load_section_generic($keys, $course, $section, get_string('week'), 'week');
$string['assignment:grade'] = 'Grade assignment';
$string['assignment:submit'] = 'Submit assignment';
$string['assignment:view'] = 'View assignment';
+$string['assignmentadministration'] = 'Assignment administration';
$string['assignmentdetails'] = 'Assignment details';
$string['assignmentmail'] = '$a->teacher has posted some feedback on your
assignment submission for \'$a->assignment\'
$string['uploadsuccess'] = 'Uploaded \'$a\' successfully';
$string['usermisconf'] = 'User is misconfigured';
$string['viewfeedback'] = 'View assignment grades and feedback';
+$string['viewmysubmission'] = 'View my submission';
$string['viewsubmissions'] = 'View $a submitted assignments';
$string['yoursubmission'] = 'Your submission';
$string['maxpublishstate'] = 'Maximum visibility for blog entry before duedate';
$submission = new Object;
$submission->assignment = $this->assignment->id;
$submission->userid = $userid;
- //$submission->timecreated = time();
- $submission->timecreated = '';
+ $submission->timecreated = time();
// teachers should not be modifying modified date, except offline assignments
if ($teachermodified) {
$submission->timemodified = 0;
default: return null;
}
}
+
+function assignment_extend_settings_navigation($navnode, $module) {
+ global $PAGE, $DB, $USER, $CFG;
+
+ $allgroups = false;
+
+ $assignmentrow = $DB->get_record("assignment", array("id" => $PAGE->cm->instance));
+ require_once "$CFG->dirroot/mod/assignment/type/$assignmentrow->assignmenttype/assignment.class.php";
+ $assignmentclass = 'assignment_'.$assignmentrow->assignmenttype;
+ $assignmentinstance = new $assignmentclass($PAGE->cm->id, $assignmentrow, $PAGE->cm, $PAGE->course);
+
+ $assignmentnodekey = $navnode->add(get_string('assignmentadministration', 'assignment'));
+ $assignmentnode = $navnode->get($assignmentnodekey);
+ $assignmentnode->forceopen = true;
+
+ if (!empty($USER->id) && !has_capability('moodle/legacy:guest', $PAGE->cm->context, NULL, false)) {
+
+ $allgroups = false;
+
+ // Add assignment submission information
+ if (has_capability('mod/assignment:grade', $PAGE->cm->context)) {
+ if ($allgroups && has_capability('moodle/site:accessallgroups', $PAGE->cm->context)) {
+ $group = 0;
+ } else {
+ $group = groups_get_activity_group($PAGE->cm);
+ }
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/submissions.php', array('id'=>$PAGE->cm->id));
+ if ($count = $assignmentinstance->count_real_submissions($group)) {
+ $string = get_string('viewsubmissions', 'assignment', $count);
+ } else {
+ $string = get_string('noattempts', 'assignment');
+ }
+ $assignmentnode->add($string, $link, navigation_node::TYPE_SETTING);
+ }
+
+ if (is_object($assignmentinstance) && method_exists($assignmentinstance, 'extend_settings_navigation')) {
+ $assignmentinstance->extend_settings_navigation($assignmentnode);
+ }
+
+ // Add update this activity link
+ if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
+ $modulename = get_string('modulename', 'assignment');
+ $string = get_string('updatethis', '', $modulename);
+ $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
+ $assignmentnode->add($string, $url, navigation_node::TYPE_SETTING);
+ }
+
+ if (count($assignmentnode->children)<1) {
+ $navnode->remove_child($assignmentnodekey);
+ }
+ }
+}
\ No newline at end of file
return '';
}
- $link = html_link::make("/mod/assignment/type/online/file.php?id=$this->cm->id&userid=$submission->userid", shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15));
+ $link = html_link::make("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}", shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15));
$link->add_action(new popup_action('click', $link->url, 'file'.$userid, array('height' => 450, 'width' => 580)));
$link->title = get_string('submission', 'assignment');
$popup = $OUTPUT->link($link);
}
function print_user_files($userid, $return=false) {
- global $OUTPUT;
+ global $OUTPUT, $CFG;
if (!$submission = $this->get_submission($userid)) {
return '';
}
- $link = html_link::make("/mod/assignment/type/online/file.php?id=$this->cm->id&userid=$submission->userid", shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15));
+ $link = html_link::make("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}", shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15));
$link->add_action(new popup_action('click', $link->url, 'file'.$userid, array('height' => 450, 'width' => 580)));
$link->title = get_string('submission', 'assignment');
$popup = $OUTPUT->link($link);
function portfolio_supported_formats() {
return array(PORTFOLIO_FORMAT_PLAINHTML);
}
+
+ function extend_settings_navigation($node) {
+ global $PAGE, $CFG, $USER;
+
+ // get users submission if there is one
+ $submission = $this->get_submission();
+ if (has_capability('mod/assignment:submit', $PAGE->cm->context)) {
+ $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
+ } else {
+ $editable = false;
+ }
+
+ // If the user has submitted something add a bit more stuff
+ if ($submission) {
+ // Add a view link to the settings nav
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/view.php', array('id'=>$PAGE->cm->id));
+ $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
+
+ if (!empty($submission->timemodified)) {
+ $key = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
+ $node->get($key)->text = preg_replace('#([^,])\s#', '$1 ', $node->get($key)->text);
+ $node->get($key)->add_class('note');
+ if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
+ $node->get($key)->add_class('early');
+ } else {
+ $node->get($key)->add_class('late');
+ }
+ }
+ }
+
+ if (!$submission || $editable) {
+ // If this assignment is editable once submitted add an edit link to the settings nav
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/view.php', array('id'=>$PAGE->cm->id, 'edit'=>1, 'sesskey'=>sesskey()));
+ $node->add(get_string('editmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
+ }
+ }
}
class mod_assignment_online_edit_form extends moodleform {
return true;
}
+ function extend_settings_navigation($node) {
+ global $CFG, $USER, $OUTPUT;
+
+ // get users submission if there is one
+ $submission = $this->get_submission();
+ if (has_capability('mod/assignment:submit', $this->cm->context)) {
+ $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
+ } else {
+ $editable = false;
+ }
+
+ // If the user has submitted something add a bit more stuff
+ if ($submission) {
+ // Add a view link to the settings nav
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/view.php', array('id'=>$this->cm->id));
+ $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
+ if (!empty($submission->timemodified)) {
+ $key = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
+ $node->get($key)->text = preg_replace('#([^,])\s#', '$1 ', $node->get($key)->text);
+ $node->get($key)->add_class('note');
+ if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
+ $node->get($key)->add_class('early');
+ } else {
+ $node->get($key)->add_class('late');
+ }
+ }
+ }
+
+ // Check if the user has uploaded any files, if so we can add some more stuff to the settings nav
+ if ($submission && has_capability('mod/assignment:submit', $this->context) && $this->count_user_files($USER->id)) {
+ $fs = get_file_storage();
+ if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $USER->id, "timemodified", false)) {
+ if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
+ $filekey = $node->add(get_string('submission', 'assignment'));
+ } else {
+ $filekey = $node->add(get_string('submissiondraft', 'assignment'));
+ }
+ foreach ($files as $file) {
+ $filename = $file->get_filename();
+ $mimetype = $file->get_mimetype();
+ $link = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$this->context->id.'/assignment_submission/'.$USER->id.'/'.$filename);
+ $node->get($filekey)->add($filename, $link, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url(file_mimetype_icon($mimetype)));
+ }
+ }
+ }
+
+ // Show a notes link if they are enabled
+ if ($this->notes_allowed()) {
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/upload.php', array('id'=>$this->cm->id, 'action'=>'editnotes', 'sesskey'=>sesskey()));
+ $node->add(get_string('notes', 'assignment'), $link);
+ }
+ }
}
class mod_assignment_upload_notes_form extends moodleform {
send_stored_file($file, 0, 0, true); // download MUST be forced - security!
}
+ function extend_settings_navigation($node) {
+ global $CFG, $USER, $OUTPUT;
+
+ // get users submission if there is one
+ $submission = $this->get_submission();
+ if (has_capability('mod/assignment:submit', $this->cm->context)) {
+ $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
+ } else {
+ $editable = false;
+ }
+
+ // If the user has submitted something add a bit more stuff
+ if ($submission) {
+ // Add a view link to the settings nav
+ $link = new moodle_url($CFG->wwwroot.'/mod/assignment/view.php', array('id'=>$this->cm->id));
+ $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
+ if (!empty($submission->timemodified)) {
+ $key = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
+ $node->get($key)->text = preg_replace('#([^,])\s#', '$1 ', $node->get($key)->text);
+ $node->get($key)->add_class('note');
+ if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
+ $node->get($key)->add_class('early');
+ } else {
+ $node->get($key)->add_class('late');
+ }
+ }
+ }
+
+ // Check if the user has uploaded any files, if so we can add some more stuff to the settings nav
+ if ($submission && has_capability('mod/assignment:submit', $this->context) && $this->count_user_files($USER->id)) {
+ $fs = get_file_storage();
+ if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $USER->id, "timemodified", false)) {
+ $filekey = $node->add(get_string('submission', 'assignment'));
+ foreach ($files as $file) {
+ $filename = $file->get_filename();
+ $mimetype = $file->get_mimetype();
+ $link = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$this->context->id.'/assignment_submission/'.$USER->id.'/'.$filename);
+ $node->get($filekey)->add($filename, $link, navigation_node::TYPE_SETTING, null, null, $OUTPUT->old_icon_url(file_mimetype_icon($mimetype)));
+ }
+ }
+ }
+ }
}
?>