Пример #1
0
     $topicresults[$mq['module_id']]['subjects'][$mq['subject_id']]['undisplayed'] += 1;
 }
 // number of free-text unrated questions
 if (strlen($mq['testlog_score']) <= 0) {
     $topicresults[$mq['module_id']]['unrated'] += 1;
     $topicresults[$mq['module_id']]['subjects'][$mq['subject_id']]['unrated'] += 1;
 }
 // score
 $topicresults[$mq['module_id']]['score'] += $mq['testlog_score'];
 $topicresults[$mq['module_id']]['subjects'][$mq['subject_id']]['score'] += $mq['testlog_score'];
 // max score
 $topicresults[$mq['module_id']]['maxscore'] += $question_max_score;
 $topicresults[$mq['module_id']]['subjects'][$mq['subject_id']]['maxscore'] += $question_max_score;
 $pdf->Cell($data_cell_width_third, $data_cell_height, $itemcount . ' ' . $qtype[$mq['question_type'] - 1], 'LTRB', 0, $dirvalue, 0);
 $pdf->Cell($data_cell_width, $data_cell_height, $mq['testlog_score'], 'LTRB', 0, 'C', 0);
 $pdf->Cell($data_cell_width, $data_cell_height, getIpAsString($mq['testlog_user_ip']), 'LTRB', 0, 'C', 0);
 if (isset($mq['testlog_display_time']) and strlen($mq['testlog_display_time']) > 0) {
     $display_time = substr($mq['testlog_display_time'], 11, 8);
 } else {
     $display_time = '--:--:--';
 }
 if (isset($mq['testlog_change_time']) and strlen($mq['testlog_change_time']) > 0) {
     $change_time = substr($mq['testlog_change_time'], 11, 8);
 } else {
     $change_time = '--:--:--';
 }
 if (isset($mq['testlog_display_time']) and isset($mq['testlog_change_time'])) {
     $diff_time = date('i:s', strtotime($mq['testlog_change_time']) - strtotime($mq['testlog_display_time']));
 } else {
     $diff_time = '--:--';
 }
