ciao a tutti
ho utilizato per creare dei test psicologici il seguente script preso da
http://www.howtocreate.co.uk/php/howto.html
scaricato anche il questans.php allegato
Ma questo script mi fa andare avanti anche se non ho cliccato su tutte le risposte, vorrei che mi indica le risposte che non ho dato. Come posso fare? posso inserire uno script nel questans.php? Grazie
Il questans.php e:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>
<?php
if( !is_array( $_REQUEST ) ) { $_REQUEST = array_merge( $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS ); }
foreach( $_REQUEST as $key => $value ) { $$key = $value; }
function stripscript( $mystring ) {
if( get_magic_quotes_gpc() ) { $mystring = stripslashes( $mystring ); }
return htmlspecialchars( $mystring );
}
print stripscript( $questiontitle )."\n";
?>
</title>
</head>
<body>
<!-- ************************************************** ***********
Questionnaire scoring script
v2.0 Written by Mark 'Tarquin' Wilton-Jones - 2002-2003
************************************************** ****************
Please see http://www.howtocreate.co.uk/jslibs/termsOfUse.html for terms and conditions of use.
Please see http://www.howtocreate.co.uk/php/ for instructions.
__________________________________________________ _________________ -->
<h1>
<?php
print stripscript( $questiontitle )."\n";
?>
</h1>
<h2><?php
$max = 0;
$total = 0;
for( $x = 1; $x <= count( $qtot ); $x++ ) {
//the hidden input gives the maximum for each question
$max += $qtot[$x];
if( $q[$x] && gettype( $q[$x] ) == 'array' ) {
//if it is a checkbox input, add the number that have been checked
$total += count( $q[$x] );
} else {
//if it is a radio input, add its value
$total += $q[$x];
}
}
$score = floor( 100 * ( $total / $max ) );
print stripscript( $questionreplystart ) ." ". $score ."% ". stripscript( $questionreplyend )."</h2>\n";
if( count( $customresponse ) ) {
//if they have chosen custom responses, find the highest valued one that works.
$got_one = "";
for( $x = 0; $x <= $score; $x++ ) {
if( $customresponse[$x] && $score >= $x ) {
$got_one = $customresponse[$x];
}
}
print "
".stripscript( $got_one )."</p>\n";
}
?>
<hr>
Questionnaire scoring script provided for free by http://www.howtocreate.co.uk.</p>
Create your own questionnairs and use this program to calculate scores.</p>
</body>
</html>