Esempio n. 1
0
/**
 * Redirects the user to login to a Turnitin page
 *
 * @global object
 * @param var $userid The User ID of the user requesting the Turnitin Page
 * @param string $jumppage A string that represents the page to jump to possible strings are 'grade','report','submission' and 'download'
 * @param array The Query Array passed to this function
 */
function turnitintool_url_jumpto($userid, $jumppage, $turnitintool, $utp = null, $objectid = null, $partid = null, $export_data = null)
{
    global $CFG;
    $thisuser = turnitintool_get_moodleuser($userid, NULL, __FILE__, __LINE__);
    $cm = get_coursemodule_from_instance("turnitintool", $turnitintool->id, $turnitintool->course);
    if ($utp > 1 and !has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) {
        turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
    }
    $loaderbar = NULL;
    $tii = new turnitintool_commclass(turnitintool_getUID($thisuser), $thisuser->firstname, $thisuser->lastname, $thisuser->email, $utp, $loaderbar, false);
    $tii->startSession();
    $newuser = turnitintool_usersetup($thisuser, get_string('userprocess', 'turnitintool'), $tii, $loaderbar);
    $post = new stdClass();
    $post->cid = turnitintool_getCID($turnitintool->course);
    $post->ctl = turnitintool_getCTL($turnitintool->course);
    $post->paperid = $objectid;
    $owner = turnitintool_get_owner($turnitintool->course);
    // Get the default main tutor (used in tem only)
    $post->tem = $owner->email;
    $post->assignid = !is_null($partid) ? turnitintool_getAID($partid) : null;
    $post->assign = !is_null($partid) ? $turnitintool->name . ' - ' . turnitintool_partnamefromnum($partid) . ' (Moodle ' . $post->assignid . ')' : null;
    $post->export_data = $export_data;
    if ($utp > 1 and !is_null($turnitintool)) {
        // If this is a tutor enrol them on the Turnitin class before redirecting
        $tii->enrolTutor($post, get_string('turnitintutorsadding', 'turnitintool'));
    }
    if ($tii->getRerror()) {
        if ($tii->getAPIunavailable()) {
            turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
        } else {
            turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__);
        }
        exit;
    }
    $tii->endSession();
    $tii->uid = $newuser->turnitin_uid;
    if ($jumppage == 'grade') {
        $url = $tii->getGradeMarkLink($post);
    } else {
        if ($jumppage == 'report') {
            $url = $tii->getReportLink($post);
        } else {
            if ($jumppage == 'submission') {
                $url = $tii->getSubmissionURL($post);
            } else {
                if ($jumppage == 'zipfile') {
                    $url = $tii->bulkDownload($post);
                } else {
                    header('Content-Disposition: attachment;');
                    $url = $tii->getSubmissionDownload($post);
                }
            }
        }
    }
    turnitintool_redirect($url);
    exit;
}
Esempio n. 2
0
    }
    if (!has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id)) and $USER->id != $submission->userid) {
        // Check to see if the user logged in is the user that submitted or is a grader (tutor)
        turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
        exit;
    }
    $fs = get_file_storage();
    $file = $fs->get_file($cm->id, 'mod_turnitintool', 'submission', $submission->id, '/', $submission->submission_filename);
    send_stored_file($file, 0, 0, true);
}
if (!is_null($param_part)) {
    if (!has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) {
        turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
        exit;
    }
    $owner = turnitintool_get_owner($course->id);
    $loaderbar = null;
    $tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar);
    $post = new stdClass();
    $post->cid = turnitintool_getCID($course->id);
    $post->assignid = turnitintool_getAID($param_part);
    $post->ctl = turnitintool_getCTL($course->id);
    $post->assign = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($param_part) . ' (Moodle ' . $post->assignid . ')';
    $post->fcmd = 4;
    $tii->listSubmissions($post, get_string('downloadingfile', 'turnitintool'));
    if ($tii->getRerror()) {
        if (!$tii->getAPIunavailable()) {
            $reason = $tii->getRcode() == TURNITINTOOL_DB_UNIQUEID_ERROR ? get_string('assignmentdoesnotexist', 'turnitintool') : $tii->getRmessage();
        } else {
            $reason = get_string('apiunavailable', 'turnitintool');
        }