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: 53 All time: 10,622 This week: 673Up
Version License PHP version Categories
tobaccoclass 0.1GNU General Publi...4Content management, Biology, Health


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: 18 packages by
Country: France France
Age: 77
All time rank: 15212 in France France
Week rank: 30 Up3 in France France Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x


$tests = new tobacco('FDH');
?><!DOCTYPE html>

<title>Tobacco tests</title>
<meta charset="UTF-8">


if(!$_POST['submit']) {
"<form method='post' name='tobacco' action='".$_SERVER['PHP_SELF']."' onsubmit='return verif()'>\n";
"</form>\n"; }
else {
// $tests->showresults();
if($tests->horn and $_POST['submit']) {
"<p class='p'>In the smoker profile, if some reasons are underlined (10 points or more),<br/>";
"they indicate those which really encourage you to smoke. The others also<br/>";
"contribute to it but it will be less difficult for you to control them.</p>\n";
"<p class='p'>Never forget: you can get help from hospitals or from your doctor.</p>\n";




MINI-DOCUMENTATION 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. examples: $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. Javascript: - 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 History: 16/01/2017 : v0.1 Initial version.

  Démo of Tobacco classExternal page  
  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,622
This week:673Up