Esempio n. 1
0
if (G_VERSIONTYPE != 'community') {
    #cpp#ifndef COMMUNITY
    if (G_VERSIONTYPE != 'standard') {
        #cpp#ifndef STANDARD
        //This file cannot be called directly, only included.
        if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) {
            exit;
        }
        $loadScripts[] = 'includes/tests';
        if (isset($_GET['solve_test']) && eF_checkParameter($_GET['solve_test'], 'id')) {
            if (isset($_GET['confirm'])) {
                $form = new HTML_QuickForm("test_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=lessons&op=tests&solve_test=' . $_GET['solve_test'] . '&confirm=1', "", null, true);
                if ($form->isSubmitted() && $form->validate()) {
                    // The skillgap test has been solved and submitted
                    $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "status != 'deleted' and tests_id = '" . $_GET['solve_test'] . "' AND users_LOGIN = '******'login'] . "'");
                    $testInstance = unserialize($result[0]['test']);
                    $testString = $testInstance->toHTMLQuickForm($form);
                    $testString = $testInstance->toHTML($testString, $remainingTime);
                    $questions = $form->exportValues('question');
                    $questions = $form->getSubmitValue('question');
                    $testInstance->completedTest['status'] = 'completed';
                    $testInstance->complete($questions);
                    eF_updateTableData("users_to_skillgap_tests", array("solved" => "1"), "tests_ID = '" . $_GET['solve_test'] . "' AND users_LOGIN = '******'login'] . "'");
                    // Check if you should automatically assign lessons and courses to the student
                    if ($testInstance->options['automatic_assignment']) {
                        $analysisResults = $testInstance->analyseSkillGapTest();
                        foreach ($analysisResults['lessons'] as $lesson) {
                            $currentUser->addLessons($lesson['lesson_ID']);
                        }
                        foreach ($analysisResults['courses'] as $course) {
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['compress_tests']) && $_GET['ajax'] == 1) {
     try {
         EfrontCompletedTest::compressTests();
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['uncompress_tests']) && $_GET['ajax'] == 1) {
     try {
         EfrontCompletedTest::uncompressTests();
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['cache']) && $_GET['ajax'] == 1) {
     try {
         if ($_GET['cache'] == 'templates') {
             clearTemplatesCache();
         } else {
             if ($_GET['cache'] == 'tests') {
                 eF_deleteTableData("cache");
             } else {
                 if ($_GET['cache'] == 'query') {
                     eF_executeNew("reset query cache");
Esempio n. 3
0
 public static function getQuestionResponseDetails($testStats)
 {
     $userQuestions = array();
     foreach ($testStats as $value) {
         foreach ($value as $user => $testAttempts) {
             foreach ($testAttempts as $testAttempt) {
                 if (is_array($testAttempt) && isset($testAttempt['id'])) {
                     $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "ct.id=" . $testAttempt['id']);
                     $test = unserialize($result[0]['test']);
                     foreach ($test->questions as $question) {
                         $answers = array();
                         if ($question instanceof MultipleManyQuestion) {
                             foreach ($question->order as $index) {
                                 if ($question->userAnswer[$index]) {
                                     $answers[] = $question->options[$index];
                                 }
                             }
                         } elseif ($question instanceof MatchQuestion || $question instanceof DragDropQuestion) {
                             foreach ($question->order as $index) {
                                 $answers[] = $question->options[$index] . ' → ' . $question->answer[$question->userAnswer[$index]];
                             }
                         } elseif ($question instanceof TrueFalseQuestion) {
                             if ($question->userAnswer === false) {
                                 $answers[] = _NORESPONSE;
                             } else {
                                 $answers[] = $question->userAnswer ? _TRUE : _FALSE;
                             }
                         } elseif ($question instanceof EmptySpacesQuestion) {
                             $occurences = preg_match_all("/###(\\d*)/", $question->question['plain_text'], $matches);
                             for ($i = 0; $i < $occurences; $i++) {
                                 $question->question['plain_text'] = preg_replace("/###(\\d*)/", "<b>" . $question->userAnswer[$i] . "</b>", $question->question['plain_text'], 1);
                             }
                             $answers[] = $question->question['plain_text'];
                         } elseif ($question instanceof MultipleOneQuestion) {
                             foreach ($question->order as $index) {
                                 if ($question->userAnswer == $index) {
                                     if ($question->userAnswer === false) {
                                         $answers[] = _NORESPONSE;
                                     } else {
                                         $answers[] = $question->options[$index];
                                     }
                                 }
                             }
                         } elseif ($question instanceof RawTextQuestion) {
                             $answers[] = $question->userAnswer;
                         }
                         $userQuestions[$question->question['id']][$user][] = implode("<br/>", $answers);
                     }
                 }
             }
         }
     }
     return $userQuestions;
 }
Esempio n. 4
0
         $courses = eF_filterData($courses, $_GET['filter']);
     }
     $smarty->assign("T_COURSES_SIZE", sizeof($courses));
     if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
         isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
         $courses = array_slice($courses, $offset, $limit);
     }
     //foreach ($courses as $key => $course) {
     //$courses[$key]['languages_NAME'] = $languages[$course['languages_NAME']];
     //}
     $smarty->assign("T_COURSES_DATA", $courses);
     $smarty->display($_SESSION['s_type'] . '.tpl');
     exit;
 }
 // We change a bit the following typical query to acquire the latest options values for the test - in case a threshold has been changed
 $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct JOIN completed_tests_blob ctb on ct.id=ctb.completed_tests_ID JOIN tests t ON t.id = ct.tests_ID", "ct.*, ctb.test, t.options", "ct.status != 'deleted' and ct.id = '" . $_GET['show_solved_test'] . "'");
 $completedTest = unserialize($result[0]['test']);
 // Take the most recent set general threshold for this test
 $temp = unserialize($result[0]['options']);
 $completedTest->options['general_threshold'] = $temp['general_threshold'];
 $smarty->assign("T_TEST_DATA", $completedTest);
 if ($_SESSION['s_type'] == 'administrator') {
     $user = eF_getTableData("users", "*", "login = '******'user'] . "'");
 } else {
     $user = eF_getTableData("users", "*", "login = '******'s_login'] . "'");
 }
 $smarty->assign("T_USER_INFO", $user[0]);
 $analysisResults = $completedTest->analyseSkillGapTest();
 if (!empty($analysisResults['testSkills'])) {
     $smarty->assign("T_SKILLSGAP", $analysisResults['testSkills']);
 }
Esempio n. 5
0
 /**
  * Save test
  *
  * This function is used to save the current test status
  * <br/>Example:
  * <code>
  * $test = new EfrontTest(23);
  * $completedTest = $test -> start('jdoe');
  * $completedTest -> pause($answers);
  * $completedTest -> save();
  * </code>
  *
  * @since 3.5.2
  * @access public
  */
 public function save()
 {
     // Added in order to prevent too big values because of leaving test (closing browser etc)
     if ($this->time['spent'] > 2 * 60 * 60) {
         $this->time['spent'] = 2 * 60 * 60;
     }
     if ($this->completedTest['id']) {
         $fields = array('test' => serialize($this), 'status' => $this->completedTest['status'], 'timestamp' => time(), 'time_start' => $this->time['start'] ? $this->time['start'] : null, 'time_end' => $this->time['end'] ? $this->time['end'] : null, 'time_spent' => $this->time['spent'] ? $this->time['spent'] : null, 'pending' => $this->completedTest['pending'] ? $this->completedTest['pending'] : 0, 'score' => $this->completedTest['score'] ? $this->completedTest['score'] : null);
         EfrontCompletedTest::updateCompletedTest("completed_tests", $fields, "id=" . $this->completedTest['id']);
         if ($this->options['maintain_history'] !== '') {
             $result = eF_getTableDataFlat("completed_tests", "id", "status != 'incomplete' and status != 'paused' and users_LOGIN = '******'login'] . "' and tests_ID=" . $this->completedTest['testsId'], "timestamp desc");
             if (sizeof($result['id']) > $this->options['maintain_history']) {
                 $deleteThreshold = $result['id'][$this->options['maintain_history']];
                 EfrontCompletedTest::updateCompletedTest("completed_tests", array("test" => '', 'status' => 'deleted'), "status != 'incomplete' and status != 'paused' and users_LOGIN = '******'login'] . "' and tests_ID=" . $this->completedTest['testsId'] . " and id <= {$deleteThreshold} and id != " . $this->completedTest['id']);
             }
         }
     } else {
         $fields = array('tests_ID' => $this->completedTest['testsId'], 'users_LOGIN' => $this->completedTest['login'], 'test' => serialize($this), 'status' => $this->completedTest['status'], 'time_start' => $this->time['start'] ? $this->time['start'] : null, 'time_end' => $this->time['end'] ? $this->time['end'] : null, 'time_spent' => $this->time['spent'] ? $this->time['spent'] : null, 'pending' => $this->completedTest['pending'] ? $this->completedTest['pending'] : 0, 'score' => $this->completedTest['score'] ? $this->completedTest['score'] : null);
         //$id = eF_insertTableData("completed_tests", $fields);
         $id = EfrontCompletedTest::storeCompletedTest("completed_tests", $fields);
         $this->completedTest['id'] = $id;
         $this->save();
     }
 }
Esempio n. 6
0
}
try {
    if (isset($_GET['test_id']) && eF_checkParameter($_GET['test_id'], 'id') && eF_checkParameter($_GET['user'], 'login')) {
        $test = new EfrontTest($_GET['test_id']);
        $doneTests = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "status != 'deleted' and users_LOGIN = '******'user'] . "' and tests_ID=" . $test->test['id']);
        //        $test -> setDone($_GET['user']);
    } else {
        if (isset($_GET['content_id']) && eF_checkParameter($_GET['content_id'], 'id') && eF_checkParameter($_GET['user'], 'login')) {
            $test = new EfrontTest($_GET['content_id'], true);
            $doneTests = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "status != 'deleted' and users_LOGIN = '******'user'] . "' and tests_ID=" . $test->test['id']);
            //        $test -> setDone($_GET['user']);
        } else {
            if (isset($_GET['done_test_id']) && eF_checkParameter($_GET['done_test_id'], 'id')) {
                $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "status != 'deleted' and ct.id=" . $_GET['done_test_id']);
                $test = new EfrontTest($result[0]['tests_ID']);
                $doneTests = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ct.*,ctb.test", "status != 'deleted' and users_LOGIN = '******'users_LOGIN'] . "' and tests_ID=" . $test->test['id']);
                $_GET['user'] = $result[0]['users_LOGIN'];
                //        $test -> setDone($result[0]['users_LOGIN']);
            } else {
                throw new Exception(_INVALIDID);
            }
        }
    }
    //Reorder done tests in a per-id fashion
    $temp = array();
    foreach ($doneTests as $value) {
        $temp[$value['id']] = $value;
    }
    $doneTests = $temp;
    if (isset($_GET['show_solved_test']) && in_array($_GET['show_solved_test'], array_keys($doneTests)) && eF_checkParameter($_GET['show_solved_test'], 'id')) {
        $showTest = unserialize($doneTests[$_GET['show_solved_test']]['test']);