Пример #2
0
/**
* Returns user test stats as HTML table
* @param $testuser_id (int) test-user ID - if greater than zero, filter stats for the specified test-user.
* return $data string containing HTML table.
*/
function F_printUserTestStat($testuser_id)
{
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_tcecode.php';
    global $db, $l;
    $testuser_id = intval($testuser_id);
    $ret = '';
    // display user questions
    $sql = 'SELECT *
		FROM ' . K_TABLE_QUESTIONS . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_MODULES . '
		WHERE question_id=testlog_question_id
			AND testlog_testuser_id=' . $testuser_id . '
			AND question_subject_id=subject_id
			AND subject_module_id=module_id
		ORDER BY testlog_id';
    if ($r = F_db_query($sql, $db)) {
        $ret .= '<ol class="question">' . K_NEWLINE;
        while ($m = F_db_fetch_array($r)) {
            $ret .= '<li>' . K_NEWLINE;
            // display question stats
            $ret .= '<strong>[' . $m['testlog_score'] . ']' . K_NEWLINE;
            $ret .= ' (';
            $ret .= 'IP:' . getIpAsString($m['testlog_user_ip']) . K_NEWLINE;
            if (isset($m['testlog_display_time']) and strlen($m['testlog_display_time']) > 0) {
                $ret .= ' | ' . substr($m['testlog_display_time'], 11, 8) . K_NEWLINE;
            } else {
                $ret .= ' | --:--:--' . K_NEWLINE;
            }
            if (isset($m['testlog_change_time']) and strlen($m['testlog_change_time']) > 0) {
                $ret .= ' | ' . substr($m['testlog_change_time'], 11, 8) . K_NEWLINE;
            } else {
                $ret .= ' | --:--:--' . K_NEWLINE;
            }
            if (isset($m['testlog_display_time']) and isset($m['testlog_change_time'])) {
                $ret .= ' | ' . date('i:s', strtotime($m['testlog_change_time']) - strtotime($m['testlog_display_time'])) . '';
            } else {
                $ret .= ' | --:--' . K_NEWLINE;
            }
            if (isset($m['testlog_reaction_time']) and $m['testlog_reaction_time'] > 0) {
                $ret .= ' | ' . $m['testlog_reaction_time'] / 1000 . '';
            } else {
                $ret .= ' | ------' . K_NEWLINE;
            }
            $ret .= ')</strong>' . K_NEWLINE;
            $ret .= '<br />' . K_NEWLINE;
            // display question description
            $ret .= F_decode_tcecode($m['question_description']) . K_NEWLINE;
            if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
                $ret .= '<br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($m['question_explanation']) . '' . K_NEWLINE;
            }
            if ($m['question_type'] == 3) {
                // TEXT
                $ret .= '<ul class="answer"><li>' . K_NEWLINE;
                $ret .= F_decode_tcecode($m['testlog_answer_text']);
                $ret .= '&nbsp;</li></ul>' . K_NEWLINE;
            } else {
                $ret .= '<ol class="answer">' . K_NEWLINE;
                // display each answer option
                $sqla = 'SELECT *
					FROM ' . K_TABLE_LOG_ANSWER . ', ' . K_TABLE_ANSWERS . '
					WHERE logansw_answer_id=answer_id
						AND logansw_testlog_id=\'' . $m['testlog_id'] . '\'
					ORDER BY logansw_order';
                if ($ra = F_db_query($sqla, $db)) {
                    while ($ma = F_db_fetch_array($ra)) {
                        $ret .= '<li>';
                        if ($m['question_type'] == 4) {
                            // ORDER
                            if ($ma['logansw_position'] > 0) {
                                if ($ma['logansw_position'] == $ma['answer_position']) {
                                    $ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">' . $ma['logansw_position'] . '</acronym>';
                                } else {
                                    $ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">' . $ma['logansw_position'] . '</acronym>';
                                }
                            } else {
                                $ret .= '<acronym title="' . $l['m_unanswered'] . '" class="offbox">&nbsp;</acronym>';
                            }
                        } elseif ($ma['logansw_selected'] > 0) {
                            if (F_getBoolean($ma['answer_isright'])) {
                                $ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">x</acronym>';
                            } else {
                                $ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">x</acronym>';
                            }
                        } elseif ($m['question_type'] == 1) {
                            // MCSA
                            $ret .= '<acronym title="-" class="offbox">&nbsp;</acronym>';
                        } else {
                            if ($ma['logansw_selected'] == 0) {
                                if (F_getBoolean($ma['answer_isright'])) {
                                    $ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">&nbsp;</acronym>';
                                } else {
                                    $ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">&nbsp;</acronym>';
                                }
                            } else {
                                $ret .= '<acronym title="' . $l['m_unanswered'] . '" class="offbox">&nbsp;</acronym>';
                            }
                        }
                        $ret .= '&nbsp;';
                        if ($m['question_type'] == 4) {
                            $ret .= '<acronym title="' . $l['w_position'] . '" class="onbox">' . $ma['answer_position'] . '</acronym>';
                        } elseif (F_getBoolean($ma['answer_isright'])) {
                            $ret .= '<acronym title="' . $l['w_answers_right'] . '" class="onbox">&reg;</acronym>';
                        } else {
                            $ret .= '<acronym title="' . $l['w_answers_wrong'] . '" class="offbox">&nbsp;</acronym>';
                        }
                        $ret .= ' ';
                        $ret .= F_decode_tcecode($ma['answer_description']);
                        if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
                            $ret .= '<br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($ma['answer_explanation']) . '' . K_NEWLINE;
                        }
                        $ret .= '</li>' . K_NEWLINE;
                    }
                } else {
                    F_display_db_error();
                }
                $ret .= '</ol>' . K_NEWLINE;
            }
            // end multiple answers
            // display teacher/supervisor comment to the question
            if (isset($m['testlog_comment']) and !empty($m['testlog_comment'])) {
                $ret .= '<ul class="answer"><li class="comment">' . K_NEWLINE;
                $ret .= F_decode_tcecode($m['testlog_comment']);
                $ret .= '&nbsp;</li></ul>' . K_NEWLINE;
            }
            $ret .= '<br /><br />' . K_NEWLINE;
            $ret .= '</li>' . K_NEWLINE;
        }
        $ret .= '</ol>' . K_NEWLINE;
    } else {
        F_display_db_error();
    }
    return $ret;
}
 // number of free-text unrated questions
 if (strlen($m['testlog_score']) <= 0) {
     $topicresults[$m['module_id']]['unrated'] += 1;
     $topicresults[$m['module_id']]['subjects'][$m['subject_id']]['unrated'] += 1;
 }
 // score
 $topicresults[$m['module_id']]['score'] += $m['testlog_score'];
 $topicresults[$m['module_id']]['subjects'][$m['subject_id']]['score'] += $m['testlog_score'];
 // max score
 $topicresults[$m['module_id']]['maxscore'] += $question_max_score;
 $topicresults[$m['module_id']]['subjects'][$m['subject_id']]['maxscore'] += $question_max_score;
 echo '<li>' . K_NEWLINE;
 // display question stats
 echo '<strong>[' . $m['testlog_score'] . ']' . K_NEWLINE;
 echo ' (';
 echo 'IP:' . getIpAsString($m['testlog_user_ip']) . K_NEWLINE;
 if (isset($m['testlog_display_time']) and strlen($m['testlog_display_time']) > 0) {
     echo ' | ' . substr($m['testlog_display_time'], 11, 8) . K_NEWLINE;
 } else {
     echo ' | --:--:--' . K_NEWLINE;
 }
 if (isset($m['testlog_change_time']) and strlen($m['testlog_change_time']) > 0) {
     echo ' | ' . substr($m['testlog_change_time'], 11, 8) . K_NEWLINE;
 } else {
     echo ' | --:--:--' . K_NEWLINE;
 }
 if (isset($m['testlog_display_time']) and isset($m['testlog_change_time'])) {
     echo ' | ' . date('i:s', strtotime($m['testlog_change_time']) - strtotime($m['testlog_display_time'])) . '';
 } else {
     echo ' | --:--' . K_NEWLINE;
 }
