コード例 #1
0
ファイル: responsezip.php プロジェクト: royalroads/RRU-Moodle
} else {
    if ($fromform = $uploadform->get_data()) {
        //Process the form data so long as it's validated
        $uploadedfile = $uploadform->get_file_content('response_zip');
        require_once $CFG->dirroot . '/mod/assignment/lib.php';
        require_once $CFG->dirroot . '/mod/assignment/type/' . $assignment->assignmenttype . '/assignment.class.php';
        $assignmentclass = 'assignment_' . $assignment->assignmenttype;
        $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course);
        $zipfile = $uploadform->save_temp_file('response_zip');
        // Unzip uploaded file to the appropriate storage area
        require_once $CFG->dirroot . '/lib/filestorage/zip_packer.php';
        $ziplib = new zip_packer();
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        print "Course ID: {$id}<br>\n";
        print "Context ID: {$context->id}<br>\n";
        $response_files = $ziplib->extract_to_storage($zipfile, $context->id, 'mod_assignment', 'response', 0, 'feedback');
        // Associate the response files with their appropriate submissions...
        $fs = get_file_storage();
        $users = get_enrolled_users($context);
        $groups = groups_get_all_groups($COURSE->id);
        foreach ($response_files as $file => $value) {
            preg_match('/(.*?)_(.*)_\\d*(\\..*)/', $file, $matches);
            $username = $matches[1];
            $filename = $matches[2];
            $fileextension = $matches[3];
            $userID = '';
            $groupID = '';
            $submission = '';
            print "Processing :{$filename}{$fileextension}<br>\n";
            if (!$assignmentinstance->assignment->groupassignment) {
                print "This is not a group assignment<br>\n";