Ejemplo n.º 1
0
// loop over assignments finding online ones
foreach ($assignments as $assignment) {
    // only interested in online assignments
    if ($assignment->assignmenttype != 'online') {
        continue;
    }
    // check we are allowed to view this
    $context = context_module::instance($assignment->coursemodule);
    if (!has_capability('mod/assignment:view', $context)) {
        continue;
    }
    // create instance of assignment class to get
    // submitted assignments
    $onlineinstance = new assignment_online($assignment->coursemodule);
    $submitted = $onlineinstance->submittedlink(true);
    $submission = $onlineinstance->get_submission();
    // submission (if there is one)
    if (empty($submission)) {
        $submissiontext = $str->emptysubmission;
        if (!empty($assignment->timedue)) {
            $submissiondate = "{$str->duedate} " . userdate($assignment->timedue);
        } else {
            $submissiondate = $str->duedateno;
        }
    } else {
        $submissiontext = format_text($submission->data1, $submission->data2);
        $submissiondate = "{$str->submitted} " . userdate($submission->timemodified);
    }
    // edit link
    $editlink = "<a href=\"{$CFG->wwwroot}/mod/assignment/view.php?" . "id={$assignment->coursemodule}&amp;edit=1\">{$str->editmysubmission}</a>";
    // format options for description
Ejemplo n.º 2
0
}
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('usermisconf', 'assignment');
}
require_login($course->id, false, $cm);
if ($USER->id != $user->id && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
    print_error('cannotviewassignment', 'assignment');
}
if ($assignment->assignmenttype != 'online') {
    print_error('invalidtype', 'assignment');
}
$assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
if ($submission = $assignmentinstance->get_submission($user->id)) {
    print_header(fullname($user, true) . ': ' . $assignment->name);
    echo $OUTPUT->box_start('generalbox boxaligcenter', 'dates');
    echo '<table>';
    if ($assignment->timedue) {
        echo '<tr><td class="c0">' . get_string('duedate', 'assignment') . ':</td>';
        echo '    <td class="c1">' . userdate($assignment->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->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
        echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')</td></tr>';
    } else {
        if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
            echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')</td></tr>';
Ejemplo n.º 3
0
             $output = '';
             foreach ($files as $file) {
                 $countfiles .= "; " . $file->get_filename();
                 $filename = $file->get_filename();
                 $mimetype = $file->get_mimetype();
                 $path = file_encode_url('pluginfile.php', '/' . $context->id . '/mod_assignment/submission/' . $submission->id . '/' . $filename);
                 $output .= '<a href="' . $path . '" >' . $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . s($filename) . '</a><br>';
             }
             echo $output;
         }
     }
     $type = $assignment->assignment->assignmenttype;
     if ($type == 'online') {
         require_once "{$CFG->dirroot}/mod/assignment/type/online/assignment.class.php";
         $assignment_online = new assignment_online($modid);
         echo $assignment_online->get_submission($userid)->data1;
     }
 } elseif ($mod->modname == 'workshop') {
     $context = context_module::instance($mod->id);
     require_once $CFG->dirroot . '/mod/workshop/locallib.php';
     $workshop = new workshop($instance, $mod, $course);
     $submission = $workshop->get_submission_by_author($user->id);
     if (is_object($submission)) {
         $content = format_text($submission->content, $submission->contentformat, array('overflowdiv' => true));
         $content = file_rewrite_pluginfile_urls($content, 'pluginfile.php', $context->id, 'mod_workshop', 'submission_content', $submission->id);
         print_r($content);
         $fs = get_file_storage();
         $ctx = $context;
         $files = $fs->get_area_files($ctx->id, 'mod_workshop', 'submission_attachment', $submission->id);
         echo '<ul>';
         foreach ($files as $file) {