コード例 #1
0
 function updateTestReport($id_tests)
 {
     $test_man = new GroupTestManagement();
     $tests_list = $test_man->getTestInfo($id_tests);
     while (list($id_test, $test_info) = each($tests_list)) {
         $query_test = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_coursereport \r\n\t\t\tSET required_score = '" . $test_info['point_required'] . "' " . ($test_info['order_type'] != 2 ? ", " . " max_score = '" . $test_man->getMaxScore($id_test) . "' " : '') . ", " . " required_score = " . $test_man->getRequiredScore($id_test) . " " . " WHERE id_course = '" . $_SESSION['idCourse'] . "' AND \r\n\t\t\t\tsource_of = 'test' AND \r\n\t\t\t\tid_source = '" . $id_test . "'";
         sql_query($query_test);
     }
 }
コード例 #2
0
ファイル: gradebook.php プロジェクト: abhinay100/forma_app
function coursereport()
{
    global $nquest;
    global $course_score, $course_score_max;
    global $test_title;
    checkPerm('view');
    require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    require_once _base_ . '/lib/lib.table.php';
    $lang =& DoceboLanguage::createInstance('gradebook', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $test_man = new GroupTestManagement();
    $report_man = new CourseReportManager();
    // XXX: update if needed
    $org_tests =& $report_man->getTest();
    $tests_info =& $test_man->getTestInfo($org_tests);
    $i_test = array();
    $i_test_report_id = array();
    // XXX: Info for updates
    $query_tot_report = "\r\n\tSELECT COUNT(*)\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "'";
    list($tot_report) = sql_fetch_row(sql_query($query_tot_report));
    $query_tests = "\r\n\tSELECT id_report, id_source\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "' AND source_of = 'test'";
    $re_tests = sql_query($query_tests);
    while (list($id_r, $id_t) = sql_fetch_row($re_tests)) {
        $i_test[$id_t] = $id_t;
        $i_test_report_id[$id_r] = $id_r;
    }
    // XXX: Update if needed
    if ($tot_report == 0) {
        $report_man->initializeCourseReport($org_tests);
    } else {
        if (is_array($i_test)) {
            $test_to_add = array_diff($org_tests, $i_test);
        } else {
            $test_to_add = $org_tests;
        }
        if (is_array($i_test)) {
            $test_to_del = array_diff($i_test, $org_tests);
        } else {
            $test_to_del = $org_tests;
        }
        if (!empty($test_to_add) || !empty($test_to_del)) {
            $report_man->addTestToReport($test_to_add, 1);
            $report_man->delTestToReport($test_to_del);
            $included_test = $org_tests;
        }
    }
    $report_man->updateTestReport($org_tests);
    $reports = array();
    $id_test = array();
    $id_report = array();
    $tests = array();
    // XXX: retrive all report info
    $query_report = "\r\n\tSELECT id_report, title, max_score, required_score, weight, show_to_user, use_for_final, source_of, id_source\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\tWHERE id_course = '" . $_SESSION['idCourse'] . "' AND show_to_user = '******'\r\n\tORDER BY sequence ";
    $re_report = sql_query($query_report);
    while ($info_report = mysql_fetch_assoc($re_report)) {
        switch ($info_report['source_of']) {
            case "test":
                $id_test[] = $info_report['id_source'];
                break;
        }
    }
    $id_user = getLogUserId();
    if (count($id_test)) {
        $title = $GLOBALS['course_descriptor']->getValue('name');
        $username = Docebo::user()->getUserName();
        $GLOBALS['page']->add(getTitleArea($lang->def('_GRADEBOOK_AREATITLE'), 'gradebook') . '<div class="std_block">' . '<div class="print">' . '<a href="#" onclick="window.print(); return false;">' . '<img src="' . getPathImage() . 'standard/print.gif" alt="' . $lang->def('_PRINT') . '" /> ' . $lang->def('_PRINT') . '</a>' . '</div>' . getBackUi('index.php?modname=gradebook&amp;op=showgrade', $lang->def('_BACK')) . '<div class="title coursereport-title">' . $username . '</div><div class="title coursereport-title">' . $title . '</div>', 'content');
        $GLOBALS['page']->add('<div class="coursereport-div"><table class="coursereport-table">' . '<tr><td><strong>' . $lang->def('_TEST_N') . '</strong></td><td><strong>' . $lang->def('_QUESTION') . '</strong></td><td align="right"><strong>' . $lang->def('_SCORE') . '</strong></td></tr>', 'content');
        $nquest = 0;
        $course_score = 0;
        $course_score_max = 0;
        $j = 0;
        for ($i = 0; $i < count($id_test); $i++) {
            $test_title = $tests_info[$id_test[$i]]['title'];
            $GLOBALS['page']->add('<tr><td colspan="3"><br /><strong>' . $test_title . '</strong></td></tr>', 'content');
            $query_track = "SELECT idTrack FROM " . $GLOBALS['prefix_lms'] . "_testtrack " . "WHERE idTest =" . $id_test[$i] . " AND idUser="******"3" align="right"><strong>' . $lang->def('_TOTAL') . ':&nbsp;' . $course_score . ' ' . $lang->def('_ON') . ' ' . $course_score_max . ' (' . $perc_course_score . '%)</strong> </td></tr>', 'content');
        $GLOBALS['page']->add('</table>', 'content');
        /*
        if ($perc_course_score<75) {
        	$msg_feedback=$lang->def('_COURSE_NOT_OK').' '.$lang->def('_COURSE_CHECK_GRAPH');
        } else {
        	$msg_feedback=$lang->def('_COURSE_OK');
        }
        
        $GLOBALS['page']->add('<p><strong>'.$msg_feedback.'</strong>', 'content');
        */
        $GLOBALS['page']->add('</div>', 'content');
        draw_bar($tests);
        $GLOBALS['page']->add('</div>', 'content');
    }
}
コード例 #3
0
ファイル: do.test.php プロジェクト: abhinay100/forma_app
function intro($object_test, $id_param)
{
    if (!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) {
        die("You can't access");
    }
    require_once _base_ . '/lib/lib.form.php';
    require_once $GLOBALS['where_lms'] . '/class.module/track.test.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
    $lang =& DoceboLanguage::createInstance('test');
    $id_test = $object_test->getId();
    $id_reference = getLoParam($id_param, 'idReference');
    $url_coded = urlencode(serialize($object_test->back_url));
    $id_track = retriveTrack($id_reference, $id_test, Docebo::user()->getIdst());
    if ($id_track === false) {
        $GLOBALS['page']->add(getErrorUi($lang->def('_TEST_TRACK_FAILURE') . getBackUi(Util::str_replace_once('&', '&amp;', $object_test->back_url), $lang->def('_BACK'))), 'content');
    }
    $track_info = Track_Test::getTrackInfoById($id_track);
    $test_man = new TestManagement($id_test);
    $play_man = new PlayTestManagement($id_test, Docebo::user()->getIdst(), $id_track, $test_man);
    $test_info = $test_man->getTestAllInfo();
    $prerequisite = $test_man->getPrerequisite();
    $group_test_man = new GroupTestManagement();
    $tests_score =& $group_test_man->getTestsScores(array($id_test), array(Docebo::user()->getIdst()));
    if ($test_info['time_dependent'] && $test_info['time_assigned']) {
        $minute_assigned = (int) ($test_info['time_assigned'] / 60);
        $second_assigned = (int) ($test_info['time_assigned'] % 60);
        if (strlen($second_assigned) == 1) {
            $second_assigned = '0' . $second_assigned;
        }
        $time_readable = str_replace('[time_assigned]', $minute_assigned . ':' . $second_assigned . '', $lang->def('_TEST_TIME_ASSIGNED'));
        $time_readable = str_replace('[second_assigned]', '' . $second_assigned, str_replace('[minute_assigned]', '' . $minute_assigned, $time_readable));
    }
    $page_title = array(Util::str_replace_once('&', '&amp;', $object_test->back_url) => $lang->def('_TITLE'), $test_info['title']);
    $GLOBALS['page']->add(getTitleArea($page_title, 'test', $lang->def('_TEST_INFO')) . '<div class="std_block">' . getBackUi(Util::str_replace_once('&', '&amp;', $object_test->back_url), $lang->def('_BACK')) . '<span class="text_bold">' . $lang->def('_TITLE') . ' : </span>' . $test_info['title'] . '<br /><br />' . ($test_info['description'] != '' ? '<span class="text_bold">' . $lang->def('_DESCRIPTION') . ' : </span>' . $test_info['description'] . '<br /><br />' : '') . (isset($track_info['score']) && $track_info['score'] >= $test_info['point_required'] ? '<span class="text_bold">' . str_replace('[score]', $track_info['score'], $lang->def('_RESTART_INFO')) . '</span><br /><br />' : ''), 'content');
    if ($test_info['hide_info'] == 0) {
        $GLOBALS['page']->add('<span class="text_bold">' . $lang->def('_TEST_INFO') . ' : </span><br />' . '<ul class="test_info_list">', 'content');
        if ($test_info['order_type'] != 2) {
            $GLOBALS['page']->add('<li>' . str_replace('[max_score]', '' . ($test_info['point_type'] != 1 ? $test_man->getMaxScore() : 100), $lang->def('_TEST_MAXSCORE')) . '</li>', 'content');
        }
        $GLOBALS['page']->add('<li>' . str_replace('[question_number]', '' . $test_man->getNumberOfQuestion(), $lang->def('_TEST_QUESTION_NUMBER')) . '</li>', 'content');
        if ($test_info['point_required'] != 0) {
            $GLOBALS['page']->add('<li>' . str_replace('[score_req]', '' . $test_info['point_required'], $lang->def('_TEST_REQUIREDSCORE')) . '</li>', 'content');
        }
        $GLOBALS['page']->add('<li>' . ($test_info['save_keep'] ? $lang->def('_TEST_SAVEKEEP') : $lang->def('_TEST_SAVEKEEP_NO')) . '</li>' . '<li>' . ($test_info['mod_doanswer'] ? $lang->def('_TEST_MOD_DOANSWER') : $lang->def('_TEST_MOD_DOANSWER_NO')) . '</li>' . '<li>' . ($test_info['can_travel'] ? $lang->def('_TEST_CAN_TRAVEL') : $lang->def('_TEST_CAN_TRAVEL_NO')) . '</li>' . '<li>' . ($test_info['show_score'] || $test_info['show_score_cat'] ? $lang->def('_TEST_SHOW_SCORE') : $lang->def('_TEST_SHOW_SCORE_NO')) . '</li>' . '<li>' . ($test_info['show_solution'] ? $lang->def('_TEST_SHOW_SOLUTION') : $lang->def('_TEST_SHOW_SOLUTION_NO')) . '</li>' . '<li>', 'content');
        switch ($test_info['time_dependent']) {
            case 0:
                $GLOBALS['page']->add($lang->def('_TEST_TIME_ASSIGNED_NO'), 'content');
                break;
            case 1:
                $GLOBALS['page']->add($time_readable, 'content');
                break;
            case 2:
                $GLOBALS['page']->add($lang->def('_TEST_TIME_ASSIGNED_QUEST'), 'content');
                break;
        }
        if ($test_info['max_attempt'] > 0) {
            $GLOBALS['page']->add('<li>' . str_replace('[remaining_attempt]', $test_info['max_attempt'] - $track_info['number_of_attempt'], Lang::t('_NUMBER_OF_ATTEMPT', 'test')) . '</li>', 'content');
        }
        $GLOBALS['page']->add('</ul>' . '<br />', 'content');
    }
    if ($tests_score[$id_test][Docebo::user()->getIdst()]['comment'] !== '') {
        $GLOBALS['page']->add('<span class="text_bold">' . $lang->def('_COMMENTS') . ' : </span>' . $tests_score[$id_test][Docebo::user()->getIdst()]['comment'] . '<br /><br />', 'content');
    }
    // Actions
    $score_status = $play_man->getScoreStatus();
    $show_result = $test_info['show_score'] || $test_info['show_score_cat'] || $test_info['show_solution'];
    $is_end = $score_status == 'valid' || $score_status == 'not_checked' || $score_status == 'passed' || $score_status == 'not_passed';
    $GLOBALS['page']->add(Form::openForm('test_intro', 'index.php?modname=test&amp;op=play') . Form::getHidden('id_test', 'id_test', $id_test) . Form::getHidden('id_param', 'id_param', $id_param) . Form::getHidden('idTrack', 'idTrack', $id_track) . Form::getHidden('back_url', 'back_url', $url_coded) . Form::getHidden('next_step', 'next_step', 'play'), 'content');
    if ($test_info['max_attempt'] > 0) {
        if ($test_info['max_attempt'] - $track_info['number_of_attempt'] <= 0) {
            //$GLOBALS['page']->add($lang->def('_MAX_ATTEMPT_REACH'), 'content');
            $GLOBALS['page']->add(Lang::t('_MAX_ATTEMPT_REACH', 'test'), 'content');
            if ($show_result) {
                $GLOBALS['page']->add('<div class="align_right">' . Form::getHidden('show_result', 'show_result', 1) . Form::getButton('show_review', 'show_review', $lang->def('_TEST_SHOW_REVIEW')) . '</div>', 'content');
            }
            $GLOBALS['page']->add(Form::closeForm() . '</div>', 'content');
            return;
        }
        if ($is_end && $track_info['score'] >= $test_info['point_required']) {
            $GLOBALS['page']->add($lang->def('_YOU_HAVE_PASS_THIS_TEST'), 'content');
            if ($show_result) {
                $GLOBALS['page']->add('<div class="align_right">' . Form::getHidden('show_result', 'show_result', 1) . Form::getButton('show_review', 'show_review', $lang->def('_TEST_SHOW_REVIEW')) . '</div>', 'content');
            }
            $GLOBALS['page']->add(Form::closeForm() . '</div>', 'content');
            return;
        }
    }
    //--- check for suspension condition -------------------------------------------
    if ($test_info['use_suspension']) {
        $attempts_until_now = $track_info['attempts_for_suspension'];
        $last_suspension_date = $track_info['suspended_until'];
        if ($last_suspension_date == "") {
            $last_suspension_date = '0000-00-00 00:00:00';
        }
        $now = date("Y-m-d H:i:s");
        //check remaining attempts
        $diff_attempts = $test_info['suspension_num_attempts'] - $attempts_until_now;
        if ($diff_attempts > 0 && ($last_suspension_date < $now || $test_info['suspension_num_hours'] <= 0)) {
            //warning: $diff_attempts remaining before suspesion
            cout(UIFeedback::pnotice($lang->def('_ATTEMPTS_REMAINING_BEFORE_SUSPENSION') . ' : ' . $diff_attempts) . '<br /><br />', 'content');
        } else {
            if ($test_info['suspension_num_hours'] <= 0) {
                cout(UIFeedback::pnotice($lang->def('_TEST_SUSPENDED')) . '<br /><br />', 'content');
                cout(Form::closeForm() . '</div>', 'content');
                return;
            } else {
                //check if last suspension date is prior to now
                if ($last_suspension_date > $now) {
                    //user is suspended for this test until "last_suspension_date"
                    cout(UIFeedback::pnotice($lang->def('_TEST_SUSPENDED_UNTIL') . ' : ' . Format::date($last_suspension_date, "datetime")) . '<br /><br />', 'content');
                    cout(Form::closeForm() . '</div>', 'content');
                    return;
                } else {
                    //we shouldn't get here, except if test options about suspension have been modified
                    //in a second time: in this case update test track data and go on
                    $suspend_info = array('attempts_for_suspension' => 0);
                    $re = Track_Test::updateTrack($id_track, $suspend_info);
                    $diff_attempts = $test_info['suspension_num_attempts'];
                    cout(UIFeedback::pnotice($lang->def('_ATTEMPTS_REMAINING_BEFORE_SUSPENSION') . ' : ' . $diff_attempts) . '<br /><br />', 'content');
                }
            }
        }
        //check if the user should re-play LO in prerequisites
        if ($test_info['suspension_prerequisites']) {
            if ($prerequisite != "") {
                //check all prerequisites conditions
                $query = "SELECT idOrg FROM " . $GLOBALS['prefix_lms'] . "_organization WHERE objectType='test' AND idResource=" . (int) $test_info['idTest'];
                list($idOrg) = sql_fetch_row(sql_query($query));
                $conditions = explode(",", $prerequisite);
                $req_arr = array();
                foreach ($conditions as $condition) {
                    if (is_numeric($condition) && (int) $condition != $idOrg) {
                        $req_arr[] = $condition;
                    }
                }
                if (count($req_arr) > 0) {
                    $query = "SELECT * FROM " . $GLOBALS['prefix_lms'] . "_commontrack WHERE idReference IN (" . implode(",", $req_arr) . ") " . " AND dateAttempt>'" . $last_suspension_date . "' AND status IN ('completed','passed')";
                    $res = sql_query($query);
                    if (sql_num_rows($res) < count($req_arr)) {
                        cout(UIFeedback::pnotice($lang->def('_UNREACHED_PREREQUISITES')) . '<br /><br />', 'content');
                        cout(Form::closeForm() . '</div>', 'content');
                        return;
                    }
                }
            }
        }
    }
    //--- end suspension check -----------------------------------------------------
    if ($score_status == 'passed') {
        $incomplete = FALSE;
    } elseif ($score_status == 'valid') {
        $track_info = $play_man->getTrackAllInfo();
        if ($track_info['score'] >= $test_info['point_required']) {
            $incomplete = FALSE;
        } else {
            $incomplete = TRUE;
        }
    } else {
        $incomplete = TRUE;
    }
    if ($score_status == 'not_complete') {
        $GLOBALS['page']->add(Form::getHidden('page_continue', 'page_continue', $play_man->getLastPageSeen()), 'content');
    }
    if ($is_end) {
        $GLOBALS['page']->add(Form::getHidden('show_result', 'show_result', 1), 'content');
    }
    if ($test_info['save_keep'] && $score_status == 'not_complete') {
        $GLOBALS['page']->add('<span class="text_bold">' . $lang->def('_TEST_SAVED') . '</span><br /><br />', 'content');
    }
    $GLOBALS['page']->add('<div class="align_right">', 'content');
    if ($is_end && $show_result) {
        $GLOBALS['page']->add(Form::getButton('show_review', 'show_review', $lang->def('_TEST_SHOW_REVIEW')), 'content');
    } elseif ($test_info['save_keep'] && $score_status == 'not_complete') {
        $GLOBALS['page']->add(Form::getButton('continue', 'continue', $lang->def('_TEST_CONTINUE')), 'content');
    }
    if ($score_status == 'not_complete') {
        $GLOBALS['page']->add(Form::getButton('restart', 'restart', $lang->def('_TEST_BEGIN')), 'content');
    } elseif ($is_end) {
        if ($_SESSION['levelCourse'] > '3') {
            $GLOBALS['page']->add(Form::getButton('restart', 'restart', $lang->def('_TEST_RESTART')), 'content');
        } elseif (str_replace('incomplete', '', $prerequisite) !== $prerequisite) {
            $incomplete ? $GLOBALS['page']->add(Form::getButton('restart', 'restart', $lang->def('_TEST_RESTART')), 'content') : $GLOBALS['page']->add($lang->def('_TEST_COMPLETED'), 'content');
        } elseif (str_replace('NULL', '', $prerequisite) !== $prerequisite) {
            $score_status !== 'valid' && $score_status !== 'passed' ? $GLOBALS['page']->add(Form::getButton('restart', 'restart', $lang->def('_TEST_RESTART')), 'content') : $GLOBALS['page']->add($lang->def('_TEST_COMPLETED'), 'content');
        } else {
            $GLOBALS['page']->add(Form::getButton('restart', 'restart', $lang->def('_TEST_RESTART')), 'content');
        }
    } else {
        resetTrack($id_test, $id_track);
        $GLOBALS['page']->add(Form::getButton('begin', 'begin', $lang->def('_TEST_BEGIN')), 'content');
    }
    $GLOBALS['page']->add('</div>' . Form::closeForm() . '</div>', 'content');
}
コード例 #4
0
ファイル: coursereport.php プロジェクト: abhinay100/forma_app
function testQuestion()
{
    checkPerm('view');
    YuiLib::load(array('animation' => 'my_animation.js'));
    addJs($GLOBALS['where_lms_relative'] . '/modules/coursereport/', 'ajax.coursereport.js');
    require_once _base_ . '/lib/lib.table.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
    $lang =& DoceboLanguage::createInstance('coursereport', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    $out->add('<script type="text/javascript">' . ' setup_coursereport(\'' . $GLOBALS['where_lms_relative'] . '/ajax.server.php?plf=lms&mn=coursereport&\'); ' . '</script>', 'page_head');
    $id_test = importVar('id_test', true, 0);
    $test_man = new GroupTestManagement();
    $lev = FALSE;
    if (isset($_GET['type_filter']) && $_GET['type_filter'] != null) {
        $lev = $_GET['type_filter'];
    }
    $students = getSubscribed((int) $_SESSION['idCourse'], FALSE, $lev, TRUE, false, false, true);
    $id_students = array_keys($students);
    $quests = array();
    $answers = array();
    $tracks = array();
    $test_info = $test_man->getTestInfo(array($id_test));
    $page_title = array('index.php?modname=coursereport&amp;op=coursereport' => $lang->def('_COURSEREPORT', 'menu_course'), $test_info[$id_test]['title']);
    $out->add(getTitleArea($page_title, 'coursereport') . '<div class="std_block">');
    $query_test = "SELECT title" . " FROM " . $GLOBALS['prefix_lms'] . "_test" . " WHERE idTest = '" . $id_test . "'";
    list($titolo_test) = sql_fetch_row(sql_query($query_test));
    $query_quest = "SELECT idQuest, type_quest, title_quest" . " FROM " . $GLOBALS['prefix_lms'] . "_testquest" . " WHERE idTest = '" . $id_test . "'" . " ORDER BY sequence";
    $result_quest = sql_query($query_quest);
    while (list($id_quest, $type_quest, $title_quest) = sql_fetch_row($result_quest)) {
        $quests[$id_quest]['idQuest'] = $id_quest;
        $quests[$id_quest]['type_quest'] = $type_quest;
        $quests[$id_quest]['title_quest'] = $title_quest;
        //		$query_answer =	"SELECT idAnswer, is_correct, answer"
        //						." FROM ".$GLOBALS['prefix_lms']."_testquestanswer"
        //						." WHERE idQuest = '".$id_quest."'"
        //						." ORDER BY sequence";
        $query_answer = "SELECT tqa.idAnswer, tqa.is_correct, tqa.answer" . " FROM " . $GLOBALS['prefix_lms'] . "_testquestanswer AS tqa" . " LEFT JOIN" . " " . $GLOBALS['prefix_lms'] . "_testtrack_answer tta ON tqa.idAnswer = tta.idAnswer" . " LEFT JOIN" . " " . $GLOBALS['prefix_lms'] . "_testtrack tt ON tt.idTrack = tta.idTrack" . " WHERE tqa.idQuest = '" . $id_quest . "'";
        $query_answer .= " and tt.idUser in (" . implode(",", $id_students) . ")";
        $query_answer .= " ORDER BY tqa.sequence";
        $result_answer = sql_query($query_answer);
        while (list($id_answer, $is_correct, $answer) = sql_fetch_row($result_answer)) {
            $answers[$id_quest][$id_answer]['idAnswer'] = $id_answer;
            $answers[$id_quest][$id_answer]['is_correct'] = $is_correct;
            $answers[$id_quest][$id_answer]['answer'] = $answer;
        }
        if ($type_quest == 'choice_multiple' || $type_quest == 'choice' || $type_quest == 'inline_choice') {
            $answers[$id_quest][0]['idAnswer'] = 0;
            $answers[$id_quest][0]['is_correct'] = 0;
            $answers[$id_quest][0]['answer'] = $lang->def('_NO_ANSWER');
        }
    }
    $query_track = "SELECT idTrack" . " FROM " . $GLOBALS['prefix_lms'] . "_testtrack" . " WHERE idTest = '" . $id_test . "'" . " AND score_status = 'valid'" . " AND idUser in (" . implode(",", $id_students) . ")";
    $result_track = sql_query($query_track);
    while (list($id_track) = sql_fetch_row($result_track)) {
        $query_track_answer = "SELECT idQuest, idAnswer, more_info" . " FROM " . $GLOBALS['prefix_lms'] . "_testtrack_answer" . " WHERE idTrack = '" . $id_track . "'";
        // COMMENTATO MA NON E' CHIARO COME MAI C'E'????
        //." AND user_answer = 1";
        //print_r($query_track_answer.'<br />');
        $result_track_answer = sql_query($query_track_answer);
        //echo $query_track_answer."<br>";
        while (list($id_quest, $id_answer, $more_info) = sql_fetch_row($result_track_answer)) {
            $tracks[$id_track][$id_quest][$id_answer]['more_info'] = $more_info;
            //echo " -> ".$id_quest." - ".$id_answer." - ".$more_info."<br>";
        }
    }
    $query_total_play = "SELECT COUNT(*)" . " FROM " . $GLOBALS['prefix_lms'] . "_testtrack" . " WHERE idTest = '" . $id_test . "'" . " AND score_status = 'valid'" . " AND idUser in (" . implode(",", $id_students) . ")";
    list($total_play) = sql_fetch_row(sql_query($query_total_play));
    /*if ($total_play == 0) {
                    $query_total_play =     "SELECT COUNT(*)"
                                                    ." FROM ".$GLOBALS['prefix_lms']."_testtrack"
                                                    ." WHERE idTest = '".$id_test."' AND score_status = 'not_checked'";
                    list($total_play2) = mysql_fetch_row(mysql_query($query_total_play));
    $total_play += $total_play2;
    
            }*/
    //print_r($tracks);
    foreach ($quests as $quest) {
        switch ($quest['type_quest']) {
            case "inline_choice":
            case "hot_text":
            case "choice_multiple":
            case "choice":
                $cont_h = array($lang->def('_ANSWER'), $lang->def('_PERCENTAGE'));
                $type_h = array('', 'image nowrap');
                $tb = new Table(0, str_replace('[title]', $quest['title_quest'], $lang->def('_TABLE_QUEST')));
                $tb->setColsStyle($type_h);
                $tb->addHead($cont_h);
                foreach ($answers[$quest['idQuest']] as $answer) {
                    $cont = array();
                    if ($answer['is_correct']) {
                        $txt = '<img src="' . getPathImage('lms') . 'standard/publish.png" alt="' . $lang->def('_ANSWER_CORRECT') . '" title="' . $lang->def('_ANSWER_CORRECT') . '" align="left" /> ';
                    } else {
                        $txt = '';
                    }
                    $cont[] = '<p>' . $txt . ' ' . $answer['answer'] . '</p>';
                    $answer_given = 0;
                    reset($tracks);
                    $i = 0;
                    foreach ($tracks as $track) {
                        $i++;
                        if (isset($track[$quest['idQuest']][$answer['idAnswer']])) {
                            $answer_given++;
                        } elseif (!isset($track[$quest['idQuest']]) && $answer['idAnswer'] == 0) {
                            $answer_given++;
                        }
                    }
                    if ($answer['idAnswer'] == 0 && $i < $total_play) {
                        //			if ($i < $total_play) {
                        $answer_given = $answer_given + ($total_play - $i);
                    }
                    if ($total_play > 0) {
                        $percentage = $answer_given / $total_play * 100;
                    } else {
                        $percentage = 0;
                    }
                    $percentage = number_format($percentage, 2);
                    $cont[] = Util::draw_progress_bar($percentage, true, false, false, false, false);
                    $tb->addBody($cont);
                }
                $out->add($tb->getTable() . '<br/>');
                break;
            case "upload":
            case "extended_text":
                $out->add('<div>');
                $out->add('<p><a href="#" onclick="getQuestDetail(' . $quest['idQuest'] . ', ' . $id_test . ', \'' . $quest['type_quest'] . '\'); return false;" id="more_quest_' . $quest['idQuest'] . '"><img src="' . getPathImage('fw') . 'standard/more.gif" alt="' . $lang->def('_MORE_INFO') . '" />' . str_replace('[title]', $quest['title_quest'], $lang->def('_TABLE_QUEST_LIST')) . '</a></p>');
                $out->add('<p><a href="#" onclick="closeQuestDetail(' . $quest['idQuest'] . '); return false;" id="less_quest_' . $quest['idQuest'] . '" style="display:none"><img src="' . getPathImage('fw') . 'standard/less.gif" alt="' . $lang->def('_CLOSE') . '" />' . str_replace('[title]', $quest['title_quest'], $lang->def('_TABLE_QUEST_LIST')) . '</a></p>');
                $out->add('</div>');
                $out->add('<div id="quest_' . $quest['idQuest'] . '">');
                $out->add('</div>');
                break;
            case "text_entry":
                $cont_h = array($lang->def('_PERCENTAGE_CORRECT'));
                $type_h = array('align-center');
                $tb = new Table(0, str_replace('[title]', $quest['title_quest'], $lang->def('_TABLE_QUEST_CORRECT_TXT')));
                $tb->setColsStyle($type_h);
                $tb->addHead($cont_h);
                foreach ($answers[$quest['idQuest']] as $answer) {
                    $cont = array();
                    $answer_correct = 0;
                    foreach ($tracks as $track) {
                        if ($track[$quest['idQuest']][$answer['idAnswer']]['more_info'] === $answer['answer']) {
                            $answer_correct++;
                        }
                    }
                    $percentage = $answer_correct / $total_play * 100;
                    $percentage = number_format($percentage, 2);
                    $cont[] = Util::draw_progress_bar($percentage, true, false, false, false, false);
                    $tb->addBody($cont);
                }
                $out->add($tb->getTable() . '<br/>');
                break;
            case "associate":
                $cont_h = array($lang->def('_ANSWER'), $lang->def('_PERCENTAGE_CORRECT'));
                $type_h = array('', 'align-center');
                $tb = new Table(0, str_replace('[title]', $quest['title_quest'], $lang->def('_TABLE_QUEST_CORRECT_ASS')));
                $tb->setColsStyle($type_h);
                $tb->addHead($cont_h);
                foreach ($answers[$quest['idQuest']] as $answer) {
                    $cont = array();
                    $cont[] = $answer['answer'];
                    $answer_correct = 0;
                    foreach ($tracks as $track) {
                        if ($track[$quest['idQuest']][$answer['idAnswer']]['more_info'] === $answer['is_correct']) {
                            $answer_correct++;
                        }
                    }
                    $percentage = $answer_correct / $total_play * 100;
                    echo "risp corrette: " . $answer_correct . " totale: " . $total_play;
                    $percentage = number_format($percentage, 2);
                    $cont[] = Util::draw_progress_bar($percentage, true, false, false, false, false);
                    $tb->addBody($cont);
                }
                $out->add($tb->getTable() . '<br/>');
                break;
        }
        reset($answers);
        reset($tracks);
    }
    $out->add('</div>');
}
コード例 #5
0
ファイル: lib.orgchart.php プロジェクト: abhinay100/forma_app
 function getFinalObjectScore($arr_user, $arr_course = false)
 {
     $l_obj = array();
     $r_obj = array();
     $score = array();
     $query_lo = "\r\n\t\tSELECT idOrg, idResource, objectType, idCourse  \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_organization \r\n\t\tWHERE milestone = 'end' " . (!empty($arr_course) ? " AND idCourse IN ( " . implode(',', $arr_course) . " )" : "") . " ";
     $re_lo = sql_query($query_lo);
     while (list($id_org, $id_resource, $obj_type, $id_course) = sql_fetch_row($re_lo)) {
         $l_obj[$obj_type][$id_resource] = $id_resource;
         $r_obj[$obj_type][$id_org] = $id_org;
         $course_obj_assoc[$obj_type][$id_resource] = $id_course;
         $course_org_assoc[$obj_type][$id_org] = $id_course;
     }
     $obj_types = array_keys($l_obj);
     while (list(, $type) = each($obj_types)) {
         switch ($type) {
             case "scormorg":
                 require_once $GLOBALS['where_lms'] . '/lib/lib.scorm.php';
                 $group_test = new GroupScormObjMan();
                 $scorm_score =& $group_test->getSimpleScormScores($r_obj['scormorg'], $arr_user);
                 while (list($id_test, $scorm_info) = each($scorm_score)) {
                     $idc = $course_org_assoc['scormorg'][$id_test];
                     $score[$idc] = $scorm_info;
                 }
                 break;
                 // ------------------------------------------------------------
             // ------------------------------------------------------------
             case "test":
                 require_once $GLOBALS['where_lms'] . '/lib/lib.test.php';
                 $group_test = new GroupTestManagement();
                 $test_score =& $group_test->getSimpleTestsScores($l_obj['test'], $arr_user);
                 while (list($id_test, $test_info) = each($test_score)) {
                     $idc = $course_obj_assoc['test'][$id_test];
                     $score[$idc] = $test_info;
                 }
                 break;
         }
     }
     return $score;
 }