<?php
/* @var $this ExammanageController */
/* @var $model Exammanage */
/* @var $form CActiveForm */
?>
<script type="text/javascript">
	$(function(){
	//单选
		$('#tt').tree({
			url:'<?php echo $this->createUrl('category/mytree')?>',
			animate:true,
			lines:true,
			cascadeCheck:false,
			onClick: function(node){
				$(this).tree('check',node.target);
				if(node.checked)
				{$(this).tree('uncheck',node.target);}
				
			},
			onCheck:function(){
				var nodes = $('#tt').tree('getChecked');
				var s = '';  
					for(var i=0; i<nodes.length; i++){  
						if (s != '') s += ',';  
						s += nodes[i].id;  
					}  
					//alert(s);
				if(s.length!=0 || 1){
					
					$.ajax({
						  type: 'POST',
						  url: '<?php echo $this->createUrl('randqq')?>',
						  data: {action:'single',qq:s},
						  success: function(data){//alert(data);
							   //if(data=="yes"){
								//$.messager.alert('系统提示',data,'info');
								$('#single').text(data);
								$("#single_max").attr("data-options","min:1,max:"+ data +",required:true");
								$("#Exammanage_singlechoicelist").attr("value",s);
								//$('#btnSave').linkbutton('disable');
							   //}else $.messager.alert('系统提示','更新失败!','info');
						   
						   },
						  dataType: "text"
					});	
					
				}
				
			}
		});
	//多选
		$('#tt2').tree({
			url:'<?php echo $this->createUrl('category/mytree')?>',
			animate:true,
			lines:true,
			cascadeCheck:false,
			onClick: function(node){
				$(this).tree('check',node.target);
				if(node.checked)
				{$(this).tree('uncheck',node.target);}
				
			},
			onCheck:function(){
				var nodes = $('#tt2').tree('getChecked');
				var s = '';  
					for(var i=0; i<nodes.length; i++){  
						if (s != '') s += ',';  
						s += nodes[i].id;  
					}  
					//alert(s);
				if(s.length!=0 || 1){
					$.ajax({
						  type: 'POST',
						  url: '<?php echo $this->createUrl('randqq')?>',
						  data: {action:'multi',qq:s},
						  success: function(data){//alert(data);
							   //if(data=="yes"){
								//$.messager.alert('系统提示',data,'info');
								$('#multi').text(data);	
								$("#Exammanage_multichoicelist").attr("value",s);
								//$('#btnSave').linkbutton('disable');
							   //}else $.messager.alert('系统提示','更新失败!','info');
						   
						   },
						  dataType: "text"
					});	
				}
				
			}
		});	
	//判断
		$('#tt3').tree({
			url:'<?php echo $this->createUrl('category/mytree')?>',
			animate:true,
			lines:true,
			cascadeCheck:false,
			onClick: function(node){
				$(this).tree('check',node.target);
				if(node.checked)
				{$(this).tree('uncheck',node.target);}
				
			},
			onCheck:function(){
				var nodes = $('#tt3').tree('getChecked');
				var s = '';  
					for(var i=0; i<nodes.length; i++){  
						if (s != '') s += ',';  
						s += nodes[i].id;  
					}  
					//alert(s);
				if(s.length!=0 || 1){
					$.ajax({
						  type: 'POST',
						  url: '<?php echo $this->createUrl('randqq')?>',
						  data: {action:'judge',qq:s},
						  success: function(data){//alert(data);
							   //if(data=="yes"){
								//$.messager.alert('系统提示',data,'info');
								$('#judge').text(data);	
								$("#Exammanage_judgelist").attr("value",s);
								//$('#btnSave').linkbutton('disable');
							   //}else $.messager.alert('系统提示','更新失败!','info');
						   
						   },
						  dataType: "text"
					});	
				}
				
			}
		});
	//操作
		$('#tt4').tree({
			url:'<?php echo $this->createUrl('category/mytree')?>',
			animate:true,
			lines:true,
			cascadeCheck:false,
			onClick: function(node){
				$(this).tree('check',node.target);
				if(node.checked)
				{$(this).tree('uncheck',node.target);}
				
			},
			onCheck:function(){
				var nodes = $('#tt4').tree('getChecked');
				var s = '';  
					for(var i=0; i<nodes.length; i++){  
						if (s != '') s += ',';  
						s += nodes[i].id;  
					}  
					//alert(s);
				if(s.length!=0 || 1){
					$.ajax({
						  type: 'POST',
						  url: '<?php echo $this->createUrl('randqq')?>',
						  data: {action:'operate',qq:s},
						  success: function(data){//alert(data);
							   //if(data=="yes"){
								//$.messager.alert('系统提示',data,'info');
								$('#operate').text(data);
								$("#Exammanage_operatelist").attr("value",s);
								//$('#btnSave').linkbutton('disable');
							   //}else $.messager.alert('系统提示','更新失败!','info');
						   
						   },
						  dataType: "text"
					});	
				}
				
			}
		});		

	});
	function single_cascade(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'cascadeCheck':true});
		($("#tt").tree('options').cascadeCheck)?$("#tt").tree({'cascadeCheck':false}):$("#tt").tree({'cascadeCheck':true});
		($("#single_cascade_").val()=="启用级联选择")?$("#single_cascade_").val("禁用级联选择"):$("#single_cascade_").val("启用级联选择");
		var queryParams = $('#single_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#single_table').datagrid('options').queryParams=queryParams;        
		$("#single_table").datagrid('reload'); 	
	}
	function single_leaf(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'onlyLeafCheck':true});
		($("#tt").tree('options').onlyLeafCheck)?$("#tt").tree({'onlyLeafCheck':false}):$("#tt").tree({'onlyLeafCheck':true});
		($("#single_leaf_").val()=="启用仅选择叶子")?$("#single_leaf_").val("禁用仅选择叶子"):$("#single_leaf_").val("启用仅选择叶子");		
		var queryParams = $('#single_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#single_table').datagrid('options').queryParams=queryParams;        
		$("#single_table").datagrid('reload'); 	
	}
