tce__functions__test_8php

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 File Reference

Namespaces

 com\tecnick\tcexam\shared
 TCExam Shared Area.
 

Functions

 F_getUserTests ()
 
 F_repeatTest ($test_id)
 
 F_isValidIP ($user_ip, $test_ips)
 
 F_isValidSSLCert ($test_id)
 
 F_isValidTestUser ($test_id, $user_ip, $test_ip)
 
 F_terminateUserTest ($test_id)
 
 F_checkTestStatus ($user_id, $test_id, $duration)
 
 F_testInfoLink ($test_id, $link_name=“)
 
 F_printTestInfo ($test_id, $showip=false)
 
 F_getTestData ($test_id)
 
 F_getUserData ($user_id)
 
 F_getTestPassword ($test_id)
 
 F_getTestName ($test_id)
 
 F_getTestDuration ($test_id)
 
 F_getTestStartTime ($testuser_id)
 
 F_twoColRow ($label="", $description="", $value="")
 
 F_executeTest ($test_id)
 
 F_isRightTestlogUser ($test_id, $testlog_id)
 
 F_selectAnswers ($question_id, $isright=“, $ordering=false, $limit=0, $startindex=0, $randorder=true, $ordmode=0)
 
 F_addLogAnswers ($testlog_id, $answers_ids)
 
 F_getFirstTestUser ($test_id)
 
 F_newTestLog ($testuser_id, $question_id, $score, $order, $num_answers=0)
 
 F_isTestOverLimits ()
 
 F_count_executed_tests ($startdate, $enddate)
 
 F_updateTestuserStat ($date)
 
 F_createTest ($test_id, $user_id)
 
 F_addQuestionAnswers ($testlog_id, $question_id, $question_type, $num_answers, $firsttest, $testdata)
 
 F_updateQuestionLog ($test_id, $testlog_id, $answpos=array(), $answer_text=“, $reaction_time=0)
 
 F_getAnswerIdFromPosition ($testlog_id, $answpos)
 
 F_questionForm ($test_id, $testlog_id, $formname)
 
 F_questionsMenu ($testdata, $testuser_id, $testlog_id=0, $disable=false)
 
 F_getNumOmittedQuestions ($test_id)
 
 F_testComment ($test_id)
 
 F_updateTestComment ($test_id, $testcomment)
 
 F_testLoginForm ($faction, $fid, $fmethod, $fenctype, $test_id)
 
 F_getTestGroups ($test_id)
 
 F_getTestSSLCerts ($test_id)
 

Detailed Description

Functions to handle test generation, status and user access.

Function Documentation

F_addLogAnswers (   $testlog_id,
  $answers_ids 
)

Add specified answers on tce_tests_logs_answer table.

Parameters
$testlog_id(int) testlog ID
$answers_ids(array) array of answer IDs to add
Returns
boolean true in case of success, false otherwise

F_addQuestionAnswers (   $testlog_id,
  $question_id,
  $question_type,
  $num_answers,
  $firsttest,
  $testdata 
)

Add answers to selected question.

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.
Returns
boolean TRUE in case of success, FALSE otherwise.

F_checkTestStatus (   $user_id,
  $test_id,
  $duration 
)

Check and returns specific test status for the specified user.

Parameters
$user_id(int) user ID
$test_id(int) test ID
$duration(int) test duration in seconds
Returns
array 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;

F_count_executed_tests (   $startdate,
  $enddate 
)

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

Parameters
$startdate(string) Star date-time interval.
$enddate(string) End date-time interval.
Returns
int number of executed tests.

F_createTest (   $test_id,
  $user_id 
)

Create user’s test and returns TRUE on success.

Parameters
$test_id(int) test ID.
$user_id(int) user ID.
Returns
boolean TRUE in case of success, FALSE otherwise.

F_executeTest (   $test_id)

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

Parameters
$test_id(int) test ID.
Returns
true if user is authorized, false otherwise.

F_getAnswerIdFromPosition (   $testlog_id,
  $answpos 
)

Returns the answer ID from position

Parameters
$testlog_id(int) Test Log ID
$answpos(array) Answer positions (order in wich they are displayed)
Returns
int answer ID

F_getFirstTestUser (   $test_id)

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

Parameters
$test_id(int) test ID
Returns
int testuser ID

F_getNumOmittedQuestions (   $test_id)

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

Parameters
$test_id(int) test ID
Returns
integer number

F_getTestData (   $test_id)

Returns the test data.

Parameters
$test_id(int) test ID.
Returns
array containing test data.

F_getTestDuration (   $test_id)

Returns the test duration time in seconds.

Parameters
$test_id(int) test ID
Returns
int test duration time in seconds

F_getTestGroups (   $test_id)

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

Parameters
$test_id(int) ID of the selected test
Returns
string containing a comma separated list fo group IDs.

F_getTestName (   $test_id)

Returns the test name.

Parameters
$test_id(int) test ID.
Returns
string test name or empty string in case of error.

F_getTestPassword (   $test_id)

