本文整理汇总了PHP中turnitintooltwo_admin_config函数的典型用法代码示例。如果您正苦于以下问题:PHP turnitintooltwo_admin_config函数的具体用法?PHP turnitintooltwo_admin_config怎么用?PHP turnitintooltwo_admin_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了turnitintooltwo_admin_config函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_content
public function get_content()
{
global $CFG, $OUTPUT, $USER, $PAGE, $DB;
if ($this->content !== null) {
return $this->content;
}
$config = turnitintooltwo_admin_config();
$output = '';
// Show link to Helpdesk wizard if enabled and the logged in user is an instrutor.
if (!empty($USER->id) && $config->helpdeskwizard && has_capability('moodle/course:manageactivities', context_system::instance())) {
$output = $OUTPUT->box(html_writer::tag('p', html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=supportwizard', get_string('helpdesklink', 'block_turnitin'))));
}
if (!empty($USER->id) && has_capability('moodle/course:create', context_system::instance())) {
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('block-turnitin', 'block_turnitin');
$cssurl = new moodle_url($CFG->wwwroot . '/mod/turnitintooltwo/css/styles_block.css');
$PAGE->requires->css($cssurl);
$output .= $OUTPUT->box($OUTPUT->pix_icon('loader', '', 'mod_turnitintooltwo'), 'centered_cell', 'block_loading');
$output .= html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=courses', html_writer::tag('noscript', get_string('coursestomigrate', 'block_turnitin', '')), array('id' => 'block_migrate_content'));
}
$this->content = new stdClass();
$this->content->text = $output;
$this->content->footer = '';
return $this->content;
}
开发者ID:uofr,项目名称:moodle-block_turnitin,代码行数:25,代码来源:block_turnitin.php
示例2: log
/**
* Log networking performance details of an individual request
*
* @param resource $ch The cURL handle corresponding to the request to log
* @param float $total_response_time Total time taken for the request in seconds
*/
protected function log($ch, $total_response_time)
{
global $CFG, $USER, $action;
static $config;
if (empty($config)) {
$config = turnitintooltwo_admin_config();
}
if ($config->enableperformancelogs) {
// We only keep 10 log files, delete any additional files.
$prefix = "perflog_";
$dirpath = $CFG->tempdir . "/turnitintooltwo/logs";
if (!file_exists($dirpath)) {
mkdir($dirpath, 0777, true);
}
$dir = opendir($dirpath);
$files = array();
while ($entry = readdir($dir)) {
if (substr(basename($entry), 0, 1) != "." and substr_count(basename($entry), $prefix) > 0) {
$files[] = basename($entry);
}
}
sort($files);
for ($i = 0; $i < count($files) - 10; $i++) {
unlink($dirpath . "/" . $files[$i]);
}
// Prepare string.
$str = '';
if (!empty($action)) {
$str .= " - {$action}";
} else {
$do = !empty($_REQUEST['do']) ? $_REQUEST['do'] : '';
if (!empty($do)) {
$str .= " - {$do}";
}
}
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$str .= " - HTTP:" . $http_status;
if ($http_status === 0 && curl_getinfo($ch, CURLINFO_SIZE_UPLOAD) === 0) {
// CURLINFO_CONNECT_TIME is not reliable when the request fails to connect.
$connect_time = $total_response_time;
} else {
$connect_time = curl_getinfo($ch, CURLINFO_CONNECT_TIME);
}
$str .= " - connect:" . sprintf('%0.3f', $connect_time);
$str .= " - total:" . sprintf('%0.3f', $total_response_time);
$str .= " - up:" . curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
$str .= " - down:" . curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$str .= " - userid:" . $USER->id;
$str .= " - " . $_SERVER['REQUEST_URI'];
if ($http_status === 0) {
$str .= " - " . curl_error($ch);
}
// Write to log file.
$filepath = $dirpath . "/" . $prefix . gmdate('Y-m-d', time()) . ".txt";
$file = fopen($filepath, 'a');
$output = date('Y-m-d H:i:s O') . $str . "\r\n";
fwrite($file, $output);
fclose($file);
}
}
开发者ID:Dextirpe,项目名称:moodle-mod_turnitintooltwo,代码行数:66,代码来源:turnitintooltwo_perflog.class.php
示例3: __construct
public function __construct($accountid = null, $accountshared = null, $url = null)
{
$config = turnitintooltwo_admin_config();
$tiiapiurl = substr($config->apiurl, -1) == '/' ? substr($config->apiurl, 0, -1) : $config->apiurl;
$this->tiiintegrationid = 12;
$this->tiiaccountid = is_null($accountid) ? $config->accountid : $accountid;
$this->tiiapiurl = is_null($url) ? $tiiapiurl : $url;
$this->tiisecretkey = is_null($accountshared) ? $config->secretkey : $accountshared;
if (empty($this->tiiaccountid) || empty($this->tiiapiurl) || empty($this->tiisecretkey)) {
turnitintooltwo_print_error('configureerror', 'turnitintooltwo');
}
$this->diagnostic = $config->enablediagnostic;
$this->langcode = $this->get_lang();
}
开发者ID:unikent,项目名称:moodle-mod_turnitintooltwo,代码行数:14,代码来源:turnitintooltwo_comms.class.php
示例4: define_structure
protected function define_structure()
{
global $DB;
$config = turnitintooltwo_admin_config();
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated
$turnitintooltwo = new backup_nested_element('turnitintooltwo', array('id'), array('type', 'name', 'grade', 'numparts', 'tiiaccount', 'defaultdtstart', 'defaultdtdue', 'defaultdtpost', 'anon', 'portfolio', 'allowlate', 'reportgenspeed', 'submitpapersto', 'spapercheck', 'internetcheck', 'journalcheck', 'maxfilesize', 'intro', 'introformat', 'timecreated', 'timemodified', 'studentreports', 'dateformat', 'usegrademark', 'gradedisplay', 'autoupdates', 'commentedittime', 'commentmaxsize', 'autosubmission', 'shownonsubmission', 'excludebiblio', 'excludequoted', 'excludevalue', 'excludetype', 'erater', 'erater_handbook', 'erater_dictionary', 'erater_spelling', 'erater_grammar', 'erater_usage', 'erater_mechanics', 'erater_style', 'transmatch'));
$parts = new backup_nested_element('parts');
$part = new backup_nested_element('part', array('id'), array('turnitintooltwoid', 'partname', 'tiiassignid', 'dtstart', 'dtdue', 'dtpost', 'maxmarks', 'deleted', 'migrated'));
$courses = new backup_nested_element('courses');
$course = new backup_nested_element('course', array('id'), array('courseid', 'ownerid', 'ownertiiuid', 'owneremail', 'ownerfn', 'ownerln', 'ownerun', 'turnitin_ctl', 'turnitin_cid', 'course_type'));
$submissions = new backup_nested_element('submissions');
$submission = new backup_nested_element('submission', array('id'), array('userid', 'submission_part', 'submission_title', 'submission_type', 'submission_filename', 'submission_objectid', 'submission_score', 'submission_grade', 'submission_gmimaged', 'submission_status', 'submission_queued', 'submission_attempts', 'submission_modified', 'submission_parent', 'submission_nmuserid', 'submission_nmfirstname', 'submission_nmlastname', 'submission_unanon', 'submission_anonreason', 'submission_transmatch', 'submission_orcapable', 'submission_acceptnothing', 'tiiuserid'));
// Build the tree
$submissions->add_child($submission);
$parts->add_child($part);
$turnitintooltwo->add_child($parts);
$turnitintooltwo->add_child($course);
$turnitintooltwo->add_child($submissions);
// Define sources
$turnitintooltwo->set_source_table('turnitintooltwo', array('id' => backup::VAR_ACTIVITYID));
$values['tiiaccount'] = $config->accountid;
$turnitintooltwo->fill_values($values);
$part->set_source_table('turnitintooltwo_parts', array('turnitintooltwoid' => backup::VAR_ACTIVITYID));
$course->set_source_sql('
SELECT t.id, t.courseid, t.ownerid, tu.turnitin_uid AS ownertiiuid,
u.email AS owneremail, u.firstname AS ownerfn, u.lastname AS ownerln,
u.username AS ownerun, t.turnitin_ctl, t.turnitin_cid
FROM {turnitintooltwo_courses} t, {user} u, {turnitintooltwo_users} tu
WHERE t.ownerid=u.id AND tu.userid=t.ownerid AND t.courseid = ?', array(backup::VAR_COURSEID));
// All the rest of elements only happen if we are including user info
if ($userinfo) {
//$submission->set_source_table('turnitintooltwo_submissions', array('turnitintooltwoid' => '../../id'));
$submission->set_source_sql('
SELECT s.*, tu.turnitin_uid AS tiiuserid
FROM {turnitintooltwo_submissions} s, {turnitintooltwo_users} tu
WHERE s.userid=tu.userid AND s.turnitintooltwoid = ?', array(backup::VAR_ACTIVITYID));
}
// Define id annotations
$submission->annotate_ids('user', 'userid');
// Define file annotations
$turnitintooltwo->annotate_files('mod_turnitintooltwo', 'intro', null);
// This file area hasn't itemid
$submission->annotate_files('mod_turnitintooltwo', 'submissions', 'id');
// Return the root element (turnitintooltwo), wrapped into standard activity structure
return $this->prepare_activity_structure($turnitintooltwo);
}
开发者ID:NeillM,项目名称:moodle-mod_turnitintooltwo,代码行数:48,代码来源:backup_turnitintooltwo_stepslib.php
示例5: process_turnitintooltwo
protected function process_turnitintooltwo($data)
{
global $DB;
$config = turnitintooltwo_admin_config();
$_SESSION['tii_assignment_reset'] = 1;
if ($this->get_setting_value('userinfo') == 1) {
$_SESSION['tii_course_reset'] = 0;
$_SESSION['tii_assignment_reset'] = 0;
}
$data = (object) $data;
$oldid = $data->id;
$data->course = $this->get_courseid();
// Work out whether we are duplicating a module activity or course.
// If activity then we do not want to reset the course.
$type = $this->get_task()->get_info()->type;
if ($type == 'activity') {
$_SESSION['tii_course_reset'] = 0;
}
if ($data->grade < 0) {
// scale found, get mapping
$data->grade = -$this->get_mappingid('scale', abs($data->grade));
}
if ($config->accountid != $data->tiiaccount) {
$a = new stdClass();
$a->backupid = $data->tiiaccount;
$a->current = $config->accountid;
turnitintooltwo_print_error('wrongaccountid', 'turnitintooltwo', NULL, $a);
return false;
} else {
// insert the activity record
$newitemid = $DB->insert_record('turnitintooltwo', $data);
$_SESSION['assignment_id'] = $newitemid;
// immediately after inserting "activity" record, call this
$this->apply_activity_instance($newitemid);
}
}
开发者ID:Dextirpe,项目名称:moodle-mod_turnitintooltwo,代码行数:36,代码来源:restore_turnitintooltwo_stepslib.php
示例6: turnitintooltwo_print_error
turnitintooltwo_print_error('coursemodidincorrect', 'turnitintooltwo');
}
}
// If opening DV then $viewcontext needs to be set to box
$viewcontext = $do == "origreport" || $do == "grademark" || $do == "default" ? "box" : $viewcontext;
require_login($course->id, true, $cm);
turnitintooltwo_activitylog('view.php?id=' . $id . '&do=' . $do, "REQUEST");
//Check if the user has the capability to view the page - used when an assignment is set to hidden.
$context = context_module::instance($cm->id);
require_capability('mod/turnitintooltwo:view', $context);
//Set the page layout to base.
$PAGE->set_pagelayout('base');
// Settings for page navigation
if ($viewcontext == "window") {
// Show navigation if required.
$config = turnitintooltwo_admin_config();
if ($config->inboxlayout == 1) {
$PAGE->set_cm($cm);
$PAGE->set_pagelayout('incourse');
}
}
// Don't show messages popup if we are in submission modal.
$forbiddenmsgscreens = array('submission_success', 'submitpaper');
if (in_array($do, $forbiddenmsgscreens)) {
$PAGE->set_popup_notification_allowed(false);
}
// Configure URL correctly.
$urlparams = array('id' => $id, 'a' => $a, 'part' => $part, 'user' => $user, 'do' => $do, 'action' => $action, 'view_context' => $viewcontext);
$url = new moodle_url('/mod/turnitintooltwo/view.php', $urlparams);
// Load Javascript and CSS.
$turnitintooltwoview->load_page_components();
开发者ID:NeillM,项目名称:moodle-mod_turnitintooltwo,代码行数:31,代码来源:view.php
示例7: edit_moodle_assignment
/**
* Edit the assignment in Moodle then on Turnitin
*
* @global type $USER
* @global type $DB
* @param boolean $createevent - setting to determine whether to create a calendar event.
* @return boolean
*/
public function edit_moodle_assignment($createevent = true)
{
global $USER, $DB, $CFG;
$config = turnitintooltwo_admin_config();
$this->turnitintooltwo->id = $this->id;
$this->turnitintooltwo->timemodified = time();
// Get Moodle Course Object.
$course = $this->get_course_data($this->turnitintooltwo->course);
// Get the Turnitin owner of this this Course or make user the owner if none.
$ownerid = $this->get_tii_owner($course->id);
if (!empty($ownerid)) {
$owner = new turnitintooltwo_user($ownerid, 'Instructor');
} else {
$owner = new turnitintooltwo_user($USER->id, 'Instructor');
}
// Edit course in Turnitin.
$this->edit_tii_course($course);
$course->turnitin_ctl = $course->fullname . " (Moodle TT)";
// Get Current Moodle Turnitin Tool data (Assignment).
if (!($turnitintooltwonow = $DB->get_record("turnitintooltwo", array("id" => $this->id)))) {
turnitintooltwo_print_error('turnitintooltwogeterror', 'turnitintooltwo', null, null, __FILE__, __LINE__);
exit;
}
// Get Current Moodle Turnitin Tool Parts Object.
if (!($parts = $DB->get_records_select("turnitintooltwo_parts", " turnitintooltwoid = ? ", array($this->id), 'id ASC'))) {
turnitintooltwo_print_error('partgeterror', 'turnitintooltwo', null, null, __FILE__, __LINE__);
exit;
}
$partids = array_keys($parts);
// Update GradeMark setting depending on config setting.
$this->turnitintooltwo->usegrademark = $config->usegrademark;
// Set the checkbox settings for updates.
$this->turnitintooltwo->erater_spelling = isset($this->turnitintooltwo->erater_spelling) ? $this->turnitintooltwo->erater_spelling : 0;
$this->turnitintooltwo->erater_grammar = isset($this->turnitintooltwo->erater_grammar) ? $this->turnitintooltwo->erater_grammar : 0;
$this->turnitintooltwo->erater_usage = isset($this->turnitintooltwo->erater_usage) ? $this->turnitintooltwo->erater_usage : 0;
$this->turnitintooltwo->erater_mechanics = isset($this->turnitintooltwo->erater_mechanics) ? $this->turnitintooltwo->erater_mechanics : 0;
$this->turnitintooltwo->erater_style = isset($this->turnitintooltwo->erater_style) ? $this->turnitintooltwo->erater_style : 0;
$this->turnitintooltwo->transmatch = isset($this->turnitintooltwo->transmatch) ? $this->turnitintooltwo->transmatch : 0;
$this->turnitintooltwo->institution_check = isset($this->turnitintooltwo->institution_check) ? $this->turnitintooltwo->institution_check : 0;
// Update each individual part.
for ($i = 1; $i <= $this->turnitintooltwo->numparts; $i++) {
// Update Turnitin Assignment.
$assignment = new TiiAssignment();
$assignment->setClassId($course->turnitin_cid);
$assignment->setAuthorOriginalityAccess($this->turnitintooltwo->studentreports);
$assignment->setRubricId(!empty($this->turnitintooltwo->rubric) ? $this->turnitintooltwo->rubric : '');
$assignment->setSubmitPapersTo($this->turnitintooltwo->submitpapersto);
$assignment->setResubmissionRule($this->turnitintooltwo->reportgenspeed);
$assignment->setBibliographyExcluded($this->turnitintooltwo->excludebiblio);
$assignment->setQuotedExcluded($this->turnitintooltwo->excludequoted);
$assignment->setSmallMatchExclusionType($this->turnitintooltwo->excludetype);
$assignment->setSmallMatchExclusionThreshold((int) $this->turnitintooltwo->excludevalue);
$assignment->setLateSubmissionsAllowed($this->turnitintooltwo->allowlate);
if ($config->repositoryoption == 1) {
$assignment->setInstitutionCheck(isset($this->turnitintooltwo->institution_check) ? $this->turnitintooltwo->institution_check : 0);
}
$attribute = "maxmarks" . $i;
$assignment->setMaxGrade($this->turnitintooltwo->{$attribute});
$assignment->setSubmittedDocumentsCheck($this->turnitintooltwo->spapercheck);
$assignment->setInternetCheck($this->turnitintooltwo->internetcheck);
$assignment->setPublicationsCheck($this->turnitintooltwo->journalcheck);
$assignment->setTranslatedMatching($this->turnitintooltwo->transmatch);
$assignment->setAllowNonOrSubmissions($this->turnitintooltwo->allownonor);
// Erater settings.
$assignment->setErater(isset($this->turnitintooltwo->erater) ? $this->turnitintooltwo->erater : 0);
$assignment->setEraterSpelling($this->turnitintooltwo->erater_spelling);
$assignment->setEraterGrammar($this->turnitintooltwo->erater_grammar);
$assignment->setEraterUsage($this->turnitintooltwo->erater_usage);
$assignment->setEraterMechanics($this->turnitintooltwo->erater_mechanics);
$assignment->setEraterStyle($this->turnitintooltwo->erater_style);
$assignment->setEraterSpellingDictionary(isset($this->turnitintooltwo->erater_dictionary) ? $this->turnitintooltwo->erater_dictionary : 'en_US');
$assignment->setEraterHandbook(isset($this->turnitintooltwo->erater_handbook) ? $this->turnitintooltwo->erater_handbook : 0);
$attribute = "dtstart" . $i;
$assignment->setStartDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "dtdue" . $i;
$assignment->setDueDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "dtpost" . $i;
$assignment->setFeedbackReleaseDate(gmdate("Y-m-d\\TH:i:s\\Z", $this->turnitintooltwo->{$attribute}));
$attribute = "partname" . $i;
$assignment->setTitle($this->turnitintooltwo->name . " " . $this->turnitintooltwo->{$attribute} . " (Moodle TT)");
// Initialise part.
$part = new stdClass();
$part->turnitintooltwoid = $this->id;
$part->partname = $this->turnitintooltwo->{$attribute};
$part->deleted = 0;
$part->maxmarks = $assignment->getMaxGrade();
$part->dtstart = strtotime($assignment->getStartDate());
$part->dtdue = strtotime($assignment->getDueDate());
$part->dtpost = strtotime($assignment->getFeedbackReleaseDate());
$parttiiassignid = 0;
if ($i <= count($partids) && !empty($partids[$i - 1])) {
$partdetails = $this->get_part_details($partids[$i - 1]);
//.........这里部分代码省略.........
开发者ID:sk-unikent,项目名称:moodle-mod_turnitintooltwo-1,代码行数:101,代码来源:turnitintooltwo_assignment.class.php
示例8: edit_tii_user
/**
* Edit the user's details on Turnitin (only name can be updated)
*
* @param object $user_details A data object for the user
* @param var $role user role to create
*/
public function edit_tii_user()
{
$config = turnitintooltwo_admin_config();
$turnitincomms = new turnitintooltwo_comms();
$turnitincall = $turnitincomms->initialise_api();
// Only update if pseudo is not enabled.
if (empty($config->enablepseudo)) {
$user = new TiiUser();
$user->setFirstName($this->firstname);
$user->setLastName($this->lastname);
$user->setUserId($this->tii_user_id);
$user->setDefaultRole($this->role);
try {
$turnitincall->updateUser($user);
turnitintooltwo_activitylog("Turnitin User updated: " . $this->id . " (" . $this->tii_user_id . ")", "REQUEST");
} catch (Exception $e) {
$toscreen = $this->workflowcontext == "cron" ? false : true;
$turnitincomms->handle_exceptions($e, 'userupdateerror', $toscreen);
}
}
}
开发者ID:NeillM,项目名称:moodle-mod_turnitintooltwo,代码行数:27,代码来源:turnitintooltwo_user.class.php
示例9: get_submission_inbox_row
/**
* Get the row for this submission in the inbox table
*
* @global object $CFG
* @global type $OUTPUT
* @param type $cm
* @param type $turnitintooltwoassignment
* @param type $parts
* @param type $partid
* @param type $submission
* @param type $useroverallgrades
* @param type $istutor
* @return type
*/
public function get_submission_inbox_row($cm, $turnitintooltwoassignment, $parts, $partid, $submission, &$useroverallgrades, $istutor, $context = 'all')
{
global $CFG, $OUTPUT, $USER, $DB;
$config = turnitintooltwo_admin_config();
$moodleuserid = substr($submission->userid, 0, 3) != 'nm-' && $submission->userid != 0 ? $submission->userid : 0;
if (!$istutor) {
$user = new turnitintooltwo_user($USER->id, "Learner");
}
$checkbox = " ";
if (!empty($submission->submission_objectid) && $istutor) {
$checkbox = html_writer::checkbox('check_' . $submission->submission_objectid, $submission->submission_objectid, false, '', array("class" => "inbox_checkbox"));
}
if (!$istutor) {
// If students viewing it will show 'digital receipt' link
if (!empty($submission->submission_objectid)) {
$studentname = html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id . '&do=digital_receipt&submissionid=' . $submission->submission_objectid . '&view_context=box', $OUTPUT->pix_icon('receipt', get_string('digitalreceipt', 'turnitintooltwo'), 'mod_turnitintooltwo', array('id' => 'tii_digital_receipt_icon')) . get_string('viewdigitalreceipt', 'turnitintooltwo'), array('class' => 'tii_digital_receipt'));
} else {
$studentname = "--";
}
//Determine whether the student can see the overall grade, based on the post time of all parts.
$display_overall_grade = 1;
foreach (array_keys($parts) as $ar_key => $ar_value) {
if ($parts[$ar_value]->dtpost > time()) {
$display_overall_grade = 0;
}
}
} else {
if ($turnitintooltwoassignment->turnitintooltwo->anon && $parts[$partid]->unanon != 1) {
if (empty($submission->submission_unanon) and $parts[$partid]->dtpost > time() and !empty($submission->submission_objectid)) {
// Anonymous marking is on, postdate has not passed and a submission has been made.
$studentname = html_writer::link('.unanonymise_form', get_string('anonenabled', 'turnitintooltwo'), array("class" => "unanonymise", "id" => "submission_" . $submission->submission_objectid));
} else {
if (($parts[$partid]->dtpost <= time() or !empty($submission->submission_unanon)) and empty($submission->nmoodle)) {
// Post date has passed or anonymous marking disabled for user and user is a moodle user.
$studentname = html_writer::link($CFG->wwwroot . "/user/view.php?id=" . $submission->userid . "&course=" . $turnitintooltwoassignment->turnitintooltwo->course, format_string($submission->lastname) . ", " . format_string($submission->firstname));
} else {
if (($parts[$partid]->dtpost <= time() or !empty($submission->submission_unanon)) and !empty($submission->nmoodle)) {
// Post date has passed or anonymous marking disabled for user and user is a NON moodle user.
$studentname = html_writer::tag("span", format_string($submission->lastname) . ", " . format_string($submission->firstname) . " (" . get_string('nonmoodleuser', 'turnitintooltwo') . ")", array("class" => "italic"));
} else {
// User has not made a submission.
$studentname = html_writer::tag("span", get_string('anonenabled', 'turnitintooltwo'), array("class" => "italic"));
}
}
}
} else {
if (empty($submission->nmoodle)) {
// Link to user profile.
$studentname = html_writer::link($CFG->wwwroot . "/user/view.php?id=" . $submission->userid . "&course=" . $turnitintooltwoassignment->turnitintooltwo->course, format_string($submission->lastname) . ", " . format_string($submission->firstname));
} else {
if (!empty($submission->nmoodle) && substr($submission->userid, 0, 3) != 'nm-') {
// Moodle User not enrolled on this course as a student.
$studentname = html_writer::link($CFG->wwwroot . "/user/view.php?id=" . $submission->userid . "&course=" . $turnitintooltwoassignment->turnitintooltwo->course, format_string($submission->lastname) . ", " . format_string($submission->firstname) . " (" . get_string('nonenrolledstudent', 'turnitintooltwo') . ")", array("class" => "italic"));
} else {
// Non Moodle user.
$studentname = html_writer::tag("span", format_string($submission->lastname) . ", " . format_string($submission->firstname) . " (" . get_string('nonmoodleuser', 'turnitintooltwo') . ")", array("class" => "italic"));
}
}
}
}
// Submission title with link to open DV.
if (!empty($submission->submission_objectid) and !empty($submission->submission_objectid)) {
$title = $OUTPUT->box_start('default_open', 'default_' . $submission->submission_objectid . '_' . $partid . '_' . $moodleuserid);
$title .= $OUTPUT->box(format_string($submission->submission_title), 'submission_title underline');
$title .= $OUTPUT->box($CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id, 'dv_url', 'default_url_' . $submission->submission_objectid);
$title .= $OUTPUT->box_end(true);
$rawtitle = $submission->submission_title;
} else {
$title = "--";
$rawtitle = "--";
}
$objectid = !empty($submission->submission_objectid) ? $submission->submission_objectid : "--";
// Show date of submission or link to submit if it didn't work.
if (empty($submission->submission_objectid) and !empty($submission->id)) {
$rawmodified = 1;
$modified = html_writer::link($CFG->wwwroot . "/mod/turnitintooltwo/view.php?id=" . $cm->id . "&action=manualsubmission" . "&sub=" . $submission->id . '&sesskey=' . sesskey(), $OUTPUT->pix_icon('icon-sml', get_string('submittoturnitin', 'turnitintooltwo'), 'mod_turnitintooltwo') . " " . get_string('submittoturnitin', 'turnitintooltwo'));
} else {
if (empty($submission->submission_objectid)) {
$rawmodified = 0;
$modified = "--";
} else {
$rawmodified = (int) $submission->submission_modified;
$modified = userdate($submission->submission_modified, get_string('strftimedatetimeshort', 'langconfig'));
if ($submission->submission_modified > $parts[$partid]->dtdue) {
$modified = html_writer::tag('span', $modified, array("class" => "late_submission"));
}
//.........这里部分代码省略.........
开发者ID:NeillM,项目名称:moodle-mod_turnitintooltwo,代码行数:101,代码来源:turnitintooltwo_view.class.php
示例10: add_elements_to_settings_form
/**
* Due to moodle's internal plugin hooks we can not use our bespoke form class for Turnitin
* settings. This form shows in settings > defaults as well as the activity creation screen.
*
* @global type $CFG
* @param type $plugin_defaults
* @return type
*/
public function add_elements_to_settings_form($mform, $course, $location = "activity", $cmid = 0, $currentrubric = 0)
{
global $CFG, $OUTPUT, $PAGE, $USER, $DB;
// Include JS strings (closebutton is needed from both plugins).
$PAGE->requires->string_for_js('changerubricwarning', 'plagiarism_turnitin');
$PAGE->requires->string_for_js('closebutton', 'turnitintooltwo');
$PAGE->requires->string_for_js('closebutton', 'plagiarism_turnitin');
$config = turnitintooltwo_admin_config();
$config_warning = '';
$rubrics = array();
if ($location == "activity") {
$instructor = new turnitintooltwo_user($USER->id, 'Instructor');
$instructor->join_user_to_class($course->turnitin_cid);
$rubrics = $instructor->get_instructor_rubrics();
// Get rubrics that are shared on the account.
$turnitinclass = new turnitin_class($course->id);
$turnitinclass->sharedrubrics = array();
$turnitinclass->read_class_from_tii();
// Merge the arrays, prioitising instructor owned arrays.
$rubrics = $rubrics + $turnitinclass->sharedrubrics;
}
$options = array(0 => get_string('no'), 1 => get_string('yes'));
$genoptions = array(0 => get_string('genimmediately1', 'plagiarism_turnitin'), 1 => get_string('genimmediately2', 'plagiarism_turnitin'), 2 => get_string('genduedate', 'plagiarism_turnitin'));
$excludetypeoptions = array(0 => get_string('no'), 1 => get_string('excludewords', 'plagiarism_turnitin'), 2 => get_string('excludepercent', 'plagiarism_turnitin'));
if ($location == "defaults") {
$mform->addElement('header', 'plugin_header', get_string('turnitindefaults', 'plagiarism_turnitin'));
$mform->addElement('html', get_string("defaultsdesc", "turnitintooltwo"));
}
if ($location != "defaults") {
$mform->addElement('header', 'plugin_header', get_string('turnitinpluginsettings', 'plagiarism_turnitin'));
// Add in custom Javascript and CSS.
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('turnitintooltwo-turnitintooltwo', 'mod_turnitintooltwo');
$PAGE->requires->jquery_plugin('plagiarism-turnitin_module', 'plagiarism_turnitin');
$PAGE->requires->jquery_plugin('turnitintooltwo-colorbox', 'mod_turnitintooltwo');
$cssurl = new moodle_url('/mod/turnitintooltwo/css/colorbox.css');
$PAGE->requires->css($cssurl);
// Refresh Grades
$refreshgrades = '';
if ($cmid != 0) {
// If assignment has submissions then show a refresh grades button
$numsubs = $DB->count_records('plagiarism_turnitin_files', array('cm' => $cmid));
if ($numsubs > 0) {
$refreshgrades = html_writer::tag('div', $OUTPUT->pix_icon('refresh', get_string('turnitinrefreshsubmissions', 'plagiarism_turnitin'), 'plagiarism_turnitin') . html_writer::tag('span', get_string('turnitinrefreshsubmissions', 'plagiarism_turnitin')), array('class' => 'plagiarism_turnitin_refresh_grades'));
$refreshgrades .= html_writer::tag('div', $OUTPUT->pix_icon('loading', get_string('turnitinrefreshingsubmissions', 'plagiarism_turnitin'), 'plagiarism_turnitin') . html_writer::tag('span', get_string('turnitinrefreshingsubmissions', 'plagiarism_turnitin')), array('class' => 'plagiarism_turnitin_refreshing_grades'));
}
}
// Quickmark Manager.
$quickmarkmanagerlink = '';
if ($config->usegrademark) {
$quickmarkmanagerlink .= $OUTPUT->box_start('row_quickmark_manager', '');
$quickmarkmanagerlink .= html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=quickmarkmanager&view_context=box', get_string('launchquickmarkmanager', 'plagiarism_turnitin'), array('class' => 'plagiarism_turnitin_quickmark_manager_launch', 'title' => get_string('launchquickmarkmanager', 'plagiarism_turnitin')));
$quickmarkmanagerlink .= html_writer::tag('span', '', array('class' => 'launch_form', 'id' => 'quickmark_manager_form'));
$quickmarkmanagerlink .= $OUTPUT->box_end(true);
}
$use_turnitin = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cmid, 'name' => 'use_turnitin'));
// Peermark Manager.
$peermarkmanagerlink = '';
if (!empty($config->enablepeermark) && !empty($use_turnitin->value)) {
if ($cmid != 0) {
$peermarkmanagerlink .= $OUTPUT->box_start('row_peermark_manager', '');
$peermarkmanagerlink .= html_writer::link($CFG->wwwroot . '/plagiarism/turnitin/ajax.php?cmid=' . $cmid . '&action=peermarkmanager&view_context=box', get_string('launchpeermarkmanager', 'plagiarism_turnitin'), array('class' => 'peermark_manager_launch', 'id' => 'peermark_manager_' . $cmid, 'title' => get_string('launchpeermarkmanager', 'plagiarism_turnitin')));
$peermarkmanagerlink .= html_writer::tag('span', '', array('class' => 'launch_form', 'id' => 'peermark_manager_form'));
$peermarkmanagerlink .= $OUTPUT->box_end(true);
}
}
if (!empty($quickmarkmanagerlink) || !empty($peermarkmanagerlink) || !empty($refreshgrades)) {
$mform->addElement('static', 'static', '', $refreshgrades . $quickmarkmanagerlink . $peermarkmanagerlink);
}
}
$locks = $DB->get_records_sql("SELECT name, value FROM {plagiarism_turnitin_config} WHERE cm IS NULL");
if (empty($config_warning)) {
$mform->addElement('select', 'use_turnitin', get_string("useturnitin", "turnitintooltwo"), $options);
$this->lock($mform, $location, $locks);
$mform->addElement('select', 'plagiarism_show_student_report', get_string("studentreports", "turnitintooltwo"), $options);
$this->lock($mform, $location, $locks);
$mform->addHelpButton('plagiarism_show_student_report', 'studentreports', 'plagiarism_turnitin');
if ($mform->elementExists('submissiondrafts') || $location == 'defaults') {
$tiidraftoptions = array(0 => get_string("submitondraft", "turnitintooltwo"), 1 => get_string("submitonfinal", "turnitintooltwo"));
$mform->addElement('select', 'plagiarism_draft_submit', get_string("draftsubmit", "turnitintooltwo"), $tiidraftoptions);
$this->lock($mform, $location, $locks);
$mform->disabledIf('plagiarism_draft_submit', 'submissiondrafts', 'eq', 0);
}
$mform->addElement('select', 'plagiarism_allow_non_or_submissions', get_string("allownonor", "turnitintooltwo"), $options);
$this->lock($mform, $location, $locks);
$mform->addHelpButton('plagiarism_allow_non_or_submissions', 'allownonor', 'plagiarism_turnitin');
$suboptions = array(0 => get_string('norepository', 'plagiarism_turnitin'), 1 => get_string('standardrepository', 'plagiarism_turnitin'));
switch ($config->repositoryoption) {
case 0:
// Standard options
$mform->addElement('select', 'plagiarism_submitpapersto', get_string('submitpapersto', 'plagiarism_turnitin'), $suboptions);
//.........这里部分代码省略.........
开发者ID:jmcgettrick,项目名称:moodle-plagiarism_turnitin,代码行数:101,代码来源:turnitinplugin_view.class.php
示例11: do_tii_submission
/**
* Make submission to Turnitin
*
* @global type $DB
* @param object $cm the course module object
* @return string $message to display to user
*/
public function do_tii_submission($cm, $turnitintooltwoassignment)
{
global $DB, $USER, $CFG;
$config = turnitintooltwo_admin_config();
$notice = array("success" => false);
$context = context_module::instance($cm->id);
// Check if user is a member of class, if not then join them to it.
$course = $turnitintooltwoassignment->get_course_data($turnitintooltwoassignment->turnitintooltwo->course);
$user = new turnitintooltwo_user($this->userid, 'Learner');
$user->join_user_to_class($course->turnitin_cid);
$user->edit_tii_user();
// Get the stored file and read it into a temp file for submitting to Turnitin.
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_turnitintooltwo', 'submissions', $this->id, "timecreated", false);
$tempfile = "";
foreach ($files as $file) {
$filename = array($this->submission_title, $cm->id);
if (!$turnitintooltwoassignment->turnitintooltwo->anon && empty($config->enablepseudo)) {
$user_details = array($this->userid, $user->firstname, $user->lastname);
$filename = array_merge($user_details, $filename);
}
$suffix = $file->get_filename();
$tempfile = turnitintooltwo_tempfile($filename, $suffix);
$fh = fopen($tempfile, "w");
fwrite($fh, $file->get_content());
fclose($fh);
}
if (!empty($tempfile)) {
$part = $turnitintooltwoassignment->get_part_details($this->submission_part);
// Initialise Comms Object.
$turnitincomms = new turnitintooltwo_comms();
$turnitincall = $turnitincomms->initialise_api();
// Create Submission object to send to Turnitin.
$newsubmission = new TiiSubmission();
$newsubmission->setAssignmentId($part->tiiassignid);
if (!is_null($this->submission_objectid)) {
$newsubmission->setSubmissionId($this->submission_objectid);
$apimethod = "replaceSubmission";
} else {
$apimethod = "createSubmission";
}
$newsubmission->setTitle($this->submission_title);
$newsubmission->setAuthorUserId($user->tii_user_id);
if ($user->id == $USER->id) {
$newsubmission->setSubmitterUserId($user->tii_user_id);
$newsubmission->setRole('Learner');
} else {
$instructor = new turnitintooltwo_user($USER->id, 'Instructor');
$instructor->edit_tii_user();
$newsubmission->setSubmitterUserId($instructor->tii_user_id);
$newsubmission->setRole('Instructor');
}
$newsubmission->setSubmissionDataPath($tempfile);
try {
$response = $turnitincall->{$apimethod}($newsubmission);
$newsubmission = $response->getSubmission();
// Save the submission.
$submission = new stdClass();
$submission->id = $this->id;
$submission->userid = $this->userid;
$submission->turnitintooltwoid = $this->turnitintooltwoid;
$submission->submission_part = $this->submission_part;
$submission->submission_title = $this->submission_title;
$submission->submission_type = $this->submission_type;
$submission->submission_filename = $this->submission_filename;
$submission->submission_objectid = $newsubmission->getSubmissionId();
$submission->submission_score = $this->submission_score;
$submission->submission_grade = $this->submission_grade;
$submission->submission_gmimaged = $this->submission_gmimaged;
$submission->submission_status = $this->submission_status;
$submission->submission_queued = $this->submission_queued;
$submission->submission_attempts = $this->submission_attempts;
$submission->submission_modified = time();
$submission->submission_nmuserid = $this->submission_nmuserid;
$submission->submission_nmfirstname = $this->submission_nmfirstname;
$submission->submission_nmlastname = $this->submission_nmlastname;
$submission->submission_unanon = $this->submission_unanon;
$submission->submission_unanonreason = $this->submission_unanonreason;
$submission->submission_transmatch = $this->submission_transmatch;
$submission->submission_acceptnothing = 0;
$DB->update_record('turnitintooltwo_submissions', $submission);
// Delete the tempfile.
if (!is_null($tempfile)) {
unlink($tempfile);
}
$notice["success"] = true;
$notice["message"] = get_string('submissionuploadsuccess', 'turnitintooltwo');
$notice["extract"] = $newsubmission->getTextExtract();
$notice["tii_submission_id"] = $submission->submission_objectid;
//Send a message to the user's Moodle inbox with the digital receipt.
$input = array('firstname' => $user->firstname, 'lastname' => $user->lastname, 'submission_title' => $this->submission_title, 'assignment_name' => $turnitintooltwoassignment->turnitintooltwo->name, 'assignment_part' => $partdetails = $turnitintooltwoassignment->get_part_details($this->submission_part)->partname, 'course_fullname' => $course->fullname, 'submission_date' => date('d-M-Y h:iA'), 'submission_id' => $submission->submission_objectid);
// Student digital receipt
$message = $this->receipt->build_message($input);
//.........这里部分代码省略.........
开发者ID:uofr,项目名称:moodle-mod_turnitintooltwo,代码行数:101,代码来源:turnitintooltwo_submission.class.php
示例12: turnitintooltwo_getusers
/**
* Get users for unlinking/relinking. Called from ajax.php via turnitintooltwo.js.
*
* @global type $DB
* @return array return array of users to display
*/
function turnitintooltwo_getusers()
{
global $DB;
$config = turnitintooltwo_admin_config();
$return = array();
$idisplaystart = optional_param('iDisplayStart', 0, PARAM_INT);
$idisplaylength = optional_param('iDisplayLength', 10, PARAM_INT);
$secho = optional_param('sEcho', 1, PARAM_INT);
$displaycolumns = array('tu.userid', 'tu.turnitin_uid', 'mu.lastname', 'mu.firstname', 'mu.email');
$queryparams = array();
// Add sort to query.
$isortcol[0] = optional_param('iSortCol_0', null, PARAM_INT);
$isortingcols = optional_param('iSortingCols', 0, PARAM_INT);
$queryorder = "";
if (!is_null($isortcol[0])) {
$queryorder = " ORDER BY ";
$startorder = $queryorder;
for ($i = 0; $i < intval($isortingcols); $i++) {
$isortcol[$i] = optional_param('iSortCol_' . $i, null, PARAM_INT);
$bsortable[$i] = optional_param('bSortable_' . $isortcol[$i], null, PARAM_TEXT);
$ssortdir[$i] = optional_param('sSortDir_' . $i, null, PARAM_TEXT);
if ($bsortable[$i] == "true") {
$queryorder .= $displaycolumns[$isortcol[$i]] . " " . $ssortdir[$i] . ", ";
}
}
if ($queryorder == $startorder) {
$queryorder = "";
} else {
$queryorder = substr_replace($queryorder, "", -2);
}
}
// Add search to query.
$ssearch = optional_param('sSearch', '', PARAM_TEXT);
$querywhere = ' WHERE ( ';
for ($i = 0; $i < count($displaycolumns); $i++) {
$bsearchable[$i] = optional_param('bSearchable_' . $i, null, PARAM_TEXT);
if (!is_null($bsearchable[$i]) && $bsearchable[$i] == "true" && $ssearch != '') {
$include = true;
if ($i <= 1) {
if (!is_int($ssearch) || is_null($ssearch)) {
$include = false;
}
}
if ($include) {
$querywhere .= $DB->sql_like($displaycolumns[$i], ':search_term_' . $i, false) . " OR ";
$queryparams['search_term_' . $i] = '%' . $ssearch . '%';
}
}
}
if ($querywhere == ' WHERE ( ') {
$querywhere = "";
} else {
$querywhere = substr_replace($querywhere, "", -3);
$querywhere .= " )";
}
$query = "SELECT tu.id AS id, tu.userid AS userid, tu.turnitin_uid AS turnitin_uid, tu.turnitin_utp AS turnitin_utp, " . "mu.firstname AS firstname, mu.lastname AS lastname, mu.email AS email " . "FROM {turnitintooltwo_users} tu " . "LEFT JOIN {user} mu ON tu.userid = mu.id " . $querywhere . $queryorder;
$users = $DB->get_records_sql($query, $queryparams, $idisplaystart, $idisplaylength);
$totalusers = count($DB->get_records_sql($query, $queryparams));
$return["aaData"] = array();
foreach ($users as $user) {
$checkbox = html_writer::checkbox('userids[]', $user->id, false, '', array("class" => "browser_checkbox"));
$pseudoemail = "";
if (!empty($config->enablepseudo)) {
$pseudouser = new TiiPseudoUser(turnitintooltwo_user::get_pseudo_domain());
$pseudouser->setEmail($user->email);
$pseudoemail = $pseudouser->getEmail();
}
$return["aaData"][] = array($checkbox, $user->turnitin_uid == 0 ? '' : $user->turnitin_uid, format_
|
请发表评论