//多选题选择表-----》结束
	function multi_cascade(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'cascadeCheck':true});
		($("#tt2").tree('options').cascadeCheck)?$("#tt2").tree({'cascadeCheck':false}):$("#tt2").tree({'cascadeCheck':true});
		($("#multi_cascade_").val()=="启用级联选择")?$("#multi_cascade_").val("禁用级联选择"):$("#multi_cascade_").val("启用级联选择");
		var queryParams = $('#multi_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#multi_table').datagrid('options').queryParams=queryParams;        
		$("#multi_table").datagrid('reload'); 	
	}
	function multi_leaf(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'onlyLeafCheck':true});
		($("#tt2").tree('options').onlyLeafCheck)?$("#tt2").tree({'onlyLeafCheck':false}):$("#tt2").tree({'onlyLeafCheck':true});
		($("#multi_leaf_").val()=="启用仅选择叶子")?$("#multi_leaf_").val("禁用仅选择叶子"):$("#multi_leaf_").val("启用仅选择叶子");		
		var queryParams = $('#multi_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#multi_table').datagrid('options').queryParams=queryParams;        
		$("#multi_table").datagrid('reload'); 	
	}
//判断题选择表-----》结束
	function judge_cascade(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'cascadeCheck':true});
		($("#tt3").tree('options').cascadeCheck)?$("#tt3").tree({'cascadeCheck':false}):$("#tt3").tree({'cascadeCheck':true});
		($("#judge_cascade_").val()=="启用级联选择")?$("#judge_cascade_").val("禁用级联选择"):$("#judge_cascade_").val("启用级联选择");
		var queryParams = $('#judge_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#judge_table').datagrid('options').queryParams=queryParams;        
		$("#judge_table").datagrid('reload'); 	
	}
	function judge_leaf(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'onlyLeafCheck':true});
		($("#tt3").tree('options').onlyLeafCheck)?$("#tt3").tree({'onlyLeafCheck':false}):$("#tt3").tree({'onlyLeafCheck':true});
		($("#judge_leaf_").val()=="启用仅选择叶子")?$("#judge_leaf_").val("禁用仅选择叶子"):$("#judge_leaf_").val("启用仅选择叶子");		
		var queryParams = $('#judge_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#judge_table').datagrid('options').queryParams=queryParams;        
		$("#judge_table").datagrid('reload'); 	
	}
//操作题选择表-----》结束
	function operate_cascade(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'cascadeCheck':true});
		($("#tt4").tree('options').cascadeCheck)?$("#tt4").tree({'cascadeCheck':false}):$("#tt4").tree({'cascadeCheck':true});
		($("#operate_cascade_").val()=="启用级联选择")?$("#operate_cascade_").val("禁用级联选择"):$("#operate_cascade_").val("启用级联选择");
		var queryParams = $('#operate_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#operate_table').datagrid('options').queryParams=queryParams;        
		$("#operate_table").datagrid('reload'); 	
	}
	function operate_leaf(){
		//$("#tt").tree({'cascadeCheck':true,'onlyLeafCheck':true});这是正确的属性设置写法
		//$("#tt").tree({'onlyLeafCheck':true});
		($("#tt4").tree('options').onlyLeafCheck)?$("#tt4").tree({'onlyLeafCheck':false}):$("#tt4").tree({'onlyLeafCheck':true});
		($("#operate_leaf_").val()=="启用仅选择叶子")?$("#operate_leaf_").val("禁用仅选择叶子"):$("#operate_leaf_").val("启用仅选择叶子");		
		var queryParams = $('#operate_table').datagrid('options').queryParams; 
		queryParams.charpter_id = '';  
		$('#operate_table').datagrid('options').queryParams=queryParams;        
		$("#operate_table").datagrid('reload'); 	
	}	
