Location: PHPKode > projects > Quadrille multimedia assessment system > quadrille/q_add_dynamic_db.php
<?
/*-------------------------------------------------------------------
   q_add_dynamic_db.php  Ver. $Revision: 1.2 $ 		$Date: 2003/05/21 02:02:15 $ 
*
   Copyright (C) 2000 Hong Kong Baptist University
*
   This file is part of the Quadrille system.
*  This program is free software; it is distributed under the terms of
   the GNU General Public License, either version 2, or (at your option)
*  any later version.

*  This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
*
---------------------------------------------------------------------
*/
?>
<?
require "global_inc.php";
require "config_inc.php";
require "template.php";

 $set=0; $c=0;
 for($j=0; $j<=$no_unit; $j++) {
    for($k=0; $k<4; $k++) {
	switch($k) {
	  case 0: $level="l"; $l="0"; break;
	  case 1: $level="m"; $l="1"; break;
	  case 2: $level="h"; $l="2"; break;
	  case 3: $level="a"; $l="0,1,2"; break;
	}
	if($j == $no_unit) {
	    	eval("if(\$level_{$level}a != \"\") {\$num[\$c]=\$level_{$level}a; \$set = 1;} else \$set = 0;"); 
	    	eval("\$unit_uid$j=\"*\";");
	}
	else {
	    	eval("if(\$level_{$level}$j != \"\") {\$num[\$c]=\$level_{$level}$j; \$set = 1;} else \$set = 0;"); 
	}
	if($set) {
	    	eval("\$string[\$c] = \"l[\$l]u[\$unit_uid$j]\";");
	    	$c++;
	    	
	}
    }
 }  
 
 $sql = "SELECT SUM(NO_OF_QUESTION) FROM PAPER_QUESTION WHERE PAPER_UID = $cookie[paper_uid]";
 $result1 = mysql_query($sql); 
 if(mysql_errno() != 0)
    header("location:qerror.php?qerr_type=1&qerr_mess=DB_NROWS");

 $number = mysql_num_rows($result1);
 $row1 = mysql_fetch_array($result1);
 $number = $row1[0];
 $question_no = $number + 1; 
 
 $query = "INSERT INTO PAPER_QUESTION (PAPER_UID, NO_OF_QUESTION, QUESTION_NO, NO_OF_TRIES,";
 $query.= "MARK_GAIN, MARK_DEDUCE, SEARCH_COND) VALUES "; 
 for($i=0; $i<$c; $i++) {
 	$query.= "('$cookie[paper_uid]','$num[$i]','$question_no','1','1','0','$string[$i]')";
 	if($i != $c-1) $query.= ",";
 	$question_no += $num[$i];
 }
//print "query=$query";
 $result = mysql_query ($query);
 if(mysql_errno() != 0)
	 header("location:qerror.php?qerr_type=1&qerr_mess=DB_NROWS");

 if($result) {       
       	header("Location: paper_enter.php");
 }
 else {
	header("Location: paper_enter.php?testing_err=1");
 }		

?>





Return current item: Quadrille multimedia assessment system