Skip to content
Permalink
Browse files

Improve speed when rendering gradebook student reports BT#14357

Using Doctrine APCU cache

Setting: $_configuration['gradebook_use_apcu_cache']
  • Loading branch information...
jmontoyaa committed Dec 3, 2018
1 parent fbc3323 commit a9a284989ca56f8e29b63ade508945f82b913cdb
Showing with 32 additions and 1 deletion.
  1. +28 −1 main/gradebook/lib/be/category.class.php
  2. +4 −0 main/install/configuration.dist.php
@@ -388,7 +388,7 @@ public static function loadSessionCategories(
$courseInfo = api_get_course_info_by_id(api_get_course_int_id());
$courseCode = $courseInfo['code'];
$session_id = intval($session_id);
$session_id = (int) $session_id;
if (!empty($session_id)) {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
@@ -940,6 +940,17 @@ public function calc_score(
$course_code = '',
$session_id = null
) {
$key = 'category:'.$this->id.'student:'.(int) $stud_id.'type:'.$type.'course:'.$course_code.'session:'.(int) $session_id;
$useCache = api_get_configuration_value('gradebook_use_apcu_cache');
$cacheAvailable = api_get_configuration_value('apc') && $useCache;
if ($cacheAvailable) {
$cacheDriver = new \Doctrine\Common\Cache\ApcuCache();
if ($cacheDriver->contains($key)) {
return $cacheDriver->fetch($key);
}
}
// Classic
if (!empty($stud_id) && $type == '') {
if (!empty($course_code)) {
@@ -1144,16 +1155,29 @@ public function calc_score(
switch ($type) {
case 'best':
if (empty($bestResult)) {
if ($cacheAvailable) {
$cacheDriver->save($key, null);
}
return null;
}
if ($cacheAvailable) {
$cacheDriver->save($key, [$bestResult, $weightsum]);
}
return [$bestResult, $weightsum];
break;
case 'average':
if (empty($ressum)) {
if ($cacheAvailable) {
$cacheDriver->save($key, null);
}
return null;
}
if ($cacheAvailable) {
$cacheDriver->save($key, [$ressum, $weightsum]);
}
return [$ressum, $weightsum];
break;
case 'ranking':
@@ -1164,6 +1188,9 @@ public function calc_score(
return AbstractLink::getCurrentUserRanking($stud_id, []);
break;
default:
if ($cacheAvailable) {
$cacheDriver->save($key, [$ressum, $weightsum]);
}
return [$ressum, $weightsum];
break;
}
@@ -1042,6 +1042,10 @@
// Disable all new exercise attempts in all the platform
// $_configuration['exercises_disable_new_attempts'] = false;
// Improve speed when rendering gradebook student reports using Doctrine APCU cache
// $_configuration['gradebook_use_apcu_cache'] = true;
// ------ Custom DB changes (keep this at the end)
// Add user activation by confirmation email
// This option prevents the new user to login in the platform if your account is not confirmed via email

0 comments on commit a9a2849

Please sign in to comment.
You can’t perform that action at this time.