Learning with Texts - Fork  2.10.0-fork
Learn foreign languages with texts
Namespaces | Functions
do_test_test.php File Reference

Show test frame. More...

Namespaces

 Lwt
 

Functions

 do_test_get_identifier ($selection, $sess_testsql, $lang, $text)
 
 do_test_get_test_sql ($selection, $sess_testsql, $lang, $text)
 
 do_test_get_test_type ($testtype)
 
 get_test_sql ()
 
 get_test_type ()
 
 do_test_test_css ()
 
 do_test_get_tomorrow_tests_count ($testsql)
 
 do_test_test_finished ($testsql, $totaltests, $ajax=false)
 
 do_test_test_sentence ($wid, $lang, $wordlc)
 
 do_test_get_term_test ( $wo_record, $sent, $testtype, $nosent, $regexword)
 
 print_term_test ($wo_record, $sent, $testtype, $nosent, $regexword)
 
 do_test_get_word ($testsql)
 
 get_test_solution ($testtype, $wo_record, $nosent, $wo_text)
 
 do_test_prepare_ajax_test_area ( $selector, $selection, $count, $testtype)
 
 prepare_test_area ($testsql, $totaltests, $count, $testtype)
 
 do_test_test_interaction_globals ($wb1, $wb2, $wb3, $lg_id)
 
 do_test_test_javascript_clickable ($wo_record, $solution)
 
 do_test_test_javascript_interaction ( $wo_record, $wb1, $wb2, $wb3, $testtype, $nosent, $save)
 
 prepare_test_footer ($notyettested)
 
 do_test_footer ($notyettested, $wrong, $correct)
 
 do_test_test_javascript ($count)
 
 do_test_test_content ()
 
 do_test_test_content_ajax ($selector, $selection)
 

Detailed Description

Show test frame.

Call: do_test_test.php?type=[testtype]&lang=[langid] Call: do_test_test.php?type=[testtype]&text=[textid] Call: do_test_test.php?type=[testtype]&selection=1 (SQL via $_SESSION['testsql'])

PHP version 8.1

Function Documentation

◆ do_test_footer()

do_test_footer (   $notyettested,
  $wrong,
  $correct 
)

Echoes HTML code for the footer of a words test page.

Parameters
int$notyettestedNumber of words left to be tested
int$wrongNumber of failed tests
int$correctNumber of correct answers.
Returns
void

◆ do_test_get_identifier()

do_test_get_identifier (   $selection,
  $sess_testsql,
  $lang,
  $text 
)

Get the SQL string to perform tests.

Parameters
int | null$selectionTest is of type selection
string | null$sess_testsqlSQL string for test
int | null$langTest is of type language, for the language $lang ID
int | null$textTesting text with ID $text
Returns
(int|int[]|string)[] Test identifier as an array(key, value)

@psalm-return list{string, int|non-empty-list<int>|string}

◆ do_test_get_term_test()

do_test_get_term_test (   $wo_record,
  $sent,
  $testtype,
  $nosent,
  $regexword 
)

Return the test relative to a word.

Parameters
array$wo_recordQuery from the database regarding a word.
string$sentSentence containing the word.
int$testtypeType of test
bool | int$nosent1 or true if you want to hide sentences.
string$regexwordRegex to select the desired word.
Returns
string[] HTML-escaped and raw text sentences (or word)

@psalm-return list{string, string}

◆ do_test_get_test_sql()

do_test_get_test_sql (   $selection,
  $sess_testsql,
  $lang,
  $text 
)

Get the SQL string to perform tests.

Parameters
int | null$selectionTest is of type selection
string | null$sess_testsqlSQL string for test
int | null$langTest is of type language, for the language $lang ID
int | null$textTesting text with ID $text
Returns
string SQL projection (selection) string

◆ do_test_get_test_type()

do_test_get_test_type (   $testtype)

Get the test type clamped between 1 and 5 (included)

Parameters
int$testtypeInitial test type value
Returns
int Clamped $testtype
  • 1: Test type is ..[L2]..
  • 2: Test type is ..[L1]..
  • 3: Test type is ..[..]..
  • 4: Test type is [L2]
  • 5: Test type is [L1]

◆ do_test_get_tomorrow_tests_count()

do_test_get_tomorrow_tests_count (   $testsql)

Return the number of test due for tomorrow.

Parameters
string$testsqlTest selection string
Returns
int Tomorrow tests

◆ do_test_get_word()

do_test_get_word (   $testsql)

Find the next word to test.

Parameters
string$testsqlTest selection string
Returns
(float|int|null|string)[] Empty array

@psalm-return array<string, float|int|null|string>

◆ do_test_prepare_ajax_test_area()

do_test_prepare_ajax_test_area (   $selector,
  $selection,
  $count,
  $testtype 
)

Preforms the HTML of the test area, to update through AJAX.

Parameters
string$selectorOn which set to run the test.
array | int$selectionID of the elements of the set to use.
int$countNumber of tests left.
int$testtypeType of test (words, sentences, etc...).
Returns
int Number of tests left to do.

@global string $tbpref Table prefix @global int $debug Show the SQL query used if 1.

@psalm-return int<0, max>

Get a new word test.

Parameters
{array}review_data Data to use

◆ do_test_test_content()

do_test_test_content ( )

Do the main content of a test page.

@global int $debug Show debug informations

Returns
void
Deprecated:
Since 2.10.0-fork, use do_test_test_content_ajax instead

◆ do_test_test_content_ajax()

do_test_test_content_ajax (   $selector,
  $selection 
)

