diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 0c56bea5..7b5813c6 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -233 +234 diff --git a/db/db.update.234.sql b/db/db.update.234.sql new file mode 100644 index 00000000..338e7506 --- /dev/null +++ b/db/db.update.234.sql @@ -0,0 +1,2 @@ +ALTER TABLE `registrations` ADD `numstudents` TINYINT( 4 ) NULL DEFAULT NULL AFTER `nummentors`; +ALTER TABLE `user_roles` ADD UNIQUE ( `users_id` , `roles_id`); diff --git a/participant.inc.php b/participant.inc.php index 523afaec..803f68d6 100644 --- a/participant.inc.php +++ b/participant.inc.php @@ -84,7 +84,17 @@ function studentsStatus($reg_id="") { if($reg_id) $rid=$reg_id; else $rid=$_SESSION['registration_id']; - $q=mysql_query("SELECT * FROM users WHERE registrations_id='$rid' AND conferences_id='".$conference['id']."'"); + //get the num students from the registrations table + $q=mysql_query("SELECT numstudents FROM registrations WHERE id='$rid'"); + $r=mysql_fetch_object($q); + $numstudents=$r->numstudents; + + //select all the users currently with this registration id + $q=mysql_query("SELECT id FROM users WHERE registrations_id='$rid' AND conferences_id='".$conference['id']."'"); + + //if we don't have what we said we were gonna have, return incomplete + if($numstudents!=mysql_num_rows($q)) + return "incomplete"; //if we dont have the minimum, return incomplete if(mysql_num_rows($q)<$config['minstudentsperproject']) diff --git a/register_participants.inc.php b/register_participants.inc.php index 1f4d6ebf..44c056c8 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -375,6 +375,16 @@ function saveProjectData($data,$registrations_id=null){ } } + //and update numstudents in registrations, yea, i know its not in the projects table + if(isset($data['numstudents'])) { + if($data['numstudents']==null) { + mysql_query("UPDATE registrations SET numstudents=NULL WHERE id='{$rid}'"); + } + else { + mysql_query("UPDATE registrations SET numstudents='".intval($data['numstudents'])."' WHERE id='{$rid}'"); + } + } + if($message == ''){ $message = 'success'; } @@ -473,7 +483,7 @@ function getRegistrationsId($user){ } function getRegistration($id) { global $conference; - $q=mysql_query("SELECT id,num,start,status,end,nummentors FROM registrations WHERE id='$id' AND conferences_id='{$conference['id']}'"); + $q=mysql_query("SELECT id,num,start,status,end,nummentors,numstudents FROM registrations WHERE id='$id' AND conferences_id='{$conference['id']}'"); $reg=mysql_fetch_assoc($q); if(!$reg) return null; @@ -493,7 +503,9 @@ function getRegistration($id) { //we'll also load it on getProejct, and save it on saveProjectData //even though its in the registrations table not the projects table $p['nummentors']=$reg['nummentors']; + $p['numstudents']=$reg['numstudents']; unset($reg['nummentors']); + unset($reg['numstudents']); $reg['project']=$p;