</script>
	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />
	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.min.js"></script>
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.pager.js"></script>
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/check.js"></script>
	<script type="text/javascript">
	$(function() {

	});
	</script>
    <style type="text/css">
/*
	th,tr>td:first-child{text-align: center; vertical-align: middle;}
	*/
	.red{color:red;}
	</style>







<div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'exammanage-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>256)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>
	<!--单选-->
	<div class="row">
			<?php echo $form->labelEx($model,'singlechoicelist'); ?>
	</div>
	<div><input onclick="single_cascade()" id="single_cascade_" type="button" value="启用级联选择" /><input id="single_leaf_" onclick="single_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;padding:5px;">
		<div>您选的章节中共有<span id="single" class="red">0</span>道单选题</div>
		
		<?php echo $form->error($model,'singlechoicelist'); ?>
		您选择的章节范围ID是：<?php echo $form->textField($model,'singlechoicelist',array('readonly'=>true)); ?>

		
		</div>
	</div>
	
	<!--多选-->
	<div class="row">
		<?php echo $form->labelEx($model,'multichoicelist'); ?>
	</div>
	<div><input onclick="multi_cascade()" id="multi_cascade_" type="button" value="启用级联选择" /><input id="multi_leaf_" onclick="multi_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt2" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;padding:5px;">
		<div>共有<span id="multi" class="red">0</span>道多选题</div>
		您选择的章节范围ID是：<?php echo $form->textField($model,'multichoicelist',array('readonly'=>true)); ?>
		<?php echo $form->error($model,'multichoicelist'); ?>
		</div>
	</div>
	<!--判断-->
	<div class="row">
		<?php echo $form->labelEx($model,'judgelist'); ?>
	</div>
	<div><input onclick="judge_cascade()" id="judge_cascade_" type="button" value="启用级联选择" /><input id="judge_leaf_" onclick="judge_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt3" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;padding:5px;">
		<div>共有<span id="judge" class="red">0</span>道判断题</div>
		您选择的章节范围ID是：<?php echo $form->textField($model,'judgelist',array('readonly'=>true)); ?>
		<?php echo $form->error($model,'judgelist'); ?>
		</div>
	</div>
	<!--操作-->
	<div class="row">
		<?php echo $form->labelEx($model,'operatelist'); ?>
	</div>
	<div><input onclick="operate_cascade()" id="operate_cascade_" type="button" value="启用级联选择" /><input id="operate_leaf_" onclick="operate_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt4" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;padding:5px;">
		<div>共有<span id="operate" class="red">0</span>道操作题</div>

		您选择的章节范围ID是：<?php echo $form->textField($model,'operatelist',array('readonly'=>true)); ?>
		<?php echo $form->error($model,'operatelist'); ?>
		</div>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'testScore'); ?>
		<?php echo $form->textField($model,'testScore',array('size'=>32,'maxlength'=>32)); ?><label>注：各题型分值,包括单选、多选、判断、操作。格式：2,3,1,10</label>
		<?php echo $form->error($model,'testScore'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'testCount'); ?>
		<?php echo $form->textField($model,'testCount',array('size'=>32,'maxlength'=>32)); ?><label>注：是否限制各题型数量,包括单选、多选、判断、操作。格式同上，1表示不限制，限制数量格式为：20,10,5,3</label>
		<?php echo $form->error($model,'testCount'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'testRand'); ?>
		<?php echo $form->textField($model,'testRand',array('size'=>32,'maxlength'=>32)); ?><label>注：是否限制各题型顺序随机,包括单选、多选、判断、操作。格式同上，0表示不随机，1表示随机</label>
		<?php echo $form->error($model,'testRand'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'summary'); ?>
		<?php echo $form->textArea($model,'summary',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'summary'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examState'); ?>
		<?php echo $form->checkBox($model,'examState'); ?>
		<?php echo $form->error($model,'examState'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examMode'); ?>
		<?php echo $form->checkBox($model,'examMode'); ?>
		<?php echo $form->error($model,'examMode'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examTime'); ?>
		<?php echo $form->textField($model,'examTime'); ?>
		<?php echo $form->error($model,'examTime'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'beforeSubmit'); ?>
		<?php echo $form->textField($model,'beforeSubmit'); ?>
		<?php echo $form->error($model,'beforeSubmit'); ?>
	</div>


	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    CKEDITOR.replace("Exammanage[summary]",
      {
        skin: "v2", width:"835", height:"200",color:"#AADC6E",toolbar:"Full",language:'zh-cn',
		filebrowserBrowseUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/ckfinder.html',
		filebrowserImageBrowseUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/ckfinder.html?Type=Images',
		filebrowserFlashBrowseUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/ckfinder.html?Type=Flash',
		filebrowserUploadUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
		filebrowserImageUploadUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
		filebrowserFlashUploadUrl : '<?php echo Yii::app()->request->baseUrl?>/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
      });	  
</script>