本文整理汇总了PHP中stored_file::get_pathnamehash方法的典型用法代码示例。如果您正苦于以下问题:PHP stored_file::get_pathnamehash方法的具体用法?PHP stored_file::get_pathnamehash怎么用?PHP stored_file::get_pathnamehash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stored_file
的用法示例。
在下文中一共展示了stored_file::get_pathnamehash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_file_results
/**
* Get the information turnitin has about a file
* @param int $cmid the id of the coursemodule file was submitted for
* @param int $userid the id of the user who submitted the file
* @param stored_file $file file object describing a moodle file which was submited to TII
* @return mixed - false if no info available, or an array describing what's known about the TII submission
*/
public function get_file_results($cmid, $userid, stored_file $file)
{
global $DB, $USER, $COURSE, $OUTPUT;
$plagiarismsettings = $this->get_settings();
if (empty($plagiarismsettings)) {
// Turnitin is not enabled
return false;
}
$plagiarismvalues = $DB->get_records_menu('plagiarism_turnitin_config', array('cm' => $cmid), '', 'name,value');
if (empty($plagiarismvalues['use_turnitin'])) {
// Turnitin not in use for this cm
return false;
}
$filehash = $file->get_pathnamehash();
$modulesql = 'SELECT m.id, m.name, cm.instance' . ' FROM {course_modules} cm' . ' INNER JOIN {modules} m on cm.module = m.id ' . 'WHERE cm.id = ?';
$moduledetail = $DB->get_record_sql($modulesql, array($cmid));
if (!empty($moduledetail)) {
$module = $DB->get_record($moduledetail->name, array('id' => $moduledetail->instance));
}
if (empty($module)) {
// No such cmid
return false;
}
$modulecontext = get_context_instance(CONTEXT_MODULE, $cmid);
// Whether the user has permissions to see all items in the context of this module.
$viewsimilarityscore = has_capability('plagiarism/turnitin:viewsimilarityscore', $modulecontext);
$viewfullreport = has_capability('plagiarism/turnitin:viewfullreport', $modulecontext);
if ($USER->id == $userid) {
// The user wants to see details on their own report
if ($plagiarismvalues['plagiarism_show_student_score'] == PLAGIARISM_TII_SHOW_ALWAYS) {
$viewsimilarityscore = true;
}
if ($plagiarismvalues['plagiarism_show_student_report'] == PLAGIARISM_TII_SHOW_ALWAYS) {
$viewfullreport = true;
}
}
if (!$viewsimilarityscore && !$viewfullreport) {
// The user has no right to see the requested detail.
return false;
}
$plagiarismfile = $DB->get_record('plagiarism_turnitin_files', array('cm' => $cmid, 'userid' => $userid, 'identifier' => $filehash));
if (empty($plagiarismfile)) {
// No record of that submission - so no links can be returned
return false;
}
$results = array('analyzed' => 0, 'score' => '', 'reporturl' => '');
if (isset($plagiarismfile->statuscode) && $plagiarismfile->statuscode != 'success') {
//always display errors - even if the student isn't able to see report/score.
$results['error'] = turnitin_error_text($plagiarismfile->statuscode);
return $results;
}
// All non-standard situations handled.
$results['analyzed'] = 1;
$results['score'] = $plagiarismfile->similarityscore;
if ($viewfullreport) {
// User gets to see link to similarity report
$results['reporturl'] = turnitin_get_report_link($plagiarismfile, $COURSE, $plagiarismsettings);
}
if (!empty($plagiarismsettings['turnitin_enablegrademark'])) {
$results['grademarklink'] = turnitin_get_grademark_link($plagiarismfile, $COURSE, $module, $plagiarismsettings);
}
return $results;
}