/** * DRY method to show return the quizzes and surveys in the correct location. * * @param string $identifer The name or numerical id of the quiz/survey * @param string $type If it is a quiz or a survey. * @since 2.2.2 */ protected function _shortcode($identifer, $type) { if (isset($_POST['wpsqt_name']) && $_POST['wpsqt_name'] != $identifer) { /* translators: %1$s will be replaced with the quiz name, please leave the HTML in tact */ printf(__('Another quiz on this page has been started and two quizzes cannot in progress at the same time. In order to start %1$s please <a href="%2$s">click here</a>.'), $identifer, $_SERVER['PHP_SELF']); return; } ob_start(); require_once WPSQT_DIR . 'lib/Wpsqt/Shortcode.php'; $objShortcode = new Wpsqt_Shortcode($identifer, $type); $objShortcode->display(); $content = ob_get_contents(); ob_end_clean(); return $content; }
$name = $poll['name']; $resultsCount = $wpdb->query("SELECT `sections` FROM `" . WPSQT_TABLE_RESULTS . "` WHERE `item_id` = '" . $id . "'", ARRAY_A); // Calculate how many blocks of 100 the results can be split into and always round up $recuranceAmount = ceil($resultsCount / 100); $counter = 0; for ($i = 0; $i < $recuranceAmount; $i++) { $a = $counter + 100; $results = $wpdb->get_results("SELECT `id`, `sections`, `cached` FROM `" . WPSQT_TABLE_RESULTS . "` WHERE `item_id` = '" . $id . "' LIMIT " . $counter . "," . $a . "", ARRAY_A); foreach ($results as $result) { // Only cache if not already cached! if ($result['cached'] == 0) { $_SESSION['wpsqt'] = array(); $_SESSION['wpsqt']['current_result_id'] = (int) $result['id']; $result = unserialize($result['sections']); // Need a SC object because the constructer sets all the $_SESSION bs we need to be able to resuse the caching method $shortcodeObj = new Wpsqt_Shortcode($name, 'poll'); // Adds answers to $_SESSION $_SESSION['wpsqt'][$name]['sections'] = $result; // Actually cache $shortcodeObj->cachePoll(); } } $counter += 100; } } echo 'Done'; case '2.9': echo '<h4>Updating to 2.9.1</h4>'; $wpdb->query("ALTER TABLE `" . WPSQT_TABLE_QUESTIONS . "` ADD `order` INT(11) DEFAULT NULL AFTER `difficulty`"); case '2.12': echo '<h4>Updating to 2.13</h4>';
/** * DRY method to show return the quizzes and surveys in the correct location. * * @param string $identifer The name or numerical id of the quiz/survey * @param string $type If it is a quiz or a survey. * @since 2.2.2 */ protected function _shortcode($identifer, $type) { ob_start(); require_once WPSQT_DIR . 'lib/Wpsqt/Shortcode.php'; $objShortcode = new Wpsqt_Shortcode($identifer, $type); $objShortcode->display(); $content = ob_get_contents(); ob_end_clean(); return $content; }