Skip to content

Commit

Permalink
Merge branch 'hotfix/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
garex committed Nov 20, 2014
2 parents 602da6f + 7e79ed0 commit 2f62337
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 114 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
## Changelog ##


### 0.5.1 ###
Add tags, improve formulas editor and docs

* Prefix screenhots by zeros
* Remove session stuff to avoid openbasedir bug
* Update compatible up to WP 4.0
* Swap formulas and results columns in editor
* Add tags to test


## 0.5 ##
Localization and quick fill

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
**Donate link:** http://apsiholog.ru/psychological-tests/
**Tags:** psychological, testing, test, quiz
**Requires at least:** 3.2
**Tested up to:** 3.9
**Stable tag:** 0.5
**Tested up to:** 4.0
**Stable tag:** 0.5.1
**License:** GPLv3
**License URI:** http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -52,15 +52,15 @@ PS: **If something broken or doesn't work**, pls create new topic in ["Support"

## Screenshots ##

1. Test editing section with menu in admin
2. Test editing section. There are fast acces buttons like "add new questions" at the top of the page. The choise of answers and scales is available in the sidebar.
3. Here we can see "Edit Questions and Scores" box where every scale has a sum of scores
4. The "Quick Fill Scores" box is opened that allows us quickly enter scores from the questions separated by commas
5. Fast adding questions from text
6. Editing formulas
7. Ready test on the home page
8. The page with the description of the test, questions and answers
9. The button is desabled untill all questions are not answered
01. Test editing section with menu in admin
02. Test editing section. There are fast acces buttons like "add new questions" at the top of the page. The choise of answers and scales is available in the sidebar.
03. Here we can see "Edit Questions and Scores" box where every scale has a sum of scores
04. The "Quick Fill Scores" box is opened that allows us quickly enter scores from the questions separated by commas
05. Fast adding questions from text
06. Editing formulas
07. Ready test on the home page
08. The page with the description of the test, questions and answers
09. The button is desabled untill all questions are not answered
10. Get test results after all questions are answered
11. The results page
12. The result page contains both the result of the test and the scales that create a result
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
60 changes: 0 additions & 60 deletions src/Doer/AbstractDoer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ abstract class WpTesting_Doer_AbstractDoer
*/
protected $wp = null;

/**
* @var string
*/
private $sessionPrefix = null;

public function __construct(WpTesting_WordPressFacade $wp)
{
$this->wp = $wp;
Expand Down Expand Up @@ -66,59 +61,4 @@ protected function isWordPressAlready($version)
return version_compare($this->wp->getVersion(), $version, '>=');
}

/**
* @param string $prefix
* @return WpTesting_Doer_AbstractDoer
*/
protected function sessionInit($prefix = __CLASS__)
{
@session_start();
$this->sessionPrefix = $prefix;
return $this;
}

/**
* @param string $key
* @param string|array $value
* @return WpTesting_Doer_AbstractDoer
*/
protected function sessionAdd($key, $value)
{
$_SESSION[$this->sessionPrefix . '::' . $key] = $value;
return $this;
}

/**
* @param string $key
* @return boolean
*/
protected function sessionHas($key)
{
return !empty($_SESSION[$this->sessionPrefix . '::' . $key]);
}

/**
* @param string $key
* @return string|array|null Value
*/
protected function sessionGet($key)
{
if (!$this->sessionHas($key)) {
return null;
}
return $_SESSION[$this->sessionPrefix . '::' . $key];
}

