Ejemplo n.º 1
0
 function get_submission($userid = 0, $createnew = false, $teachermodified = false)
 {
     global $CFG;
     $submission = parent::get_submission($userid, $createnew, $teachermodified);
     if ($submission) {
         $onlinejudge = get_record('assignment_oj_submissions', 'submission', $submission->id);
         if (empty($onlinejudge) && $createnew) {
             $newsubmission = new Object();
             $newsubmission->submission = $submission->id;
             if (!insert_record("assignment_oj_submissions", $newsubmission)) {
                 error("Could not insert a new empty onlinejudge submission");
             }
             unset($newsubmission);
         }
         $onlinejudge = get_record('assignment_oj_submissions', 'submission', $submission->id);
         if ($onlinejudge) {
             $submission->judged = $onlinejudge->judged;
             $submission->oj_id = $onlinejudge->id;
         } else {
             $submission->judged = 0;
         }
         if ($submission->judged) {
             $results = get_recordset_select('assignment_oj_results', 'submission = ' . $submission->id . ' AND judgetime >= ' . $submission->timemodified, 'judgetime DESC', '*', '', '1');
             $results = recordset_to_array($results);
             if ($results) {
                 $result = array_pop($results);
                 $submission->info = $result->info;
                 $submission->status = $result->status;
                 $submission->judgetime = $result->judgetime;
                 $submission->output = $result->output;
             } else {
                 $submission->judged = 0;
                 //It is been judging
                 $submission->status = 'pending';
             }
         } else {
             if (($files = get_directory_list($CFG->dataroot . '/' . $this->file_area_name($userid))) && count($files) != 0) {
                 // Submitted but unjudged
                 $submission->status = 'pending';
             }
         }
     }
     return $submission;
 }
Ejemplo n.º 2
0
$id = optional_param('id', null, PARAM_INT);
$formdata = new stdClass();
$formdata->userid = required_param('userid', PARAM_INT);
$formdata->offset = optional_param('offset', null, PARAM_INT);
$formdata->forcerefresh = optional_param('forcerefresh', null, PARAM_INT);
$formdata->mode = optional_param('mode', null, PARAM_ALPHA);
$url = new moodle_url('/mod/assignment/type/uploadsingle/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);
if (!($assignment = $DB->get_record('assignment', array('id' => $cm->instance)))) {
    print_error('invalidid', 'assignment');
}
require_login($course, true, $cm);
if (isguestuser()) {
    die;
}
$instance = new assignment_uploadsingle($cm->id, $assignment, $cm, $course);
$fullname = format_string($course->fullname, true, array('context' => context_course::instance($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);
$options = array('subdirs' => 0, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $assignment->maxbytes), 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
$mform = new mod_assignment_uploadsingle_form(null, array('contextid' => $contextid, 'userid' => $formdata->userid, 'options' => $options));
if ($mform->is_cancelled()) {
    redirect(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id)));
} else {
    if ($mform->get_data()) {
        $instance->upload($mform);
        die;
        //    redirect(new moodle_url('/mod/assignment/view.php', array('id'=>$cm->id)));