/shared/code/tce_functions_test.php

Description

Functions to handle test generation, status and user access.

  • since: 2004-05-28
  • link: www.tecnick.com
  • copyright: Copyright © 2004-2006, Tecnick.com S.r.l. - Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
  • author: Nicola Asuni
Functions
F_addLogAnswers (line 538)

Add specified answers on tce_tests_logs_answer table.

  • return: true in case of success, false otherwise
boolean F_addLogAnswers (int $testlog_id, array $answers_ids)
  • int $testlog_id: testlog ID
  • array $answers_ids: array of answer IDs to add
F_checkTestStatus (line 181)

Check and returns specific test status for the specified user.

  • 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);
test F_checkTestStatus (int $user_id, int $test_id, int $duration)
  • int $user_id: user ID
  • int $test_id: test ID
  • int $duration: test duration in seconds
F_createTest (line 602)

Create user's test and returns TRUE on success.

  • return: TRUE in case of success, FALSE otherwise.
boolean F_createTest (int $test_id, int $user_id)
  • int $test_id: test ID.
  • int $user_id: user ID.
F_executeTest (line 425)

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

true F_executeTest (int $test_id)
  • int $test_id: test ID.
F_getFirstTestUser (line 558)

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

  • return: testuser ID
int F_getFirstTestUser (int $test_id)
  • int $test_id: test ID
F_getTestBasicScore (line 354)

Returns the basic score for right questions.

  • return: basic score for each difficulty level of questions.
double F_getTestBasicScore (int $test_id)
  • int $test_id: test ID.
F_getTestData (line 324)

Returns the test data.

  • return: containing test data.
array F_getTestData (int $test_id)
  • int $test_id: test ID.
F_getTestDuration (line 364)

Returns the test duration time in seconds.

  • return: test duration time in seconds
int F_getTestDuration (int $test_id)
  • int $test_id: test ID
F_getTestName (line 344)

Returns the test name.

  • return: test name or empty string in case of error.
string F_getTestName (int $test_id)
  • int $test_id: test ID.
F_getTestStartTime (line 375)

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

  • return: start time in seconds
int F_getTestStartTime (int $testuser_id)
  • int $testuser_id: user's test ID
F_getUserTests (line 37)

Returns an XHTML unordered list of user's enabled tests.

  • return: containing an XHTML unordered list
string F_getUserTests ()
F_isRightTestlogUser (line 473)

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

  • return: TRUE in case of success, FALSE otherwise
boolean F_isRightTestlogUser (int $test_id, int $testlog_id)
  • int $test_id: test ID
  • int $testlog_id: test log ID
F_isValidIP (line 107)

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

  • return: if IP is valid, false otherwise
true F_isValidIP (int $user_ip, int $test_ip)
  • 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".
F_isValidTestUser (line 145)

Check if user is authorized to execute the specified test

  • return: if is user is authorized, false otherwise
true F_isValidTestUser (int $test_id, int $user_ip, int $test_ip)
  • 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".
F_newTestLog (line 582)

Creates a new tce_tests_logs table entry and returns inserted ID.

  • return: testlog ID
int F_newTestLog (int $testuser_id, int $question_id, int $score)
  • int $testuser_id: ID of tce_tests_users
  • int $question_id: question ID
  • int $score: score for unanswered questions
F_printTestInfo (line 285)

Returns an XHTML string containing specified test information.

string F_printTestInfo (int $test_id, [boolean $showip = false])
  • int $test_id: test ID
  • boolean $showip: if true display enabled users' IP range
F_questionForm (line 873)

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

  • return: XHTML code
string F_questionForm (int $test_id, int $testlog_id, string $formname)
  • int $test_id: test ID
  • int $testlog_id: test log ID
  • string $formname: form name (form ID)
F_questionsMenu (line 1026)

Return a formatted XHTML ordered list containing test questions menu.

  • return: XHTML code
string F_questionsMenu (int $test_id, int $testuser_id, [mixed $testlog_id = 0], string $formname)
  • int $test_id: test ID
  • int $testuser_id: user's test ID
  • string $formname: form name (form ID)
F_selectAnswers (line 503)

Return an array containing answer_id field of selected answers.

  • return: id of selected answers
array F_selectAnswers (int $question_id, boolean $checktype, int $type, int $limit, [int $startindex = 0], [int $exclude_id = 0])
  • int $question_id: question ID
  • boolean $checktype: if true checks for answer_isright value on WHERE clause
  • int $type: answer_isright value (0 = false, 1 = true)
  • int $limit: maximum number of IDs to return
  • int $startindex: array starting index (default = 0)
  • int $exclude_id: ID of the answer to be excluded from selection (default=0)
F_terminateUserTest (line 164)

Terminate user's test

  • since: 4.0.000 (2006-09-27)
void F_terminateUserTest (mixed $testid, int $test_id)
  • int $test_id: test ID
F_testComment (line 1150)

Display a textarea for user's comment.

  • return: XHTML code
  • since: 4.0.000 (2006-10-01)
string F_testComment (int $testid)
  • int $testid: test ID
F_testInfoLink (line 257)

Returns XHTML link to open test info popup.

void F_testInfoLink (int $test_id, [string $link_name = ""])
  • int $test_id: test ID
  • string $link_name: link caption return XHTML code
F_twoColRow (line 404)

Return a formatted XHTML row to display 2 columns data.

See CSS classes:

  • div.row span.label
  • div.row span.formw

  • return: XHTML code
string F_twoColRow ([string $label = ""], [string $description = ""], [string $value = ""])
  • 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
F_updateQuestionLog (line 762)

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

  • return: TRUE in case of success, FALSE otherwise
boolean F_updateQuestionLog (int $test_id, int $testlog_id, [int $answer_id = 0], [string $answer_text = ""])
  • int $test_id: test ID
  • int $testlog_id: test log ID
  • int $answer_id: answer ID
  • string $answer_text: answer text
F_updateTestComment (line 1180)

Updates user's test comment.

  • return: XHTML code
  • since: 4.0.000 (2006-10-01)
string F_updateTestComment (int $testid, mixed $testcomment, string $comment)
  • int $testid: test ID
  • string $comment: user's comment.

Documentation generated on Fri, 24 Nov 2006 21:16:24 +0100 by phpDocumentor 1.3.0RC3