Merge pull request #3 from INOPIAE/bug-1140

bug 1140: added the status passed to the progress table
This commit is contained in:
Bernhard Fröhlich 2013-04-07 07:50:27 -07:00
commit 7711fd61e8
2 changed files with 224 additions and 184 deletions

View file

@ -14,6 +14,7 @@ class Quiz
var $rawToPass;
var $question;
var $percentTest;
var $testPassed;
function Quiz(){
$this->topicID=0;
@ -463,7 +464,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 +496,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 +509,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,25 +64,34 @@ 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>";
echo"<td class='td'>".$this->progress[$i]['number']."</td>";
if ($this->progress[$i]['number'] > 0) {
$percent=($this->progress[$i]['correct']/$this->progress[$i]['number'])*100;
} else {
$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 "</tr>";
}
echo"</table>";
echo"<td class='td'>".$this->progress[$i]['date']."</td>";
echo"<td class='td'>".$this->progress[$i]['number']."</td>";
echo"<td class='td'>".getPassedImage($this->progress[$i]['passed'])."</td>";
if ($this->progress[$i]['number'] > 0) {
$percent=($this->progress[$i]['correct']/$this->progress[$i]['number'])*100;
} else {
$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 "</tr>";
}
$this->totalresult['count']=$i;
echo "<tr>";
echo "<td class='td' colspan='6' align='center'>".Statistic_04.' '.$this->totalresult['passed'].'/'.$this->totalresult['count']."</td>";
echo "</tr>";
echo"</table>";
}
}
function checkProgressData(){
@ -208,5 +223,17 @@ class Progress
}
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;
}
}
?>