Exemplo n.º 1
0
 /**
  * @param WpTesting_Model_Test $test
  * @return WpTesting_Model_Passing
  */
 public function populate(WpTesting_Model_Test $test)
 {
     $this->setCreated(time())->setModified(time())->setTestId($test->getId());
     parent::populate(true);
     $this->linkWpTesting_Model_Answers();
     return $this;
 }
Exemplo n.º 2
0
 private function setupScalesDiagram(WpTesting_Model_Test $test, WpTesting_Model_Passing $passing)
 {
     if (!$test->isShowScalesDiagram()) {
         return $this;
     }
     $sorryBrowser = sprintf(__('Sorry but your browser %s is not compatible to display the chart', 'wp-testing'), $this->getUserAgent());
     $scales = $this->toJson($passing->buildScalesWithRangeOnce());
     return $this->addJsData('warningIncompatibleBrowser', $sorryBrowser)->addJsData('scales', $scales)->enqueueScript('line-diagram', array('jquery', 'raphael-scale', 'raphael-line-diagram'));
 }
Exemplo n.º 3
0
 /**
  * @return WpTesting_Model_Formula
  */
 public function getFormula()
 {
     $empty = new WpTesting_Model_Formula();
     $empty->setResultId($this->getId());
     if (is_null($this->test)) {
         return $empty;
     }
     $empty->setTestId($this->test->getId());
     /* @var $formulas fRecordSet */
     $formulas = $this->test->buildFormulas();
     foreach ($formulas->filter(array('getResultId=' => $this->getId())) as $formula) {
         return $formula;
     }
     return $empty;
 }
Exemplo n.º 4
0
 public function renderTestContent($content)
 {
     // Protection for calling the_content filter not on current test content
     $isSimilar = 50 > levenshtein($this->prepareToLevenshein($this->test->getContent()), $this->prepareToLevenshein($content));
     if (!$isSimilar) {
         return $content;
     }
     // Protection for many times calling the_content filter
     if (!is_null($this->filteredTestContent)) {
         return $this->filteredTestContent;
     }
     $action = $this->getTestPassingAction();
     $template = $this->wp->locateTemplate('entry-content-wpt-test-' . $action . '.php');
     $template = $template ? $template : 'Test/Passer/' . $action;
     $this->wp->doAction('wp_testing_passer_render_content', $this->test);
     $this->wp->doAction('wp_testing_passer_render_content_' . $action, $this->test);
     $this->filteredTestContent = $this->createActionProcessor($action)->renderContent($content, $template);
     return $this->filteredTestContent;
 }
Exemplo n.º 5
0
 public function getQuestionsCount()
 {
     return $this->test->buildQuestions()->count();
 }
Exemplo n.º 6
0
 /**
  * Creates test with injected WP facade
  * @param mixed $key
  * @return WpTesting_Model_Test
  */
 protected function createTest($key = null)
 {
     $test = new WpTesting_Model_Test($key);
     return $test->setWp($this->wp);
 }