Skip to content
Permalink
Browse files

Setting lp_minimum_item, depends in the course and session extra field

The extra field "new_tracking_system". It should be turned on in order
to process the new stats, otherwise it will load the classic stats.

BT#15252
  • Loading branch information...
jmontoyaa committed Feb 6, 2019
1 parent 1cf0203 commit e226292b8579a3f60928bf01b0ca9e5767af4c60
@@ -2483,11 +2483,11 @@ public function portal_homepage_edited_event_send_mail_filter_func(&$values)
*/
public static function registerLog($logInfo)
{
if (!Tracking::minimunTimeAvailable(api_get_course_int_id())) {
if (!Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
return false;
}
$loginAs = (int) (Session::read('login_as') === true);
$loginAs = (int) Session::read('login_as') === true;
$logInfo['user_id'] = api_get_user_id();
$logInfo['date_reg'] = api_get_utc_datetime();
@@ -436,7 +436,7 @@ public static function getLpStats(
$score = $row['myscore'];
$time_for_total = $row['mytime'];
if (self::minimunTimeAvailable($course_id)) {
if (self::minimunTimeAvailable($session_id, $course_id)) {
$timeCourse = self::getCalculateTime($user_id, $course_id, $session_id);
Session::write('trackTimeCourse', $timeCourse);
$lp_time = $timeCourse[TOOL_LEARNPATH];
@@ -1616,18 +1616,31 @@ public static function get_time_spent_on_the_platform(
/**
* Checks if the "lp_minimum_time" feature is available for the course.
*
* @param int $sessionId
* @param int $courseId
*
* @return bool
*/
public static function minimunTimeAvailable($courseId)
public static function minimunTimeAvailable($sessionId, $courseId)
{
if (api_get_configuration_value('lp_minimum_time') && $courseId) {
$extraFieldValue = new ExtraFieldValue('course');
$value = $extraFieldValue->get_values_by_handler_and_field_variable($courseId, 'new_tracking_system');
if (!api_get_configuration_value('lp_minimum_time')) {
return false;
}
if (!empty($sessionId)) {
$extraFieldValue = new ExtraFieldValue('session');
$value = $extraFieldValue->get_values_by_handler_and_field_variable($sessionId, 'new_tracking_system');
if ($value && isset($value['value']) && $value['value'] == 1) {
return true;
}
} else {
if ($courseId) {
$extraFieldValue = new ExtraFieldValue('course');
$value = $extraFieldValue->get_values_by_handler_and_field_variable($courseId, 'new_tracking_system');
if ($value && isset($value['value']) && $value['value'] == 1) {
return true;
}
}
}
return false;
@@ -1653,7 +1666,7 @@ public static function get_time_spent_on_the_course(
return 0;
}
if (self::minimunTimeAvailable($courseId)) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
$courseTime = self::getCalculateTime($user_id, $courseId, $session_id);
$time = isset($courseTime['total_time']) ? $courseTime['total_time'] : 0;
@@ -1831,7 +1844,7 @@ public static function get_first_connection_date_on_the_course(
$courseId = (int) $courseId;
$session_id = (int) $session_id;
if (self::minimunTimeAvailable($courseId)) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
$tbl_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT access_date
FROM '.$tbl_track_e_access.'
@@ -1903,7 +1916,7 @@ public static function get_last_connection_date_on_the_course(
$session_id = (int) $session_id;
$courseId = $courseInfo['real_id'];
if (self::minimunTimeAvailable($courseId)) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
// Show the last date on which the user acceed the session when it was active
$where_condition = '';
$userInfo = api_get_user_info($student_id);
@@ -2413,7 +2413,7 @@ public static function isBlockedByPrerequisite(
$isBlocked = true;
}
if (Tracking::minimunTimeAvailable($courseId)) {
if (Tracking::minimunTimeAvailable($sessionId, $courseId)) {
// Block if it does not exceed minimum time
// Minimum time (in minutes) to pass the learning path
$accumulateWorkTime = self::getAccumulateWorkTimePrerequisite($prerequisite, $courseId);
@@ -1889,7 +1889,7 @@ public function fixAbusiveTime($time)
$sessionLifetime = 3600;
}
if (!Tracking::minimunTimeAvailable(api_get_course_int_id())) {
if (!Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$fixedAddedMinute = 5 * 60; // Add only 5 minutes
if ($time > $sessionLifetime) {
error_log("fixAbusiveTime: Total time is too big: $time replaced with: $fixedAddedMinute");
@@ -218,7 +218,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
"olms.asset_timer = 0;";
$updateMinTime = '';
if (Tracking::minimunTimeAvailable(api_get_course_int_id())) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$timeLp = $mylp->getAccumulateWorkTime();
$timeTotalCourse = $mylp->getAccumulateWorkTimeTotalCourse();
// Minimum connection percentage
@@ -160,7 +160,7 @@ function activate_end_date() {
$form->addElement('html', '</div>');
// Time Control
if (Tracking::minimunTimeAvailable(api_get_course_int_id())) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime();
$form->addText('accumulate_work_time', [get_lang('LpMinTime'), get_lang('LpMinTimeDescription')]);
$defaults['accumulate_work_time'] = $accumulateTime;
@@ -155,7 +155,7 @@ function confirmation(name) {
$test_mode = api_get_setting('server_type');
$showBlockedPrerequisite = api_get_configuration_value('show_prerequisite_as_blocked');
$allowLpChamiloExport = api_get_configuration_value('allow_lp_chamilo_export');
$allowMinTime = Tracking::minimunTimeAvailable(api_get_course_int_id());
$allowMinTime = Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id());
$user = api_get_user_entity($userId);
$ending = true;
@@ -559,7 +559,7 @@
$template->assign('lp_author', $lp->get_author());
$lpMinTime = '';
if (Tracking::minimunTimeAvailable(api_get_course_int_id())) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
// Calulate minimum and accumulated time
$timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
$timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
@@ -1387,7 +1387,7 @@
];
$timeCourse = null;
if (Tracking::minimunTimeAvailable($courseInfo['real_id'])) {
if (Tracking::minimunTimeAvailable($session_id, $courseInfo['real_id'])) {
$timeCourse = Tracking::getCalculateTime($student_id, $courseInfo['real_id'], $session_id);
}

0 comments on commit e226292

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