@ -14,6 +14,7 @@ class Quiz
var $rawToPass;
var $question;
var $percentTest;
var $testPassed;
function Quiz(){
$this->topicID=0;
@ -85,8 +86,7 @@ class Quiz
$i++;
}
$_SESSION['values']['questionList']=$this->questionList;
}
else{
} else {
echo "< h5 > ".Class_Quiz_01." < / h5 > ";
$value ="notEnoughQuestions";
return $value;
@ -212,7 +212,6 @@ class Quiz
}
function FillInTheBlanks($i,$value,$question) {
echo '< td class = "answer" valign = "top" colspan = "2" > ';
$correctAns=$this->question->getCorrectAnswerFillInTheBlanks($question); // korrekte Antworen ermitteln
$numberOfAnswers=$this->questionList[$i]['numberOfAnswers'];
@ -236,7 +235,6 @@ class Quiz
}
echo"< / select > ";
}
else if((strstr($array[$k],']'))){
$array[$k]=str_replace("]",'', $array[$k]); // Klammer entfernen
echo $array[$k];
@ -250,9 +248,7 @@ class Quiz
}
function evaluateQuiz() {
echo"< div > ";
echo "< fieldset > ";
@ -270,19 +266,24 @@ class Quiz
}
$this->topicID=$this->questionList[$i]['t_id'];
switch($this->questionList[$i]['qt_id']){
case 1: {$this->evaluateSingleSelection($i,$value);
case 1: {
$this->evaluateSingleSelection($i,$value);
break;}
case 2: {$this->evaluateMultipleChoice($i,$value);
break;}
case 3: { $this->evaluateSingleSelection($i,$value); // Kann die selbe Maske verwendet werden
break;}
case 4:{ //$this->getDBAnswers();
break;
}
case 2: {
$this->evaluateMultipleChoice($i,$value);
break;
}
case 3: {
$this->evaluateSingleSelection($i,$value); // Kann die selbe Maske verwendet werden
break;
}
case 4:{
//$this->getDBAnswers();
$this->evaluateFillInTheBlanks($i,$value,$question);
break;}
break;
}
}
}
@ -329,7 +330,7 @@ class Quiz
echo"< / tr > ";
}
if(isset($this->selectedAnswers[$value]) & & isset($this->answerList[$value][$j]['correct']) & &
if (isset($this->selectedAnswers[$value]) & & isset($this->answerList[$value][$j]['correct']) & &
$this->selectedAnswers[$value]==$this->answerList[$value][$j]['a_id'] & & $this->answerList[$value][$j]['correct']==1) {
$correct[]=1;
}
@ -384,8 +385,6 @@ class Quiz
}
function evaluateFillInTheBlanks($i,$value,$question){
$addSlashes= preg_quote($question, '[^]'); // Slash hinzufügen wenn KLammer gefunden wird
$array=explode('\\',$addSlashes); // String teilen
// Was Benutzer markiert hat
@ -434,7 +433,7 @@ class Quiz
$this->checkAnswers($correct,$value);
}
function checkAnswers($correct,$value) {
function checkAnswers($correct,$value) {
$check = in_array(0, $correct); // Prüfen ob im Array der Wert 0 ist, denn dann wurde mindestens eine Antwort falsch beantwortet
echo "\n< tr > ";
if(!$check)echo"< td class = 'symbol' colspan = '7' > < img src = 'images/correct.png' alt = '' / > < / td > ";
@ -443,7 +442,7 @@ function checkAnswers($correct,$value) {
echo"< td class = 'symbol' colspan = '7' > < img src = 'images/wrong.png' alt = '' / > < / td > ";
}
echo "< / tr > ";
}
}
function updateStatistic() {
for($i=1;$i< =$this->questionLimit;$i++) {
@ -463,7 +462,17 @@ function checkAnswers($correct,$value) {
$date= date("Y-m-d H:i:s" ,$timestamp); // aktuelles Datum und Uhrzeit berechnen
$correctAnswers=$this->questionLimit-count($this->wrongQuestions);
$wrongAnswers=count($this->wrongQuestions);
$sql="INSERT INTO learnprogress (user_id,root,date,t_id,number,correct,wrong,percentage) VALUES ('".mysql_real_escape_string($_SESSION['profile']['id'])."','".mysql_real_escape_string($_SESSION['profile']['root'])."','$date',".intval($this->topicID).",".intval($this->questionLimit).",".intval($correctAnswers).",".intval($wrongAnswers).",".mysql_real_escape_string($this->percentTest).")";
$passed=$this->testPassed;
$sql="INSERT INTO learnprogress (user_id,root,date,t_id,number,correct,wrong,percentage,passed)
VALUES ('".mysql_real_escape_string($_SESSION['profile']['id'])."',
'".mysql_real_escape_string($_SESSION['profile']['root'])."',
'$date',
".intval($this->topicID).",
".intval($this->questionLimit).",
".intval($correctAnswers).",
".intval($wrongAnswers).",
".mysql_real_escape_string($this->percentTest).",
".intval($passed).")";
$query = mysql_query($sql);
$this->lp_id = mysql_insert_id();
$this->insertAnswersIncorrect();
@ -485,6 +494,7 @@ function checkAnswers($correct,$value) {
$percentTest=round($percentTest, 2);
$this->percentTest=$percentTest;
$this->testPassed=0;
if($this->rawToPass > 0 & & $this->rawToPass < = $percentTest)$value="".Class_Quiz_08."";
else $value="".Class_Quiz_09."";
@ -497,6 +507,7 @@ function checkAnswers($correct,$value) {
//createLearnProgress();
if($this->rawToPass > 0 & & $this->rawToPass < = $percentTest) {
$this->testPassed=1;
// Test has been passed, maybe a paper/PDF-certificate can be requested
if ($_SERVER['SSL_CLIENT_S_DN_CN']=="CAcert WoT User") {
// Sorry, we cannot issue certificates for anonymous users