Ejemplo n.º 1
0
function asci_graph($r)
{
    $width = 40;
    $max = max($r);
    $ratio = $width / $max;
    $sum = array_sum($r);
    $ret[] = array('valeur', 'nombre', 'pourcentage', 'graph');
    foreach ($r as $k => $v) {
        $ret[] = array($k, $v, round($v / $sum * 100, 2) . '%', draw_bar($v * $ratio));
    }
    //$ret[]=array('total',$sum,'','');
    return $ret;
}
Ejemplo n.º 2
0
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');
    }
}