PHP Classes

Tobacco Class: Display and evaluate tobacco tests

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 49 All time: 10,134 This week: 349Up
Version License PHP version Categories
tobaccoclass 0.1GNU General Publi...4Content management, Biology, Health
Description Author

This class can can display and evaluate tobacco test questions.

It can generate HTML and JavaScript for forms to display three types of tests about tobacco:

- Demaria, Grimaldi and Lagrue test (for motivation in smoking cessation)
- Fagerström test (dependency to nicotine),
- Horn Test (for smoker profile)

The class evaluates the results and displays them on the page either in English or French.

Innovation Award
PHP Programming Innovation award nominee
February 2017
Number 11

Prize: One copy of DWebPro Standard License
Tobacco tests are useful to determine how much the consumption of tobacco is affecting the health of a person.

This class can display and evaluate questionnaires to people that consume tobacco to figure their motivation levels, dependency on nicotine and smoker profile.

Manuel Lemos
Picture of Pierre FAUQUE
  Performance   Level  
Name: Pierre FAUQUE <contact>
Classes: 15 packages by
Country: France France
Age: 75
All time rank: 15711 in France France
Week rank: 92 Up3 in France France Up
Innovation award
Innovation award
Nominee: 9x

Winner: 1x


This class displays and evaluates three different tests about tobacco :
- The Fagerström test to evaluate the dependency to nicotine,
- The Demaria, Grimaldi and Lagrue test, used to determinate the motivation for smoking cessation,
- The Horn test used to determinate the smoker profile.
- Maybe other tests in a future version...

You have to intanciate the class using the initials of de desired tests :
- D for Demaria, Grimaldi and Lagrue test,
- F for Fagerström test and
- H for Horn test
Uppercase and lowercase for these initials are accepted.

You might display one, two or three tests.
The order of initals determines the displayed order.

$test = new tobacco('F');   // Only Fagerström test.
$test = new tobacco('DFH'); // Test in order Demaria, Fagerström, Horn.
$test = new tobacco('FDH'); // Test in order Fagerström, Demaria, Horn.
$test = new tobacco('DH');  // Only two tests : Demaria first, Horn after.

The results of each test are always stored in arrays :
$test->tabd for Demaria test
$test->tabf for Fagerström test
$test->tabh for Horn test

The attribute $test->showtest can be set to 0 or 1.
1 : the results of tests are shown. It is the default value.
0 : the results are not shown.
You can set the value of this attribute at the instanciation :
$test = new tobacco('DFH'); or $test = new tobacco('DFH',1); // to display results
$test = new tobacco('DFH',0); // to not display

If $test->showtest is set to 0, the results are not displayed and you can
use the results array ($test->tabd, $test->tabf, $test->tabh) to write your
own texts with the styles you want. The answers made, whether the results are displayed
or not, are always stored in these arrays.

To display the test(s), use the method $test->display();
To evaluate the test(s), use the method $test->evaluate();
To write the corresponding javascript, use the method $test->write_js();
To see the answers array or the results array, use the method $test->showresults();
after the method $test->evaluate(); whether the $test->showtest attribute is set to 0 or 1.

- In the Fagerström test, all questions must be answered.
- In the Demaria test, the first question (radio: 3 choices) must be ansewered.
     All other propositions can be checked if they are true.
- In the Horn test, all questions must be answered.

Take a look at the demo.en.php file

16/01/2017 : v0.1     Initial version.

  Démo of Tobacco classExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Plain text file class.tobacco.en.php Class Main class (English)
Plain text file Class Main Class (French)
Accessible without login Plain text file demo.en.php Example Example (English)
Accessible without login Plain text file Example Exemple (French)
Accessible without login Plain text file DOC.en.txt Doc. Documentation (English)
Accessible without login Plain text file Doc. Documentation (French)
Accessible without login Plain text file tests.en.txt Doc. The tests (English)
Accessible without login Plain text file Doc. The tests (French)
Accessible without login Plain text file README.txt Data General informations

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:10,134
This week:349Up
For more information send a message to info at phpclasses dot org.