From 2dbc8fc0676c61402cc38c92046d2a41268a3fb5 Mon Sep 17 00:00:00 2001 From: james Date: Sun, 15 Oct 2006 20:14:54 +0000 Subject: [PATCH] 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 --- scripts/assignprojectnumbers.php | 2 +- scripts/populate_fake.php | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/assignprojectnumbers.php b/scripts/assignprojectnumbers.php index cdb76d50..f8af0325 100644 --- a/scripts/assignprojectnumbers.php +++ b/scripts/assignprojectnumbers.php @@ -24,7 +24,7 @@ id; diff --git a/scripts/populate_fake.php b/scripts/populate_fake.php index 1bbc6628..43a3456b 100644 --- a/scripts/populate_fake.php +++ b/scripts/populate_fake.php @@ -47,6 +47,16 @@ $nouns=array("age","animal","arm","baby","ball","bat","bear","boat","camp","car" $starters=array("effects of","study of","analysis of"); $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++) { $id=0; @@ -55,7 +65,7 @@ for($x=0;$x<$numprojects;$x++) $pd=rand(1,$prob_unpaid); 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()) { @@ -66,14 +76,15 @@ for($x=0;$x<$numprojects;$x++) if($gradenum<6) { $grade=rand(7,8); $cat=1;} else if($gradenum<8) { $grade=rand(9,10); $cat=2; } 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++) { $sexnum=rand(1,3); 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"; - 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')"); } }