tce_functions_test.php

Functions to handle test generation, status and user access.

Source: shared/code/tce_functions_test.php

Functions to handle test generation, status and user access.

Functions

F_addLogAnswers()

Add specified answers on tce_tests_logs_answer table.

function F_addLogAnswers(mixed $testlog_id, mixed $answers_ids): bool

Parameters:

  • $testlog_id (mixed): (int) testlog ID
  • $answers_ids (mixed): (array) array of answer IDs to add

Returns: bool: true in case of success, false otherwise

Source: shared/code/tce_functions_test.php:1055

F_addQuestionAnswers()

Add answers to selected question.

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

Parameters:

  • $testlog_id (mixed): (int) testlog ID.
  • $question_id (mixed): (int) question ID.
  • $question_type (mixed): (int) type of question.
  • $num_answers (mixed): (int) number of alternative answers to display.
  • $firsttest (mixed): (int) ID of first test testuser_id.
  • $testdata (mixed): (array) array of test data.

Returns: bool: TRUE in case of success, FALSE otherwise.

Source: shared/code/tce_functions_test.php:1623

F_checkTestStatus()

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

function F_checkTestStatus(mixed $user_id, mixed $test_id, mixed $duration): array

Parameters:

  • $user_id (mixed): (int) user ID
  • $test_id (mixed): (int) test ID
  • $duration (mixed): (int) test duration in seconds

Returns: array: of (test_status_code, testuser_id). test_status_code: <ul><li>0 = the test generation process is started but not completed;</li><li>1 = the test has been successfully created;</li><li>2 = all questions have been displayed to the user;</li><li>3 = all questions have been answered;</li><li>4 = test locked (for timeout);</li><li>5 or more = old version of repeated test;</li></ul>

Source: shared/code/tce_functions_test.php:479

F_count_executed_tests()

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

function F_count_executed_tests(mixed $startdate, mixed $enddate): int

Parameters:

  • $startdate (mixed): (string) Star date-time interval.
  • $enddate (mixed): (string) End date-time interval.

Returns: int: number of executed tests.

Source: shared/code/tce_functions_test.php:1225

F_countUserTest()

Count the number times of retries.<br>

function F_countUserTest(mixed $user_id, mixed $test_id): retried

Parameters:

  • $user_id (mixed): (int) user ID
  • $test_id (mixed): (int) test ID

Returns: retried: times

Source: shared/code/tce_functions_test.php:464

F_createTest()

Create user’s test and returns TRUE on success.

function F_createTest(mixed $test_id, mixed $user_id): bool

Parameters:

  • $test_id (mixed): (int) test ID.
  • $user_id (mixed): (int) user ID.

Returns: bool: TRUE in case of success, FALSE otherwise.

Source: shared/code/tce_functions_test.php:1265

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.

function F_executeTest(mixed $test_id): true

Parameters:

  • $test_id (mixed): (int) test ID.

Returns: true: if user is authorized, false otherwise.

Source: shared/code/tce_functions_test.php:847

F_getAnswerIdFromPosition()

Returns the answer ID from position

function F_getAnswerIdFromPosition(mixed $testlog_id, mixed $answpos): int

Parameters:

  • $testlog_id (mixed): (int) Test Log ID
  • $answpos (mixed): (array) Answer positions (order in wich they are displayed)

Returns: int: answer ID

Source: shared/code/tce_functions_test.php:2012

F_getFirstTestUser()

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

function F_getFirstTestUser(mixed $test_id): int

Parameters:

  • $test_id (mixed): (int) test ID

Returns: int: testuser ID

Source: shared/code/tce_functions_test.php:1087

F_getNumOmittedQuestions()

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

function F_getNumOmittedQuestions(mixed $test_id): int

Parameters:

  • $test_id (mixed): (int) test ID

Returns: int: number

Source: shared/code/tce_functions_test.php:2693

F_getTestData()

Returns the test data.

function F_getTestData(mixed $test_id): array

Parameters:

  • $test_id (mixed): (int) test ID.

Returns: array: containing test data.

Source: shared/code/tce_functions_test.php:709

F_getTestDuration()

Returns the test duration time in seconds.

function F_getTestDuration(mixed $test_id): int

Parameters:

  • $test_id (mixed): (int) test ID

Returns: int: test duration time in seconds

