table='topics'; $this->topicName=''; $this->topics = array(); $this->topicID=0; $this->rawToPass=0; $this->numOfQu=0; $this->error=''; $this->question=new Question (); } function setTopicName($topicName){ $this->topicName=$topicName; } function setNumOfQu($numOfQu){ $this->numOfQu=$numOfQu; if(is_numeric($this->numOfQu)==true && $this->numOfQu>0) return 0; else return 1; } function setrawToPass($rawToPass){ $this->rawToPass=$rawToPass; if(is_numeric($this->rawToPass)==true && $this->rawToPass<=100 && $this->rawToPass>0) return 0; else return 1; } function setError($error){ $this->error=$error; } function setTopic($t_id){ $this->topicID=$t_id; $sql ="SELECT topic,numOfQu,percentage FROM topics WHERE t_id='".intval($t_id)."'"; // fehlt noch dass Variable genommen wird $query = mysql_query($sql)OR die(mysql_error()); while($topic = mysql_fetch_array( $query,MYSQL_BOTH )){ $this->topicName= $topic['topic']; $this->rawToPass=$topic['percentage']; $this->numOfQu=$topic['numOfQu']; } $this->setSession(); } function setInactiveTopic() { $sql="UPDATE topics SET active=".intval(0)." WHERE t_id=".intval($this->topicID).""; $ok= mysql_query($sql)OR die(mysql_error()); if (!$ok) { $error=mysql_errno() ; } } function setActiveTopic(){ $sql="UPDATE topics SET active=".intval(1)." WHERE t_id=".intval($this->topicID).""; $ok= mysql_query($sql)OR die(mysql_error()); if (!$ok){ $error=mysql_errno() ; } } function getNumOfQu (){ $sql ="SELECT numOfQu FROM topics WHERE t_id=".intval($this->topicID).""; // fehlt noch dass Variable genommen wird $query = mysql_query($sql)OR die(mysql_error()); $numOfQu = mysql_fetch_assoc($query); return $numOfQu ['numOfQu']; } function getrawToPass (){ $sql ="SELECT percentage FROM topics WHERE t_id=".intval($this->topicID).""; // fehlt noch dass Variable genommen wird $query = mysql_query($sql)OR die(mysql_error()); $rawToPass = mysql_fetch_assoc($query); return $rawToPass ['percentage']; } function setTopicID($t_id){ $this->topicID=$t_id; } function getTopicID(){ return $this->topicID; } function getTopicName(){ return $this->topicName ; } function saveTopic(){ if($this->topicName!=null && $this->numOfQu!=null &&$this->rawToPass!=null){ $sql = 'INSERT INTO topics (topic,active,numOfQu,percentage)VALUES ("'.mysql_real_escape_string($this->topicName).'","'.intval(1).'",'.intval($this->numOfQu).','.intval($this->rawToPass).') '; $ok= mysql_query($sql); if (!$ok){ $error=mysql_errno() ; if($error=='1062') return "existing"; } return "none"; } else return "missing"; } function getActiveTopic(){ $sql ='SELECT * FROM topics WHERE active="'.intval(1).'"'; $query = mysql_query($sql)OR die(mysql_error()); if(!$query){ // Wenn Fehler $error=mysql_errno() ; } else{ $i=1; while($topic =mysql_fetch_array($query,MYSQL_BOTH )){ $this->topics[$i]['t_id']=$topic['t_id']; // in arra speichern $this->topics[$i]['topic']=$topic['topic']; $this->topics[$i]['rawToPass']=$topic['percentage']; $this->topics[$i]['numOfQu']=$topic['numOfQu']; $i++; } } } function getTopic(){ $sql ='SELECT * FROM topics'; // fehlt noch dass Variable genommen wird $query = mysql_query($sql)OR die(mysql_error()); if(!$query) { // Wenn Fehler $error=mysql_errno() ; } else{ $i=1; while($topic =mysql_fetch_array($query,MYSQL_BOTH )){ $this->topics[$i]['t_id']=$topic['t_id']; // in arra speichern $this->topics[$i]['topic']=$topic['topic']; $this->topics[$i]['rawToPass']=$topic['percentage']; $this->topics[$i]['numOfQu']=$topic['numOfQu']; $this->topics[$i]['active']=$topic['active']; $i++; } } } function getTopicArray(){ // Liefert das Array mit den Topics zurück return $this->topics; } function setSession(){ $_SESSION['values']['topic']['t_id']= $this->topicID; $_SESSION['values']['topic']['topicName']= $this->topicName; $_SESSION['values']['topic']['numOfQu']=$this->numOfQu; $_SESSION['values']['topic']['rawToPass']=$this->rawToPass; } function unsetSession(){ unset($_SESSION['values']['topic']); } function showTopicTable($number){ // Topics in Tabelle anzeigen echo"
".Class_Topic_01." | "; echo"".Class_Topic_02." | "; echo"".Class_Topic_03." | "; echo"".Class_Topic_04." | "; echo""; echo" | "; echo" | "; echo" | ||
topics[$i]['t_id']."\">".stripslashes($this->topics[$i]['topic'])." | "; else echo"topics[$i]['t_id']."\">".stripslashes($this->topics[$i]['topic'])." | "; echo"".$number[$i]." | "; // array Werte ausgeben echo"".$this->topics[$i]['numOfQu']." | "; echo"".$this->topics[$i]['rawToPass']." % | "; echo""; if($this->topics[$i]['active']==0)echo" | "; else echo" | "; echo" | "; echo " |