<html>
<head>
<title>网络考试系统企业版</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>

<?php
   
    $objcode=new com("datacode.dbcode");
	
?>

<?php include("../conn.php"); ?>

<? 

$read_juan_id=$_GET["juan_id"];
$sql="select  *  from  database_name  where   id=";
$sql=$sql." (select  database_id  from  fenlei   where   id=".$read_juan_id.")";
$rs=$conn->execute($sql);
if (!$rs->EOF)
{
  $read_database_name=$rs->fields["database_name"];
} 

$rs->close;

$sql="select  *  from  fenlei  where   id=".$read_juan_id;
$rs=$conn->execute($sql);
if (!$rs->EOF)
{

  $read_juan_name=$rs->fields["exam_juan_name"];
} 

$rs->close;

?>

<? 


$question="";
$questiontype=$_POST["type"];
$question=$_POST["shiti"];
$get_pic=trim($_POST["moviepic"]);
$answer=$_POST["answer"];
$fen=$_POST["score"];

?>
     
   
<? 

if ($questiontype=='' || $question=='' || $fen=='' || $answer=='')
{

    $url="admin_add_lunshu.php";
    echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
    echo "<body>";
    echo "<script language=javascript>";
    echo "alert('[软件提示]：所填写数据不能为空.');";
    echo "window.location.href='$url';";
    echo "</script>";
    echo "</body>";
    exit; 
	
 } 
 
 ?>
  
<? 

$get_cur_len=0;
$get_cur_len=strlen($question);
if ($get_cur_len>5000)
{

    $url="admin_add_lunshu.php";
	$msg="[软件提示]:题干最多字符数5000字符，当前有 [".$get_cur_len_str."] 个字符.";
    echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
    echo "<body>";
    echo "<script language=javascript>";
    echo "alert('$msg');";
    echo "window.location.href='$url';";
    echo "</script>";
    echo "</body>";
    exit; 

}

?>  
  

<? 



  
  $questiontype=5;
  
  $question=trim($question);
  $answer=trim($answer);
  
  $question=str_replace(chr(13),"<BR>",$question);
  $question=iconv("utf-8","gb2312",$question);
  $question=$objcode->encodetxt_data(trim($question));
  $shiti_seletion=1;
  
  $answer=iconv("utf-8","gb2312",$answer);
  $get_corrent_answer=$objcode->encodetxt_data(trim($answer));
 
  
  $get_shiti_fen=intval($fen);
  $get_images=$get_pic;
  $get_juan_fenlei=intval($read_juan_id);
    
  $sql="insert into ".$read_database_name;
  $sql=$sql." (题目类型,题目,题目选择,正确答案,本题分数,images,试卷分类) ";
  $sql=$sql." values( ";
  $sql=$sql.intval($questiontype).",";
  $sql=$sql."'".$question."',";
  $sql=$sql.$shiti_seletion.",";
  $sql=$sql."'".$get_corrent_answer."',";
  $sql=$sql.$get_shiti_fen.",";
  $sql=$sql."'".$get_images."',";
  $sql=$sql.$get_juan_fenlei;
  $sql=$sql." )";
  
  
  $rs=$conn->execute($sql);
 
  $rs->close;
   

?>


<? 

    $conn->close;

    $objcode=null;

?>



  <?php  
  
   
	$url="admin_add_lunshu.php?juan_id=".$read_juan_id;
    
    echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
    echo "<body>";
    echo "<script language=javascript>";
    echo "window.location.href='$url';";
    echo "</script>";
    echo "</body>";
    
   ?>


			


  </body>
  </html>
   
