PHP Classes

Tobacco Class: Display and evaluate tobacco tests

Recommend this page to a friend!
  Info   Example   Demos   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 53 All time: 10,641 This week: 673Up
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: 18 packages by
Country: France France
Age: 77
All time rank: 15212 in France France
Week rank: 50 Up4 in France France Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Example

<?php
require("class.tobacco.en.php");
$tests = new tobacco('FDH');
?><!DOCTYPE html>

<head>
<title>Tobacco tests</title>
<meta charset="UTF-8">
<?php
$tests
->styles();
$tests->write_js();
?>
</head>

<body>

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

</body>

</html>


Details

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 (9)  
File Role Description
Plain text file class.tobacco.en.php Class Main class (English)
Plain text file class.tobacco.fr.php Class Main Class (French)
Accessible without login Plain text file demo.en.php Example Example (English)
Accessible without login Plain text file demo.fr.php Example Exemple (French)
Accessible without login Plain text file DOC.en.txt Doc. Documentation (English)
Accessible without login Plain text file DOC.fr.txt Doc. Documentation (French)
Accessible without login Plain text file tests.en.txt Doc. The tests (English)
Accessible without login Plain text file tests.fr.txt Doc. The tests (French)
Accessible without login Plain text file README.txt Data General informations

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:53
This week:0
All time:10,641
This week:673Up