Exercises: Fix LP update after finishing an exercise

pull/3984/head
Julio 4 years ago
parent f0998b210f
commit 1a61a91b36
  1. 15
      public/main/exercise/exercise.class.php
  2. 21
      public/main/exercise/exercise_result.php
  3. 10
      public/main/exercise/result.php
  4. 16
      public/main/lp/learnpath.class.php
  5. 3
      public/main/lp/lp_view.php

@ -8796,12 +8796,6 @@ class Exercise
$qb->andWhere($qb->expr()->isNull('resource.exerciseCategory'));
}
/*$editAccess = Container::getAuthorizationChecker()->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER);
return Container::$container->get('twig')->render(
'@ChamiloCore/Resource/grid.html.twig',
['grid' => $grid]
);*/
$allowDelete = self::allowAction('delete');
$allowClean = self::allowAction('clean_results');
@ -8839,7 +8833,7 @@ class Exercise
[],
$column,
self::PAGINATION_ITEMS_PER_PAGE,
'exercises_cat_'.$categoryId
'exercises_cat_'.$categoryId.'_'.api_get_course_int_id().'_'.api_get_session_id()
);
$limit = $table->per_page;
@ -9889,7 +9883,6 @@ class Exercise
$sql = "SELECT iid FROM $TBL_LP_ITEM_VIEW
WHERE
c_id = $course_id AND
lp_item_id = $safe_item_id AND
lp_view_id = $viewId
ORDER BY iid DESC
@ -9918,13 +9911,13 @@ class Exercise
$sql = "UPDATE $TBL_LP_ITEM_VIEW SET
status = '$status',
score = $score,
total_time = $duration
score = '$score',
total_time = '$duration'
WHERE iid = $lp_item_view_id";
Database::query($sql);
$sql = "UPDATE $TBL_TRACK_EXERCICES SET
orig_lp_item_view_id = $lp_item_view_id
orig_lp_item_view_id = '$lp_item_view_id'
WHERE exe_id = ".$safe_exe_id;
Database::query($sql);
}

@ -46,9 +46,6 @@ if (empty($objExercise)) {
api_not_allowed(true);
}
//$js = '<script>'.api_get_language_translate_html().'</script>';
//$htmlHeadXtra[] = $js;
if (api_is_in_gradebook()) {
$interbreadcrumb[] = [
'url' => Category::getUrl(),
@ -63,23 +60,12 @@ $interbreadcrumb[] = [
'url' => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Tests'),
];
if (RESULT_DISABLE_RADAR === (int) $objExercise->results_disabled) {
//$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
}
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
if (api_get_configuration_value('quiz_prevent_copy_paste')) {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'jquery.nocopypaste.js"></script>';
}
if (!empty($objExercise->getResultAccess())) {
/*$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');*/
}
$showHeader = false;
$showFooter = false;
$showLearnPath = true;
@ -112,10 +98,9 @@ if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) {
);
}
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId);
$learnpath_id = isset($exercise_stat_info['orig_lp_id']) ? $exercise_stat_info['orig_lp_id'] : 0;
$learnpath_item_id = isset($exercise_stat_info['orig_lp_item_id']) ? $exercise_stat_info['orig_lp_item_id'] : 0;
$learnpath_item_view_id = isset($exercise_stat_info['orig_lp_item_view_id'])
? $exercise_stat_info['orig_lp_item_view_id'] : 0;
$learnpath_id = $exercise_stat_info['orig_lp_id'] ?? 0;
$learnpath_item_id = $exercise_stat_info['orig_lp_item_id'] ?? 0;
$learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'] ?? 0;
$logInfo = [
'tool' => TOOL_QUIZ,

@ -68,16 +68,6 @@ if ($student_id === $current_user_id && ExerciseSignaturePlugin::exerciseHasSign
}
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
if (!empty($objExercise->getResultAccess())) {
/*$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');*/
}
$htmlHeadXtra[] = api_get_build_js('exercise.js');
if ($show_headers) {

@ -242,7 +242,7 @@ class learnpath
$lp_item_id_list[] = $itemId;
switch ($this->type) {
case 3: //aicc
case CLp::AICC_TYPE:
$oItem = new aiccItem('db', $itemId, $course_id);
if (is_object($oItem)) {
$oItem->set_lp_view($this->lp_view_id, $course_id);
@ -252,7 +252,7 @@ class learnpath
$this->refs_list[$oItem->ref] = $itemId;
}
break;
case 2:
case CLp::SCORM_TYPE:
$oItem = new scormItem('db', $itemId);
if (is_object($oItem)) {
$oItem->set_lp_view($this->lp_view_id, $course_id);
@ -262,7 +262,7 @@ class learnpath
$this->refs_list[$oItem->ref] = $itemId;
}
break;
case 1:
case CLp::LP_TYPE:
default:
$oItem = new learnpathItem(null, $item);
if (is_object($oItem)) {
@ -309,9 +309,11 @@ class learnpath
while ($row = Database:: fetch_array($res)) {
$status_list[$row['lp_item_id']] = $row['status'];
}
foreach ($lp_item_id_list as $item_id) {
if (isset($status_list[$item_id])) {
$status = $status_list[$item_id];
if (is_object($this->items[$item_id])) {
$this->items[$item_id]->set_status($status);
if (empty($status)) {
@ -2368,10 +2370,8 @@ class learnpath
/**
* Generate and return the table of contents for this learnpath. The (flat) table returned can be
* used by get_html_toc() to be ready to display.
*
* @return array TOC as a table with 4 elements per row: title, link, status and level
*/
public function get_toc()
public function get_toc(): array
{
$toc = [];
foreach ($this->ordered_items as $item_id) {
@ -2379,8 +2379,8 @@ class learnpath
$toc[] = [
'id' => $item_id,
'title' => $this->items[$item_id]->get_title(),
'status' => $this->items[$item_id]->get_status(),
'status_class' => self::getStatusCSSClassName($this->items[$item_id]->get_status()),
'status' => $this->items[$item_id]->get_status(false),
'status_class' => self::getStatusCSSClassName($this->items[$item_id]->get_status(false)),
'level' => $this->items[$item_id]->get_level(),
'type' => $this->items[$item_id]->get_type(),
'description' => $this->items[$item_id]->get_description(),

@ -544,7 +544,7 @@ $template->assign('lp_title_scorm', $lp->getName());
} else {*/
$template->assign('data_panel', null);
//echo '<pre>';var_dump($oLP->get_toc(), array_column($oLP->get_toc(), 'status_class', 'id'));
//echo '<pre>';var_dump($oLP->get_toc(), array_column($oLP->get_toc(), 'status_class', 'id'));exit;
$template->assign('status_list', array_column($oLP->get_toc(), 'status_class', 'id'));
$template->assign('data_list', $oLP->getListArrayToc());
//var_dump($oLP->getListArrayToc($get_toc_list));
@ -569,6 +569,7 @@ $template->displayTemplate('@ChamiloCore/LearnPath/view.html.twig');
//$_setting['show_navigation_menu'] = $save_setting;
//Session::write('oLP', $lp);
Session::write('oLP', $oLP);
if ($debug) {
error_log(' ------- end lp_view.php ------');

Loading…
Cancel
Save