// 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');
        }
        turnitintool_print_error('downloadingfileerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
        exit;
Exemple #2
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;
}
                     $output .= '<a href="' . $CFG->wwwroot . '/mod/turnitintool/extras.php?do=' . $param_do . '&filedate=' . $date . '">' . ucfirst($param_do) . ' (' . userdate(strtotime($year . '-' . $month . '-' . $day), '%Y-%m-%d %H:%M:%S') . ')</a><br />' . PHP_EOL;
                 }
             }
             echo $output;
         } else {
             echo get_string("nologsfound");
         }
         echo "<br />";
         turnitintool_box_end();
         turnitintool_footer();
     }
 } else {
     $post = new stdClass();
     $post->utp = '2';
     $loaderbar = new turnitintool_loaderbarclass(3);
     $tii = new turnitintool_commclass(turnitintool_getUID($USER), $USER->firstname, $USER->lastname, $USER->email, 2, $loaderbar);
     $tii->startSession();
     $result = $tii->createUser($post, get_string('connecttesting', 'turnitintool'));
     $rcode = $tii->getRcode();
     $rmessage = $tii->getRmessage();
     $tiiuid = $tii->getUserID();
     $tii->endSession();
     turnitintool_header(NULL, NULL, $_SERVER["REQUEST_URI"], get_string("modulenameplural", "turnitintool"), $SITE->fullname);
     turnitintool_box_start('generalbox boxwidthwide boxaligncenter', 'general');
     if ($rcode >= API_ERROR_START or empty($rcode)) {
         if (empty($rmessage)) {
             $rmessage = get_string('connecttestcommerror', 'turnitintool');
         }
         turnitintool_print_error('connecttesterror', 'turnitintool', $CFG->wwwroot . '/admin/module.php?module=turnitintool', $rmessage, __FILE__, __LINE__);
     } else {
         $data = new object();