<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;

?>




<? 



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

$s1=trim($_POST["as"]);
$s2=trim($_POST["bs"]);
$s3=trim($_POST["cs"]);
$s4=trim($_POST["ds"]);

$get_answer=$_POST["sele_answer"];
   
$an="";   
foreach ($get_answer as $k=>$v)
{
	$an=$an.$v;
}

$answer=$an;


$fen=$_POST["score"];






?>
 
<? 

if ($questiontype=='' || $question=='' || $fen=='' || $s1=='' || $s2=='' || $s3=='' || $s4=='' || $answer=='')
{

    $url="admin_add_d.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_d.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; 

}

 ?>  
 
 
<? 



if (strlen($s1)>200)
{

    $url="admin_add_d.php";
	$msg="[软件提示]:选择项不要超过200字符，当前有 [".strlen($s1)."] 个字符.";
    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; 
	
} ?> 

<? 


if (strlen($s2)>200)
{

   $url="admin_add_d.php";
	$msg="[软件提示]:选择项不要超过200字符，当前有 [".strlen($s2)."] 个字符.";
    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; 
	
 } ?> 
 
 <? 
 
 
if (strlen($s3)>200)
{

    $url="admin_add_d.php";
	$msg="[软件提示]:选择项不要超过200字符，当前有 [".strlen($s3)."] 个字符.";
    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; 
	
 } ?> 
 


<? 
 
if (strlen($s4)>200)
{

    $url="admin_add_d.php";
	$msg="[软件提示]:选择项不要超过200字符，当前有 [".strlen($s4)."] 个字符.";
    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; 
	
} 

?> 
 
 
 
 <? 

  /*
  if ($questiontype=="2")
  {

    
	if (strlen($answer)==4)
    {
      $getnewchar1=substr($answer,0,1);
      $getnewchar2=substr($answer,3,1);
      $answer=$getnewchar1.$getnewchar2;
    } 

    if (strlen($answer)==7)
    {
      $getnewchar1=substr($answer,0,1);
      $getnewchar2=substr($answer,3,1);
      $getnewchar3=substr($answer,6,1);

      $answer=$getnewchar1.$getnewchar2.$getnewchar3;

    } 
    if (strlen($answer)==10)
    {

      $getnewchar1=substr($answer,0,1);
      $getnewchar2=substr($answer,3,1);
      $getnewchar3=substr($answer,6,1);
      $getnewchar4=substr($answer,9,1);

      $answer=$getnewchar1.$getnewchar2.$getnewchar3.$getnewchar4;

    } 
  } 
  
  */

?>
  
	 
<? 

  
   $question=str_replace(chr(13),"<BR>",$question);
  
   $question=iconv("utf-8","gb2312",$question);
   $question=$objcode->encodetxt_data(trim($question));
   //$newq=$objcode->uncodetxt_data(trim($question));
  
  
   $shiti_seletion=1;
  
  
   $s1=iconv("utf-8","gb2312",$s1);
   $as=$objcode->encodetxt_data(trim($s1));
   //$as=$objcode->uncodetxt_data($as);

   $s2=iconv("utf-8","gb2312",$s2);
   $bs=$objcode->encodetxt_data(trim($s2));
   //$bs=$objcode->uncodetxt_data($bs);


   $s3=iconv("utf-8","gb2312",$s3);
   $cs=$objcode->encodetxt_data(trim($s3));
   //$cs=$objcode->uncodetxt_data($cs);


   $s4=iconv("utf-8","gb2312",$s4);
   $ds=$objcode->encodetxt_data(trim($s4));
   //$ds=$objcode->uncodetxt_data($ds);


  
  
?> 


 



<?php 
  


  $get_corrent_answer=$objcode->encodetxt_data(trim($answer));
  
  //echo $get_corrent_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." (题目类型,题目,题目选择,选择项1,选择项2,选择项3,选择项4,正确答案,本题分数,images,试卷分类) ";
  $sql=$sql." values( ";
  $sql=$sql.intval($questiontype).",";
  
  $sql=$sql."'".$question."',";
  
  $sql=$sql.$shiti_seletion.",";
  
  $sql=$sql."'".$as."',";
  $sql=$sql."'".$bs."',";
  $sql=$sql."'".$cs."',";
  $sql=$sql."'".$ds."',";
  $sql=$sql."'".$get_corrent_answer."',";
  $sql=$sql.$get_shiti_fen.",";
  $sql=$sql."'".$get_images."',";
  $sql=$sql.$get_juan_fenlei;
  
  
  $sql=$sql." )";
  
  //echo $question."<br>";
  
  
  $rs=$conn->execute($sql);
 
  $rs->close;

 ?>
 
 
 <? 

    $conn->close;

    $objcode=null;


  ?>
 
 
 
 <?php
 
 
    $url="admin_add_d.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>";
    exit; 



?>	






</body>
</html>
