Skip to content

Commit

Permalink
Allow poll results to be shown if already taken
Browse files Browse the repository at this point in the history
  • Loading branch information
Ollie Armstrong committed Nov 8, 2011
1 parent bcdedb6 commit e56a4f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Wpsqt/Form/Poll.php
Expand Up @@ -21,6 +21,7 @@ public function __construct( array $options = array() ){
$options = array('name' => false,
'limit_one' => false,
'limit_one_wp' => false,
'show_results_limited' => true,
'finish_display' => false,
'status' => false,
'store_results' => 'yes',
Expand All @@ -30,6 +31,7 @@ public function __construct( array $options = array() ){
$this->addOption("wpsqt_name", "Name", "text", $options['name'], "What you would like the poll to be called." )
->addOption("wpsqt_limit_one", "Limit to one submission per IP","yesno", $options['limit_one'], "Limit the poll to one submission per IP.")
->addOption("wpsqt_limit_one_wp", "Limit to one submission per WP user","yesno", $options['limit_one_wp'], "Limit the quiz to one submission per WP user. You must have the Use WP Details option below set to yes.")
->addOption("wpsqt_show_results_limited", "Show the results if the user has already taken the poll", "yesno", $options['show_results_limited'], "If limiting is enabled (by either method) do you want to show the results to the user if they have already taken the poll?")
->addOption("wpsqt_finish_display", "Finish Display",'select', $options['finish_display'], "What should be displayed on the finishing of the poll.", array("Finish message","Poll results"))
->addOption("wpsqt_status", "Status", "select", $options['status'], "Status of the poll either enabled where users can take it or disabled where users can't.", array('enabled','disabled'))
->addOption("wpsqt_store_results", "Save Results", "yesno", $options['store_results'], "If the poll results should be saved.")
Expand Down
5 changes: 5 additions & 0 deletions lib/Wpsqt/Shortcode.php
Expand Up @@ -165,6 +165,11 @@ public function display(){
$results = $wpdb->get_results('SELECT * FROM `'.WPSQT_TABLE_RESULTS. '` WHERE `ipaddress` = "'.$ip.'" AND `item_id` = "'.$item_id.'"', ARRAY_A);
if (count($results) != 0) {
echo 'You appear to have already taken this '.$this->_type.'.';
if ($this->_type == 'poll' && isset($_SESSION['wpsqt'][$quizName]['details']['show_results_limited']) && $_SESSION['wpsqt'][$quizName]['details']['show_results_limited'] == 'yes') {
require_once WPSQT_DIR.'/lib/Wpsqt/Page.php';
require_once WPSQT_DIR.'/lib/Wpsqt/Page/Main/Results/Poll.php';
Wpsqt_Page_Main_Results_Poll::displayResults($item_id);
}
return;
}
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Expand Up @@ -69,6 +69,7 @@ Any further issues then feel free to create a thread on the <a href="http://word

* Rewritten the poll results backend, now much more reliable
* Polls with multiple sections now work entirely
* Allow poll results to be shown if the poll is already taken and limiting is enabled

= 2.7.4 =

Expand Down

0 comments on commit e56a4f7

Please sign in to comment.