$cstr .= ' ' . F_formatPdfPercentage($columns['right'] / $usrtestdata['all']);
        }
        $pdf->Cell($data_cell_width * 7 / 5, $data_cell_height, $cstr, 1, 0, 'R', 0);
        $cstr = F_formatFloat($columns['wrong']);
        if (in_array($row, $calcpercent)) {
            $cstr .= ' ' . F_formatPdfPercentage($columns['wrong'] / $usrtestdata['all']);
        }
        $pdf->Cell($data_cell_width * 7 / 5, $data_cell_height, $cstr, 1, 0, 'R', 0);
        $cstr = F_formatFloat($columns['unanswered']);
        if (in_array($row, $calcpercent)) {
            $cstr .= ' ' . F_formatPdfPercentage($columns['unanswered'] / $usrtestdata['all']);
        }
        $pdf->Cell($data_cell_width * 7 / 5, $data_cell_height, $cstr, 1, 0, 'R', 0);
        $cstr = F_formatFloat($columns['undisplayed']);
        if (in_array($row, $calcpercent)) {
            $cstr .= ' ' . F_formatPdfPercentage($columns['undisplayed'] / $usrtestdata['all']);
        }
        $pdf->Cell($data_cell_width * 7 / 5, $data_cell_height, $cstr, 1, 1, 'R', 0);
    }
}
$pdf->lastpage(true);
$pdf->SetAutoPageBreak(false);
$pdf->SetFont('helvetica', '', 5);
$pdf->SetTextColor(0, 127, 255);
$msg = "Powered by TCExam (www.tcexam.org)";
$lnk = "http://www.tcexam.org";
$pdf->SetXY(15, $pdf->getPageHeight(), true);
$pdf->Cell(0, 0, $msg, 0, 0, 'R', 0, $lnk, 0, false, 'B', 'B');
// Send PDF output
$pdf->Output('tcexam_user_results_' . $user_id . '_' . date('YmdHis') . '.pdf', 'D');
//============================================================+
Exemplo n.º 2
0
     $str = $res_module['score'] . ' / ' . $res_module['maxscore'] . ' ' . F_formatPdfPercentage($score_percent);
     $pdf->Cell($data_cell_width, $data_cell_height, $str, 1, 0, 'R', 0);
     $score_percent = $res_module['right'] / $res_module['num'];
     $str = $res_module['right'] . ' / ' . $res_module['num'] . ' ' . F_formatPdfPercentage($score_percent);
     $pdf->Cell($data_cell_width, $data_cell_height, $str, 1, 0, 'R', 0);
     $pdf->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA);
     $pdf->Cell($data_cell_width * 5, $data_cell_height, $res_module['name'], 1, 1, $dirvalue, 0);
     $pdf->Ln(0.5);
     foreach ($res_module['subjects'] as $res_subject) {
         $pdf->SetFont($numberfont, '', 6);
         $pdf->Cell($data_cell_width, $data_cell_height, '', 0, 0, 'C', 0);
         $score_percent = $res_subject['score'] / $res_subject['maxscore'];
         $str = $res_subject['score'] . ' / ' . $res_subject['maxscore'] . ' ' . F_formatPdfPercentage($score_percent);
         $pdf->Cell($data_cell_width, $data_cell_height, $str, 1, 0, 'R', 0);
         $score_percent = $res_subject['right'] / $res_subject['num'];
         $str = $res_subject['right'] . ' / ' . $res_subject['num'] . ' ' . F_formatPdfPercentage($score_percent);
         $pdf->Cell($data_cell_width, $data_cell_height, $str, 1, 0, 'R', 0);
         $pdf->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
         $pdf->Cell($data_cell_width * 4, $data_cell_height, $res_subject['name'], 1, 1, $dirvalue, 0);
         $pdf->Ln(0.5);
     }
 }
 // do not split BLOCKS in multiple pages
 if ($pdf->getPage() == $block_page) {
     $print_block = 0;
 } else {
     // rolls back to the last (re)start
     $pdf = $pdf->rollbackTransaction();
     $pdf->AddPage();
     $block_page = $pdf->getPage();
     --$print_block;
Exemplo n.º 3
0
 /**
  * Print testuser data
  * @param $data (array) Array containing test statistics.
  * @param $onlytext (boolean) If true print only text questions.
  */
 function printTestUserInfo($data, $onlytext = false)
 {
     require_once '../config/tce_config.php';
     global $l;
     $this->SetFillColor(204, 204, 204);
     $this->SetLineWidth(0.1);
     $this->SetDrawColor(0, 0, 0);
     if ($l['a_meta_dir'] == 'rtl') {
         $dirlabel = 'L';
         $dirvalue = 'R';
     } else {
         $dirlabel = 'R';
         $dirvalue = 'L';
     }
     // add a bookmark
     $this->Bookmark($data['user_lastname'] . ' ' . $data['user_firstname'] . ' (' . $data['user_name'] . '), ' . $data['total_score'] . ' ' . F_formatPdfPercentage($data['total_score_perc'], false), 0, 0);
     // --- display test info ---
     $info_cell_width = round($this->tce_page_width / 4, 2);
     $boxStartY = $this->GetY();
     // store current Y position
     // test name
     $this->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA * HEAD_MAGNIFICATION);
     $this->Cell($this->tce_page_width, $this->tce_data_cell_height * HEAD_MAGNIFICATION, $l['w_test'] . ': ' . $data['test']['test_name'], 1, 1, '', 1);
     $this->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
     $infoStartY = $this->GetY() + 2;
     // store current Y position
     $this->SetY($infoStartY);
     $column_names_width = round($info_cell_width * 0.75, 2);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_lastname'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['user_lastname'], 0, 1, $dirvalue, 0, '', 1);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_firstname'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['user_firstname'], 0, 1, $dirvalue, 0, '', 1);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_user'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['user_name'], 0, 1, $dirvalue, 0, '', 1);
     // test start time
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_time_begin'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['user_test_start_time'], 0, 1, $dirvalue, 0, '', 1);
     // test end time
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_time_end'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['user_test_end_time'], 0, 1, $dirvalue, 0, '', 1);
     // test duration
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_test_time'].' ['.$l['w_minutes'].']: ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_duration_time'], 0, 1, $dirvalue, 0, '', 1);
     if (!isset($data['test']['user_test_end_time']) or $data['test']['user_test_end_time'] <= 0 or strtotime($data['test']['user_test_end_time']) < strtotime($data['test']['user_test_start_time'])) {
         $time_diff = $data['test']['test_duration_time'] * 60;
     } else {
         $time_diff = strtotime($data['test']['user_test_end_time']) - strtotime($data['test']['user_test_start_time']);
         //sec
     }
     $time_diff = gmdate('H:i:s', $time_diff);
     // elapsed time (time difference)
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_time'] . ': ', 0, 0, $dirlabel, 0);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $time_diff, 0, 1, $dirvalue, 0);
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_ip_range'].': ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_ip_range'], 0, 1, $dirvalue, 0, '', 1);
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_score_right'].': ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_score_right'], 0, 1, $dirvalue, 0, '', 1);
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_score_wrong'].': ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_score_wrong'], 0, 1, $dirvalue, 0, '', 1);
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_score_unanswered'].': ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_score_unanswered'], 0, 1, $dirvalue, 0, '', 1);
     // max score
     //$this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_max_score'].': ', 0, 0, $dirlabel, 0, '', 1);
     //$this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_max_score'], 0, 1, $dirvalue, 0, '', 1);
     $passmsg = '';
     if ($data['test']['test_score_threshold'] > 0) {
         $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_test_score_threshold'] . ': ', 0, 0, $dirlabel, 0, '', 1);
         $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['test']['test_score_threshold'], 0, 1, $dirvalue, 0, '', 1);
         if ($data['total_score'] >= $data['test']['test_score_threshold']) {
             $passmsg = ' - ' . $l['w_passed'];
         } else {
             $passmsg = ' - ' . $l['w_not_passed'];
         }
     }
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_answers_right'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['right'] . ' ' . F_formatPdfPercentage($data['right_perc'], false), 0, 1, $dirvalue, 0, '', 1);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_answers_wrong'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['wrong'] . ' ' . F_formatPdfPercentage($data['wrong_perc'], false), 0, 1, $dirvalue, 0, '', 1);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_questions_unanswered'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['unanswered'] . ' ' . F_formatPdfPercentage($data['unanswered_perc'], false), 0, 1, $dirvalue, 0, '', 1);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_questions_undisplayed'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['undisplayed'] . ' ' . F_formatPdfPercentage($data['undisplayed_perc'], false), 0, 1, $dirvalue, 0, '', 1);
     $this->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA);
     $this->Cell($column_names_width, $this->tce_data_cell_height, $l['w_score'] . ': ', 0, 0, $dirlabel, 0, '', 1);
     $this->Cell($info_cell_width, $this->tce_data_cell_height, $data['total_score'] . ' / ' . $data['test']['test_max_score'] . ' ' . F_formatPdfPercentage($data['total_score_perc'], false) . $passmsg, 0, 1, $dirvalue, 0, '', 1);
     $this->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
     $boxEndY = $this->GetY();
     $this->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
     // test description
     $this->writeHTMLCell(0, $boxEndY - $infoStartY + 4, PDF_MARGIN_LEFT + $info_cell_width * 2, $infoStartY - 2, $data['test']['test_description'], 1, 0);
     $boxEndY = max($boxEndY, $this->GetY());
     // print box around test info
     $this->SetY($boxStartY);
     $this->Cell($this->tce_page_width, $boxEndY - $boxStartY + 2, '', 1, 1, 'C', 0, '', 1);
     $this->SetY($boxEndY - 1);
     // --- end test info ---
     // print user's comments
     if (!empty($data['test']['user_comment'])) {
         $this->Cell($this->tce_page_width, $this->tce_data_cell_height, '', 0, 1, '', 0);
         $this->writeHTMLCell($this->tce_page_width, $this->tce_data_cell_height, '', '', '<b>' . $l['w_comment'] . '</b>:<br />' . $data['test']['user_comment'], 1, 1);
     }
     $this->Ln(4);
     $this->printUserTestDetails($data, $onlytext);
 }