Merge branch 'bug-1140' into release

This commit is contained in:
Bernhard Fröhlich 2014-02-12 22:04:16 +01:00
commit aae47d592b
2 changed files with 624 additions and 581 deletions

View file

@ -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

View file

@ -7,6 +7,8 @@ class Progress
var $incorrect_answers;
var $percentArray;
var $maximum;
var $passed;
var $totalresult=array();
function Progress() {
$this->progress=array();
@ -15,6 +17,7 @@ class Progress
$this->topic=0;
$this->lp_id=0;
$this->percentArray=array();
$this->passed=0;
}
function setTopic($t_id){
@ -29,7 +32,7 @@ class Progress
$this->progress=$value;
}
function getProgress(){
$sql= "SELECT lp_id,date,number,correct,wrong FROM learnprogress WHERE user_id='".mysql_real_escape_string($_SESSION['profile']['id'])."' AND t_id='".mysql_real_escape_string($this->topic)."' AND root ='".mysql_real_escape_string($_SESSION['profile']['root'])."' order by date";
$sql= "SELECT lp_id,date,number,correct,wrong, passed FROM learnprogress WHERE user_id='".mysql_real_escape_string($_SESSION['profile']['id'])."' AND t_id='".mysql_real_escape_string($this->topic)."' AND root ='".mysql_real_escape_string($_SESSION['profile']['root'])."' order by date";
$query = mysql_query($sql) OR die(mysql_error());
$i=1;
while($progress =mysql_fetch_array($query,MYSQL_BOTH )){
@ -38,6 +41,7 @@ class Progress
$this->progress[$i]['number']=$progress['number']; // in arra speichern
$this->progress[$i]['correct']=$progress['correct'];
$this->progress[$i]['wrong']=$progress['wrong'];
$this->progress[$i]['passed']=$progress['passed'];
$i++;
}
@ -49,6 +53,8 @@ class Progress
}
function showTable() {
$this->totalresult['count']=0;
$this->totalresult['passed']=0;
if(count($this->progress)==0) echo "<div class='h8'>".Global_07."</div>";
else {
echo"<br /> <br />";
@ -58,9 +64,13 @@ class Progress
echo"<td class='th th_pos_date'>".Global_04."</td>";
echo"<td class='th th_count'>".Class_Progress_01."</td>";
echo"<td class='th th_count'>".Global_03."</td>";
echo"<td class='th th_count'>".Statistic_04."</td>";
echo "<td class='th th_buttons'></td>";
echo"</tr>";
for ($i=1;$i<=count($this->progress);$i++){
if (1==$this->progress[$i]['passed']) {
$this->totalresult['passed']+=1;
}
echo "<tr>";
echo"<td class='td'>$i</td>";
echo"<td class='td'>".$this->progress[$i]['date']."</td>";
@ -71,11 +81,23 @@ class Progress
$percent = 0;
}
$percent=round ($percent,2);
echo"<td class='td'>$percent %</td>";
echo"<td class='td'> <a href='?site=progress&amp;action=showIncorrectAnswers&amp;lp_id=".$this->progress[$i]['lp_id']."&amp;t_id=$this->topic'><img src='images/details.png' class='linkimage' alt='' /></a></td>";
echo "<td class='td'>$percent %</td>";
echo "<td class='td'>".$this->getPassedImage($this->progress[$i]['passed'])."</td>";
echo "<td class='td'> <a href='?site=progress&amp;action=showIncorrectAnswers&amp;lp_id=";
echo $this->progress[$i]['lp_id']."&amp;t_id=$this->topic'><img src='images/details.png' class='linkimage' alt='' /></a></td>";
echo "</tr>";
}
$this->totalresult['count']=$i-1;
echo "<tr>";
echo "<td class='td' colspan='6' align='center'>".Statistic_04.' '.$this->totalresult['passed'].'/'.$this->totalresult['count']."</td>";
echo "</tr>\n";
echo"</table>";
if ($this->totalresult['passed'] > 0) {
echo "<form class='info' action='index.php?site=start_test&amp;action=requestCert' method='post'>";
echo "<input type='hidden' name='t_id' value='$this->topic' />";
echo "<input name='submit' class='Button_middle' type='submit' value='".Class_Quiz_11_RequestCert."' />";
echo "</form>";
}
}
}
@ -166,8 +188,7 @@ class Progress
echo"<td class='question_incorrect' valign='top'>".$questionText."</td>";
}
else{
} else {
echo "<td class='question_incorrect' valign='top'>". $question['question']."</td>";
}
}
@ -203,10 +224,21 @@ class Progress
$answer=str_replace("]",'', $answer); // Klammer entfernen
$key = array_search($answer, $array);
$answer=str_replace("[",'', $answer); // Klammer entfernen
}
}
return $questionText;
}
function getPassedImage($passed){
// returns the image depending on the status of a test result
$img="<img src='images/details.png' alt='' />";
if (0==$passed) {
$img="<img src='images/wrong.png' alt='' />";
}
if (1==$passed) {
$img="<img src='images/correct.png' alt='' />";
}
return $img;
}
}
?>