diff --git a/classes/Quiz.class.php b/classes/Quiz.class.php index 0848c91..3465a55 100755 --- a/classes/Quiz.class.php +++ b/classes/Quiz.class.php @@ -1,6 +1,6 @@ topicID=0; $this->questionLimit=0; @@ -29,56 +30,56 @@ class Quiz $this->question=new Question(); $this->percentTest=0; } - - function getQuestionLimit() { + + function getQuestionLimit() { return $this->questionLimit; } - + function setQuestionLimit($numOfQu){ $this->questionLimit= $numOfQu; } - + function setTopicID($id) { $this->topicID=$id; } - + function getTopicID(){ return $this->topicID; } - - + + function getAnswerList () { return $this->answerList; } - + 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); + $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 )) - { - + 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 )) - { + $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 + // 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); + $query_desc=mysql_query($sql_desc); $desc = mysql_fetch_assoc($query_desc); $this->questionList[$i]['description_text']=stripslashes($desc['description']); } @@ -87,31 +88,31 @@ class Quiz $_SESSION['values']['questionList']=$this->questionList; } else{ - echo "