files-shared-code-tce-functions-test

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.

tce_functions_test.php

Tags
file

Functions to handle test generation, status and user access.

author

Nicola Asuni

since
2004-05-28

Table of Contents

Functions

F_getUserTests()  : string
Returns an XHTML table of user's tests.
F_repeatTest()  : mixed
Mark previous test attempts as repeated.
F_isValidIP()  : true
Check if user's IP is valid over test IP range
F_isValidSSLCert()  : true
Check if user's IP is valid over test IP range
F_isValidTestUser()  : true
Check if user is authorized to execute the specified test
F_terminateUserTest()  : mixed
Terminate user's test<br>
F_countUserTest()  : retried
Count the number times of retries.<br>
F_checkTestStatus()  : array<string|int, mixed>
Check and returns specific test status for the specified user.<br>
F_testInfoLink()  : mixed
Returns XHTML link to open test info popup.
F_printTestInfo()  : string
Returns an XHTML string containing specified test information.
F_getTestData()  : array<string|int, mixed>
Returns the test data.
F_getUserData()  : array<string|int, mixed>
Returns user data.
F_getTestPassword()  : string
Returns the test password.
F_getTestName()  : string
Returns the test name.
F_getTestDuration()  : int
Returns the test duration time in seconds.
F_getTestStartTime()  : int
Returns the user's test start time in seconds since UNIX epoch (1970-01-01 00:00:00).
F_twoColRow()  : string
Return a formatted XHTML row to display 2 columns data.<br> See CSS classes:<ul> <li>div.row span.label</li> <li>div.row span.formw</li> </ul>
F_executeTest()  : true
Returns true if the current user is authorized to execute the selected test.<br> Generates the test if it's not already generated.
F_isRightTestlogUser()  : bool
Checks if the current user is the right testlog_id owner.<br> This function is used for security reasons.
F_selectAnswers()  : array<string|int, mixed>
Return an array containing answer_id field of selected answers.<br>
F_addLogAnswers()  : bool
Add specified answers on tce_tests_logs_answer table.
F_getFirstTestUser()  : int
Returns the ID of the tce_tests_users table corresponding to a complete test of $test_id type.
F_newTestLog()  : int
Creates a new tce_tests_logs table entry and returns inserted ID.
F_isTestOverLimits()  : bool
Returns false if the number of executed tests is under the limits, true otherwise.
F_count_executed_tests()  : int
Returns the number of executed tests on the specified time interval.
F_updateTestuserStat()  : mixed
Track generated tests.
F_createTest()  : bool
Create user's test and returns TRUE on success.
F_addQuestionAnswers()  : bool
Add answers to selected question.
F_updateQuestionLog()  : bool
Updates question log data (register user's answers and calculate scores).
F_getAnswerIdFromPosition()  : int
Returns the answer ID from position
F_questionForm()  : string
Returns a formatted XHTML form code to handle the specified question.<br> Form fields names are: answer_text, answer_id<br> CSS classes:<ul> <li>div.tcecontentbox</li> <li>div.rowl</li> <li>textarea.answertext</li> </ul>
F_questionsMenu()  : string
Returns a questions menu and navigator buttons.
F_getNumOmittedQuestions()  : int
Returns the number of omitted questions (unanswered + undisplayed).
F_testComment()  : string
Display a textarea for user's comment.<br>
F_updateTestComment()  : string
Updates user's test comment.<br>
F_testLoginForm()  : XHTML
Returns XHTML / CSS formatted page string to insert the test password.<br> The CSS classes used are: <ul> <li>div.login_form : container for login box</li> <li>div.login_form div.login_row : container for label + input field or button</li> <li>div.login_form div.login_row span.label : container for input label</li> <li>div.login_form div.login_row span.formw : container for input form</li> </ul>
F_getTestGroups()  : string
Get a comma separated list of valid group IDs for the selected test.
F_getTestSSLCerts()  : string
Get a comma separated list of valid SSL certificates IDs for the selected test.

Functions

F_getUserTests()

Returns an XHTML table of user's tests.

F_getUserTests() : string
Return values
string

containing an XHTML table of user's tests.

F_repeatTest()

Mark previous test attempts as repeated.

F_repeatTest( $test_id) : mixed
Parameters
$test_id :

(int) Test ID

F_isValidIP()

Check if user's IP is valid over test IP range

F_isValidIP( $user_ip,  $test_ips) : true
Parameters
$user_ip :

(int) user's IP address in expanded IPv6 format.

$test_ips :

(int) 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.

Return values
true

if IP is valid, false otherwise

F_isValidSSLCert()

Check if user's IP is valid over test IP range

F_isValidSSLCert( $test_id) : true
Parameters
$test_id :

(int) Test ID

Return values
true

if the client certifiate is valid, false otherwise

F_isValidTestUser()

Check if user is authorized to execute the specified test

F_isValidTestUser( $test_id,  $user_ip,  $test_ip) : true
Parameters
$test_id :

(int) ID of the selected test

$user_ip :

(int) user's IP address.

$test_ip :

(int) test IP valid addresses. Various IP addresses may be separated using comma character. The asterisk character may be used to indicate "any number".

Return values
true

if is user is authorized, false otherwise

F_terminateUserTest()

Terminate user's test<br>

F_terminateUserTest( $test_id) : mixed
Parameters
$test_id :

(int) test ID

Tags
since
4.0.000

(2006-09-27)

F_countUserTest()

Count the number times of retries.<br>

F_countUserTest( $user_id,  $test_id) : retried
Parameters
$user_id :

(int) user ID

$test_id :

(int) test ID

Return values
retried

times

F_checkTestStatus()

Check and returns specific test status for the specified user.<br>

F_checkTestStatus( $user_id,  $test_id,  $duration) : array<string|int, mixed>
Parameters
$user_id :

(int) user ID

$test_id :

(int) test ID

$duration :

(int) test duration in seconds

Return values
array<string|int, mixed>

of (test_status_code, testuser_id). test_status_code:

  • 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);
  • 5 or more = old version of repeated test;