Returns the test password.

Parameters
$test_id(int) test ID.
Returns
string test password or empty string in case of error.

F_getTestSSLCerts (   $test_id)

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

Parameters
$test_id(int) ID of the selected test
Returns
string containing a comma separated list SSL certificates IDs.

F_getTestStartTime (   $testuser_id)

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

Parameters
$testuser_id(int) user’s test ID
Returns
int start time in seconds

F_getUserData (   $user_id)

Returns user data.

Parameters
$user_id(int) User ID.
Returns
array containing test data.

F_getUserTests ( )

Returns an XHTML table of user’s tests.

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

F_isRightTestlogUser (   $test_id,
  $testlog_id 
)

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

Parameters
$test_id(int) test ID
$testlog_id(int) test log ID
Returns
boolean TRUE in case of success, FALSE otherwise

F_isTestOverLimits ( )

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

Returns
boolean true/false.

F_isValidIP (   $user_ip,
  $test_ips 
)

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

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.
Returns
true if IP is valid, false otherwise

F_isValidSSLCert (   $test_id)

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

Parameters
$test_id(int) Test ID
Returns
true if the client certifiate is valid, false otherwise

F_isValidTestUser (   $test_id,
  $user_ip,
  $test_ip 
)

Check if user is authorized to execute the specified test

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”.
Returns
true if is user is authorized, false otherwise

F_newTestLog (   $testuser_id,
  $question_id,
  $score,
  $order,
  $num_answers = 0 
)

Creates a new tce_tests_logs table entry and returns inserted ID.

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(int) number of alternative answers
Returns
int testlog ID

F_printTestInfo (   $test_id,
  $showip = false 
)

Returns an XHTML string containing specified test information.

Parameters
$test_id(int) test ID
$showip(boolean) if true display enabled users’ IP range
Returns
string containing an XHTML code

F_questionForm (   $test_id,
  $testlog_id,
  $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
Parameters
$test_id(int) test ID
$testlog_id(int) test log ID
$formname(string) form name (form ID)
Returns
string XHTML code

F_questionsMenu (   $testdata,
  $testuser_id,
  $testlog_id = 0,
  $disable = false 
)

Returns a questions menu and navigator buttons.

Parameters
$testdata(array) test data
$testuser_id(int) user’s test ID
$testlog_id(int) test log ID
$disable(boolean) if TRUE disable the questions list.
Returns
string XHTML code

F_repeatTest (   $test_id)

Mark previous test attempts as repeated.

Parameters
$test_id(int) Test ID

F_selectAnswers (   $question_id,
  $isright = ,
  $ordering = false,
  $limit = 0,
  $startindex = 0,
  $randorder = true,
  $ordmode = 0 
)

Return an array containing answer_id field of selected answers.

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(int) Ordering type question (0 = false, 1 = true).
$limit(int) Maximum number of IDs to return.
$startindex(int) Array starting index (default = 0).
$randorder(boolean) If true user random order.
$ordmode(int) Ordering mode: 0=position; 1=alphabetical; 2=ID.
Returns
array id of selected answers

F_terminateUserTest (   $test_id)

Terminate user’s test

Parameters
$test_id(int) test ID
Since
4.0.000 (2006-09-27)

F_testComment (   $test_id)

Display a textarea for user’s comment.

Parameters
$test_id(int) test ID
Returns
string XHTML code
Since
4.0.000 (2006-10-01)

F_testInfoLink (   $test_id,
  $link_name =  
)

Returns XHTML link to open test info popup.

Parameters
$test_id(int) test ID
$link_name(string) link caption return XHTML code

F_testLoginForm (   $faction,
  $fid,
  $fmethod,
  $fenctype,
  $test_id 
)

Returns XHTML / CSS formatted page string to insert the test password.
The CSS classes used are:

  • div.login_form : container for login box
  • div.login_form div.login_row : container for label + input field or button
  • div.login_form div.login_row span.label : container for input label
  • div.login_form div.login_row span.formw : container for input form
Parameters
factionString action attribute
fidString form ID attribute
fmethodString method attribute (get/post)
fenctypeString enctype attribute
test_idint ID of the test
Returns
XHTML string for login form

F_twoColRow (   $label = "",
  $description = "",
  $value = "" 
)

Return a formatted XHTML row to display 2 columns data.
See CSS classes:

  • div.row span.label
  • div.row span.formw
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
Returns
string XHTML code

F_updateQuestionLog (   $test_id,
  $testlog_id,
  $answpos = array(),
  $answer_text = ,
  $reaction_time = 0 
)

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

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(int) reaction time in milliseconds
Returns
boolean TRUE in case of success, FALSE otherwise

F_updateTestComment (   $test_id,
  $testcomment 
)

Updates user’s test comment.

Parameters
$test_id(int) test ID
$testcomment(string) user comment.
Returns
string XHTML code
Since
4.0.000 (2006-10-01)

F_updateTestuserStat (   $date)

Track generated tests.

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

 

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