/**
* @param string $key
* @return string|array|null Value
*/
protected function sessionGetRemove($key)
{
$value = $this->sessionGet($key);
if ($this->sessionHas($key)) {
unset($_SESSION[$this->sessionPrefix . '::' . $key]);
}
return $value;
}
}
10 changes: 1 addition & 9 deletions src/Doer/TestEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function customizeUi($screen)
if (!$this->isTestScreen($screen)) {
return;
}
$this->sessionInit(__CLASS__)->wp
$this->wp
->enqueuePluginStyle('wpt_admin', 'css/admin.css')
->enqueuePluginScript('wpt_test_edit_fix_styles', 'js/test-edit-fix-styles.js', array('jquery'), false, true)
->enqueuePluginScript('field_selection', 'js/vendor/kof/field-selection.js', array(), false, true)
Expand All @@ -24,7 +24,6 @@ public function customizeUi($screen)
->addMetaBox('wpt_edit_questions', __('Edit Questions and Scores', 'wp-testing'), array($this, 'renderEditQuestions'), 'wpt_test')
->addMetaBox('wpt_add_questions', __('Add New Questions', 'wp-testing'), array($this, 'renderAddQuestions'), 'wpt_test')
->addMetaBox('wpt_edit_formulas', __('Edit Formulas', 'wp-testing'), array($this, 'renderEditFormulas'), 'wpt_test')
->addAction('admin_notices', array($this, 'printAdminMessages'))
->addAction('save_post', array($this, 'saveTest'), 10, 2)
;
}
Expand Down Expand Up @@ -130,13 +129,6 @@ public function saveTest($id, $item)
}
}

public function printAdminMessages()
{
if ($this->sessionHas('admin_message')) {
$this->output('Test/Editor/admin-message', $this->sessionGetRemove('admin_message'));
}
}

/**
* Do we currently at tests?
*
Expand Down
30 changes: 1 addition & 29 deletions src/Doer/WordPressEntitiesRegistrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct(WpTesting_WordPressFacade $wp)
'wpt_answer',
'wpt_scale',
'wpt_result',
'post_tag',
'wpt_category',
),
'has_archive' => true,
Expand Down Expand Up @@ -147,37 +148,8 @@ public function __construct(WpTesting_WordPressFacade $wp)
$this->wp->getRewrite()->flush_rules();
}

protected function generateLabels($name, $pluralName = null)
{
$name = ucfirst($name);
$pluralName = ($pluralName) ? $pluralName : $name . 's';
$pluralName = ucfirst($pluralName);
return array(
'name' => "Test $pluralName",
'singular_name' => "Test $name",
'add_new_item' => "Add New $name",
'edit_item' => "Edit $name",
'view_item' => "View $name",
'search_items' => "Search $pluralName",
'parent_item_colon' => "Parent $name:",

'menu_name' => "$pluralName",
'all_items' => "All $pluralName",
'update_item' => "Update $name",
'new_item_name' => "New $name Name",
'parent_item' => "Parent $name",

'new_item' => "New $name",
'not_found' => "No $pluralName found",
'not_found_in_trash' => "No $pluralName found in Trash",
);
}

protected function addTaxonomy($name, $parameters = array())
{
if (empty($parameters['labels'])) {
$parameters['labels'] = $this->generateLabels($name);
}
$this->wp->registerTaxonomy('wpt_' . $name, array('wpt_test'), $parameters + array(
'hierarchical' => true,
'public' => false,
Expand Down
8 changes: 4 additions & 4 deletions src/Template/Test/Editor/edit-formulas.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<table class="widefat wpt_formulas">
<tr>
<th class="bar"><?php echo __('Result', 'wp-testing') ?></th>
<th class="bar"><?php echo __('Formula', 'wp-testing') ?></th>
<th class="bar"><?php echo __('Result', 'wp-testing') ?></th>
</tr>
<?php foreach($results as $r => $result): /* @var $result WpTesting_Model_Result */ ?>
<tr class="wpt_result<?php echo ($r%2) ? ' alternate' : '' ?>">
<td class="wpt_title">
<?php echo $result->getTitle() ?>
</td>
<td class="wpt_formula">
<?php $formula = $result->getFormula() ?>
<input type="text"
Expand All @@ -20,6 +17,9 @@
id="wpt_formula_source_<?php echo $r ?>"
value="<?php echo htmlspecialchars($formula->getSource()) ?>" />
</td>
<td class="wpt_title">
<?php echo $result->getTitle() ?>
</td>
</tr>
<?php endforeach ?>
<?php if (!count($results)): ?>
Expand Down
2 changes: 1 addition & 1 deletion wp-testing.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Wp-testing
* Plugin URI: http://wordpress.org/extend/plugins/wp-testing/
* Description: Helps to create psychological tests.
* Version: 0.5
* Version: 0.5.1
* Author: Alexander Ustimenko
* Author URI: http://ustimen.co
* License: GPL3
Expand Down

0 comments on commit 2f62337

Please sign in to comment.