$expmode = intval($_REQUEST['expmode']);
    $module_id = intval($_REQUEST['module_id']);
    $subject_id = intval($_REQUEST['subject_id']);
} else {
    exit;
}
// check user's authorization for module
if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $module_id, 'module_user_id')) {
    exit;
}
$show_answers = true;
if (isset($_REQUEST['hide_answers']) and $_REQUEST['hide_answers'] == 1) {
    $show_answers = false;
}
$doc_title = unhtmlentities($l['t_questions_list']);
$doc_description = F_compact_string(unhtmlentities($l['hp_select_all_questions']));
$page_elements = 6;
$qtype = array('S', 'M', 'T', '0');
// question types
$qright = array(' ', '*');
// question types
// --- create pdf document
if ($l['a_meta_dir'] == 'rtl') {
    $dirlabel = 'L';
    $dirvalue = 'R';
} else {
    $dirlabel = 'R';
    $dirvalue = 'L';
}
$isunicode = strcasecmp($l['a_meta_charset'], 'UTF-8') == 0;
//create new PDF document (document units are set by default to millimeters)
Ejemplo n.º 2
0
    exit;
}
if (isset($_REQUEST['testid'])) {
    $test_id = intval($_REQUEST['testid']);
} else {
    echo $l['m_authorization_denied'];
    exit;
}
$testdata = F_getTestData($test_id);
if (!F_getBoolean($testdata['test_report_to_users'])) {
    echo $l['m_authorization_denied'];
    exit;
}
$user_id = intval($_SESSION['session_user_id']);
$doc_title = unhtmlentities($l['t_result_user']);
$doc_description = F_compact_string(unhtmlentities($l['hp_result_user']));
$page_elements = 7;
$temp_order_field = '';
$qtype = array('S', 'M', 'T', 'O');
// question types
// --- create pdf document
if ($l['a_meta_dir'] == 'rtl') {
    $dirlabel = 'L';
    $dirvalue = 'R';
} else {
    $dirlabel = 'R';
    $dirvalue = 'L';
}
$isunicode = strcasecmp($l['a_meta_charset'], 'UTF-8') == 0;
//create new PDF document (document units are set by default to millimeters)
$pdf = new TCPDFEX(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, $isunicode);
Ejemplo n.º 3
0
if (isset($_REQUEST['test_id']) and $_REQUEST['test_id'] > 0) {
    $test_id = intval($_REQUEST['test_id']);
    // check user's authorization
    if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
        exit;
    }
} else {
    exit;
}
if (isset($_REQUEST['num'])) {
    $test_num = intval($_REQUEST['num']);
} else {
    $test_num = 1;
}
$doc_title = unhtmlentities($l['w_test']);
$doc_description = F_compact_string(unhtmlentities($l['h_test']));
$page_elements = 6;
$qtype = array('S', 'M', 'T', 'O');
// question types
// --- create pdf document
if ($l['a_meta_dir'] == 'rtl') {
    $dirlabel = 'L';
    $dirvalue = 'R';
} else {
    $dirlabel = 'R';
    $dirvalue = 'L';
}
$isunicode = strcasecmp($l['a_meta_charset'], 'UTF-8') == 0;
//create new PDF document (document units are set by default to millimeters)
$pdf = new TCPDFEX(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, $isunicode);
// set header backlink QR-Code
Ejemplo n.º 4
0
/**
 * Converts tcecode text to simple string for XHTML title attribute.
 * @param $str (string) text to process
 * return string
 */
