<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ListView id="__c9QHLzwIdAmWu56Okdp">
  <name>app获取随机试题</name>
  <parentId>__euq1TkJApfGq6XF6FL2</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <pagination>false</pagination>
  <pageLines>10</pageLines>
  <showTotalRow>false</showTotalRow>
  <refresh>false</refresh>
  <refreshAll>false</refreshAll>
  <newPage>false</newPage>
  <readonly>false</readonly>
  <relatedMap><![CDATA[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ]]></relatedMap>
  <displayType>relatedForm</displayType>
  <defaultShowMode>month</defaultShowMode>
  <collapsibleShowMode>normal</collapsibleShowMode>
  <showWaterMark>false</showWaterMark>
  <showActivityColumnType>0</showActivityColumnType>
  <searchFormId>__zqRAGWQlDRKzQ3AApyB</searchFormId>
  <autoCompose>false</autoCompose>
  <relatedForm>__arWdO3ygPkbj81UMFJa</relatedForm>
  <permissionType>public</permissionType>
  <filterScript><![CDATA[]]></filterScript>
  <sqlFilterScript><![CDATA[(function(){
var quizTopic = getItemValueAsString("quizTopic");
var quizType = getItemValueAsString("quizType");

var textId=decodeURI(getParameter("textId"));  
var examInfoDoc=findDocument(textId);
var singleNum= parseDouble(examInfoDoc.findItem("singleNum").getValue());
var multipleNum= parseDouble(examInfoDoc.findItem("multipleNum").getValue());
var judgeNum= parseDouble(examInfoDoc.findItem("judgeNum").getValue());
var singleNum= parseInt(singleNum);
var multipleNum= parseInt(multipleNum);
var judgeNum= parseInt(judgeNum);

var singleScore= parseDouble(examInfoDoc.findItem("singleScore").getValue());
var multipleScore= parseDouble(examInfoDoc.findItem("multipleScore").getValue());
var judgeScore= parseDouble(examInfoDoc.findItem("judgeScore").getValue());

var testTopicBank=examInfoDoc.findItem("testTopicBank").getValue();
var wheretopicBankId=" ";
var where =" where 1=1 ";
if(isNotNull(testTopicBank)){
  wheretopicBankId +=" and t3.ID = '"+testTopicBank+"' ";
}
if(isNotNull(quizTopic)){
  where +=" and (y.ITEM_QUIZTOPIC like concat('%','"+quizTopic+"','%'))"; 
}
if(isNotNull(quizType)){
  where +=" and (y.ITEM_QUIZTYPE like concat('%','"+quizType+"','%'))"; 
}
 var sql = 
"SELECT"+
"	y.domainid,"+
"	y.ID,"+
"	y.ITEM_ID,"+
"	y.ITEM_QUIZTOPIC,"+
"	CASE y.ITEM_QUIZTYPE WHEN '0' THEN '单选题' WHEN '1' THEN '多选题' ELSE '判断题' END ITEM_QUIZTYPE,"+
"	case y.ITEM_ANSWER when '对' then 'A' when '错' then 'B' else y.ITEM_ANSWER end ITEM_ANSWER,"+
"	y.ITEM_QUIZANALYSIS,"+
"	y.ITEM_QUIZCODE,"+
"	y.ITEM_MYSCORE,"+
"	y.ITEM_OPTION "+
" FROM "+
"	( "+
" ( "+
"	SELECT "+
"		t.* "+
"	FROM"+
"		("+
"		SELECT"+
"			'"+getDomainid()+"' AS domainid,"+
"			t4.ID,"+
"			t4.ID AS ITEM_ID,"+
"			t4.ITEM_QUIZTOPIC,"+
"			t4.ITEM_QUIZTYPE,"+
"			t4.ITEM_ANSWER,"+
     		"'"+singleScore+"' AS ITEM_MYSCORE,"+
"			t4.ITEM_QUIZCODE,"+
"			t4.ITEM_QUIZANALYSIS,"+
"			GROUP_CONCAT( t5.ITEM_OPTIONNAME, '.', t5.ITEM_OPTIONCONTENT ORDER BY t5.ITEM_OPTIONNAME , '.', t5.ITEM_OPTIONCONTENT Separator '$$') AS ITEM_OPTION,"+
"			t5.ITEM_OPTIONIMAGE "+
"		FROM"+
"			tlk_topic_bank_base_info t3"+
"			INNER JOIN tlk_test_quiz_base_info t4 ON t3.ID = t4.ITEM_TOPICBANKID"+
"			LEFT JOIN tlk_test_quiz_option t5 ON t5.ITEM_QUIZID = t4.ID  where ITEM_QUIZTYPE = '0'"+wheretopicBankId+
"		GROUP BY"+
"			t4.ID "+
" ORDER BY "+
"			t4.ID  "+
"		) t "+
"	ORDER BY"+
"		RAND() "+
"		LIMIT "+singleNum+
"	)  "+
" UNION ALL "+
  " ( "+
"	SELECT "+
"		t.* "+
"	FROM"+
"		("+
"		SELECT"+
"			'"+getDomainid()+"' AS domainid,"+
"			t4.ID,"+
"			t4.ID AS ITEM_ID,"+
"			t4.ITEM_QUIZTOPIC,"+
"			t4.ITEM_QUIZTYPE,"+
"			t4.ITEM_ANSWER,"+
     	"'"+multipleScore+"' AS ITEM_MYSCORE,"+
"			t4.ITEM_QUIZCODE,"+
"			t4.ITEM_QUIZANALYSIS,"+
"			GROUP_CONCAT( t5.ITEM_OPTIONNAME , '.', t5.ITEM_OPTIONCONTENT  ORDER BY t5.ITEM_OPTIONNAME , '.', t5.ITEM_OPTIONCONTENT Separator '$$') AS ITEM_OPTION,"+
"			t5.ITEM_OPTIONIMAGE "+
"		FROM"+
"			tlk_topic_bank_base_info t3"+
"			INNER JOIN tlk_test_quiz_base_info t4 ON t3.ID = t4.ITEM_TOPICBANKID"+
"			LEFT JOIN tlk_test_quiz_option t5 ON t5.ITEM_QUIZID = t4.ID  where ITEM_QUIZTYPE = '1'"+wheretopicBankId+
"		GROUP BY"+
"			t4.ID "+
" ORDER BY "+
"			t4.ID  "+
"		) t "+
"	ORDER BY"+
"		RAND() "+
"		LIMIT "+multipleNum+
"	)  "+
  " UNION ALL "+
  " ( "+
"	SELECT "+
"		t.* "+
"	FROM"+
"		("+
"		SELECT"+
"			'"+getDomainid()+"' AS domainid,"+
"			t4.ID,"+
"			t4.ID AS ITEM_ID,"+
"			t4.ITEM_QUIZTOPIC,"+
"			t4.ITEM_QUIZTYPE,"+
"			t4.ITEM_ANSWER,"+
     "'"+judgeScore+"' AS ITEM_MYSCORE,"+
"			t4.ITEM_QUIZCODE,"+
"			t4.ITEM_QUIZANALYSIS,"+
"			GROUP_CONCAT( t5.ITEM_OPTIONNAME , '.', t5.ITEM_OPTIONCONTENT ORDER BY t5.ITEM_OPTIONNAME , '.', t5.ITEM_OPTIONCONTENT Separator '$$') AS ITEM_OPTION,"+
"			t5.ITEM_OPTIONIMAGE "+
"		FROM"+
"			tlk_topic_bank_base_info t3"+
"			INNER JOIN tlk_test_quiz_base_info t4 ON t3.ID = t4.ITEM_TOPICBANKID"+
"			LEFT JOIN tlk_test_quiz_option t5 ON t5.ITEM_QUIZID = t4.ID  where ITEM_QUIZTYPE = '2'"+wheretopicBankId+
"		GROUP BY"+
"			t4.ID "+
" ORDER BY "+
"			t4.ID  "+
"		) t "+
"	ORDER BY"+
"		RAND() "+
"		LIMIT "+judgeNum+
"	)  "+
" ) y "+where;
println("sql==>" + sql);
return sql;
})()]]></sqlFilterScript>
  <procedureFilterScript><![CDATA[]]></procedureFilterScript>
  <filterCondition><![CDATA[[]]]></filterCondition>
  <commonFilterCondition><![CDATA[[{"field":"quizTopic","isCommonFilter":"true"},{"field":"quizType","isCommonFilter":"true"}]]]></commonFilterCondition>
  <authorityCondition>[]</authorityCondition>
  <openType>1</openType>
  <editMode>02</editMode>
  <width>0</width>
  <height>0</height>
</ListView>