protected function process_turnitintool($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $oldid = $data->id;
     $data->course = $this->get_courseid();
     if ($data->grade < 0) {
         // scale found, get mapping
         $data->grade = -$this->get_mappingid('scale', abs($data->grade));
     }
     if ($CFG->turnitin_account_id != $data->tiiaccount) {
         $a = new stdClass();
         $a->backupid = $data->tiiaccount;
         $a->current = $CFG->turnitin_account_id;
         turnitintool_print_error('wrongaccountid', 'turnitintool', NULL, $a);
         return false;
     } else {
         // insert the activity record
         $newitemid = $DB->insert_record('turnitintool', $data);
         // immediately after inserting "activity" record, call this
         $this->apply_activity_instance($newitemid);
     }
 }
Ejemplo n.º 2
0
/**
 * Checks for error session array and if it is present display the error stored and exit
 */
function turnitintool_process_api_error()
{
    if (isset($_SESSION['turnitintool_errorarray'])) {
        $errorarray = $_SESSION['turnitintool_errorarray'];
        turnitintool_activitylog($errorarray['input'], "API_ERROR");
        unset($_SESSION['turnitintool_errorarray']);
        turnitintool_print_error($errorarray['input'], $errorarray['module'], $errorarray['link'], $errorarray['param'], $errorarray['file'], $errorarray['line']);
        exit;
    }
}
Ejemplo n.º 3
0
 $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;
 } else {
     $output = $tii->getFileData();
     if (function_exists('mb_strlen')) {
         $size = mb_strlen($output, '8bit');
     } else {
         $size = strlen($output);
     }
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-control: must-revalidate, post-check=0, pre-check=0");
     header("Content-type: application/force-download");
     header("Content-type: application/octet-stream");
     header("Content-type: application/download");
     header("Content-disposition: attachment; filename=" . get_string('file', 'turnitintool') . "_" . $post->assignid . ".xls");
Ejemplo n.º 4
0
if ($do == 'intro') {
    if (isset($notice['error'])) {
        turnitintool_box_start('generalbox boxwidthwide boxaligncenter error', 'errorbox');
        echo $notice['message'];
        turnitintool_box_end();
    } else {
        $notice = NULL;
    }
    // Update the GradeBook to make sure the grade stays 'hidden' until and wasn't revealed by modedit
    turnitintool_grade_item_update($turnitintool);
    echo turnitintool_duplicatewarning($cm, $turnitintool);
    echo turnitintool_introduction($cm, $turnitintool, $notice);
}
if ($do == 'submissions') {
    if (!has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id)) and !has_capability('mod/turnitintool:submit', turnitintool_get_context('MODULE', $cm->id))) {
        turnitintool_print_error('permissiondeniederror', 'turnitintool');
        exit;
    } else {
        echo turnitintool_view_student_submissions($cm, $turnitintool);
        if (isset($notice["error"]) && $CFG->branch < 29) {
            turnitintool_box_start('generalbox boxwidthwide boxaligncenter error', 'errorbox');
            echo $notice["error"];
            turnitintool_box_end();
        }
        echo turnitintool_view_submission_form($cm, $turnitintool);
    }
}
if ($do == 'allsubmissions') {
    if (!empty($notice)) {
        turnitintool_box_start('generalbox boxwidthwide boxaligncenter error', 'errorbox');
        echo $notice;
Ejemplo n.º 5
0
 /**
  * Call to API FID15, FCMD3 to set the GradeMark grade for a particular submission
  *
  * @param object $post The post object that contains the necessary query parameters for the call
  * @param string $status The status to pass to the loaderbar class
  */
 function setGradeMark($post, $status)
 {
     if (!turnitintool_check_config()) {
         turnitintool_print_error('configureerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
         exit;
     }
     $assigndata = array('gmtime' => $this->tiiGmtime(), 'encrypt' => TII_ENCRYPT, 'aid' => $this->accountid, 'diagnostic' => 0, 'fcmd' => 3, 'cid' => $post->cid, 'oid' => $post->oid, 'utp' => 2, 'fid' => 15, 'uid' => $this->uid, 'uem' => $this->uem, 'ufn' => $this->ufn, 'uln' => $this->uln);
     $assigndata['dis'] = $this->disableEmail();
     $assigndata["md5"] = $this->doMD5($assigndata);
     $assigndata['session-id'] = $this->tiisession;
     $assigndata["score"] = $post->score;
     $assigndata['src'] = TURNITIN_APISRC;
     $assigndata['apilang'] = $this->getLang();
     $this->result = $this->doRequest("POST", $this->apiurl, $assigndata, true, $status);
 }
 protected function process_turnitintool_courses($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $oldid = $data->id;
     $data->courseid = $this->get_courseid();
     $owneremail = empty($data->owneremail) ? join(array_splice(explode(".", $data->ownerun), 0, -1)) : $data->owneremail;
     $owner = $DB->get_record('user', array('email' => $owneremail));
     if ($owner) {
         $data->ownerid = $owner->id;
     } else {
         // Turnitin class owner not found from email address etc create user account
         $i = 0;
         $newuser = false;
         while (!is_object($newuser)) {
             // Keep trying to create a new username
             $username = $i == 0 ? $data->ownerun : $data->ownerun . '_' . $i;
             // Append number if username exists
             $i++;
             $newuser = create_user_record($username, substr($i . "-" . md5($username), 0, 8));
             if (is_object($newuser)) {
                 $newuser->email = $owneremail;
                 $newuser->firstname = $data->ownerfn;
                 $newuser->lastname = $data->ownerln;
                 if (!$DB->update_record("user", $newuser)) {
                     turnitintool_print_error('userupdateerror', 'turnitintool');
                 }
             }
         }
         $data->ownerid = $newuser->id;
     }
     $tiiowner = new object();
     $tiiowner->userid = $data->ownerid;
     $tiiowner->turnitin_uid = $data->ownertiiuid;
     if (!($tiiuser = $DB->get_record('turnitintool_users', array('userid' => $data->ownerid)))) {
         $DB->insert_record('turnitintool_users', $tiiowner);
     }
     if (!$DB->get_records_select('turnitintool_courses', 'courseid=' . $data->courseid)) {
         $newitemid = $DB->insert_record('turnitintool_courses', $data);
         $this->set_mapping('turnitintool_courses', $oldid, $newitemid);
     }
 }
Ejemplo n.º 7
0
 */
require_once __DIR__ . "/../../config.php";
require_once __DIR__ . "/lib.php";
if (isset($PAGE) and is_callable(array($PAGE->requires, 'js'))) {
    // Are we using new moodle or old?
    $jsurl = new moodle_url($CFG->wwwroot . '/mod/turnitintool/scripts/turnitintool.js');
    $PAGE->requires->js($jsurl, true);
    $cssurl = new moodle_url($CFG->wwwroot . '/mod/turnitintool/styles.css');
    $PAGE->requires->css($cssurl);
} else {
    require_js($CFG->wwwroot . '/mod/turnitintool/scripts/turnitintool.js');
}
$id = required_param('id', PARAM_INT);
// course
if (!($course = turnitintool_get_record("course", "id", $id))) {
    turnitintool_print_error('courseiderror', 'turnitintool');
}
require_login($course->id);
turnitintool_add_to_log($course->id, "list turnitintool", "index.php?id={$course->id}", "User viewed the Turnitin assignment list for course {$course->id}", 0);
/// Get all required stringsnewmodule
$strturnitintools = get_string("modulenameplural", "turnitintool");
$strturnitintool = get_string("modulename", "turnitintool");
if (is_object($PAGE) && @is_callable(array($PAGE->navbar, 'add'))) {
    $navigation = '';
} elseif (!is_callable('build_navigation')) {
    $navigation = array(array('title' => $course->shortname, 'url' => $CFG->wwwroot . "/course/view.php?id={$course->id}", 'type' => 'course'), array('title' => $strturnitintools, 'url' => '', 'type' => 'activity'));
} else {
    $navigation = array(array('name' => $strturnitintools, 'url' => '', 'type' => 'activity'));
    $navigation = build_navigation($navigation, "");
}
/// Print the header
Ejemplo n.º 8
0
 $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;
     $data->turnitin_uid = $tiiuid;
     $data->turnitin_utp = $tii->utp;
     if ($tiiuser = turnitintool_get_record('turnitintool_users', 'userid', $USER->id)) {
         $data->id = $tiiuser->id;
         turnitintool_update_record('turnitintool_users', $data);
     } else {
         turnitintool_insert_record('turnitintool_users', $data);
     }
     print_string('connecttestsuccess', 'turnitintool');
 }
 turnitintool_box_end();
 turnitintool_footer();
Ejemplo n.º 9
0
 $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 >= TURNITINTOOL_API_ERROR_START or empty($rcode)) {
     if (empty($rmessage)) {
         $rmessage = get_string('connecttestcommerror', 'turnitintool');
     }
     turnitintool_print_error('connecttesterror', 'turnitintool', $CFG->wwwroot . '/admin/settings.php?section=modsettingturnitintool', $rmessage, __FILE__, __LINE__);
 } else {
     $data = new object();
     $data->userid = $USER->id;
     $data->turnitin_uid = $tiiuid;
     $data->turnitin_utp = $tii->utp;
     if ($tiiuser = turnitintool_get_record('turnitintool_users', 'userid', $USER->id)) {
         $data->id = $tiiuser->id;
         turnitintool_update_record('turnitintool_users', $data);
     } else {
         turnitintool_insert_record('turnitintool_users', $data);
     }
     print_string('connecttestsuccess', 'turnitintool');
 }
 turnitintool_box_end();
 turnitintool_footer();