function F_tcecodeToTitle($str)
{
    require_once '../config/tce_config.php';
    global $l;
    $str = F_remove_tcecode($str);
    $str = F_compact_string($str);
    $str = htmlspecialchars($str, ENT_COMPAT, $l['a_meta_charset']);
    return $str;
}
        echo '<td class="numeric">' . $usrtestdata['unanswered'] . '&nbsp;' . F_formatPercentage($usrtestdata['unanswered'] / $usrtestdata['all']) . '</td>' . K_NEWLINE;
        echo '<td class="numeric">' . $usrtestdata['undisplayed'] . '&nbsp;' . F_formatPercentage($usrtestdata['undisplayed'] / $usrtestdata['all']) . '</td>' . K_NEWLINE;
        echo '<td class="numeric">' . $usrtestdata['unrated'] . '&nbsp;' . F_formatPercentage($usrtestdata['unrated'] / $usrtestdata['all']) . '</td>' . K_NEWLINE;
        if ($mr['testuser_status'] == 4) {
            echo '<td style="background-color:#FFBBBB;">' . $l['w_locked'];
        } else {
            echo '<td style="background-color:#BBFFBB;">' . $l['w_unlocked'];
        }
        // remaining user time in minutes
        $remaining_time = round((time() - strtotime($usrtestdata['time']) - $test_duration_time) / K_SECONDS_IN_MINUTE);
        if ($remaining_time < 0) {
            echo ' (' . $remaining_time . ')';
        }
        echo '</td>' . K_NEWLINE;
        if (!empty($usrtestdata['comment'])) {
            echo '<td title="' . substr(F_compact_string(htmlspecialchars($usrtestdata['comment'], ENT_NOQUOTES, $l['a_meta_charset'])), 0, 255) . '">' . $l['w_yes'] . '</td>' . K_NEWLINE;
        } else {
            echo '<td>&nbsp;</td>' . K_NEWLINE;
        }
        echo '</tr>' . K_NEWLINE;
        // collects data for descriptive statistics
        $statsdata['score'][] = $mr['total_score'];
        $statsdata['right'][] = $usrtestdata['right'];
        $statsdata['wrong'][] = $usrtestdata['wrong'];
        $statsdata['unanswered'][] = $usrtestdata['unanswered'];
        $statsdata['undisplayed'][] = $usrtestdata['undisplayed'];
        $statsdata['unrated'][] = $usrtestdata['unrated'];
    }
} else {
    F_display_db_error();
}
Ejemplo n.º 6
0
/**
* Returns test stats as HTML table
* @param $data (array) Array containing test statistics.
* @param $nextorderdir (int) next order direction.
* @param $order_field (string) order fields.
* @param $filter (string) filter string for URLs.
* @param $pubmode (boolean) If true filter the results for the public interface.
* @param $stats (int) 2 = full stats; 1 = user stats; 0 = disabled stats;
* return HTML table string.
*/
function F_printTestResultStat($data, $nextorderdir, $order_field, $filter, $pubmode = false, $stats = 1)
{
    require_once '../config/tce_config.php';
    global $db, $l;
    if (empty($data['num_records'])) {
        return;
    }
    if ($l['a_meta_dir'] == 'rtl') {
        $tdalignr = 'left';
        $tdalign = 'right';
    } else {
        $tdalignr = 'right';
        $tdalign = 'left';
    }
    $ret = '';
    $ret .= '<table class="userselect">' . K_NEWLINE;
    $ret .= '<tr>' . K_NEWLINE;
    $ret .= '<th>&nbsp;</th>' . K_NEWLINE;
    $ret .= '<th>#</th>' . K_NEWLINE;
    $ret .= F_select_table_header_element('testuser_creation_time', $nextorderdir, $l['h_time_begin'], $l['w_time_begin'], $order_field, $filter);
    //$ret .= F_select_table_header_element('testuser_end_time', $nextorderdir, $l['h_time_end'], $l['w_time_end'], $order_field, $filter);
    $ret .= '<th title="' . $l['h_test_time'] . '">' . $l['w_time'] . '</th>' . K_NEWLINE;
    $ret .= F_select_table_header_element('testuser_test_id', $nextorderdir, $l['h_test'], $l['w_test'], $order_field, $filter);
    if (!$pubmode) {
        $ret .= F_select_table_header_element('user_name', $nextorderdir, $l['h_login_name'], $l['w_user'], $order_field, $filter);
        $ret .= F_select_table_header_element('user_lastname', $nextorderdir, $l['h_lastname'], $l['w_lastname'], $order_field, $filter);
        $ret .= F_select_table_header_element('user_firstname', $nextorderdir, $l['h_firstname'], $l['w_firstname'], $order_field, $filter);
    }
    $ret .= F_select_table_header_element('total_score', $nextorderdir, $l['h_score_total'], $l['w_score'], $order_field, $filter);
    if ($stats > 0) {
        $ret .= '<th title="' . $l['h_answers_right'] . '">' . $l['w_answers_right'] . '</th>' . K_NEWLINE;
        $ret .= '<th title="' . $l['h_answers_wrong'] . '">' . $l['w_answers_wrong'] . '</th>' . K_NEWLINE;
        $ret .= '<th title="' . $l['h_questions_unanswered'] . '">' . $l['w_questions_unanswered'] . '</th>' . K_NEWLINE;
        $ret .= '<th title="' . $l['h_questions_undisplayed'] . '">' . $l['w_questions_undisplayed'] . '</th>' . K_NEWLINE;
        $ret .= '<th title="' . $l['h_questions_unrated'] . '">' . $l['w_questions_unrated'] . '</th>' . K_NEWLINE;
    }
    $ret .= '<th title="' . $l['w_status'] . ' (' . $l['w_time'] . ' [' . $l['w_minutes'] . '])">' . $l['w_status'] . ' (' . $l['w_time'] . ' [' . $l['w_minutes'] . '])</th>' . K_NEWLINE;
    $ret .= '<th title="' . $l['h_testcomment'] . '">' . $l['w_comment'] . '</th>' . K_NEWLINE;
    $ret .= '</tr>' . K_NEWLINE;
    foreach ($data['testuser'] as $tu) {
        $ret .= '<tr>';
        $ret .= '<td>';
        $ret .= '<input type="checkbox" name="testuserid' . $tu['num'] . '" id="testuserid' . $tu['num'] . '" value="' . $tu['id'] . '" title="' . $l['w_select'] . '"';
        if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) {
            $ret .= ' checked="checked"';
        }
        $ret .= ' />';
        $ret .= '</td>' . K_NEWLINE;
        if (!$pubmode or F_getBoolean($tu['test']['test_report_to_users'])) {
            $ret .= '<td><a href="tce_show_result_user.php?testuser_id=' . $tu['id'] . '&amp;test_id=' . $tu['test']['test_id'] . '&amp;user_id=' . $tu['user_id'] . '" title="' . $l['h_view_details'] . '">' . $tu['num'] . '</a></td>' . K_NEWLINE;
        } else {
            $ret .= '<td>' . $tu['num'] . '</td>' . K_NEWLINE;
        }
        $ret .= '<td style="text-align:center;">' . $tu['testuser_creation_time'] . '</td>' . K_NEWLINE;
        //$ret .= '<td style="text-align:center;">'.$tu['testuser_end_time'].'</td>'.K_NEWLINE;
        $ret .= '<td style="text-align:center;">' . $tu['time_diff'] . '</td>' . K_NEWLINE;
        $passmsg = '';
        if ($tu['passmsg'] === true) {
            $passmsg = ' title="' . $l['w_passed'] . '" style="background-color:#BBFFBB;"';
        } elseif ($tu['passmsg'] === false) {
            $passmsg = ' title="' . $l['w_not_passed'] . '" style="background-color:#FFBBBB;"';
        }
        if ($pubmode) {
            $ret .= '<td style="text-align:' . $tdalign . ';">' . $tu['test']['test_name'] . '</td>' . K_NEWLINE;
        } else {
            $ret .= '<td style="text-align:' . $tdalign . ';"><a href="tce_edit_test.php?test_id=' . $tu['test']['test_id'] . '">' . $tu['test']['test_name'] . '</a></td>' . K_NEWLINE;
            $ret .= '<td style="text-align:' . $tdalign . ';"><a href="tce_edit_user.php?user_id=' . $tu['user_id'] . '">' . $tu['user_name'] . '</a></td>' . K_NEWLINE;
            $ret .= '<td style="text-align:' . $tdalign . ';">&nbsp;' . $tu['user_lastname'] . '</td>' . K_NEWLINE;
            $ret .= '<td style="text-align:' . $tdalign . ';">&nbsp;' . $tu['user_firstname'] . '</td>' . K_NEWLINE;
        }
        $ret .= '<td' . $passmsg . ' class="numeric">' . F_formatFloat($tu['total_score']) . '&nbsp;' . F_formatPercentage($tu['total_score_perc'], false) . '</td>' . K_NEWLINE;
        if ($stats > 0) {
            $ret .= '<td class="numeric">' . $tu['right'] . '&nbsp;' . F_formatPercentage($tu['right_perc'], false) . '</td>' . K_NEWLINE;
            $ret .= '<td class="numeric">' . $tu['wrong'] . '&nbsp;' . F_formatPercentage($tu['wrong_perc'], false) . '</td>' . K_NEWLINE;
            $ret .= '<td class="numeric">' . $tu['unanswered'] . '&nbsp;' . F_formatPercentage($tu['unanswered_perc'], false) . '</td>' . K_NEWLINE;
            $ret .= '<td class="numeric">' . $tu['undisplayed'] . '&nbsp;' . F_formatPercentage($tu['undisplayed_perc'], false) . '</td>' . K_NEWLINE;
            $ret .= '<td class="numeric">' . $tu['unrated'] . '&nbsp;' . F_formatPercentage($tu['unrated_perc'], false) . '</td>' . K_NEWLINE;
        }
        if ($tu['locked']) {
            $ret .= '<td style="background-color:#FFBBBB;">' . $l['w_locked'];
        } else {
            $ret .= '<td style="background-color:#BBFFBB;">' . $l['w_unlocked'];
        }
        if ($tu['remaining_time'] < 0) {
            $ret .= ' (' . $tu['remaining_time'] . ')';
        }
        $ret .= '</td>' . K_NEWLINE;
        if (!empty($tu['user_comment'])) {
            $ret .= '<td title="' . substr(F_compact_string(htmlspecialchars($tu['user_comment'], ENT_NOQUOTES, $l['a_meta_charset'])), 0, 255) . '">' . $l['w_yes'] . '</td>' . K_NEWLINE;
        } else {
            $ret .= '<td>&nbsp;</td>' . K_NEWLINE;
        }
        $ret .= '</tr>' . K_NEWLINE;
    }
    $ret .= '<tr>';
    $colspan = 16;
    if ($pubmode) {
        $colspan -= 3;
    }
    if ($stats == 0) {
        $colspan -= 5;
    }
    $ret .= '<td colspan="' . $colspan . '" style="text-align:' . $tdalign . ';font-weight:bold;padding-right:10px;padding-left:10px;';
    if ($data['passed_perc'] > 50) {
        $ret .= ' background-color:#BBFFBB;"';
    } else {
        $ret .= ' background-color:#FFBBBB;"';
    }
    $ret .= '>' . $l['w_passed'] . ': ' . $data['passed'] . ' ' . F_formatPercentage($data['passed_perc'], false) . '</td>' . K_NEWLINE;
    $ret .= '</tr>';
    // print statistics
    $printstat = array('mean', 'median', 'mode', 'standard_deviation', 'skewness', 'kurtosi');
    $noperc = array('skewness', 'kurtosi');
    foreach ($data['statistics'] as $row => $col) {
        if (in_array($row, $printstat)) {
            $ret .= '<tr>';
            $scolspan = 8;
            if ($pubmode) {
                $scolspan -= 3;
            }
            $ret .= '<th colspan="' . $scolspan . '" style="text-align:' . $tdalignr . ';">' . $l['w_' . $row] . '</th>' . K_NEWLINE;
            if (in_array($row, $noperc)) {
                $ret .= '<td class="numeric">' . F_formatFloat($col['score_perc']) . '</td>' . K_NEWLINE;
                if ($stats > 0) {
                    $ret .= '<td class="numeric">' . F_formatFloat($col['right_perc']) . '</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . F_formatFloat($col['wrong_perc']) . '</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . F_formatFloat($col['unanswered_perc']) . '</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . F_formatFloat($col['undisplayed_perc']) . '</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . F_formatFloat($col['unrated_perc']) . '</td>' . K_NEWLINE;
                }
            } else {
                $ret .= '<td class="numeric">' . round($col['score_perc']) . '%</td>' . K_NEWLINE;
                if ($stats > 0) {
                    $ret .= '<td class="numeric">' . round($col['right_perc']) . '%</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . round($col['wrong_perc']) . '%</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . round($col['unanswered_perc']) . '%</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . round($col['undisplayed_perc']) . '%</td>' . K_NEWLINE;
                    $ret .= '<td class="numeric">' . round($col['unrated_perc']) . '%</td>' . K_NEWLINE;
                }
            }
            $ret .= '<td colspan="2">&nbsp;</td>' . K_NEWLINE;
            $ret .= '</tr>';
        }
    }
    $ret .= '</table>' . K_NEWLINE;
    return $ret;
}
/**
 * Export all test results to CSV.
 * @author Nicola Asuni
 * @since 2006-03-30
 * @param $test_id (int) Test ID
 * @param $group_id (int) Group ID
 * @param $order_field (string) ORDER BY portion of the SQL query
 * @return CSV data
 */
