/**
  * Set seen unit
  *
  * This function is used to set the designated unit as seen or not seen,
  * according to $seen parameter. It also sets current unit to be the seen
  * unit, if we are setting a unit as seen. Otherwise, the current unit is
  * either leaved unchanged, or, if it matches the unset unit, it points
  * to another seen unit.
  * <br/>Example:
  * <code>
  * $user -> setSeenUnit(32, 2, true);						   //Set the unit with id 32 in lesson 2 as seen
  * $user -> setSeenUnit(32, 2, false);						  //Set the unit with id 32 in lesson 2 as not seen
  * </code>
  * From version 3.5.2 and above, this function also sets the lesson as completed, if the conditions are met
  *
  * @param mixed $unit The unit to set status for, can be an id or an EfrontUnit object
  * @param mixed $lesson The lesson that the unit belongs to, can be an id or an EfrontLesson object
  * @param boolean $seen Whether to set the unit as seen or not
  * @return boolean true if the lesson was completed as well
  * @since 3.5.0
  * @access public
  */
 public function setSeenUnit($unit, $lesson, $seen)
 {
     if (isset($this->coreAccess['content']) && $this->coreAccess['content'] != 'change') {
         //If user type is not plain 'student' and is not set to 'change' mode, do nothing
         return true;
     }
     if ($unit instanceof EfrontUnit) {
         //Check validity of $unit
         $unit = $unit['id'];
     } elseif (!eF_checkParameter($unit, 'id')) {
         throw new EfrontContentException(_INVALIDID . ": {$unit}", EfrontContentException::INVALID_ID);
     }
     if ($lesson instanceof EfrontLesson) {
         //Check validity of $lesson
         $lesson = $lesson->lesson['id'];
     } elseif (!eF_checkParameter($lesson, 'id')) {
         throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID);
     }
     $lessons = $this->getLessons();
     if (!in_array($lesson, array_keys($lessons))) {
         //Check if the user is actually registered in this lesson
         throw new EfrontUserException(_USERDOESNOTHAVETHISLESSON . ": " . $lesson, EfrontUserException::USER_NOT_HAVE_LESSON);
     }
     $result = eF_getTableData("users_to_lessons", "done_content, current_unit", "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson);
     sizeof($result) > 0 ? $doneContent = unserialize($result[0]['done_content']) : ($doneContent = array());
     $current_unit = 0;
     if ($seen) {
         $doneContent[$unit] = $unit;
         $current_unit = $unit;
     } else {
         if (isset($doneContent[$unit])) {
             //Because of Fatal error: Cannot unset string offsets error
             unset($doneContent[$unit]);
         }
         if ($unit == $result[0]['current_unit']) {
             sizeof($doneContent) ? $current_unit = end($doneContent) : ($current_unit = 0);
         }
     }
     sizeof($doneContent) ? $doneContent = serialize($doneContent) : ($doneContent = null);
     eF_updateTableData("users_to_lessons", array('done_content' => $doneContent, 'current_unit' => $current_unit), "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson);
     //		$cacheKey = "user_lesson_status:lesson:".$lesson."user:"******"type" => EfrontEvent::CONTENT_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $lesson, "entity_ID" => $current_unit));
     }
     //Set the lesson as complete, if it can be.
     $completedLesson = false;
     $userProgress = EfrontStats::getUsersLessonStatus($lesson, $this->user['login']);
     $userProgress = $userProgress[$lesson][$this->user['login']];
     //eF_updateTableData("users_to_lessons", array('progress' => $userProgress['overall_progress']), "users_LOGIN='******'login']."' and lessons_ID=".$lesson);
     if ($seen) {
         if ($userProgress['lesson_passed'] && !$userProgress['completed']) {
             $lesson = new EfrontLesson($lesson);
             if ($lesson->options['auto_complete']) {
                 $userProgress['tests_avg_score'] ? $avgScore = $userProgress['tests_avg_score'] : ($avgScore = 100);
                 $timestamp = _AUTOCOMPLETEDAT . ': ' . date("Y/m/d, H:i:s");
                 $this->completeLesson($lesson, $avgScore, $timestamp);
                 $completedLesson = true;
             }
         }
         if (!self::$cached_modules) {
             self::$cached_modules = eF_loadAllModules();
         }
         // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen
         foreach (self::$cached_modules as $module) {
             $module->onCompleteUnit($unit, $this->user['login']);
         }
     }
     return $completedLesson;
 }
