progress=array();
$this->incorrect_answers=array();
$this->maximum=5;
$this->topic=0;
$this->lp_id=0;
$this->percentArray=array();
}
function setTopic($t_id){
$this->topic=$t_id;
}
function setLp_id($lp_id){
$this->lp_id=$lp_id;
}
function setData($value){
$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";
$query = mysql_query($sql) OR die(mysql_error());
$i=1;
while($progress =mysql_fetch_array($query,MYSQL_BOTH )){
$this->progress[$i]['lp_id']=$progress['lp_id'];
$this->progress[$i]['date']=$progress['date'];
$this->progress[$i]['number']=$progress['number']; // in arra speichern
$this->progress[$i]['correct']=$progress['correct'];
$this->progress[$i]['wrong']=$progress['wrong'];
$i++;
}
}
function count() {
$numberOfTests=count($this->progress);
return $numberOfTests;
}
function showTable() {
if(count($this->progress)==0) echo "
".Global_07."
";
else {
echo"
";
echo"";
echo "";
echo"".Global_10." | ";
echo"".Global_04." | ";
echo"".Class_Progress_01." | ";
echo"".Global_03." | ";
echo " | ";
echo"
";
for ($i=1;$i<=count($this->progress);$i++){
echo "";
echo"$i | ";
echo"".$this->progress[$i]['date']." | ";
echo"".$this->progress[$i]['number']." | ";
if ($this->progress[$i]['number'] > 0) {
$percent=($this->progress[$i]['correct']/$this->progress[$i]['number'])*100;
} else {
$percent = 0;
}
$percent=round ($percent,2);
echo"$percent % | ";
echo" topic'> | ";
echo "
";
}
echo"
";
}
}
function checkProgressData(){
if(count($this->progress)==0) echo "".Global_07."
";
else {
$percentArray=array();
$limit=count($this->progress);
if($limit>$this->maximum){
$k=($limit-$this->maximum)+1;
$limit=($k+$this->maximum)-1;
echo ''.Class_Progress_02." ".Class_Progress_03." $this->maximum ".Class_Progress_04.".
";
} else $k=1;
$j=0;
for ($i=$k;$i<=$limit;$i++){
if ($this->progress[$i]['number'] > 0) {
$percent=($this->progress[$i]['correct']/$this->progress[$i]['number'])*100;
} else {
$percent=0;
}
$this->percentArray[$j][]=$this->progress[$i]['date'];
$this->percentArray[$j][]=$percent;
$j++;
}
}
}
function showBalken(){
$this->checkProgressData();
$this->percentArray= serialize($this->percentArray);
$this->percentArray=base64_encode ($this->percentArray);
$titley=Global_15;
$titlex=Global_04;
echo " \n";
echo "
";
echo "
\n";
}
function showGraph(){
$this->checkProgressData();
$this->percentArray= serialize($this->percentArray);
$this->percentArray=base64_encode ($this->percentArray);
$titley=Global_15;
$titlex=Global_04;
echo " \n";
echo "
";
echo "
\n";
}
function showPie(){
echo " \n";
echo "
";
echo "
\n";
}
function getIncorrectAnswers()
{
$sql="SELECT q_id FROM answers_incorrect WHERE lp_id=".intval($this->lp_id)."";
$query = mysql_query($sql);
$i=1;
while($incorrect_answers =mysql_fetch_array($query,MYSQL_BOTH ))
{
$this->incorrect_answers[$i]['q_id']=$incorrect_answers['q_id'];
$i++;
}
$this->showIncorrectAnswers();
}
function showIncorrectAnswers(){
echo "";
}
function getFIBQuestion($question){
$addSlashes= preg_quote( $question, '[^]'); // Slash hinzufügen wenn KLammer gefunden wird
$array=explode('\\',$addSlashes); // String teilen
$questionText= $question;
if(substr_count($question,"[")==substr_count($question,"]")) { // gleiche anzahl von Klammer auf und zu
for($i=1;$i<=substr_count($question,"[");$i++){ // Wird solange durchlaufne wie Klammern vorhanden sind
$beginPos = strpos($questionText, "["); // Anfangspunkt festlegen
$endPos=strpos($questionText, "]"); // Endpunkt festlegen
$length=(($endPos+1)-$beginPos) ; // Länge der Strings ermitteln
$answer=substr ($questionText,$beginPos,$length );// den String zwischen den Klammern suchen
$questionText=str_replace($answer,'(xxx)', $questionText); // gespeicherten Wert aus string löschen
$answer=str_replace("]",'', $answer); // Klammer entfernen
$key = array_search($answer, $array);
$answer=str_replace("[",'', $answer); // Klammer entfernen
}
}
return $questionText;
}
}
?>