com-tecnick-tcexam-shared

# Procedural File: tce_functions_test.php Source Location: /shared/code/tce_functions_test.php ## Page Details: Functions to handle test generation, status and user access. #### Tags:
author: | Nicola Asuni
copyright: | Copyright © 2004-2010, Nicola Asuni - Tecnick.com S.r.l. - ITALY - www.tecnick.com - info@tecnick.com
link: | www.tecnick.com
since: | 2004-05-28
license: | GNU Affero General Public License
### F_addLogAnswers [line 718]
`boolean F_addLogAnswers( int $testlog_id, array $answers_ids)`
Add specified answers on tce_tests_logs_answer table. #### Tags:
return: | true in case of success, false otherwise
#### Parameters
int | $testlog_id | testlog ID
array | $answers_ids | array of answer IDs to add
[ Top ] ### F_addQuestionAnswers [line 1032]
`boolean F_addQuestionAnswers( int $testlog_id, int $question_id, int $question_type, $num_answers, int $firsttest, array $testdata, int $tsubset_answers)`
Add answers to selected question. #### Tags:
return: | TRUE in case of success, FALSE otherwise.
#### Parameters
int | $testlog_id | testlog ID.
int | $question_id | question ID.
int | $question_type | type of question.
int | $tsubset_answers | number of alternative answers to display.
int | $firsttest | ID of first test testuser_id.
array | $testdata | array of test data.
| $num_answers |
[ Top ] ### F_checkTestStatus [line 304]
`test F_checkTestStatus( int $user_id, int $test_id, int $duration)`
Check and returns specific test status for the specified user. #### Tags:
return: | status: 0 = the test generation process is started but not completed; 1 = the test has been successfully created; 2 = all questions have been displayed to the user; 3 = all questions have been answered; 4 = test locked (for timeout);
#### Parameters
int | $user_id | user ID
int | $test_id | test ID
int | $duration | test duration in seconds
[ Top ] ### F_createTest [line 815]
`boolean F_createTest( int $test_id, int $user_id)`
Create user's test and returns TRUE on success. #### Tags:
return: | TRUE in case of success, FALSE otherwise.
#### Parameters
int | $test_id | test ID.
int | $user_id | user ID.
[ Top ] ### F_executeTest [line 583]
`true F_executeTest( int $test_id)`
Returns true if the current user is authorized to execute the selected test. Generates the test if it's not already generated. #### Tags:
return: | if user is authorized, false otherwise.
usedby: | tce_test_execute.php
#### Parameters
int | $test_id | test ID.
[ Top ] ### F_getFirstTestUser [line 749]
`int F_getFirstTestUser( int $test_id)`
Returns the ID of the tce_tests_users table corresponding to a complete test of $test_id type. #### Tags:
return: | testuser ID
#### Parameters
int | $test_id | test ID
[ Top ] ### F_getNumOmittedQuestions [line 1730]
`integer F_getNumOmittedQuestions( int $test_id)`
Returns the number of omitted questions (unanswered + undisplayed). #### Tags:
return: | number
#### Parameters
int | $test_id | test ID
[ Top ] ### F_getTestData [line 465]
`array F_getTestData( int $test_id)`
Returns the test data. #### Tags:
return: | containing test data.
#### Parameters
int | $test_id | test ID.
[ Top ] ### F_getTestDuration [line 520]
`int F_getTestDuration( int $test_id)`
Returns the test duration time in seconds. #### Tags:
return: | test duration time in seconds
#### Parameters
int | $test_id | test ID
[ Top ] ### F_getTestName [line 509]
`string F_getTestName( int $test_id)`
Returns the test name. #### Tags:
return: | test name or empty string in case of error.
#### Parameters
int | $test_id | test ID.
[ Top ] ### F_getTestStartTime [line 532]
`int F_getTestStartTime( int $testuser_id)`
Returns the user's test start time in seconds since UNIX epoch (1970-01-01 00:00:00). #### Tags:
return: | start time in seconds
#### Parameters
int | $testuser_id | user's test ID
[ Top ] ### F_getUserData [line 487]
`array F_getUserData( $user_id, int $test_id)`
Returns user data. #### Tags:
return: | containing test data.
#### Parameters
int | $test_id | test ID.
| $user_id |
[ Top ] ### F_getUserTests [line 57]
`string F_getUserTests( )`
Returns an XHTML table of user's tests. #### Tags:
return: | containing an XHTML table of user's tests.
[ Top ] ### F_isRightTestlogUser [line 633]
`boolean F_isRightTestlogUser( int $test_id, int $testlog_id)`
Checks if the current user is the right testlog_id owner. This function is used for security reasons. #### Tags:
return: | TRUE in case of success, FALSE otherwise
#### Parameters
int | $test_id | test ID
int | $testlog_id | test log ID
[ Top ] ### F_isValidIP [line 201]
`true F_isValidIP( int $user_ip, int $test_ips)`
Check if user's IP is valid over test IP range #### Tags:
return: | if IP is valid, false otherwise
#### Parameters
int | $user_ip | user's IP address in expanded IPv6 format.
int | $test_ips | comma separated list of valid test IP addresses. The '*' character may be used to indicate any number in IPv4 addresses. Intervals must be specified using the '-' character.
[ Top ] ### F_isValidTestUser [line 259]
`true F_isValidTestUser( int $test_id, int $user_ip, int $test_ip)`
Check if user is authorized to execute the specified test #### Tags:
return: | if is user is authorized, false otherwise
#### Parameters
int | $test_id | ID of the selected test
int | $user_ip | user's IP address.
int | $test_ip | test IP valid addresses. Various IP addresses may be separated using comma character. The asterisk character may be used to indicate "any number".
[ Top ] ### F_newTestLog [line 778]
`int F_newTestLog( int $testuser_id, int $question_id, int $score, int $order, [ $num_answers = 0])`
Creates a new tce_tests_logs table entry and returns inserted ID. #### Tags:
return: | testlog ID
#### Parameters
int | $testuser_id | ID of tce_tests_users
int | $question_id | question ID
int | $score | score for unanswered questions
int | $order | question display order
| $num_answers |
[ Top ] ### F_printTestInfo [line 416]
`string F_printTestInfo( int $test_id, [boolean $showip = false])`
Returns an XHTML string containing specified test information. #### Tags:
return: | containing an XHTML code
usedby: | tce_popup_test_info.php
usedby: | tce_popup_test_info.php
#### Parameters
int | $test_id | test ID
boolean | $showip | if true display enabled users' IP range
[ Top ] ### F_questionForm [line 1331]
`string F_questionForm( int $test_id, int $testlog_id, string $formname)`
Returns a formatted XHTML form code to handle the specified question. Form fields names are: answer_text, answer_id CSS classes: div.tcecontentbox div.rowl textarea.answertext #### Tags:
return: | XHTML code
#### Parameters
int | $test_id | test ID
int | $testlog_id | test log ID
string | $formname | form name (form ID)
[ Top ] ### F_questionsMenu [line 1605]
`string F_questionsMenu( array $testdata, int $testuser_id, [ $testlog_id = 0], [boolean $disable = false])`
Returns a questions menu and navigator buttons. #### Tags:
return: | XHTML code
#### Parameters
array | $testdata | test data
int | $testuser_id | user's test ID
boolean | $disable | if TRUE disable the questions list.
| $testlog_id |
[ Top ] ### F_removeTestResults [line 171]
`void F_removeTestResults( int $test_id)`
Remove the specified test results for the current user #### Parameters
int | $test_id | Test ID
[ Top ] ### F_selectAnswers [line 668]
`array F_selectAnswers( int $question_id, [int $isright = ''], [int $ordering = false], [int $limit = 0], [int $startindex = 0], [boolean $randorder = true], boolean $checktype)`
Return an array containing answer_id field of selected answers. #### Tags:
return: | id of selected answers
#### Parameters
int | $question_id | question ID
boolean | $checktype | if true checks for answer_isright value on WHERE clause
int | $isright | value (0 = false, 1 = true), if non-empty checks for answer_isright value on WHERE clause
int | $ordering | ordering type question (0 = false, 1 = true)
int | $limit | maximum number of IDs to return
int | $startindex | array starting index (default = 0)
boolean | $randorder | if true user random order
[ Top ] ### F_terminateUserTest [line 283]
`void F_terminateUserTest( int $test_id)`
Terminate user's test #### Tags:
since: | 4.0.000 (2006-09-27)
#### Parameters
int | $test_id | test ID
[ Top ] ### F_testComment [line 1750]
`string F_testComment( int $test_id)`
Display a textarea for user's comment. #### Tags:
return: | XHTML code
since: | 4.0.000 (2006-10-01)
#### Parameters
int | $test_id | test ID
[ Top ] ### F_testInfoLink [line 390]
`void F_testInfoLink( int $test_id, [string $link_name = ''])`
Returns XHTML link to open test info popup. #### Parameters
int | $test_id | test ID
string | $link_name | link caption return XHTML code
[ Top ] ### F_twoColRow [line 562]
`string F_twoColRow( [string $label = &quot;&quot;], [string $description = &quot;&quot;], [string $value = &quot;&quot;])`
Return a formatted XHTML row to display 2 columns data. See CSS classes: div.row span.label div.row span.formw #### Tags:
return: | XHTML code
#### Parameters
string | $label | string to display on the left column
string | $description | string to display on the title attribute of the left column field
string | $value | string to display on the right column
[ Top ] ### F_updateQuestionLog [line 1107]
`boolean F_updateQuestionLog( int $test_id, int $testlog_id, [array $answer_id = 0], [string $answer_text = ''], [int $reaction_time = 0])`
Updates question log data (register user's answers and calculate scores). #### Tags:
return: | TRUE in case of success, FALSE otherwise
#### Parameters
int | $test_id | test ID
int | $testlog_id | test log ID
array | $answer_id | answer_id form field value
string | $answer_text | answer text
int | $reaction_time | reaction time in milliseconds
[ Top ] ### F_updateTestComment [line 1786]
`string F_updateTestComment( int $test_id, $testcomment, string $comment)`
Updates user's test comment. #### Tags:
return: | XHTML code
since: | 4.0.000 (2006-10-01)
#### Parameters
int | $test_id | test ID
string | $comment | user's comment.
| $testcomment |
[ Top ] Documentation generated on Mon, 06 Dec 2010 12:03:05 +0100 by phpDocumentor 1.4.3