diff --git a/classes/Quiz.class.php b/classes/Quiz.class.php
index 3465a55..be3ddef 100755
--- a/classes/Quiz.class.php
+++ b/classes/Quiz.class.php
@@ -16,7 +16,7 @@ class Quiz
var $percentTest;
var $testPassed;
- function Quiz(){
+ function Quiz(){
$this->topicID=0;
$this->questionLimit=0;
$this->questionList= array();
@@ -29,261 +29,261 @@ class Quiz
$this->rawToPass;
$this->question=new Question();
$this->percentTest=0;
- }
+ }
- function getQuestionLimit() {
- return $this->questionLimit;
- }
+ function getQuestionLimit() {
+ return $this->questionLimit;
+ }
- function setQuestionLimit($numOfQu){
- $this->questionLimit= $numOfQu;
- }
+ function setQuestionLimit($numOfQu){
+ $this->questionLimit= $numOfQu;
+ }
- function setTopicID($id) {
+ function setTopicID($id) {
$this->topicID=$id;
- }
+ }
- function getTopicID(){
+ function getTopicID(){
return $this->topicID;
- }
+ }
- function getAnswerList () {
- return $this->answerList;
- }
+ function getAnswerList () {
+ return $this->answerList;
+ }
- function setRawToPass($percentage){
- $this->rawToPass=$percentage;
- }
+ function setRawToPass($percentage){
+ $this->rawToPass=$percentage;
+ }
- function generateQuestions(){ // Fragen werden random aus DB gelesen
- $sqlGetQu=" SELECT q_id,qt_id,t_id,question,description FROM questions WHERE t_id =".intval($this->topicID)." AND active=".intval(1)." ORDER BY RAND()LIMIT ".intval($this->questionLimit)."";
- $queryGetQu = mysql_query($sqlGetQu);
- $number=mysql_num_rows($queryGetQu);
- if($number== $this->questionLimit){
- $i=1; // zähler
- while($questions =mysql_fetch_array($queryGetQu ,MYSQL_BOTH ))
- {
+ function generateQuestions(){ // Fragen werden random aus DB gelesen
+ $sqlGetQu=" SELECT q_id,qt_id,t_id,question,description FROM questions WHERE t_id =".intval($this->topicID)." AND active=".intval(1)." ORDER BY RAND()LIMIT ".intval($this->questionLimit)."";
+ $queryGetQu = mysql_query($sqlGetQu);
+ $number=mysql_num_rows($queryGetQu);
+ if($number== $this->questionLimit){
+ $i=1; // zähler
+ while($questions =mysql_fetch_array($queryGetQu ,MYSQL_BOTH ))
+ {
- $this->questionList[$i]['q_id']=$questions['q_id']; // in arra speichern
- $this->questionList[$i]['qt_id']=$questions['qt_id'];
- $this->questionList[$i]['t_id']=$questions['t_id'];
- $this->questionList[$i]['question']=stripslashes($questions['question']);
- $this->questionList[$i]['description']=$questions['description'];
- $sqlGetNumber="SELECT count(a_id)as number FROM answers WHERE q_id=".intval($questions['q_id'])." GROUP BY q_id";
- $queryGetNumber = mysql_query($sqlGetNumber);
- while($number =mysql_fetch_array( $queryGetNumber ,MYSQL_BOTH ))
- {
- $this->questionList[$i]['numberOfAnswers']=$number['number'];
- }
- if($this->questionList[$i]['description']==1) {
- // beschreibung in Session speichern falls vorhanden
- $sql_desc="SELECT description FROM question_description WHERE q_id=".intval($questions['q_id'])."";
- $query_desc=mysql_query($sql_desc);
- $desc = mysql_fetch_assoc($query_desc);
- $this->questionList[$i]['description_text']=stripslashes($desc['description']);
- }
- $i++;
- }
- $_SESSION['values']['questionList']=$this->questionList;
- }
- else{
- echo "
".Class_Quiz_01."
";
- $value ="notEnoughQuestions";
- return $value;
- }
- }
+ $this->questionList[$i]['q_id']=$questions['q_id']; // in arra speichern
+ $this->questionList[$i]['qt_id']=$questions['qt_id'];
+ $this->questionList[$i]['t_id']=$questions['t_id'];
+ $this->questionList[$i]['question']=stripslashes($questions['question']);
+ $this->questionList[$i]['description']=$questions['description'];
+ $sqlGetNumber="SELECT count(a_id)as number FROM answers WHERE q_id=".intval($questions['q_id'])." GROUP BY q_id";
+ $queryGetNumber = mysql_query($sqlGetNumber);
+ while($number =mysql_fetch_array( $queryGetNumber ,MYSQL_BOTH ))
+ {
+ $this->questionList[$i]['numberOfAnswers']=$number['number'];
+ }
+ if($this->questionList[$i]['description']==1) {
+ // beschreibung in Session speichern falls vorhanden
+ $sql_desc="SELECT description FROM question_description WHERE q_id=".intval($questions['q_id'])."";
+ $query_desc=mysql_query($sql_desc);
+ $desc = mysql_fetch_assoc($query_desc);
+ $this->questionList[$i]['description_text']=stripslashes($desc['description']);
+ }
+ $i++;
+ }
+ $_SESSION['values']['questionList']=$this->questionList;
+ } else {
+ echo "
".Class_Quiz_01."
";
+ $value ="notEnoughQuestions";
+ return $value;
+ }
+ }
- function getQuestionList() {
- return $this->questionList;
- }
+ function getQuestionList() {
+ return $this->questionList;
+ }
- function setQuestions() {
- $this->questionList=$_SESSION['values']['questionList'];
- }
+ function setQuestions() {
+ $this->questionList=$_SESSION['values']['questionList'];
+ }
- function getDBAnswers() { // Antworten zu den Frage aus DB holen
- for($i=1;$i<=$this->questionLimit;$i++){
- $value= $this->questionList[$i]['q_id'];
- $sqlGetAns="SELECT a_id,answer,correct FROM answers WHERE q_id=".intval($value)." ORDER BY RAND()";
- $queryGetAns = mysql_query($sqlGetAns);
- $j=1; // Zähler
- while($answers =mysql_fetch_array($queryGetAns ,MYSQL_BOTH )) {
- $this->answerList[$value][$j]['q_id']= $value;
- $this->answerList[$value][$j]['a_id']=$answers['a_id']; // in arra speichern
- $this->answerList[$value][$j]['answer']=stripslashes($answers['answer']);
- $this->answerList[$value][$j]['correct']=$answers['correct'];
- $j++;
- }
- }
- $_SESSION ['values'] ['answerList']= $this->answerList;
- }
+ function getDBAnswers() { // Antworten zu den Frage aus DB holen
+ for($i=1;$i<=$this->questionLimit;$i++){
+ $value= $this->questionList[$i]['q_id'];
+ $sqlGetAns="SELECT a_id,answer,correct FROM answers WHERE q_id=".intval($value)." ORDER BY RAND()";
+ $queryGetAns = mysql_query($sqlGetAns);
+ $j=1; // Zähler
+ while($answers =mysql_fetch_array($queryGetAns ,MYSQL_BOTH )) {
+ $this->answerList[$value][$j]['q_id']= $value;
+ $this->answerList[$value][$j]['a_id']=$answers['a_id']; // in arra speichern
+ $this->answerList[$value][$j]['answer']=stripslashes($answers['answer']);
+ $this->answerList[$value][$j]['correct']=$answers['correct'];
+ $j++;
+ }
+ }
+ $_SESSION ['values'] ['answerList']= $this->answerList;
+ }
- function setAnswers(){
- $this->answerList=$_SESSION ['values']['answerList'];
- }
+ function setAnswers(){
+ $this->answerList=$_SESSION ['values']['answerList'];
+ }
function setSelectedAnswers (){
- $this->selectedAnswers=$_SESSION ['values']['selectedAnswers'];
- }
+ $this->selectedAnswers=$_SESSION ['values']['selectedAnswers'];
+ }
function showQuiz() {
- echo "";
}
- function SingleSelection($i,$value){
- for ($j=1;$j<=$this->questionList[$i]['numberOfAnswers'];$j++){ // Solange Schleife durchlaufen wie die maximale Anzahl der Antworten ist
- $answer=$this->answerList[$value][$j]['answer'];
- $answerNumber=$this->answerList[$value][$j]['a_id'];
- if($answer!=null) { // Wenn es eine Antwort gibt soll diese angezeigt werden
- echo "
";
- echo "
";
- echo"
";
- if ($answer=='true') echo"
".Class_Answer_09."
";
- else if ($answer=='false') echo"
".Class_Answer_10."
";
- else echo"
$answer
";
- echo "
";
- echo "
";
- }
- }
- echo "
";
- }
+ function SingleSelection($i,$value){
+ for ($j=1;$j<=$this->questionList[$i]['numberOfAnswers'];$j++){ // Solange Schleife durchlaufen wie die maximale Anzahl der Antworten ist
+ $answer=$this->answerList[$value][$j]['answer'];
+ $answerNumber=$this->answerList[$value][$j]['a_id'];
+ if($answer!=null) { // Wenn es eine Antwort gibt soll diese angezeigt werden
+ echo "
";
+ echo "
";
+ echo"
";
+ if ($answer=='true') echo"
".Class_Answer_09."
";
+ else if ($answer=='false') echo"
".Class_Answer_10."
";
+ else echo"
$answer
";
+ echo "
";
+ echo "
";
+ }
+ }
+ echo "
";
+ }
function MultipleChoice($i,$value){
- for ($j=1;$j<=$this->questionList[$i]['numberOfAnswers'];$j++){ // Solange Schleife durchlaufen wie die maximale Anzahl der Antworten ist
- $answer=$this->answerList[$value][$j]['answer'];
- $answerNumber=$this->answerList[$value][$j]['a_id'];
- if($answer!=null){ // Wenn es eine Antwort gibt soll diese angezeigt werden
- echo "
";
- echo "
";
- echo "
";
- echo "
$answer
";
- echo "
";
- echo "
";
- }
- }
- echo "
";
- }
+ for ($j=1;$j<=$this->questionList[$i]['numberOfAnswers'];$j++){ // Solange Schleife durchlaufen wie die maximale Anzahl der Antworten ist
+ $answer=$this->answerList[$value][$j]['answer'];
+ $answerNumber=$this->answerList[$value][$j]['a_id'];
+ if($answer!=null){ // Wenn es eine Antwort gibt soll diese angezeigt werden
+ echo "