Source: shared/code/tce_functions_test.php:781

F_getTestGroups()

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

function F_getTestGroups(mixed $test_id): string

Parameters:

  • $test_id (mixed): (int) ID of the selected test

Returns: string: containing a comma separated list fo group IDs.

Source: shared/code/tce_functions_test.php:2872

F_getTestName()

Returns the test name.

function F_getTestName(mixed $test_id): string

Parameters:

  • $test_id (mixed): (int) test ID.

Returns: string: test name or empty string in case of error.

Source: shared/code/tce_functions_test.php:769

F_getTestPassword()

Returns the test password.

function F_getTestPassword(mixed $test_id): string

Parameters:

  • $test_id (mixed): (int) test ID.

Returns: string: test password or empty string in case of error.

Source: shared/code/tce_functions_test.php:757

F_getTestSSLCerts()

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

function F_getTestSSLCerts(mixed $test_id): string

Parameters:

  • $test_id (mixed): (int) ID of the selected test

Returns: string: containing a comma separated list SSL certificates IDs.

Source: shared/code/tce_functions_test.php:2901

F_getTestStartTime()

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

function F_getTestStartTime(mixed $testuser_id): int

Parameters:

  • $testuser_id (mixed): (int) user’s test ID

Returns: int: start time in seconds

Source: shared/code/tce_functions_test.php:794

F_getUserData()

Returns user data.

function F_getUserData(mixed $user_id): array

Parameters:

  • $user_id (mixed): (int) User ID.

Returns: array: containing test data.

Source: shared/code/tce_functions_test.php:733

F_getUserTests()

Returns an XHTML table of user’s tests.

function F_getUserTests(): string

Returns: string: containing an XHTML table of user’s tests.

Source: shared/code/tce_functions_test.php:28

F_isRightTestlogUser()

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

function F_isRightTestlogUser(mixed $test_id, mixed $testlog_id): bool

Parameters:

  • $test_id (mixed): (int) test ID
  • $testlog_id (mixed): (int) test log ID

Returns: bool: TRUE in case of success, FALSE otherwise

Source: shared/code/tce_functions_test.php:927

F_isTestOverLimits()

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

function F_isTestOverLimits(): bool

Returns: bool: true/false.

Source: shared/code/tce_functions_test.php:1171

F_isValidIP()

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

function F_isValidIP(mixed $user_ip, mixed $test_ips): bool

Parameters:

  • $user_ip (mixed): (string) user’s IP address (IPv4 or IPv6).
  • $test_ips (mixed): (string) 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.

Returns: bool: true if IP is valid, false otherwise

Source: shared/code/tce_functions_test.php:287

F_isValidSSLCert()

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

function F_isValidSSLCert(mixed $test_id): true

Parameters:

  • $test_id (mixed): (int) Test ID

Returns: true: if the client certifiate is valid, false otherwise

Source: shared/code/tce_functions_test.php:368

F_isValidTestUser()

Check if user is authorized to execute the specified test

function F_isValidTestUser(mixed $test_id, mixed $user_ip, mixed $test_ip): true

Parameters:

  • $test_id (mixed): (int) ID of the selected test
  • $user_ip (mixed): (int) user’s IP address.
  • $test_ip (mixed): (int) test IP valid addresses. Various IP addresses may be separated using comma character. The asterisk character may be used to indicate “any number”.

Returns: true: if is user is authorized, false otherwise

Source: shared/code/tce_functions_test.php:401

F_newTestLog()

Creates a new tce_tests_logs table entry and returns inserted ID.

function F_newTestLog(
    mixed $testuser_id,
    mixed $question_id,
    mixed $score,
    mixed $order,
    mixed $num_answers = 0
): int

Parameters:

  • $testuser_id (mixed): (int) ID of tce_tests_users
  • $question_id (mixed): (int) question ID
  • $score (mixed): (int) score for unanswered questions
  • $order (mixed): (int) question display order
  • $num_answers (mixed): (int) number of alternative answers

Returns: int: testlog ID

Source: shared/code/tce_functions_test.php:1119

F_printTestInfo()

Returns an XHTML string containing specified test information.

function F_printTestInfo(mixed $test_id, mixed $showip = false): string

Parameters:

  • $test_id (mixed): (int) test ID
  • $showip (mixed): (boolean) if true display enabled users’ IP range

