/** * @param WpTesting_Model_Passing $item * @param string $column_name * @return string */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { switch ($column_name) { case 'passing_created': return $item->getCreated(); } return ''; }
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')); }
public function beforeRender(WpTesting_Model_Test $test, WpTesting_Model_Passing $passing = null) { $this->test = $test; $this->passing = $passing; $passing->setIp($this->getClientIp())->setDeviceUuid($this->extractUuid('device_uuid', $_COOKIE))->setUserAgent($this->getUserAgent())->setRespondentId($this->wp->getCurrentUserId()); try { $passing->storeAll(); $link = $passing->getUrl($this->getCurrentUrl()); return $this->redirectAndDie($link); } catch (fValidationException $e) { return $this->dieNotValid($e->getMessage()); } }
public function beforeRender(WpTesting_Model_Test $test, WpTesting_Model_Passing $passing = null) { $this->test = $test; $this->passing = $passing; if ($this->test->isOneQuestionPerStep()) { $stepStrategy = new WpTesting_Component_StepStrategy_OneToOne($test, $passing->buildAnswers()); } else { $stepStrategy = new WpTesting_Component_StepStrategy_AllInOne($test, $passing->buildAnswers()); } $stepStrategy = $this->wp->applyFilters('wp_testing_passer_step_strategy', $stepStrategy); $this->passing->setStepStrategy($stepStrategy); $this->upgradeJqueryForOldWordPress()->addJsData('evercookieBaseurl', $this->wp->getPluginUrl('vendor/samyk/evercookie'))->enqueueScript('test-pass-fill-form', array('jquery', 'pnegri_uuid', 'samyk_evercookie', 'webshim')); $this->wp->addFilter('wp_title', array($this, 'extractTitleSeparator'), 10, 2)->doAction('wp_testing_passer_fill_form_before_render', $this->passing, $this->test); }
/** * @param WpTesting_Model_Passing $item * @param string $column_name * @return string */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { switch ($column_name) { case 'id': return $item->getId(); case 'passing_device_uuid': return $item->getDeviceUuid(); case 'passing_ip': return $item->getIp(); case 'passing_user_agent': return $item->getUserAgent(); case 'test_title': $test = $item->createTest(); return $this->render_link($this->wp->getEditPostLink($test->getId()), $test->getTitle()); case 'results': $links = array(); /* @var $result WpTesting_Model_Result */ foreach ($item->buildResults() as $result) { $links[] = $this->render_link($this->wp->getEditTermLink($result->getId(), 'wpt_result', 'wpt_test'), $result->getTitle()); } return implode(', ', $links); case 'scales': $links = array(); foreach ($item->buildScalesWithRangeOnce() as $scale) { $link = $this->render_link($this->wp->getEditTermLink($scale->getId(), 'wpt_scale', 'wpt_test'), $scale->getTitle()); $outOf = ' (' . sprintf(__('%1$d out of %2$d', 'wp-testing'), $scale->getValue(), $scale->getMaximum()) . ')'; $links[] = $link . str_replace(' ', ' ', $outOf); } return implode(', ', $links); case 'user': $user = $this->wp->getUserdata($item->getRespondentId()); if (!$user) { return ''; } $avatar = $this->wp->getAvatar($user->ID, 32); $editLink = $this->wp->getEditUserLink($user->ID); return "{$avatar} <strong><a href=\"{$editLink}\">{$user->user_login}</a></strong>"; case 'actions': $actions = array(); $url = '?post_type=wpt_test&page=wpt_test_respondents_results&passing_id=' . $item->getId() . '&action='; if ($this->is_trash) { $head = $this->render_link($url . 'untrash', $this->wp->translate('Untrash'), 'row-title', array('title' => $this->wp->translate('Restore this item from the Trash'))); $actions[] = $this->render_tag('span', array('class' => 'delete'), $this->render_link($url . 'delete', $this->wp->translate('Delete Permanently'), 'submitdelete', array('title' => $this->wp->translate('Delete this item permanently')))); } else { $head = $this->render_link($item->getUrl(), $this->wp->translate('View'), 'row-title', array('title' => sprintf(html_entity_decode($this->wp->translate('View “%s”')), $item->getSlug($this->wp->getSalt())))); $actions[] = $this->render_tag('span', array('class' => 'trash'), $this->render_link($url . 'trash', $this->wp->translate('Trash'), 'submitdelete', array('title' => $this->wp->translate('Move this item to the Trash')))); } return $this->render_tag('strong', array(), $head) . $this->render_tag('div', array('class' => 'row-actions'), implode(' | ', $actions)); } return parent::render_static_column($item, $column_name); }
/** * @param WpTesting_Model_Passing $item * @param string $column_name * @return string */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { switch ($column_name) { case 'row_number': return $this->get_row_number(); case 'test_title': $test = $item->createTest(); return $this->render_link($this->wp->getPostPermalink($test->getId()), $test->getTitle()); case 'results': $links = array(); /* @var $result WpTesting_Model_Result */ foreach ($item->buildResults() as $result) { $links[] = $result->getTitle(); } return implode(', ', $links); case 'scales': $links = array(); foreach ($item->buildScalesWithRangeOnce() as $scale) { $link = $scale->getTitle(); $outOf = ' (' . sprintf(__('%1$d out of %2$d', 'wp-testing'), $scale->getValue(), $scale->getMaximum()) . ')'; $links[] = $link . str_replace(' ', ' ', $outOf); } return implode(', ', $links); case 'view': return $this->render_link($item->getUrl()); } return parent::render_static_column($item, $column_name); }
private function getTestPassingAction() { if ($this->wp->getQuery()->get('wpt_passing_slug')) { return self::ACTION_GET_RESULTS; } $this->passing = new WpTesting_Model_Passing(); $this->passing->setWp($this->wp); if ($this->isPost()) { $this->passing->populate($this->test); if (self::ACTION_PROCESS_FORM == $this->getRequestValue('passer_action')) { return self::ACTION_PROCESS_FORM; } } return self::ACTION_FILL_FORM; }