Exemplo n.º 1
0
 function testCrudFunctions()
 {
     $script = new Script($this->DBI);
     $script->setKey(2);
     $script->retrieve();
     $this->assertTrue(count($script->pages->getPageKeys()) === 2, 'Ensure script has retrieved successfully');
     $this->assertTrue($script->pages->getPageKeyAt(0) === 'script2_page1', 'Test read page');
     $script->pages->swapPages(0, 1);
     $this->assertTrue($script->pages->getPageKeyAt(0) === 'script2_page2', 'Test swap page');
     $script->pages->removePage(1);
     $this->assertTrue(count($script->pages->getPageKeys()) === 1, 'Test page delete');
     $script->update();
     $script = new Script($this->DBI);
     $script->setKey(2);
     $script->retrieve();
     $this->assertTrue(count($script->pages->getPageKeys()) === 1, 'Test page updated after deleting');
     //echo "\n\n **** REMOVING PAGE 0 *** \n";
     $script->pages->removePage(0);
     $this->assertTrue(count($script->pages->getPageKeys()) === 0, 'Test page delete after update');
     //echo "\n\n **** UPDATE WITH 0 *** \n";
     $script->update();
     //echo "\n\n **** RETRIEVE WITH 0 *** \n";
     $script = new Script($this->DBI);
     $script->setKey(2);
     $script->retrieve();
     $this->assertTrue(count($script->pages->getPageKeys()) === 0, 'Test page updated and retrieved with 0 script keys');
     $script = new Script($this->DBI);
     $script->createNewScriptFor('*****@*****.**');
     $key = $script->getKey();
     $script->pages->addPage(1, 'fourxx', 'old');
     $script->update();
     $script = new Script($this->DBI);
     $script->setKey($key);
     $script->retrieve();
     $this->assertTrue($script->get('email') === '*****@*****.**', 'Test createNewScriptFor');
     $this->assertTrue($script->pages->getPageKeyAt(0) === 'fourxx', 'Test create, update, and retrieve');
 }
Exemplo n.º 2
0
 /**
  * Returns the progress steps for this controller
  *
  * @return Array $progress
  *
  */
 private function _progressSteps(Script $script)
 {
     $uploadStatus = '';
     $detailsStatus = 'disabled';
     $payStatus = 'disabled';
     $subject = $script->get('subject');
     $question = $script->get('question');
     if (!empty($subject) && !empty($question) && $script->pages->getPageKeys()) {
         $detailsStatus = 'complete';
         $detailsComplete = true;
     }
     if ($script->pages->getPageKeys()) {
         $uploadStatus = 'complete';
         if ($detailsStatus != 'complete') {
             $detailsStatus = 'active';
         }
         $pagesAdded = true;
     }
     if (@$pagesAdded && @$detailsComplete) {
         $payStatus = '';
     }
     $upload = array('Upload page images', site_url('user/upload'), @$uploadStatus);
     $details = array('Enter essay details', site_url('user/upload/details'), @$detailsStatus);
     $pay = array('Pay', site_url('user/pay', true), @$payStatus);
     return array('upload' => $upload, 'details' => $details, 'pay' => $pay);
 }
Exemplo n.º 3
0
 /**
  * Method for saving Flex models.Mark.
  * @param POST jsonData - holds the markData information in JSON format
  */
 public function addMark()
 {
     if (!($jsonData = $this->input->post('jsonData'))) {
         return;
     }
     $this->load->model('mark');
     $this->load->model('script');
     $this->load->library('json');
     $decoded = $this->json->decode($jsonData);
     $script = new Script();
     $script->setKey($decoded->script);
     $mark = new Mark();
     $mark->setKey($script->getKey());
     $mark->retrieve();
     // make sure the marker has right to mark this
     if ($mark->get('marker') !== $this->_getUser()) {
         $this->_flexResult(I_FlexMarksIn::NOT_AUTH);
         return;
     }
     // store data
     $mark->set('markData', $jsonData);
     $mark->set('targets', serialize($decoded->targets));
     $mark->set('generalComment', $decoded->generalComment);
     // change status
     $mark->submit();
     if (!$mark->update()) {
         // @todo add some Flex handeling for this if it occurs
         $this->_flexResult(I_FlexMarksIn::ERROR);
         return;
     }
     // set script's status to marked
     $script->marked();
     $script->update();
     // get the script data to use in the email
     $script->retrieve();
     $customerEmail = $script->get('email');
     $scriptID = $script->getKey();
     $lastPage = count($script->pages->getPageKeys());
     // save an email for the customers, to be send by cron task
     $subject = 'A tutor has read your exam essay and provided feedback';
     foreach ($decoded->targets as $target) {
         $newTarget['type'] = $target->type;
         $newTarget['text'] = $target->text;
         $emailData['targets'][] = $newTarget;
     }
     $emailData['generalComment'] = $decoded->generalComment;
     // link for user to launch flex viewer
     $emailData['viewURL'] = site_url("/user/scripts/viewfeedback/{$scriptID}/{$lastPage}");
     $msg = $this->load->view('email/marked', $emailData, true);
     $this->load->model('email');
     $this->email->set('sender', '*****@*****.**');
     $this->email->set('receiver', $customerEmail);
     $this->email->set('subject', $subject);
     $this->email->set('message', $msg);
     //$this->email->set('messageHTML',$msgHTML);
     $this->email->create();
     $this->_flexResult(I_FlexMarksIn::SAVE_SUCCESSFUL);
 }
Exemplo n.º 4
0
 private function _scriptAuthCheck($scriptNum, Script $script = null)
 {
     if (!$script) {
         $this->load->model('script');
         $script = new Script();
     }
     $script->retrieve($scriptNum);
     // is the script this user's?
     if ($script->get('email') === $this->_getUser()) {
         return true;
     }
     return false;
 }