Example #1
0
    $view->submissiontext = $submissiontext;
    $view->submissiondate = $submissiondate;
    $view->cm = $assignment->coursemodule;
    $views[] = $view;
}
//===================
// DISPLAY
//===================
$PAGE->set_title($str->assignments);
echo $OUTPUT->header();
foreach ($views as $view) {
    echo $OUTPUT->container_start('clearfix generalbox assignment');
    // info bit
    echo $OUTPUT->heading("{$view->section} - {$view->name}", 3, 'mdl-left');
    if (!empty($view->submitted)) {
        echo '<div class="reportlink">' . $view->submitted . '</div>';
    }
    // description part
    echo '<div class="description">' . $view->description . '</div>';
    //submission part
    echo $OUTPUT->container_start('generalbox submission');
    echo '<div class="submissiondate">' . $view->submissiondate . '</div>';
    echo "<p class='no-overflow'>{$view->submissiontext}</p>\n";
    echo "<p>{$view->editlink}</p>\n";
    echo $OUTPUT->container_end();
    // feedback part
    $onlineinstance = new assignment_online($view->cm);
    $onlineinstance->view_feedback();
    echo $OUTPUT->container_end();
}
echo $OUTPUT->footer();
Example #2
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('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) {
             $countfiles = count($files) . " " . get_string("uploadedfiles", "assignment");
             $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>';