Returns XHTML link to open test info popup.

F_testInfoLink( $test_id[,  $link_name = '' ]) : mixed
Parameters
$test_id :

(int) test ID

$link_name : = ''

(string) link caption return XHTML code

F_printTestInfo()

Returns an XHTML string containing specified test information.

F_printTestInfo( $test_id[,  $showip = false ]) : string
Parameters
$test_id :

(int) test ID

$showip : = false

(boolean) if true display enabled users' IP range

Return values
string

containing an XHTML code

F_getTestData()

Returns the test data.

F_getTestData( $test_id) : array<string|int, mixed>
Parameters
$test_id :

(int) test ID.

Return values
array<string|int, mixed>

containing test data.

F_getUserData()

Returns user data.

F_getUserData( $user_id) : array<string|int, mixed>
Parameters
$user_id :

(int) User ID.

Return values
array<string|int, mixed>

containing test data.

F_getTestPassword()

Returns the test password.

F_getTestPassword( $test_id) : string
Parameters
$test_id :

(int) test ID.

Return values
string

test password or empty string in case of error.

F_getTestName()

Returns the test name.

F_getTestName( $test_id) : string
Parameters
$test_id :

(int) test ID.

Return values
string

test name or empty string in case of error.

F_getTestDuration()

Returns the test duration time in seconds.

F_getTestDuration( $test_id) : int
Parameters
$test_id :

(int) test ID

Return values
int

test duration time in seconds

F_getTestStartTime()

Returns the user's test start time in seconds since UNIX epoch (1970-01-01 00:00:00).

F_getTestStartTime( $testuser_id) : int
Parameters
$testuser_id :

(int) user's test ID

Return values
int

start time in seconds

F_twoColRow()

Return a formatted XHTML row to display 2 columns data.<br> See CSS classes:<ul> <li>div.row span.label</li> <li>div.row span.formw</li> </ul>