Пример #4
0
    /**
     * print test details for the selected user
     * @param $data (array) Testuser data array.
     * @param $onlytext (boolean) If true print only text questions.
     */
    public function printUserTestDetails($data, $onlytext = false)
    {
        require_once '../config/tce_config.php';
        require_once '../../shared/code/tce_functions_test_stats.php';
        require_once '../../shared/code/tce_functions_tcecode.php';
        global $db, $l;
        $testuser_id = intval($data['id']);
        $qtype = array('S', 'M', 'T', 'O');
        // question types
        $num_column = 7;
        $tce_data_cell_width = round($this->tce_page_width / $num_column, 2);
        $tce_data_cell_width_third = round($tce_data_cell_width / 3, 2);
        $tce_data_cell_width_half = round($tce_data_cell_width / 2, 2);
        $numberfont = 'courier';
        // display user questions
        $sql = 'SELECT *
			FROM ' . K_TABLE_QUESTIONS . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_MODULES . '
			WHERE question_id=testlog_question_id
				AND testlog_testuser_id=' . $testuser_id . '
				AND question_subject_id=subject_id
				AND subject_module_id=module_id';
        if ($onlytext) {
            // display only TEXT questions
            $sql .= ' AND question_type=3';
        }
        $sql .= ' ORDER BY testlog_id';
        if ($r = F_db_query($sql, $db)) {
            $this->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA);
            $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '#', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_score'], 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_ip'], 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $l['w_start'] . ' [' . $l['w_time_hhmmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $l['w_end'] . ' [' . $l['w_time_hhmmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_time'] . ' [' . $l['w_time_mmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_reaction'] . ' [sec]', 1, 1, 'C', 1);
            $this->Ln($this->tce_data_cell_height);
            // print table rows
            $this->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
            $itemcount = 1;
            while ($m = F_db_fetch_array($r)) {
                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $itemcount . ' ' . $qtype[$m['question_type'] - 1], 1, 0, 'R', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $m['testlog_score'], 1, 0, 'C', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, getIpAsString($m['testlog_user_ip']), 1, 0, 'C', 0);
                if (isset($m['testlog_display_time']) and strlen($m['testlog_display_time']) > 0) {
                    $display_time = substr($m['testlog_display_time'], 11, 8);
                } else {
                    $display_time = '--:--:--';
                }
                if (isset($m['testlog_change_time']) and strlen($m['testlog_change_time']) > 0) {
                    $change_time = substr($m['testlog_change_time'], 11, 8);
                } else {
                    $change_time = '--:--:--';
                }
                if (isset($m['testlog_display_time']) and isset($m['testlog_change_time'])) {
                    $diff_time = date('i:s', strtotime($m['testlog_change_time']) - strtotime($m['testlog_display_time']));
                } else {
                    $diff_time = '--:--';
                }
                if (isset($m['testlog_reaction_time']) and strlen($m['testlog_reaction_time']) > 0) {
                    $reaction_time = $m['testlog_reaction_time'] / 1000;
                } else {
                    $reaction_time = '';
                }
                $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $display_time, 1, 0, 'C', 0);
                $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $change_time, 1, 0, 'C', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $diff_time, 1, 0, 'C', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $reaction_time, 1, 1, 'C', 0);
                $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['question_description']), 1, 1);
                if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
                    $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
                    $this->SetFont('', 'BIU');
                    $this->Cell(0, $this->tce_data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0);
                    $this->SetFont('', '');
                    $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['question_explanation']), 'LRB', 1, '', '');
                }
                if ($m['question_type'] == 3) {
                    // free-text question - print user text answer
                    $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 2 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['testlog_answer_text']), 1, 1);
                } else {
                    // display each answer option
                    $sqla = 'SELECT * FROM ' . K_TABLE_LOG_ANSWER . ', ' . K_TABLE_ANSWERS . ' WHERE logansw_answer_id=answer_id AND logansw_testlog_id=' . $m['testlog_id'] . ' ORDER BY logansw_order';
                    if ($ra = F_db_query($sqla, $db)) {
                        $idx = 0;
                        // count items
                        while ($ma = F_db_fetch_array($ra)) {
                            $posfill = 0;
                            $idx++;
                            $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
                            if ($m['question_type'] == 4) {
                                if ($ma['logansw_position'] > 0) {
                                    if ($ma['logansw_position'] == $ma['answer_position']) {
                                        $posfill = 1;
                                        $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['logansw_position'], 1, 0, 'C', 1);
                                    } else {
                                        $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['logansw_position'], 1, 0, 'C', 0);
                                    }
                                } else {
                                    $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
                                }
                            } elseif ($ma['logansw_selected'] > 0) {
                                // selected
                                if (F_getBoolean($ma['answer_isright'])) {
                                    $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '+', 1, 0, 'C', 1);
                                } else {
                                    $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '-', 1, 0, 'C', 1);
                                }
                            } elseif ($m['question_type'] == 1) {
                                // MCSA
                                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
                            } else {
                                if ($ma['logansw_selected'] == 0) {
                                    // unselected
                                    if (F_getBoolean($ma['answer_isright'])) {
                                        $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '-', 1, 0, 'C', 0);
                                    } else {
                                        $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '+', 1, 0, 'C', 0);
                                    }
                                } else {
                                    // no answer
                                    $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
                                }
                            }
                            if ($m['question_type'] == 4) {
                                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['answer_position'], 1, 0, 'C', $posfill);
                            } elseif (F_getBoolean($ma['answer_isright'])) {
                                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $idx, 1, 0, 'C', 1);
                            } else {
                                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $idx, 1, 0, 'C', 0);
                            }
                            $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width, $this->GetY(), F_decode_tcecode($ma['answer_description']), 'LRTB', 1);
                            if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
                                $this->Cell(3 * $tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
                                $this->SetFont('', 'BIU');
                                $this->Cell(0, $this->tce_data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0);
                                $this->SetFont('', '');
                                $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 3 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($ma['answer_explanation']), 'LRB', 1, '', '');
                            }
                        }
                    } else {
                        F_display_db_error();
                    }
                }
                // end multiple answers
                if (strlen($m['testlog_comment']) > 0) {
                    // teacher / supervisor comment
                    $this->SetTextColor(255, 0, 0);
                    $this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 2 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['testlog_comment']), 'LRTB', 1);
                    $this->SetTextColor(0, 0, 0);
                }
                $this->Ln($this->tce_data_cell_height);
                $itemcount++;
            }
        } else {
            F_display_db_error();
        }
        $stats = F_getTestStat($data['test']['test_id'], 0, $data['user_id'], 0, 0, $data['id']);
        $this->printQuestionStats($stats['qstats'], 1);
    }