Do the main content of a test page.

Parameters
string$selectorType of test to run
array | int$selectionItems to run the test on

@global int $debug Show debug informations

Returns
void

◆ do_test_test_css()

do_test_test_css ( )

Prepare the css code for tests.

Deprecated:
2.6.0-fork Do not use this function since it was causing wrong display. Will be removed in 3.0.0.
Returns
void

◆ do_test_test_finished()

do_test_test_finished (   $testsql,
  $totaltests,
  $ajax = false 
)

Output a message for a finished test, with the number of tests for tomorrow.

Parameters
string$testsqlQuery used to select words.
int$totaltestsTotal number of tests.
bool$ajaxAJAX mode, content will not be displayed.
Returns
void

◆ do_test_test_interaction_globals()

do_test_test_interaction_globals (   $wb1,
  $wb2,
  $wb3,
  $lg_id 
)

Prepare JavaScript code globals so that you can click on words.

Parameters
string$wb1URL of the first dictionary.
string$wb2URL of the secondary dictionary.
string$wb3URL of the google translate dictionary.
int$lg_idLanguage ID (since 2.10.0-fork)
Returns
void
Since
2.10.0-fork Takes a language ID as the fourth argument

◆ do_test_test_javascript()

do_test_test_javascript (   $count)

Prepare JavaScript code for interacting between the different frames.

Parameters
int$countTotal number of tests that were done today
Returns
void

Prepare the different frames for a test.

Adds a word reading event.

Parameters
{string}term_text Term to read
{int}lang_id Language ID

Insert a new word test.

Parameters
{number}word_id Word ID
{string}solution Test answer
{string}group HTML group to display (either term, translation, sentence...)

Handles an ajax query for word tests.

Parameters
{JSON}current_test Current test data
{number}total_tests Total number of tests for the day
{string}test_key Key identifier for the test to run
{string}selection Selection of data to run the test on

Get new term to test through AJAX

Parameters
{JSON}review_data Various data on the current test

Make a custom display when tests are finished for today.

◆ do_test_test_javascript_clickable()

do_test_test_javascript_clickable (   $wo_record,
  $solution 
)

Prepare JavaScript code so that you can click on words.

Parameters
array$wo_recordWord record. Associative array with keys 'WoID', 'WoTranslation'.
string$solutionSolution to the test (as HTML)
Returns
void

Read the word aloud

◆ do_test_test_javascript_interaction()

do_test_test_javascript_interaction (   $wo_record,
  $wb1,
  $wb2,
  $wb3,
  $testtype,
  $nosent,
  $save 
)

Prepare JavaScript code so that you can click on words.

Parameters
array$wo_recordWord record. Associative array with keys 'WoID', 'WoTranslation'.
string$wb1URL of the first dictionary.
string$wb2URL of the secondary dictionary.
string$wb3URL of the google translate dictionary.
int$testtypeType of test
int$nosent1 to use single word instead of sentence.
string$saveWord or sentence to use for the test
Returns
void

@global string $tbpref Database table prefix @global string $angDefs Languages definition array

◆ do_test_test_sentence()

do_test_test_sentence (   $wid,
  $lang,
  $wordlc 
)

Get a sentence containing the word.

The sentence should contain at least 70% of known words.

Parameters
int$widThe word to test.
mixed$langID of the language, will be removed in PHP 3.0.0
string$wordlcWord in lowercase

@global string $tbpref Table prefix

Returns
(int|null|string)[] Sentence with escaped word and 1.
Since
2.5.3-fork Properly return sentences with at least 70% of known words. Previously, it was supposed to be 100%, but buggy.
2.10.0-fork Always return a sentence, even the 70% known words ratio is not matched

@psalm-return list{null|string, 0|1}

◆ get_test_solution()

get_test_solution (   $testtype,
  $wo_record,
  $nosent,
  $wo_text 
)

Get the solution to a test.

Parameters
int$testtypeTest type between 1 and 5
array$wo_recordWord record element
bool$nosentTest is in word mode
string$wo_textWord text
Returns
string Solution to display.

◆ get_test_sql()

get_test_sql ( )

Set sql request for the word test.

Returns
string SQL request string

@global string $tbpref

Deprecated:
2.9.0-fork Use do_test_get_sql instead

◆ get_test_type()

get_test_type ( )

Give the test type.

Returns
int<1, 5> Test type between 1 and 5 (included)
Deprecated:
2.9.0-fork Use do_test_get_test_type instead.

◆ prepare_test_area()

prepare_test_area (   $testsql,
  $totaltests,
  $count,
  $testtype 
)

Preforms the HTML of the test area.

Parameters
string$testsqlSQL query of for the words that should be tested.
int$totaltestsTotal number of tests to do.
int$countNumber of tests left.
int$testtypeType of test.
Returns
int Number of tests left to do.

@global string $tbpref Table prefix @global int $debug Show the SQL query used if 1.

@psalm-return int<0, max>

◆ prepare_test_footer()

prepare_test_footer (   $notyettested)

Get the data and echoes the footer.

Parameters
int$notyettestedNumber of words left to be tested.
Returns
void

◆ print_term_test()

print_term_test (   $wo_record,
  $sent,
  $testtype,
  $nosent,
  $regexword 
)

Echo the test relative to a word.

Parameters
array$wo_recordQuery from the database regarding a word.
string$sentSentence containing the word.
int$testtypeType of test
int$nosent1 if you want to hide sentences.
string$regexwordRegex to select the desired word.
Returns
string HTML-escaped and raw text sentences (or word)