F_twoColRow([ $label = "" ][,  $description = "" ][,  $value = "" ]) : string
Parameters
$label : = ""

(string) string to display on the left column

$description : = ""

(string) string to display on the title attribute of the left column field

$value : = ""

(string) string to display on the right column

Return values
string

XHTML code

F_executeTest()

Returns true if the current user is authorized to execute the selected test.<br> Generates the test if it's not already generated.

F_executeTest( $test_id) : true
Parameters
$test_id :

(int) test ID.

Return values
true

if user is authorized, false otherwise.

F_isRightTestlogUser()

Checks if the current user is the right testlog_id owner.<br> This function is used for security reasons.

F_isRightTestlogUser( $test_id,  $testlog_id) : bool
Parameters
$test_id :

(int) test ID

$testlog_id :

(int) test log ID

Return values
bool

TRUE in case of success, FALSE otherwise

F_selectAnswers()

Return an array containing answer_id field of selected answers.<br>

F_selectAnswers( $question_id[,  $isright = '' ][,  $ordering = false ][,  $limit = 0 ][,  $startindex = 0 ][,  $randorder = true ][,  $ordmode = 0 ]) : array<string|int, mixed>
Parameters
$question_id :

(int) Question ID.

$isright : = ''

(int) Value (0 = false, 1 = true), if non-empty checks for answer_isright value on WHERE clause.

$ordering : = false

(int) Ordering type question (0 = false, 1 = true).

$limit : = 0

(int) Maximum number of IDs to return.

$startindex : = 0

(int) Array starting index (default = 0).

$randorder : = true

(boolean) If true user random order.

$ordmode : = 0

(int) Ordering mode: 0=position; 1=alphabetical; 2=ID.

Return values
array<string|int, mixed>

id of selected answers

F_addLogAnswers()

Add specified answers on tce_tests_logs_answer table.

F_addLogAnswers( $testlog_id,  $answers_ids) : bool
Parameters
$testlog_id :

(int) testlog ID

$answers_ids :

(array) array of answer IDs to add

Return values
bool

true in case of success, false otherwise

F_getFirstTestUser()

Returns the ID of the tce_tests_users table corresponding to a complete test of $test_id type.

F_getFirstTestUser( $test_id) : int
Parameters
$test_id :

(int) test ID

Return values
int

testuser ID

F_newTestLog()

Creates a new tce_tests_logs table entry and returns inserted ID.

F_newTestLog( $testuser_id,  $question_id,  $score,  $order[,  $num_answers = 0 ]) : int
Parameters
$testuser_id :

(int) ID of tce_tests_users

$question_id :

(int) question ID

$score :

(int) score for unanswered questions

$order :

(int) question display order

$num_answers : = 0

(int) number of alternative answers

Return values
int

testlog ID

F_isTestOverLimits()

Returns false if the number of executed tests is under the limits, true otherwise.

F_isTestOverLimits() : bool
Return values
bool

true/false.

F_count_executed_tests()

Returns the number of executed tests on the specified time interval.

F_count_executed_tests( $startdate,  $enddate) : int
Parameters
$startdate :

(string) Star date-time interval.

$enddate :

(string) End date-time interval.

Return values
int

number of executed tests.

F_updateTestuserStat()

Track generated tests.

F_updateTestuserStat( $date) : mixed
Parameters
$date :

(string) date-time when the test was generated.

F_createTest()

Create user's test and returns TRUE on success.

F_createTest( $test_id,  $user_id) : bool
Parameters
$test_id :

(int) test ID.

$user_id :

(int) user ID.

Return values
bool

TRUE in case of success, FALSE otherwise.

F_addQuestionAnswers()

Add answers to selected question.

F_addQuestionAnswers( $testlog_id,  $question_id,  $question_type,  $num_answers,  $firsttest,  $testdata) : bool
Parameters
$testlog_id :

(int) testlog ID.

$question_id :

