本文整理匯總了PHP中assign_plugin::get_files方法的典型用法代碼示例。如果您正苦於以下問題:PHP assign_plugin::get_files方法的具體用法?PHP assign_plugin::get_files怎麽用?PHP assign_plugin::get_files使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類assign_plugin
的用法示例。
在下文中一共展示了assign_plugin::get_files方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: is_file_modified
/**
* Does this file exist in any of the current files supported by this plugin for this user?
*
* @param assign $assignment - The assignment instance
* @param stdClass $user The user matching this uploaded file
* @param assign_plugin $plugin The matching plugin from the filename
* @param string $filename The parsed filename from the zip
* @param stored_file $fileinfo The info about the extracted file from the zip
* @return bool - True if the file has been modified or is new
*/
public function is_file_modified($assignment, $user, $plugin, $filename, $fileinfo) {
$sg = null;
if ($plugin->get_subtype() == 'assignsubmission') {
$sg = $assignment->get_user_submission($user->id, false);
} else if ($plugin->get_subtype() == 'assignfeedback') {
$sg = $assignment->get_user_grade($user->id, false);
} else {
return false;
}
if (!$sg) {
return true;
}
foreach ($plugin->get_files($sg, $user) as $pluginfilename => $file) {
if ($pluginfilename == $filename) {
// Extract the file and compare hashes.
$contenthash = '';
if (is_array($file)) {
$content = reset($file);
$contenthash = sha1($content);
} else {
$contenthash = $file->get_contenthash();
}
if ($contenthash != $fileinfo->get_contenthash()) {
return true;
} else {
return false;
}
}
}
return true;
}