/** * Singleton method to provide a token object * with the default tokens and descriptions. * * @since 2.0 */ public static function getTokenObject() { if (!is_a(self::$instance, "Wpsqt_Tokens")) { self::$instance = new Wpsqt_Tokens(); self::$instance->addToken("USER_NAME", "The name of the user who has taken the quiz or survey.")->addToken("QUIZ_NAME", "The name of the quiz that has been taken, <strong>same as %SURVEY_NAME%</strong>.")->addToken("SURVEY_NAME", "The name of the survey that has been taken, <strong>same as %QUIZ_NAME%</strong>.")->addToken("DATE_EU", "The date the quiz or survey was taken in EU format.")->addToken("DATE_US", "The date the quiz or survey was taken in US format.")->addToken("SCORE", "Score gained in quiz, only works if automarking is enabled.")->addToken("SCORE_PERCENTAGE", "Score gained in quiz, in a percentage.")->addToken("RESULT_URL", "A link to view the results in the dashboard.")->addToken("DATETIME_EU", "The date and time the quiz or survey was taken in EU format.")->addToken("DATETIME_US", "The date and time the quiz or survey was taken in US format.")->addToken("IP_ADDRESS", "The IP address of the user who has taken the quiz or survey.")->addToken("HOSTNAME", "The hostname of the IP address of the user who has taken the quiz or survey.")->addToken("USER_AGENT", "The user agent of the user who has taken the quiz or survey.")->addToken("USER_EMAIL", "The email address of the user who has taken the quiz or survey.")->addToken("USER_FNAME", "The first name of the user")->addToken("USER_LNAME", "The last name of the user"); } return apply_filters("wpsqt_replacement_tokens", self::$instance); }
/** * Singleton method to provide a token object * with the default tokens and descriptions. * * @since 2.0 */ public static function getTokenObject() { if (!is_a(self::$instance, "Wpsqt_Tokens")) { self::$instance = new Wpsqt_Tokens(); self::$instance->addToken("USER_NAME", "The name of the user who has taken the quiz or survey.")->addToken("QUIZ_NAME", "The name of the quiz that has been taken, <strong>same as %SURVEY_NAME%</strong>.")->addToken("SURVEY_NAME", "The name of the survey that has been taken, <strong>same as %QUIZ_NAME%</strong>.")->addToken("DATE_EU", "The date the quiz or survey was taken in EU format.")->addToken("DATE_US", "The date the quiz or survey was taken in US format.")->addToken("SCORE", "Score gained in quiz, only works if automarking is enabled.")->addToken("SCORE_PERCENTAGE", "Score gained in quiz, in a percentage.")->addToken("SCORE_PASSFAIL", "Shows either 'Pass' or 'Fail' depending on score.")->addToken("SCORE_COMPETENT", "Shows either 'Competent' or 'Not yet competent' depending on pass or fail.")->addToken("RESULT_URL", "A link to mark the results in the dashboard.")->addToken("RESULT_VIEW_URL", "A link to view the results in the dashboard.")->addToken("DATETIME_EU", "The date and time the quiz or survey was taken in EU format.")->addToken("DATETIME_US", "The date and time the quiz or survey was taken in US format.")->addToken("IP_ADDRESS", "The IP address of the user who has taken the quiz or survey.")->addToken("HOSTNAME", "The hostname of the IP address of the user who has taken the quiz or survey.")->addToken("USER_AGENT", "The user agent of the user who has taken the quiz or survey.")->addToken("USER_EMAIL", "The email address of the user who has taken the quiz or survey.")->addToken("USER_FNAME", "The first name of the user")->addToken("USER_LNAME", "The last name of the user")->addToken("TB_B", "Toggle block of information after this tag")->addToken("TB_E", "End of block of information to be toggled"); } return apply_filters("wpsqt_replacement_tokens", self::$instance); }
/** * Checks to see if the proper description is being outputed. * * @since 2.0 */ public function testDescription() { $objTokens = new Wpsqt_Tokens(); $objTokens->addToken("name", "My name", "Iain Cambridge")->addToken("email", "My email address", "*****@*****.**"); $descriptionHtml = "<ul>"; $descriptionHtml .= "<li><strong>%NAME%</strong> - My name</li>"; $descriptionHtml .= "<li><strong>%EMAIL%</strong> - My email address</li>"; $descriptionHtml .= "</ul>"; $this->assertEquals($descriptionHtml, $objTokens->getDescriptions(), "The html doesn't match what was expected"); }