예제 #1
0
파일: Quiz.php 프로젝트: sutantyo/itec810
 public function getTestedConcepts()
 {
     $db = Zend_Registry::get("db");
     $vReturn = array();
     $sql = "SELECT * FROM concepts_tested WHERE quizquiz_id=" . $db->quote($this->quiz_id);
     //echo "SQL: $sql";
     $result = $db->query($sql);
     $rows = $result->fetchAll();
     foreach ($rows as $row) {
         $vReturn[] = Model_Quiz_TestedConcept::fromID($row['ctest_id']);
     }
     return $vReturn;
 }
예제 #2
0
 public static function fromScratch($lower_difficulty, $higher_difficulty, $number_tested, $vConcept, $vQuiz)
 {
     $db = Zend_Registry::get("db");
     $sql = "INSERT INTO concepts_tested(ctest_id,lower_difficulty,higher_difficulty,number_tested,conceptsconcept_name,quizquiz_id) VALUES(NULL, " . $db->quote($lower_difficulty) . "," . $db->quote($higher_difficulty) . "," . $db->quote($number_tested) . "," . $db->quote($vConcept->getID()) . "," . $db->quote($vQuiz->getID()) . ")";
     $db->query($sql);
     //Now find the appropriate entry in the database
     //	A safe (default) assumption for this is a query that looks for everything you just put in.
     $sql = "SELECT ctest_id FROM concepts_tested WHERE lower_difficulty=" . $db->quote($lower_difficulty) . " AND higher_difficulty=" . $db->quote($higher_difficulty) . " AND number_tested=" . $db->quote($number_tested) . " AND conceptsconcept_name=" . $db->quote($conceptsconcept_name) . " AND quizquiz_id=" . $db->quote($quizquiz_id);
     $result = $db->query($sql);
     $row = $result->fetch();
     if ($row['ctest_id'] != null) {
         return Model_Quiz_TestedConcept::fromID($row['ctest_id']);
     } else {
         return null;
         //Something didn't happen
     }
 }
예제 #3
0
 /**
  * Deletes a Concept
  * Expects parameter [concept_id] to be passed
  *
  * @return void
  * @author Ben Evans
  */
 public function deleteconceptAction()
 {
     $concept_id = $this->_getParam("concept_id");
     if (!isset($concept_id)) {
         throw new Exception("Count not delete concept. No identifier passed", 3000);
     }
     $vTestedConcept = Model_Quiz_TestedConcept::fromID($concept_id);
     if ($vTestedConcept == null) {
         throw new Exception("ID passed did not correspond to a valid TestedConcept");
     }
     $vQuiz = $vTestedConcept->getQuiz();
     //For the return page
     $vTestedConcept->remove();
     //Redirect to the concept page
     $params = array('id' => $vQuiz->getID());
     $this->_helper->redirector("showconcepts", "admin", null, $params);
 }