Professional Documents
Culture Documents
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.error {
color:red;
}
</style>
<body>
<?php
//Step 1: Determine number of questions;
// $lastRow = $objPHPExcel->getActiveSheet()->getHighestRow();
// Step 2: Determine type of question;
//Step 3: Determine answer(s) based on type of question;
//Step 4: Display answer and scores.
function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}
$inputFileType = 'Excel2007';
$inputFileName = './englishtest/dethithu.xls';
$sheetname = 'test1';
class MyReadFilter implements PHPExcel_Reader_IReadFilter
{
private $_startRow = 0;
private $_endRow = 0;
= $startRow;
$this->_endRow
= $endRow;
$this->_columns
= $columns;
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
//$objReader->setLoadSheetsOnly(array($sheetname,$sheetname1)) neu doc
multiple sheet
$objReader->setLoadSheetsOnly($sheetname);
$objPHPExcel = $objReader->load($inputFileName);
$lastRow = $objPHPExcel->getActiveSheet()->getHighestRow();
lastrow
$qorder=array(); //order of question
$qtype = array(); // questions type array
$rquestion = array(); // questions array
// Read
if (isset($_POST['submit'])){
button is set
echo '<b>';
echo'' .$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
// display answers
echo '<input type="';
echo 'radio"';
echo 'name="qr'. $qorder[$i];
echo ' " ';
echo 'value=0>';
echo ' ' .$ranswers[$i][0];
echo '<b>';
} //third curl closing
//finish first question
if (!empty($ranswers[$i][1])){//3rd curl
echo '<b>';
echo ' '.$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
echo 'value=1>';
echo ' '.$ranswers[$i][1];
echo '<b>';
//finish 2nd question
}//3rd curl closing
if (!empty($ranswers[$i][2])){//3rd curl
echo '<b>';
echo ' ' .$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
if ($qtype[$i]==2){
echo 'value=0>';
echo ' ' .$ranswers[$i][0];
echo '<b>';
}
} //close 2nd curl
//=================================================
=check if not set
else{
if (!empty($ranswers[$i][1])){//3rd curl
echo '<b>';
echo ' '.$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
echo 'value=1>';
echo ' '.$ranswers[$i][1];
echo '<b>';
//finish 2nd question
}//3rd curl closing
if (!empty($ranswers[$i][2])){//3rd curl
echo '<b>';
echo ' ' .$qorder[$i];
echo '.';
if ($qtype[$i]==2){
echo 'value=0>';
echo ' ' .$ranswers[$i][0];
echo '<b>';
} //third curl closing
//finish first question
if (!empty($ranswers[$i][1])){ //3rd curl
echo '<b>';
echo ' '.$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
echo '<input type="';
echo 'checkbox"';
echo 'name="qc'. $qorder[$i];
echo ' [] ';
echo ' " ';
echo 'value=1>';
echo ' '.$ranswers[$i][1];
echo '<b>';
//finish 2nd question
} //3rd curl closing
if (!empty($ranswers[$i][2])){ //3rd curl
echo '<b>';
echo ' ' .$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
echo '<input type="';
echo 'checkbox"';
echo 'name="qc'. $qorder[$i];
echo ' [] ';
echo ' " ';
echo 'value=2>';
echo ' ' .$ranswers[$i][2];
echo '<b>';
//finish third question
} //3rd curl closing
if (!empty($ranswers[$i][3])){ //3rd curl
echo '<b>';
echo ' ' .$qorder[$i];
echo '.';
//==============danh de thu
for ($i = 2; $i <= 4; $i++) {
echo '<input type="button" value="Xem ket qua">';
echo '<b>';
echo ' '.$qorder[$i];
echo '.';
echo ' ' .$rquestion[$i];
echo '</b>';
echo '<br>';
echo 'radio"';
echo 'name="qr'. $qorder[$i];
echo ' " ';
echo 'value=1>';
echo ' '.$ranswers[$i][1];
echo '<b>';
}
?>
</body>
</html>