MDL-44583 Assign: performance fixes

This commit is contained in:
Damyon Wiese
2014-03-31 12:53:41 +08:00
committed by Marina Glancy
parent 26a44fc7bb
commit 6d458076d5
2 changed files with 22 additions and 12 deletions
+11 -7
View File
@@ -37,6 +37,9 @@ use \assignfeedback_editpdf\page_editor;
*/
class assign_feedback_editpdf extends assign_feedback_plugin {
/** @var boolean|null $enabledcache Cached lookup of the is_enabled function */
private $enabledcache = null;
/**
* Get the name of the file feedback plugin
* @return string
@@ -265,14 +268,15 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
* @return bool
*/
public function is_enabled() {
$testpath = assignfeedback_editpdf\pdf::test_gs_path(false);
if (!extension_loaded('zlib')) {
return false;
if ($this->enabledcache === null) {
if (!extension_loaded('zlib')) {
$this->enabledcache = false;
} else {
$testpath = assignfeedback_editpdf\pdf::test_gs_path(false);
$this->enabledcache = ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK);
}
}
if ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK) {
return true;
}
return false;
return $this->enabledcache;
}
/**
* Automatically hide the setting for the editpdf feedback plugin.
+11 -5
View File
@@ -36,6 +36,9 @@ require_once($CFG->dirroot.'/grade/grading/lib.php');
*/
class assign_feedback_offline extends assign_feedback_plugin {
/** @var boolean|null $activecache Cached lookup of advanced grading */
private $activecache = null;
/**
* Get the name of the file feedback plugin
* @return string
@@ -373,14 +376,17 @@ class assign_feedback_offline extends assign_feedback_plugin {
* @return bool
*/
public function is_enabled() {
$gradingmanager = get_grading_manager($this->assignment->get_context(), 'mod_assign', 'submissions');
$controller = $gradingmanager->get_active_controller();
$active = !empty($controller);
if ($this->activecache === null) {
$gradingmanager = get_grading_manager($this->assignment->get_context(), 'mod_assign', 'submissions');
$controller = $gradingmanager->get_active_controller();
$this->activecache = !empty($controller);
}
if ($active) {
if ($this->activecache) {
return false;
} else {
return parent::is_enabled();
}
return parent::is_enabled();
}
/**