Location: PHPKode > projects > Teacher Evaluation based on phpsurveyor > DONT USE/mod_evaluation/batchcreatesurveys.php
require_once "header.php";
 * Teacher survey batch create
 * @version $Id$
 * @copyright 2004
$daysuntilnextgeneration=90;  // should be equal the expires date in the template; TODO

require_once "dump_template_survey.php";

//modify $filestring to fit teacher

//replace $teachername with  for each teacher import it than

//from database get list of teachers for each to create a survey
$querystring="Select * from teacher WHERE sidvalidthrough < NOW()";

//this function is originally in importsurvey.php - but because this file is called a couple of times we cannot declare it there or it would be redeclared ->error

require_once "evaluation.classes.php";

require "importsurvey.php";

while ($row = mysql_fetch_assoc($result)) {
			$surveyname=$row['idteacher'] . " " . $row['lastname'] . " " . $row['firstname'];
            $teachername=$row['lastname'] . " " . $row['firstname'];
			$thisteachersurvey=str_replace('%teachername%',$teachername, $filestring);
			$thisteachersurvey=str_replace('%surveyname%',$teachername, $filestring);
			//echo $thisteachersurvey;
			echo "<b>Teacher $teachername sql created...</b>";
			$idteacher=$row['idteacher'];  //this variable is used by the import survey to set the foreign key idteacher
			ob_start(); //dont show output
				$thissid=importsurvey($the_full_file_path); //wrapped in a function to reset variables on every call
			echo "<b>survey created. OK</b>";
			echo " sid = $thissid<br>";
			mysql_query("UPDATE teacher SET currentsid=$thissid ,pretoken_generated=0 where idteacher=$idteacher"); //update teacher line
			//activate survey
//fill pretoken table - all the teachers that just got a new survey have  pretoken_generated =0
INSERT INTO pretoken(idstudent,idteacher,token,validuntil,sid,active)
SELECT s.idstudent, 
concat(s.idstudent, hex(rand() * 100000000)) as token,
bin(1) as active
FROM class_has_teacher c, class cl, student s, teacher t 
WHERE c.idclass=cl.idclass  AND cl.idclass=s.idclass  AND 
c.idteacher=t.idteacher AND t.pretoken_generated=0";
echo mysql_affected_rows() . " new Pretokens have been created <br>";
mysql_query("UPDATE teacher SET pretoken_generated=1"); 
echo mysql_affected_rows() . " Teachers have been set to pretoken generated=true<br>";

echo "The surveys for the teachers have been set. the surveys will be regernerated in $daysuntilnextgeneration days.";
require "footer.php";
Return current item: Teacher Evaluation based on phpsurveyor