function F_csv_export_result_allusers($test_id, $group_id = 0, $order_field = "")
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_authorization.php';
    require_once '../../shared/code/tce_functions_test_stats.php';
    require_once 'tce_functions_user_select.php';
    require_once '../code/tce_functions_statistics.php';
    $test_id = intval($test_id);
    $group_id = intval($group_id);
    $order_field = F_escape_sql($order_field);
    // check user's authorization
    if (!F_isAuthorizedUser(K_TABLE_TESTS, 'test_id', $test_id, 'test_user_id')) {
        return '';
    }
    if (!F_isAuthorizedEditorForGroup($group_id)) {
        return '';
    }
    // statistical data
    $statsdata = array();
    $statsdata['score'] = array();
    $statsdata['right'] = array();
    $statsdata['wrong'] = array();
    $statsdata['unanswered'] = array();
    $statsdata['undisplayed'] = array();
    $statsdata['unrated'] = array();
    $csv = '';
    // CSV data to be returned
    // general data
    $csv .= 'TCExam Results Summary' . K_NEWLINE . K_NEWLINE;
    $csv .= 'version' . K_TAB . K_TCEXAM_VERSION . K_NEWLINE;
    $csv .= 'lang' . K_TAB . K_USER_LANG . K_NEWLINE;
    $csv .= 'date' . K_TAB . date(K_TIMESTAMP_FORMAT) . K_NEWLINE;
    $csv .= 'test_id' . K_TAB . $test_id . K_NEWLINE;
    $csv .= 'group_id' . K_TAB . $group_id . K_NEWLINE;
    $csv .= K_NEWLINE . K_NEWLINE;
    // separator
    // print column names
    $csv .= '#';
    $csv .= K_TAB . $l['w_time_begin'];
    $csv .= K_TAB . $l['w_time_end'];
    $csv .= K_TAB . $l['w_time'];
    $csv .= K_TAB . $l['w_lastname'];
    $csv .= K_TAB . $l['w_firstname'];
    $csv .= K_TAB . $l['w_user'];
    $csv .= K_TAB . $l['w_passed'];
    $csv .= K_TAB . $l['w_score'];
    $csv .= K_TAB . $l['w_answers_right'];
    $csv .= K_TAB . $l['w_answers_wrong'];
    $csv .= K_TAB . $l['w_questions_unanswered'];
    $csv .= K_TAB . $l['w_questions_undisplayed'];
    $csv .= K_TAB . $l['w_questions_unrated'];
    $csv .= K_TAB . $l['w_comment'];
    $passed = 0;
    // output users stats
    $sqlr = 'SELECT
		testuser_id,
		testuser_creation_time,
		user_id,
		user_lastname,
		user_firstname,
		user_name,
		SUM(testlog_score) AS total_score,
		MAX(testlog_change_time) AS testuser_end_time
		FROM ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_USERS . '
		WHERE testlog_testuser_id=testuser_id
			AND testuser_user_id=user_id
			AND testuser_test_id=' . $test_id . '';
    if ($group_id > 0) {
        $sqlr .= ' AND testuser_user_id IN (
				SELECT usrgrp_user_id
				FROM ' . K_TABLE_USERGROUP . '
				WHERE usrgrp_group_id=' . $group_id . '
			)';
    }
    if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
        $sqlr .= ' AND (user_level<' . $_SESSION['session_user_level'] . ' OR user_id=' . $_SESSION['session_user_id'] . ')';
    }
    $sqlr .= ' GROUP BY testuser_id, testuser_creation_time, user_id, user_lastname, user_firstname, user_name
		ORDER BY ' . $order_field . '';
    if ($rr = F_db_query($sqlr, $db)) {
        $itemcount = 0;
        while ($mr = F_db_fetch_array($rr)) {
            $itemcount++;
            $csv .= K_NEWLINE . $itemcount;
            $csv .= K_TAB . $mr['testuser_creation_time'];
            $csv .= K_TAB . $mr['testuser_end_time'];
            $time_diff = strtotime($mr['testuser_end_time']) - strtotime($mr['testuser_creation_time']);
            //sec
            $time_diff = gmdate('H:i:s', $time_diff);
            $csv .= K_TAB . $time_diff;
            $csv .= K_TAB . $mr['user_lastname'];
            $csv .= K_TAB . $mr['user_firstname'];
            $csv .= K_TAB . $mr['user_name'];
            $usrtestdata = F_getUserTestStat($test_id, $mr['user_id']);
            $halfscore = $usrtestdata['max_score'] / 2;
            if ($usrtestdata['score_threshold'] > 0) {
                if ($usrtestdata['score'] >= $usrtestdata['score_threshold']) {
                    $csv .= K_TAB . 'true';
                    $passed++;
                } else {
                    $csv .= K_TAB . 'false';
                }
            } else {
                $csv .= K_TAB;
                if ($usrtestdata['score'] > $halfscore) {
                    $passed++;
                }
            }
            $csv .= K_TAB . $mr['total_score'];
            $csv .= K_TAB . $usrtestdata['right'];
            $csv .= K_TAB . $usrtestdata['wrong'];
            $csv .= K_TAB . $usrtestdata['unanswered'];
            $csv .= K_TAB . $usrtestdata['undisplayed'];
            $csv .= K_TAB . $usrtestdata['unrated'];
            $csv .= K_TAB . F_compact_string(htmlspecialchars($usrtestdata['comment'], ENT_NOQUOTES, $l['a_meta_charset']));
            // collects data for descriptive statistics
            $statsdata['score'][] = $mr['total_score'] / $usrtestdata['max_score'];
            $statsdata['right'][] = $usrtestdata['right'] / $usrtestdata['all'];
            $statsdata['wrong'][] = $usrtestdata['wrong'] / $usrtestdata['all'];
            $statsdata['unanswered'][] = $usrtestdata['unanswered'] / $usrtestdata['all'];
            $statsdata['undisplayed'][] = $usrtestdata['undisplayed'] / $usrtestdata['all'];
            $statsdata['unrated'][] = $usrtestdata['unrated'] / $usrtestdata['all'];
        }
    } else {
        F_display_db_error();
    }
    $csv .= K_NEWLINE;
    // separator
    // calculate statistics
    $stats = F_getArrayStatistics($statsdata);
    $excludestat = array('sum', 'variance');
    $calcpercent = array('mean', 'median', 'mode', 'minimum', 'maximum', 'range', 'standard_deviation');
    $csv .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . 'passed_total' . K_TAB . $passed . K_NEWLINE;
    $csv .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . 'passed_percent [%]' . K_TAB . round(100 * ($passed / $itemcount)) . K_NEWLINE;
    $csv .= K_NEWLINE;
    // separator
    $csv .= $l['w_statistics'] . K_NEWLINE;
    // separator
    // headers
    $csv .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB;
    $csv .= $l['w_score'] . K_TAB;
    $csv .= $l['w_answers_right_th'] . K_TAB;
    $csv .= $l['w_answers_wrong_th'] . K_TAB;
    $csv .= $l['w_questions_unanswered_th'] . K_TAB;
    $csv .= $l['w_questions_undisplayed_th'] . K_TAB;
    $csv .= $l['w_questions_unrated'] . K_NEWLINE;
    foreach ($stats as $row => $columns) {
        if (!in_array($row, $excludestat)) {
            $csv .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . $l['w_' . $row] . K_TAB;
            $csv .= round($columns['score'], 3) . K_TAB;
            $csv .= round($columns['right'], 3) . K_TAB;
            $csv .= round($columns['wrong'], 3) . K_TAB;
            $csv .= round($columns['unanswered'], 3) . K_TAB;
            $csv .= round($columns['undisplayed'], 3) . K_TAB;
            $csv .= round($columns['unrated'], 3) . K_NEWLINE;
            if (in_array($row, $calcpercent)) {
                $csv .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . $row . ' [%]' . K_TAB;
                $csv .= round(100 * ($columns['score'] / $usrtestdata['max_score'])) . K_TAB;
                $csv .= round(100 * ($columns['right'] / $usrtestdata['all'])) . K_TAB;
                $csv .= round(100 * ($columns['wrong'] / $usrtestdata['all'])) . K_TAB;
                $csv .= round(100 * ($columns['unanswered'] / $usrtestdata['all'])) . K_TAB;
                $csv .= round(100 * ($columns['undisplayed'] / $usrtestdata['all'])) . K_TAB;
                $csv .= round(100 * ($columns['unrated'] / $usrtestdata['all'])) . K_NEWLINE;
            }
        }
    }
    return $csv;
}
Ejemplo n.º 8
0
/**
 * Get an object description in dot format for graphviz.
 * @param $obj_id (int) ID of parent object.
 * @param $obj_level (int) Nesting level.
 * @return string dot map.
 */
