change scripts for fairyear 2007

select a random school from a list of all available schools assuming that only 1 in every 4 schools actually participate
This commit is contained in:
james 2006-10-15 20:14:54 +00:00
parent 130f0f5786
commit 2dbc8fc067
2 changed files with 16 additions and 5 deletions

View File

@ -24,7 +24,7 @@
<? <?
include "../common.inc.php"; include "../common.inc.php";
$projq=mysql_query("SELECT id FROM registrations WHERE status='complete' OR status='paymentpending' AND year='2006'"); $projq=mysql_query("SELECT id FROM registrations WHERE status='complete' OR status='paymentpending' AND year='2007'");
while($projr=mysql_fetch_object($projq)) while($projr=mysql_fetch_object($projq))
{ {
$reg_id=$projr->id; $reg_id=$projr->id;

View File

@ -47,6 +47,16 @@ $nouns=array("age","animal","arm","baby","ball","bat","bear","boat","camp","car"
$starters=array("effects of","study of","analysis of"); $starters=array("effects of","study of","analysis of");
$joiners=array("on","combined with","broken apart by","burned with","attacked by","left alone with"); $joiners=array("on","combined with","broken apart by","burned with","attacked by","left alone with");
$numschools=mysql_query("SELECT id FROM schools WHERE year='2007'");
while($s=mysql_fetch_object($numschools))
{
//1 in 4 chance of actually using this school
$o=rand(1,4);
if($o==1)
$schools[]=$s->id;
}
$ns=count($schools);
for($x=0;$x<$numprojects;$x++) for($x=0;$x<$numprojects;$x++)
{ {
$id=0; $id=0;
@ -55,7 +65,7 @@ for($x=0;$x<$numprojects;$x++)
$pd=rand(1,$prob_unpaid); $pd=rand(1,$prob_unpaid);
if($pd==1) $status='paymentpending'; else $status='complete'; if($pd==1) $status='paymentpending'; else $status='complete';
$q=mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES ('$regnum','$email',NOW(),'$status',2006)"); $q=mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES ('$regnum','$email',NOW(),'$status',2007)");
if($id=mysql_insert_id()) if($id=mysql_insert_id())
{ {
@ -66,14 +76,15 @@ for($x=0;$x<$numprojects;$x++)
if($gradenum<6) { $grade=rand(7,8); $cat=1;} if($gradenum<6) { $grade=rand(7,8); $cat=1;}
else if($gradenum<8) { $grade=rand(9,10); $cat=2; } else if($gradenum<8) { $grade=rand(9,10); $cat=2; }
else if($gradenum<10) { $grade=rand(11,12); $cat=3; } else if($gradenum<10) { $grade=rand(11,12); $cat=3; }
$schools_id=rand(1,2);
$schools_id=$schools[rand(0,$ns)];
for($a=1;$a<=$num;$a++) for($a=1;$a<=$num;$a++)
{ {
$sexnum=rand(1,3); $sexnum=rand(1,3);
if($sexnum<3) $sex="male"; else $sex="female"; if($sexnum<3) $sex="male"; else $sex="female";
mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,grade,year,schools_id) VALUES ('$id','".getrand($firstnames)."','".getrand($lastnames)."','$sex','$grade',2006,'$schools_id')"); mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,grade,year,schools_id) VALUES ('$id','".getrand($firstnames)."','".getrand($lastnames)."','$sex','$grade','2007','$schools_id')");
} }
@ -90,7 +101,7 @@ for($x=0;$x<$numprojects;$x++)
if($langnum<4) $lang="fr"; else $lang="en"; if($langnum<4) $lang="fr"; else $lang="en";
mysql_query("INSERT INTO projects (registrations_id,projectcategories_id,projectdivisions_id,title,year,req_electricity,req_table,language) VALUES ('$id','$cat','$div','$title',2006,'$req_e','$req_t','$lang')"); mysql_query("INSERT INTO projects (registrations_id,projectcategories_id,projectdivisions_id,title,year,req_electricity,req_table,language) VALUES ('$id','$cat','$div','$title',2007,'$req_e','$req_t','$lang')");
} }
} }