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;
}
                 }
             }
             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();
         $data->userid = $USER->id;