function F_get_object_dot_map($obj_id, $obj_level)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    include '../../shared/code/htmlcolors.php';
    $dot = '';
    $spacer = str_repeat(K_TAB, $obj_level);
    $spacerb = $spacer . K_TAB;
    // get object data
    $sqlobj = 'SELECT * FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECT_TYPES . ' WHERE obj_obt_id=obt_id AND obj_id=' . $obj_id . ' ORDER BY obj_name ASC';
    if ($robj = F_db_query($sqlobj, $db)) {
        $mobj = F_db_fetch_array($robj);
    } else {
        F_display_db_error();
    }
    $color = array_keys(TCPDF_COLORS::$webcolor, $mobj['obt_color']);
    if (!empty($color) and isset($color[0])) {
        $color = $color[0];
    } else {
        $color = 'white';
    }
    if (F_count_rows(K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP, 'WHERE omp_child_obj_id=obj_id AND omp_parent_obj_id=' . $obj_id) > 0) {
        // CLUSTER
        $dot .= $spacer . 'subgraph clusterOBJ' . $mobj['obj_id'] . ' {' . K_NEWLINE;
        $dot .= $spacerb . 'color=' . (getContrastColor(TCPDF_COLORS::$webcolor[$color]) == '000000' ? 'black' : 'white') . ';' . K_NEWLINE;
        $dot .= $spacerb . 'bgcolor=' . $color . ';' . K_NEWLINE;
        $dot .= $spacerb . 'label="' . F_compact_string($mobj['obj_name'], true) . '";' . K_NEWLINE;
        $dot .= $spacerb . 'URL="tce_view_object?obj_id=' . $mobj['obj_id'] . '";' . K_NEWLINE;
        $dot .= $spacerb . 'tooltip="' . F_compact_string($mobj['obj_description'] . ' - ' . $mobj['obj_label'] . ' - ' . $mobj['obj_tag'], true) . '";' . K_NEWLINE;
        $dot .= $spacerb . 'node [shape=circle,style=filled,color=black,fontname=Helvetica,fontsize=12,fontcolor=black];' . K_NEWLINE;
        // for each child
        $sql = 'SELECT obj_id, obj_name, obj_label, obj_tag FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . ' WHERE omp_child_obj_id=obj_id AND omp_parent_obj_id=' . $obj_id . ' ORDER BY obj_name ASC';
        if ($r = F_db_query($sql, $db)) {
            while ($m = F_db_fetch_array($r)) {
                $dot .= F_get_object_dot_map($m['obj_id'], $obj_level + 1);
            }
        } else {
            F_display_db_error();
        }
        $dot .= $spacer . '}' . K_NEWLINE;
    } else {
        // NODE
        $dot .= $spacer . 'OBJ' . $mobj['obj_id'] . ' [fillcolor=' . $color . ',label="' . F_compact_string($mobj['obj_name'], true) . '",URL="tce_edit_objects.php?obj_id=' . $mobj['obj_id'] . '",tooltip="' . F_compact_string($mobj['obj_description'] . ' - ' . $mobj['obj_label'] . ' - ' . $mobj['obj_tag'], true) . '"];' . K_NEWLINE;
    }
    return $dot;
}