(int) question ID.

$question_type :

(int) type of question.

$num_answers :

(int) number of alternative answers to display.

$firsttest :

(int) ID of first test testuser_id.

$testdata :

(array) array of test data.

Return values
bool

TRUE in case of success, FALSE otherwise.

F_updateQuestionLog()

Updates question log data (register user's answers and calculate scores).

F_updateQuestionLog( $test_id,  $testlog_id[,  $answpos = [] ][,  $answer_text = '' ][,  $reaction_time = 0 ]) : bool
Parameters
$test_id :

(int) test ID

$testlog_id :

(int) test log ID

$answpos : = []

(array) Array of answer positions

$answer_text : = ''

(string) answer text

$reaction_time : = 0

(int) reaction time in milliseconds

Return values
bool

TRUE in case of success, FALSE otherwise

F_getAnswerIdFromPosition()

Returns the answer ID from position

F_getAnswerIdFromPosition( $testlog_id,  $answpos) : int
Parameters
$testlog_id :

(int) Test Log ID

$answpos :

(array) Answer positions (order in wich they are displayed)

Return values
int

answer ID

F_questionForm()

Returns a formatted XHTML form code to handle the specified question.<br> Form fields names are: answer_text, answer_id<br> CSS classes:<ul> <li>div.tcecontentbox</li> <li>div.rowl</li> <li>textarea.answertext</li> </ul>

F_questionForm( $test_id,  $testlog_id,  $formname) : string
Parameters
$test_id :

(int) test ID

$testlog_id :

(int) test log ID

$formname :

(string) form name (form ID)

Return values
string

XHTML code

F_questionsMenu()

Returns a questions menu and navigator buttons.

F_questionsMenu( $testdata,  $testuser_id[,  $testlog_id = 0 ][,  $disable = false ]) : string
Parameters
$testdata :

(array) test data

$testuser_id :

(int) user's test ID

$testlog_id : = 0

(int) test log ID

$disable : = false

(boolean) if TRUE disable the questions list.

Return values
string

XHTML code

F_getNumOmittedQuestions()

Returns the number of omitted questions (unanswered + undisplayed).

F_getNumOmittedQuestions( $test_id) : int
Parameters
$test_id :

(int) test ID

Return values
int

number

F_testComment()

Display a textarea for user's comment.<br>

F_testComment( $test_id) : string
Parameters
$test_id :

(int) test ID

Tags
since
4.0.000

(2006-10-01)

Return values
string

XHTML code

F_updateTestComment()

Updates user's test comment.<br>

F_updateTestComment( $test_id,  $testcomment) : string
Parameters
$test_id :

(int) test ID

$testcomment :

(string) user comment.

Tags
since
4.0.000

(2006-10-01)

Return values
string

XHTML code

F_testLoginForm()

Returns XHTML / CSS formatted page string to insert the test password.<br> The CSS classes used are: <ul> <li>div.login_form : container for login box</li> <li>div.login_form div.login_row : container for label + input field or button</li> <li>div.login_form div.login_row span.label : container for input label</li> <li>div.login_form div.login_row span.formw : container for input form</li> </ul>

F_testLoginForm(mixed $faction, mixed $fid, mixed $fmethod, mixed $fenctype, mixed $test_id) : XHTML
Parameters
$faction : mixed
$fid : mixed
$fmethod : mixed
$fenctype : mixed
$test_id : mixed
Return values
XHTML

string for login form

F_getTestGroups()

Get a comma separated list of valid group IDs for the selected test.

F_getTestGroups( $test_id) : string
Parameters
$test_id :

(int) ID of the selected test

Return values
string

containing a comma separated list fo group IDs.

F_getTestSSLCerts()

Get a comma separated list of valid SSL certificates IDs for the selected test.

F_getTestSSLCerts( $test_id) : string
Parameters
$test_id :

(int) ID of the selected test

Return values
string

containing a comma separated list SSL certificates IDs.

On this page
 

© 2004-2024 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy