Ejemplo n.º 1
0
 public function getQuestions($limit, $mode)
 {
     $questions = array();
     $result = array();
     foreach ($this->dbGetCol('SELECT question_id from test_content WHERE test_id=:test_id ', array('test_id' => $this->id)) as $quest_id) {
         $question = new Question();
         $question->createFromID($quest_id);
         $questions[] = $question;
     }
     $this->avg_diff = $this->countAvgDiff($questions);
     $result = $this->testMode($mode, $limit, $questions);
     return $result;
 }
Ejemplo n.º 2
0
 public function getDirectQuestions()
 {
     $this->initConnection();
     $questions = array();
     $result = array();
     $result = $this->dbQuery('SELECT q.id AS id, q.mark AS mark FROM `questions` AS q
                 JOIN `slide_revision` AS s ON q.item_id = s.slide
                 JOIN `deck_content` AS d ON s.id = d.item_id
                 WHERE d.deck_revision_id=:id AND q.mark="accepted" AND d.item_type="slide" AND q.based_on IS NULL', array('id' => $this->item_id));
     if (count($result)) {
         foreach ($result as $question_row) {
             $question = new Question();
             $question->createFromID($question_row['id']);
             $lastId = $question->getLastRevision();
             $lastRevision = new Question();
             $lastRevision->createFromID($lastId);
             $questions[] = $lastRevision;
         }
     }
     return $questions;
 }
Ejemplo n.º 3
0
    public function getQuestions()
    {
        $questions = array();
        $suggested = array();
        $accepted = array();
        $doubtful = array();
        $basic_id = $this->getBasicId();
        if ($basic_id == NULL) {
            return array("accepted" => array(), "suggested" => array(), "doubtful" => array());
        }
        $array = array();
        $owner_id = $this->getOwnerID();
        $array = $this->dbQuery('SELECT *
			FROM questions INNER JOIN users on questions.user_id = users.id
			WHERE questions.based_on IS NULL AND questions.mark = "suggested" AND questions.item_id=' . $basic_id);
        if (count($array)) {
            foreach ($array as $row) {
                $question = new Question();
                $question->createFromID($row['0']);
                $lastId = $question->getLastRevision();
                $lastRevision = new Question();
                $lastRevision->createFromID($lastId);
                $lastRevision->slide_revision = $this->id;
                $lastRevision->item_owner = $owner_id;
                $suggested[] = $lastRevision;
            }
        }
        $array = $this->dbQuery('SELECT *
			FROM questions INNER JOIN users on questions.user_id = users.id
			WHERE questions.based_on IS NULL AND questions.mark = "accepted" AND questions.item_id=' . $basic_id);
        if (count($array)) {
            foreach ($array as $row) {
                $question = new Question();
                $question->createFromID($row['0']);
                $lastId = $question->getLastRevision();
                $lastRevision = new Question();
                $lastRevision->createFromID($lastId);
                $lastRevision->slide_revision = $this->id;
                $lastRevision->item_owner = $owner_id;
                $accepted[] = $lastRevision;
            }
        }
        $array = $this->dbQuery('SELECT *
			FROM questions INNER JOIN users on questions.user_id = users.id
			WHERE questions.based_on IS NULL AND questions.mark = "doubtful" AND questions.item_id=' . $basic_id);
        if (count($array)) {
            foreach ($array as $row) {
                $question = new Question();
                $question->createFromID($row['0']);
                $lastId = $question->getLastRevision();
                $lastRevision = new Question();
                $lastRevision->createFromID($lastId);
                ${$lastRevision}->item_owner = $owner_id;
                $doubtful[] = $lastRevision;
            }
        }
        $questions['suggested'] = $suggested;
        $questions['accepted'] = $accepted;
        $questions['doubtful'] = $doubtful;
        return $questions;
    }
Ejemplo n.º 4
0
 public function getLastRevision()
 {
     $timestamp = $this->timestamp;
     $last_id = $this->id;
     foreach ($this->dbQuery('SELECT * FROM questions WHERE based_on=:id', array('id' => $last_id)) as $question_row) {
         if ($timestamp < $question_row['timestamp']) {
             $question = new Question();
             $question->createFromID($question_row['id']);
             $last_id = $question->getLastRevision();
         }
     }
     return $last_id;
 }