Exemplo n.º 2
0
            $result = eF_getTableData("users_to_content", "visits, attempt_identifier", "content_ID={$unit['id']} and users_LOGIN='******'login']}'");
            if (!empty($result)) {
                // 				vd($_SESSION['attempt_identifier']);
                // 				vd($result[0]['attempt_identifier']);
                $visits = $result[0]['visits'];
                if ($_SESSION['attempt_identifier'] != $result[0]['attempt_identifier']) {
                    eF_updateTableData("users_to_content", array("visits" => $result[0]['visits'] + 1, "attempt_identifier" => $_SESSION['attempt_identifier']), "content_ID={$unit['id']} and users_LOGIN='******'login']}'");
                    $visits = $result[0]['visits'] + 1;
                }
            } else {
                eF_insertTableData("users_to_content", array("attempt_identifier" => $_SESSION['attempt_identifier'], "visits" => 1, "content_ID" => $unit['id'], "lessons_ID" => $unit['lessons_ID'], "users_LOGIN" => $scoUser->user['login']));
                $visits = 1;
            }
            $remaining_times = $unit['options']['scorm_times'] - $visits;
        }
    }
    $newUserProgress = EfrontStats::getUsersLessonStatus($scoLesson, $scoUser->user['login']);
    $newPercentage = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['overall_progress'];
    $newConditionsPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['conditions_passed'];
    $newLessonPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['lesson_passed'];
    if ($scoLesson->lesson['course_only'] && $_SESSION['s_courses_ID']) {
        $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'");
        if ($res[0]['issued_certificate'] != "") {
            $courseCertified = true;
        }
    }
    echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, $scormState, $redirectTo, $trackActivityInfo, $courseCertified, $remaining_times));
} catch (Exception $e) {
    echo json_encode(array('error' => $e->getMessage()));
}
exit;
         $nextLesson = $currentUser->getNextLesson($currentLesson, $_SESSION['s_courses_ID']);
         if ($currentLesson->lesson['course_only'] && isset($_SESSION['s_courses_ID'])) {
             $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'");
             if ($res[0]['issued_certificate'] != "") {
                 $courseCertified = true;
             }
         }
         echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, false, false, false, $courseCertified));
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['ajax']) && isset($_GET['check_conditions'])) {
     try {
         $newUserProgress = EfrontStats::getUsersLessonStatus($currentLesson, $currentUser->user['login']);
         $newPercentage = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['overall_progress'];
         $newConditionsPassed = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['conditions_passed'];
         $newLessonPassed = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['lesson_passed'];
         $nextLesson = $currentUser->getNextLesson($currentLesson, $_SESSION['s_courses_ID']);
         if ($currentLesson->lesson['course_only'] && isset($_SESSION['s_courses_ID'])) {
             $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'");
             if ($res[0]['issued_certificate'] != "") {
                 $courseCertified = true;
             }
         }
         echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, false, false, false, $courseCertified));
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
Exemplo n.º 4
0
     $infoUser = EfrontUserFactory::factory($_GET['sel_user']);
 } else {
     eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=statistics&option=user&message=' . urlencode(_USERISNOTVALIDORYOUCANNOTSEEUSER . ": " . $_GET['sel_user']));
     exit;
 }
 if ($isSupervisor || $currentUser->user['user_type'] == 'administrator') {
     $smarty->assign("T_EDIT_USER_LINK", array(array('text' => _EDITUSER, 'image' => "16x16/edit.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"T_USER_LOGIN", $infoUser->user['login']);
 $smarty->assign("T_REPORTS_USER", $infoUser);
 if ($_GET['specific_lesson_info'] && $_GET['lesson']) {
     $lessons = $infoUser->getUserStatusInLessons($_GET['lesson']);
     $smarty->assign("T_USER_STATUS_IN_LESSON", $lessons[$_GET['lesson']]);
     $status = EfrontStats::getUsersLessonStatus($_GET['lesson'], $infoUser->user['login']);
     $doneTests = EfrontStats::getStudentsDoneTests($_GET['lesson'], $infoUser->user['login']);
     $feedbacks = eF_getTableDataFlat("tests t, content c", "t.id, t.content_ID", "c.id=t.content_ID and c.ctg_type='feedback'");
     foreach ($doneTests[$infoUser->user['login']] as $contentId => $test) {
         unset($pendingTests[$test['tests_ID']]);
         //remove done tests
         if (in_array($contentId, $feedbacks['content_ID'])) {
             unset($doneTests[$infoUser->user['login']][$contentId]);
             //remove done tests
         }
     }
     $smarty->assign("T_USER_PENDING_TESTS", $pendingTests);
     $smarty->assign("T_USER_DONE_TESTS", $doneTests[$infoUser->user['login']]);
     $smarty->assign("T_USER_STATUS", $status[$_GET['lesson']][$infoUser->user['login']]);
 } elseif ($_GET['specific_course_info'] && $_GET['course']) {
     $lessons = $infoUser->getUserStatusInCourseLessons(new EfrontCourse($_GET['course']), true);