Returns: string: containing an XHTML code

Source: shared/code/tce_functions_test.php:630

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>

function F_questionForm(mixed $test_id, mixed $testlog_id, mixed $formname): string

Parameters:

  • $test_id (mixed): (int) test ID
  • $testlog_id (mixed): (int) test log ID
  • $formname (mixed): (string) form name (form ID)

Returns: string: XHTML code

Source: shared/code/tce_functions_test.php:2051

F_questionsMenu()

Returns a questions menu and navigator buttons.

function F_questionsMenu(
    mixed $testdata,
    mixed $testuser_id,
    mixed $testlog_id = 0,
    mixed $disable = false
): string

Parameters:

  • $testdata (mixed): (array) test data
  • $testuser_id (mixed): (int) user’s test ID
  • $testlog_id (mixed): (int) test log ID
  • $disable (mixed): (boolean) if TRUE disable the questions list.

Returns: string: XHTML code

Source: shared/code/tce_functions_test.php:2501

F_repeatTest()

Mark previous test attempts as repeated.

function F_repeatTest(mixed $test_id)

Parameters:

  • $test_id (mixed): (int) Test ID

Source: shared/code/tce_functions_test.php:243

F_selectAnswers()

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

function F_selectAnswers(
    mixed $question_id,
    mixed $isright = '',
    mixed $ordering = false,
    mixed $limit = 0,
    mixed $startindex = 0,
    mixed $randorder = true,
    mixed $ordmode = 0
): array

Parameters:

  • $question_id (mixed): (int) Question ID.
  • $isright (mixed): (int) Value (0 = false, 1 = true), if non-empty checks for answer_isright value on WHERE clause.
  • $ordering (mixed): (int) Ordering type question (0 = false, 1 = true).
  • $limit (mixed): (int) Maximum number of IDs to return.
  • $startindex (mixed): (int) Array starting index (default = 0).
  • $randorder (mixed): (boolean) If true user random order.
  • $ordmode (mixed): (int) Ordering mode: 0=position; 1=alphabetical; 2=ID.

Returns: array: id of selected answers

Source: shared/code/tce_functions_test.php:964

F_terminateUserTest()

Terminate user’s test<br>

function F_terminateUserTest(mixed $test_id)

Parameters:

  • $test_id (mixed): (int) test ID

Source: shared/code/tce_functions_test.php:435

F_testComment()

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

function F_testComment(mixed $test_id): string

Parameters:

  • $test_id (mixed): (int) test ID

Returns: string: XHTML code

Source: shared/code/tce_functions_test.php:2717

Returns XHTML link to open test info popup.

function F_testInfoLink(mixed $test_id, mixed $link_name = '')

Parameters:

  • $test_id (mixed): (int) test ID
  • $link_name (mixed): (string) link caption return XHTML code

Source: shared/code/tce_functions_test.php:596

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>

function 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)

Returns: XHTML: string for login form

Source: shared/code/tce_functions_test.php:2814

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>

function F_twoColRow(mixed $label = '', mixed $description = '', mixed $value = ''): string

Parameters:

  • $label (mixed): (string) string to display on the left column
  • $description (mixed): (string) string to display on the title attribute of the left column field
  • $value (mixed): (string) string to display on the right column

Returns: string: XHTML code

Source: shared/code/tce_functions_test.php:826

F_updateQuestionLog()

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

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

Parameters:

  • $test_id (mixed): (int) test ID
  • $testlog_id (mixed): (int) test log ID
  • $answpos (mixed): (array) Array of answer positions
  • $answer_text (mixed): (string) answer text
  • $reaction_time (mixed): (int) reaction time in milliseconds

Returns: bool: TRUE in case of success, FALSE otherwise

Source: shared/code/tce_functions_test.php:1741

F_updateTestComment()

Updates user’s test comment.<br>

function F_updateTestComment(mixed $test_id, mixed $testcomment): string

Parameters:

  • $test_id (mixed): (int) test ID
  • $testcomment (mixed): (string) user comment.

Returns: string: XHTML code

Source: shared/code/tce_functions_test.php:2772

F_updateTestuserStat()

Track generated tests.

function F_updateTestuserStat(mixed $date)

Parameters:

  • $date (mixed): (string) date-time when the test was generated.

Source: shared/code/tce_functions_test.php:1249