Skip to content

Commit

Permalink
Learnpath: log learning path creation, update and deletion into track…
Browse files Browse the repository at this point in the history
…_e_default - refs BT#21185
  • Loading branch information
ywarnier committed Nov 3, 2023
1 parent 0d533ef commit 9914b74
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions main/inc/lib/api.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
define('LOG_EXERCISE_CREATE', 'exe_created');
define('LOG_EXERCISE_UPDATE', 'exe_updated');
define('LOG_EXERCISE_DELETE', 'exe_deleted');
define('LOG_LP_CREATE', 'lp_created');
define('LOG_LP_UPDATE', 'lp_updated');
define('LOG_LP_DELETE', 'lp_deleted');
// All results from an exercise
define('LOG_EXERCISE_RESULT_DELETE', 'exe_result_deleted');
define('LOG_EXERCISE_RESULT_DELETE_INCOMPLETE', 'exe_incomplete_results_deleted');
Expand Down
11 changes: 8 additions & 3 deletions main/lp/aicc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public function import_aicc($course_code)
}
Database::query($sql);
$lp_id = Database::insert_id();
Event::addEvent(
LOG_LP_CREATE,
LOG_LP_ID,
$lp_id.' - '.$this->course_title
);

if ($lp_id) {
$sql = "UPDATE $new_lp SET id = iid WHERE iid = $lp_id";
Expand Down Expand Up @@ -647,7 +652,7 @@ public function set_preview_image($preview_image = '')
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql);

Expand All @@ -670,7 +675,7 @@ public function set_author($author = '')
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET author = '$author'
$sql = "UPDATE $tbl_lp SET author = '$author'
WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql);

Expand All @@ -696,7 +701,7 @@ public function set_maker($maker = '')
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET content_maker = '$maker'
$sql = "UPDATE $tbl_lp SET content_maker = '$maker'
WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql);

Expand Down
10 changes: 10 additions & 0 deletions main/lp/learnpath.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,11 @@ public static function add_lp(
$session_id,
$userId
);
Event::addEvent(
LOG_LP_CREATE,
LOG_LP_ID,
$newLp->getIid().' - '.$name
);

return $newLp->getIid();
}
Expand Down Expand Up @@ -1140,6 +1145,11 @@ public function delete($courseInfo = null, $id = null, $delete = 'keep')
'delete',
api_get_user_id()
);
Event::addEvent(
LOG_LP_DELETE,
LOG_LP_ID,
$this->lp_id.' - '.$this->get_name()
);

$link_info = GradebookUtils::isResourceInCourseGradebook(
api_get_course_id(),
Expand Down
5 changes: 5 additions & 0 deletions main/lp/lp_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,11 @@ function(reponse) {
}
}
}
Event::addEvent(
LOG_LP_UPDATE,
LOG_LP_ID,
$_SESSION['oLP']->lp_id
);
Display::addFlash(Display::return_message(get_lang('Updated')));
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
Expand Down
5 changes: 5 additions & 0 deletions main/lp/scorm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ public function import_manifest(
'visible',
$userId
);
Event::addEvent(
LOG_LP_CREATE,
LOG_LP_ID,
$this->lp_id.' - '.$myname
);

// Now insert all elements from inside that learning path.
// Make sure we also get the href and sco/asset from the resources.
Expand Down

0 comments on commit 9914b74

Please sign in to comment.