Exemplo n.º 1
0
 public function __construct($userid, $connection)
 {
     $set = null;
     $setid = -1;
     $questionid = -1;
     $answerid = -1;
     foreach ($connection->query('SELECT * FROM fullQuestionSet WHERE ownerid="' . $userid . '"') as $row) {
         if ($row['setid'] != $setid) {
             $set = new cardSet();
             $set->setSetId($row['setid']);
             $set->setSetName($row['setname']);
             $set->setSetDescription($row['setdescription']);
         }
         if ($questionid != $row['questionid'] && $row['questionid'] != null) {
             $question = new question();
             $question->setId($row['questionid']);
             $question->setQuestion($row['question']);
             $question->setMode($row['mode']);
             $question->setRightAnswered($row['rightAnswered']);
             $question->setWrongAnswered($row['wrongAnswered']);
         }
         if ($answerid != $row['answerid'] && $row['answerid'] != null) {
             $answerobj = new answer();
             $answerobj->setAnswer($row['answertext']);
             $answerobj->setAnswerId($row['answerid']);
         }
         if ($answerid != $row['answerid'] && $row['answerid'] != null) {
             $question->addAnswer($answerobj);
             $answerid = $row['answerid'];
         }
         if ($questionid != $row['questionid'] && $row['questionid'] != null) {
             $set->addQuestion($question);
             $questionid = $row['questionid'];
         }
         if ($set != null && $row['setid'] != $setid) {
             $setid = $row['setid'];
             array_push($this->sets, $set);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Create a new set..
  * @param cardSet $set
  * @param int $userid
  * @param PDO $connection
  */
 public function newSet($set, $userid, $connection)
 {
     $connection->exec("INSERT INTO " . $GLOBALS['dbPrefix'] . "question_set (`setname`,`setdescription`, `ownerid`,  `editcount`, `createtimestamp`, `firstowner`) VALUES ('" . $set->getSetName() . "', '" . $set->getSetDescription() . "', " . $userid . ", 1, '2009-00-00 00:00:00', " . $userid . ");");
     $set->setSetId($connection->lastInsertId());
     array_push($this->sets, $set);
 }