Exemplo n.º 1
0
 protected function doProcess($data)
 {
     $seq = Model_Quiz_Sequence::load($data['id']);
     if (!$seq) {
         throw new Exception('Invalid sequence');
     }
     $db = Zend_Registry::get('db');
     $db->beginTransaction();
     try {
         //remove previous
         $db->delete('sequence_quiz', array('sequence_id=?' => $seq->id));
         $items = $this->get($data['items'], array());
         $cnt = 1;
         foreach ($items as $quiz_id) {
             $db->insert('sequence_quiz', array('sequence_id' => $seq->id, 'quiz_id' => $quiz_id, 'position' => $cnt));
             $cnt++;
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
 }
Exemplo n.º 2
0
 function addQuizzesToSequenceAction()
 {
     $seq = Model_Quiz_Sequence::load($this->_getParam("id"));
     if (!$seq) {
         throw new Exception("Invalid sequence.");
     }
     $available = array();
     foreach ($seq->getAvailableQuizzes() as $row) {
         $available[$row['id']] = $row['name'];
     }
     $current = array();
     foreach ($seq->getQuizzes() as $row) {
         $current[$row['id']] = $row['name'];
     }
     $this->view->seq = $seq;
     $this->view->available = $available;
     $this->view->current = $current;
     $this->render('sequence-editor');
 }