Skip to content

Instantly share code, notes, and snippets.

View goldhat's full-sized avatar

Joel Milne goldhat

View GitHub Profile
@goldhat
goldhat / show-quiz-box.php
Created January 27, 2017 23:58
Quiz showQuizBox()
public function showQuizBox($questionCount)
{
$globalPoints = 0;
$json = array();
$catPoints = array();
?>
<div style="display: none;" class="quizMaster_quiz">
<ol class="quizMaster_list">
<?php
$index = 0;
@goldhat
goldhat / stats-save.php
Created February 4, 2017 14:47
Stats Save
public function save($quiz = null) {
$quizId = $this->_post['quizId'];
$array = $this->_post['results'];
$lockIp = $this->getIp();
$userId = get_current_user_id();
if ($lockIp === false) {
return false;
}
@goldhat
goldhat / xml-pq-export.xml
Created February 12, 2017 17:04
WP Pro Quiz Exports
<?xml version="1.0" encoding="utf-8"?>
<wpProQuiz><header version="0.37" exportVersion="1"/><data><quiz><title titleHidden="false"><![CDATA[Demo Tommy Quiz 1]]></title><text><![CDATA[This is a Demo of WP Pro Quiz functionality. The settings are very open ended, so as to permit the test user to freely skip questions and return to previous ones.]]></text><category>Demo</category><resultText gradeEnabled="true"><text prozent="15"><![CDATA[These are your graduation results!]]></text><text prozent=""><![CDATA[]]></text></resultText><btnRestartQuizHidden>false</btnRestartQuizHidden><btnViewQuestionHidden>false</btnViewQuestionHidden><questionRandom>false</questionRandom><answerRandom>false</answerRandom><timeLimit>600</timeLimit><showPoints>true</showPoints><statistic activated="true" ipLock="1440"/><quizRunOnce type="1" cookie="false" time="0">false</quizRunOnce><numberedAnswer>true</numberedAnswer><hideAnswerMessageBox>false</hideAnswerMessageBox><disabledAnswerMark>false</disabledAnswerMark><showMaxQuestion show
@goldhat
goldhat / access-code.php
Created February 18, 2017 17:24
QuizMaster Access Code Processing Functions
/* Global Scope (Not On Ready) */
function quizmasterProcessAccessCode( codeEntered, code ) {
if( codeEntered == code ) {
console.log("code is correct");
quizmasterGrantAccessByCode();
} else {
quizmasterDenyAccessByCode();
}
}
@goldhat
goldhat / gist:73db243cddb7efa2e12ad70219566721
Created March 8, 2017 01:59
Signup Error from GFSignup::get( $key )
object(WP_Error)#693 (2) {
["errors"]=>
array(1) {
["already_active"]=>
array(1) {
[0]=>
string(27) "The user is already active."
}
}
["error_data"]=>
@goldhat
goldhat / gpls_rulegroups.php
Created April 8, 2017 14:50
Filter gpls_rulegroups from Gravity Perks Submission Limits
// Method A - using form ID
add_filter('gpls_rulegroups', 'gpls_globalize');
function gpls_globalize( $rulegroups ) {
return array_merge( $rulegroups, GPLS_RuleGroup::load_by_form( 2 ) );
}
// Method B - using rulegroup id (GF feed ID)
add_filter('gpls_rulegroups', 'gpls_globalize');
function gpls_globalize( $rulegroups ) {
$rulegroups[] = GPLS_RuleGroup::load_by_id( 60 ) );
@goldhat
goldhat / quizmaster-associate-quiz-question.php
Last active May 16, 2017 16:16
QuizMaster plugin - associate question with quiz programmatically
<?php
/*
* $quiz QuizMaster_Model_Quiz
* $question QuizMaster_Model_Question
*/
QuizMaster_Model_Quiz_Question::associate( $quiz->getId(), $question->getId() );
<?php
// time period handling segment
$time_period = $this->_args['time_period'];
$time_period_sql = false;
if( $time_period === false ) {
// no time period
} else if( intval( $time_period ) > 0 ) {
$time_period_sql = $wpdb->prepare( 'date_created BETWEEN DATE_SUB(utc_timestamp(), INTERVAL %d SECOND) AND utc_timestamp()', $this->_args['time_period'] );
} else {
@goldhat
goldhat / gist:19b4756edb1b2a0dacb6b8982618907c
Created June 4, 2017 20:40
quizmaster_extension_autoload.php
public static function autoload( $class, $dir ) {
$registeredExtensions = $this->register();
print '<pre>';
var_dump( $registeredExtensions );
print '</pre>';
foreach( $registeredExtensions as $ext => $extSettings ) {
if( $extSettings['type'] == 'pro' ) {
@goldhat
goldhat / QuizMaster_Helper_CopyPost.php
Created June 6, 2017 07:54
QuizMaster Helper CopyPost
<?php
class QuizMaster_Helper_CopyPost {
private $postTypes = array();
public function __construct( $postTypes = array() ) {
if( empty( $postTypes )) {
$this->postTypes = false;
} else {