Ejemplo n.º 1
0
    print_error('invalidid', 'assignment');
}
if (!($course = $DB->get_record('course', array('id' => $assignment->course)))) {
    print_error('coursemisconf', 'assignment');
}
if (!($user = $DB->get_record('user', array('id' => $userid)))) {
    print_error("invaliduserid");
}
require_login($course->id, false, $cm);
if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
    print_error('cannotviewassignment', 'assignment');
}
if ($assignment->assignmenttype != 'upload') {
    print_error('invalidtype', 'assignment');
}
$assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course);
$returnurl = "../../submissions.php?id={$assignmentinstance->cm->id}&userid={$userid}&offset={$offset}&mode=single";
if ($submission = $assignmentinstance->get_submission($user->id) and !empty($submission->data1)) {
    print_header(fullname($user, true) . ': ' . $assignment->name);
    print_heading(get_string('notes', 'assignment') . ' - ' . fullname($user, true));
    print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%');
    if ($mode != 'single') {
        close_window_button();
    } else {
        print_continue($returnurl);
    }
    print_footer('none');
} else {
    print_header(fullname($user, true) . ': ' . $assignment->name);
    print_heading(get_string('notes', 'assignment') . ' - ' . fullname($user, true));
    print_simple_box(get_string('notesempty', 'assignment'), 'center', '100%');
Ejemplo n.º 2
0
$url = new moodle_url('/mod/assignment/type/upload/upload.php', array('contextid' => $contextid, 'id' => $id, 'offset' => $formdata->offset, 'forcerefresh' => $formdata->forcerefresh, 'userid' => $formdata->userid, 'mode' => $formdata->mode));
list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course, true, $cm);
if (isguestuser()) {
    die;
}
if (!($assignment = $DB->get_record('assignment', array('id' => $cm->instance)))) {
    print_error('invalidid', 'assignment');
}
$fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$PAGE->set_url($url);
$PAGE->set_context($context);
$title = strip_tags($fullname . ': ' . get_string('modulename', 'assignment') . ': ' . format_string($assignment->name, true));
$PAGE->set_title($title);
$PAGE->set_heading($title);
$instance = new assignment_upload($cm->id, $assignment, $cm, $course);
$submission = $instance->get_submission($formdata->userid, false);
$filemanager_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
$mform = new mod_assignment_upload_form(null, array('contextid' => $contextid, 'userid' => $formdata->userid, 'options' => $filemanager_options));
if ($mform->is_cancelled()) {
    redirect(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id)));
} else {
    if ($formdata = $mform->get_data()) {
        $instance->upload($mform, $filemanager_options);
        die;
    }
}
echo $OUTPUT->header();
echo $OUTPUT->box_start('generalbox');
if ($instance->can_upload_file($submission) && $id == null) {
    $data = new stdClass();
 /**
  * Sets up form elements specific to this assignment type for use in a special section
  * of the activity editing form
  *
  * @param  object  $mform  The form to update in-place with additional fields
  */
 function setup_elements(&$mform)
 {
     $repo = $this->get_repository_object();
     if ($repo === false) {
         //core repository error message
         $message = get_string('errorrepository', 'assignment_backpack');
         //wrap it with helpful instructions
         $message = get_string('errorrepositoryconfig', 'assignment_backpack', $message);
         //this will set text color to red
         $message = '<span class="notifyproblem">' . $message . '</span>';
         //add the message as text
         $mform->addElement('static', 'repositoryerror', '', $message);
     } else {
         //config is ok, so add the appropriate elements
         return parent::setup_elements($mform);
     }
 }
 function assignment_team($cmid = 'staticonly', $assignment = NULL, $cm = NULL, $course = NULL)
 {
     parent::assignment_upload($cmid, $assignment, $cm, $course);
     $this->type = 'typeteam';
 }
 function submissions($mode)
 {
     $forcejudge = optional_param('forcejudge', FALSE, PARAM_TEXT);
     if ($forcejudge) {
         $user = required_param('userid', PARAM_INT);
         $this->request_judge($this->get_submission($user));
         $offset = required_param('offset', PARAM_INT);
         $id = required_param('id', PARAM_INT);
         redirect('submissions.php?id=' . $id . '&userid=' . $user . '&mode=single&offset=' . $offset);
     }
     parent::submissions($mode);
 }