| applications_simplequiz

# Class: Bs_SimpleQuiz Source Location: /applications/simplequiz/Bs_SimpleQuiz.class.php
### Class Overview
    Bs_Object
       |
       --Bs_SimpleQuiz
Simple Quiz Class. #### Author(s): andrej arn <at blueshoes dot org> #### Version: 4.3.$Revision: 1.4 $ $Date: 2003/09/08 05:17:37 $ #### Copyright: blueshoes.org | ### Variables $Bs_TextUtil $dontKnow $form $giveNegativePoints $language $percentForComplete $questions $resultStyle $text | ### Methods Bs_SimpleQuiz buildForm createLogTables doItYourself generateChartQuestions generateChartUsers loadJpGraph logQuizInput setDbInfo validateUserInput
### Inherited Variables | ### Inherited Methods #### Class: Bs_Object Bs_Object::Bs_Object() Bs_Object::getErrors() Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack. Bs_Object::getLastError() Basic error handling: Get last error string from the global Bs_Error-error stack. Bs_Object::getLastErrors() Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors(). Bs_Object::persist() Persists this object by serializing it and saving it to a file with unique name. Bs_Object::setError() Basic error handling: Push an error string on the global Bs_Error-error stack. Bs_Object::toHtml() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::toString() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::unpersist() Fetches an object that was persisted with persist()
### Class Details [line 47] Simple Quiz Class. currently only supports 1 correct answer per question. #### Tags:
since: | bs4.3
copyright: | blueshoes.org
pattern: | singleton: (pseudostatic)
access: | public
version: | 4.3.$Revision: 1.4 $ $Date: 2003/09/08 05:17:37 $
author: | andrej arn <at blueshoes dot org>
[ Top ] ### Class Variables #### $Bs_TextUtil = [line 56] reference to the global pseudostatic Bs_TextUtil. gets set in the constructor automatically. #### Tags:
access: | public
Type: | object
[ Top ] #### $dontKnow = FALSE [line 123] #### Tags:
todo: | ?
access: | public
Type: | bool
[ Top ] #### $form = [line 221] instance of Bs_Form. set after calling doItYourself(). #### Tags:
access: | public
Type: | object
[ Top ] #### $giveNegativePoints = FALSE [line 116] #### Tags:
todo: | all
access: | public
Type: | bool
[ Top ] #### $language = 'en' [line 109] the language to use. default is 'en'. #### Tags:
access: | public
Type: | string
[ Top ] #### $percentForComplete = 50 [line 130] only if the user filled in at least this amount of questions, then the submit is considered complete. and only then the submit makes it into the statistics/charts.
Type: | mixed
[ Top ] #### $questions = [line 158] example: $sq->questions = array( array( 'question' => array('en'=>'', 'de'=>''), 'options' => array('a'=>'foo', 'b'=>'bar', 'c'=>'hello'), 'answers' => array('a', 'b'), 'multiple' => TRUE, 'pointsAllCorrect' => 1, 'pointsNegPerWrong' => 1, ), ); #### Tags:
access: | public
Type: | mixed
[ Top ] #### $resultStyle = array( 'en' => '<li>Question: __QUESTION__<br>Possible answers: __OPTIONS_STRING__<br>Your answer: __ANSWER__<br><span class="quizResult__IS_OK__">Right is: __RESULT__</span><br><br></li>', 'de' => '<li>Frage: __QUESTION__<br>Mögliche Antworten: __OPTIONS_STRING__<br>Ihre Antwort: __ANSWER__<br><span class="quizResult__IS_OK__">Korrekt ist: __RESULT__</span><br><br></li>', ) [line 182] style for the result output per question. placeholders that can be used: __QUESTION__ => string __ANSWER__ => string __OPTIONS_STRING__ => comma separated values __RESULT__ => string __IS_OK__ => 1 = ok, 0 = wrong all values use the current language. example (and default): <li> Mögliche Antworten: __QUESTION__ Mögliche Antworten: __OPTIONS_STRING__ Ihre Antwort: __ANSWER__ <span class="quizResult__IS_OK__">Korrekt ist: __RESULT__</span> </li> #### Tags:
var: | (language dependant)
access: | public
Type: | mixed
[ Top ] #### $text = array( 'en' => array( 'numQuestions' => 'Number of questions: ', 'correctAnswers' => 'Correct answers: ', 'userStatsForQuiz' => 'User Statistics for the Quiz', 'percentOfCorrectAnswers' => 'Percent of correct answers', 'numberOfUsers' => 'Number of users', 'questionStatsForQuiz' => 'Question Statistics for the Quiz', 'questionNumber' => 'Question number', 'submit' => 'Submit', ),'de'=>array('numQuestions'=>'Anzahl Fragen: ','correctAnswers'=>'Korrekte Antworten: ','userStatsForQuiz'=>'Benutzerstatistik fürs Quiz','percentOfCorrectAnswers'=>'Prozent an korrekten Antworten','numberOfUsers'=>'Anzahl Benutzer','questionStatsForQuiz'=>'Quiz-Statistik pro Frage','questionNumber'=>'Frage-Nummer','submit'=>'Abschicken',),) [line 192] language dependant words. #### Tags:
var: | (language dependant)
access: | public
Type: | mixed
[ Top ] ### Class Methods ### constructor Bs_SimpleQuiz [line 228]
`Bs_SimpleQuiz Bs_SimpleQuiz( )`
constructor [ Top ] ### method buildForm [line 465]
`&$form &buildForm( )`
Generates the Bs_Form object. #### Tags:
access: | public
[ Top ] ### method createLogTables [line 424]
`void createLogTables( )`
#### Tags:
access: | public
[ Top ] ### method doItYourself [line 254]
`void doItYourself( )`
handles everything itself. [ Top ] ### method generateChartQuestions [line 640]
`bool generateChartQuestions( string $path, string $file)`
generates/updates the user chart for the current language. params $path and $file: path: absolute path from the web root, without first slash. example: 'img/chart/' file: file name without ending '.png'. example: 'user' that will result in the file 'img/chart/user.en.png' if english is used as language. it will be prefixed with $_SERVER['DOCUMENT_ROOT']. the path gets created if it does not exist. #### Tags:
access: | public
#### Parameters:
string | $path | (see above)
string | $file | (without the ending .png)
[ Top ] ### method generateChartUsers [line 556]
`bool generateChartUsers( string $path, string $file, [string $steps = 10])`
generates/updates the user chart for the current language. params $path and $file: path: absolute path from the web root, without first slash. example: 'img/chart/' file: file name without ending '.png'. example: 'user' that will result in the file 'img/chart/user.en.png' if english is used as language. it will be prefixed with $_SERVER['DOCUMENT_ROOT']. the path gets created if it does not exist. param $steps: how many 'steps' to show. 10 means we have the steps 0-10%, 10-20% etc. 20 means we have the steps 0-5%, 5-10% etc. #### Tags:
access: | public
#### Parameters:
string | $path | (see above)
string | $file | (without the ending .png)
string | $steps | (default is 10, see above)
[ Top ] ### method loadJpGraph [line 708]
`bool loadJpGraph( [string $jpGraphDir = NULL])`
loads the jpgraph libraries. #### Tags:
access: | public
#### Parameters:
string | $jpGraphDir |
[ Top ] ### method logQuizInput [line 392]
`void logQuizInput( int $percentRight, int $percentFilled, int $numWrong, int $numQuestions, array $rightWrongArray, int $secsNeeded, bool $isComplete, [bool $secondCall = FALSE])`
#### Tags:
access: | public
#### Parameters:
int | $percentRight |
int | $percentFilled |
int | $numWrong |
int | $numQuestions |
array | $rightWrongArray |
int | $secsNeeded |
bool | $isComplete |
bool | $secondCall | (used internally only!)
[ Top ] ### method setDbInfo [line 243]
`void setDbInfo( object &$bsDb, string $tblNameRecord, string $tblNameQuestion, [bool $logToDb = TRUE])`
setst he needed db info for logging. #### Tags:
see: | vars _bsDb, _tblNameRecord, _tblNameQuestion, _logToDb
#### Parameters:
object | &$bsDb |
string | $tblNameRecord |
string | $tblNameQuestion |
bool | $logToDb | (default is TRUE)
[ Top ] ### method validateUserInput [line 273]
`string validateUserInput( array $userInput, array $formInfo)`
#### Tags:
return: | (html output)
#### Parameters:
array | $userInput | (from $form->getValuesArray().)
array | $formInfo | (from $form->getInfo().)
[ Top ] Documentation generated on Mon, 29 Dec 2003 21:12:40 +0100 by phpDocumentor 1.2.3