Wtf.EditorGridComp=function(D){Wtf.apply(this,D);this.id=D.id;this.comp=D.compId;if(this.flag){var G=this.flag}else{var G=this.comp.mytree.getSelectionModel().getSelectedNode().attributes.id}if(this.nodeVno){this.openMode=this.nodeVno}else{this.openMode=0}this.Task=Wtf.data.Record.create([{name:"taskid",type:"int"},{name:"type",type:"string",dataIndex:"type"},{name:"question",type:"string",dataIndex:"question"},{name:"feedback",type:"string",dataIndex:"feedback"},{name:"attempts",type:"int",dataIndex:"attempts"},{name:"points",type:"int",dataIndex:"points"},{name:"difficulty",type:"int",dataIndex:"difficulty"},{name:"shuffle",dataIndex:"shuffle"},{name:"timelimit",type:"int",dataIndex:"timelimit"},{name:"del123",dataIndex:"del"},{name:"quesid",dataIndex:"quesid",type:"string"},{name:"author",dataIndex:"author",type:"string"}]);this.dsstore=new Wtf.data.Store({url:Wtf.req.lms+"quiz.jsp",reader:new Wtf.data.JsonReader({root:"data"},["row","type","question","feedback","attempts","points","difficulty","shuffle","timelimit","del","quesid","choice","correctans","pic"])});this.dsstore.on("load",H,this);function H(N,O,L){var M=null;if(O[0].data.quesid!=""){if(this.nodeidObj){Wtf.getCmp("previewquiz"+this.combId).enable()}else{Wtf.getCmp("previewquiztab"+G).enable()}if(this.owner){this.getfirstrow()}}Wtf.getCmp(this.combId).loadQuiz.hide()}this.dsstore.load({params:{flag:"1",quiznode:G,mode:"0",pubmode:this.openMode,cid:this.comp.courseid}});var K=new Wtf.data.SimpleStore({fields:["abbr","state"],data:[["1","True/False"],["2","Multiple Choice"],["3","Fill in the Blank"],["4","Matching"],["5","Ranking"],["6","Multiple Response"]]});this.RootMenu=new Wtf.menu.Menu({shadow:false,id:"contextMenu",items:[{id:"insert",text:"Insert Option",scope:this,icon:"../images/s.gif",shadow:false,menu:[{id:"truefalse",text:"True / False ...",scope:this,icon:"../images/s.gif",handler:function(){Truefalseshowwin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}},{id:"mulchoice",text:"Multiple choice ...",scope:this,icon:"../images/s.gif",handler:function(){MultipleShowWin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}},{id:"fillblank",text:"Fill in the blanks ...",scope:this,icon:"../images/s.gif",handler:function(){FillBlankShowWin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}},{id:"matching",text:"Matching ...",scope:this,icon:"../images/s.gif",handler:function(){MatchingShowWin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}},{id:"ranking",text:"Ranking ...",scope:this,icon:"../images/s.gif",handler:function(){RankShowWin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}},{id:"mulresponse",text:"Multiple Response ...",scope:this,icon:"../images/s.gif",handler:function(){MultipleResponseShowWin(this.comp,this.dsstore,this.Task,null,this.nodeidObj)}}]},{id:"delete",text:"Delete Question",scope:this,icon:"images/cancel.png",shadow:false,handler:this.deletequestion}]});this.cmodel=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),{header:"Type",width:0.15,dataIndex:"type",align:"left",editor:cb1=new Wtf.form.ComboBox({id:"combo"+this.id,store:K,displayField:"state",typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,lazyRender:true,emptyText:"",editable:false})},{header:"Question",width:0.28,align:"left",dataIndex:"question"},{header:"Feedback",width:0.07,align:"center",dataIndex:"feedback"},{header:"Attempts",width:0.07,align:"center",dataIndex:"attempts"},{header:"Points",width:0.06,align:"center",dataIndex:"points"},{header:"Difficulty Level",width:0.12,align:"center",dataIndex:"difficulty"},{header:"Shuffle choices",width:0.12,align:"center",dataIndex:"shuffle"},{header:"Time Limit",width:0.08,align:"center",dataIndex:"timelimit"},{header:"",width:0.05,align:"center",renderer:I,dataIndex:"del"}]);this.cmodel.defaultSortable=true;function I(){return"<div id=img class=img></div>"}Wtf.EditorGridComp.superclass.constructor.call(this,{ds:this.dsstore,cm:this.cmodel,clicksToEdit:1,selModel:new Wtf.grid.RowSelectionModel(),viewConfig:{forceFit:true,autoFill:true}});if(this.owner){this.addListener("contextmenu",this.rightclick);this.on("rowdblclick",this.retriveinfo);this.on("cellclick",this.cellclicked);this.on("beforeedit",this.beforeEdit);this.getfirstrow()}else{this.cmodel.setEditable(1,false);this.cmodel.setHidden(9,true)}this.on("rowclick",this.setinfo);cb1=Wtf.getCmp("combo"+this.id);cb1.on("select",C);var E=this.Task;var F=this.dsstore;var J=this.comp;var A=this.nodeidObj;var B=this.innertab;function C(L){var M=L.getValue();switch(M){case"True/False":Truefalseshowwin(J,F,E,null,A,null,B);break;case"Multiple Choice":MultipleShowWin(J,F,E,null,A,null,B);break;case"Fill in the Blank":FillBlankShowWin(J,F,E,null,A,null,B);break;case"Matching":MatchingShowWin(J,F,E,null,A,null,B);break;case"Ranking":RankShowWin(J,F,E,null,A,null,B);break;case"Multiple Response":MultipleResponseShowWin(J,F,E,null,A,null,B);break}}};Wtf.extend(Wtf.EditorGridComp,Wtf.grid.EditorGridPanel,{getfirstrow:function(){var B=this.dsstore.getCount();var A=new this.Task({type:"",question:"",feedback:"",attempts:"",points:"",difficulty:"",shuffle:"",timelimit:"",del123:""});this.dsstore.insert(B,A)},beforeEdit:function(A){if(A.value!=""){A.cancel=true}},getStore:function(){return this.dsstore},createtruefalseques:function(A){Truefalseshowwin(this.comp,A,this.Task,null,this.nodeidObj)},createMulChoiceques:function(A){MultipleShowWin(this.comp,A,this.Task,null,this.nodeidObj)},createFillBlankques:function(A){FillBlankShowWin(this.comp,A,this.Task,null,this.nodeidObj)},createMatchingques:function(A){MatchingShowWin(this.comp,A,this.Task,null,this.nodeidObj)},createRankques:function(A){RankShowWin(this.comp,A,this.Task,null,this.nodeidObj)},MultipleResponseques:function(A){MultipleResponseShowWin(this.comp,A,this.Task,null,this.nodeidObj)},rightclick:function(A){A.preventDefault();this.RootMenu.showAt(A.getXY())},retriveinfo:function(A,C,B){type=this.dsstore.getAt(C).data["type"];switch(type){case"True/False":Truefalseshowwin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break;case"Multiple Choice":MultipleShowWin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break;case"Fill in the Blanks":FillBlankShowWin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break;case"Matching":MatchingShowWin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break;case"Ranking":RankShowWin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break;case"Multiple Response":MultipleResponseShowWin(this.comp,this.dsstore,this.Task,C,this.nodeidObj);break}},cellclicked:function(B,D,A,C){if(this.dsstore.getCount()!=D+1){if(A==9){this.deletequestion()}}},deletequestion:function(){dstore=this.dsstore;grid1=this;compId=this.comp;Wtf.MessageBox.confirm("Confirm","Are you sure you want to delete?",this.showResult,this)},showResult:function(H){var D;if(this.innertab){D=this.comp.ownerCt.innerTabPanel.getActiveTab().id}else{D=this.comp.tabPanelContainer.getActiveTab().id}if(H=="yes"){nodeid=(D).substring(3);courseid=this.comp.courseid;var A=dstore.getAt(rowid);var G=dstore.getAt(rowid).data["quesid"];dstore.remove(A);var E=document.getElementById("inner1"+D);for(var F=0;E.childNodes.length;){E.removeChild(E.childNodes[F])}var C="3";var B=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:Wtf.req.lms+"quiz.jsp"}),reader:new Wtf.data.JsonReader({root:"data"},["Details"])});B.load({params:{flag:C,quesid:G,node:nodeid,cid:courseid}});grid1.getView().refresh();if(dstore.getCount()==1){Wtf.getCmp("previewquiz"+D).disable()}}},setinfo:function(I,N,K){rowid=N;type=this.dsstore.getAt(N).data["type"];feed=this.dsstore.getAt(N).data["feedback"];var Q=this.dsstore.getAt(N).data["pic"];var C=Wtf.getLmsImgPath+Q;if(!(feed=="None")){var J=feed.split("/");feed=J[0]}ques=this.dsstore.getAt(N).data["question"];points=this.dsstore.getAt(N).data["points"];timelimit=this.dsstore.getAt(N).data["timelimit"];diff=this.dsstore.getAt(N).data["difficulty"];var O;var B;if(this.innertab){B=this.comp.ownerCt.innerTabPanel.getActiveTab().id;O=document.getElementById("inner1"+B)}else{B=this.comp.tabPanelContainer.getActiveTab().id;O=document.getElementById("inner1"+B)}if(type!=""){O.innerHTML="<div class='flabel'><div  id = 'topdiv' class = 'title1'>"+type+"</div><div class = 'feed'><div class='fontstyleFeed'> Feedback:"+feed+"</div></div><br><div class='flabel'><div class='fontstyle1'> "+ques+"</div><div class='qpic'><img id='picUpload' src='"+C+"'></img></div></div><div><div class='fontstyle3'>Points:"+points+"</div><div class='fontstyle3'>Time Limit:"+timelimit+"</div><div class='fontstyle3'>Difficulty Level:"+diff+"</div></div></div><br><br>"}else{O.innerHTML=""}switch(type){case"True/False":var E=this.dsstore.getAt(N).data["correctans"];var M=E.split("@");O.innerHTML+="<table class='ansshow' cellspacing=15><tr><td>Options</td><td>Correct</td><td>Answer</td></tr><tr><td>T</td><td><input type='checkbox' id='chk1"+B+"'  class='displaychk' name='chk1' DISABLED/></td><td>True</td></tr><td>F</td><td><input type='checkbox' id='chk2"+B+"'  class='displaychk' name='chk2' DISABLED/></td><td>False</td></tr></table>";if(M[0]=="1"){document.getElementById("chk1"+B).checked=true;document.getElementById("chk1"+B).style.display="block"}else{document.getElementById("chk2"+B).checked=true;document.getElementById("chk2"+B).style.display="block"}break;case"Multiple Choice":var M=this.dsstore.getAt(N).data["correctans"];var H=M.split("@");var F=this.dsstore.getAt(N).data["choice"];var D=F.split("/");O.innerHTML+="<table class='ansshow' id='table1"+B+"' cellspacing=15 ><tr><td>Options</td><td>Correct</td><td>Answer</td></tr></table>";var G=document.getElementById("table1"+B);for(var L=1;L<D.length;L++){var A="<tr><td>"+String.fromCharCode(65+parseInt(L-1))+"</</td><td><input type='checkbox' id='chk"+L+B+"'  class='displaychk' name='chk1' DISABLED/></td><td>"+D[L-1]+"</td></tr>";Wtf.DomHelper.insertHtml("afterEnd",Wtf.DomQuery.select("table#table1"+B)[0].lastChild,A)}for(var L=1;L<D.length;L++){if(H[L-1]=="1"){document.getElementById("chk"+L+B).checked=true;document.getElementById("chk"+L+B).style.display="block"}}break;case"Fill in the Blanks":var F=this.dsstore.getAt(N).data["choice"];var M=this.dsstore.getAt(N).data["correctans"];var H=M.split("@");var D=F.split("/");O.innerHTML+="<table class='ansshow' id='table1"+B+"' cellspacing=15 ><tr><td></td><td>Answer</td></tr></table>";var G=document.getElementById("table1"+B);for(var L=1;L<D.length;L++){var A="<tr><td>"+String.fromCharCode(65+parseInt(L-1))+"</</td><td>"+D[L-1]+"</td></tr>";Wtf.DomHelper.insertHtml("afterEnd",Wtf.DomQuery.select("table#table1"+B)[0].lastChild,A)}break;case"Ranking":var M=this.dsstore.getAt(N).data["correctans"];var F=this.dsstore.getAt(N).data["choice"];var H=M.split("@");var D=F.split("/");O.innerHTML+="<table class='ansshow' id='table1"+B+"' cellspacing=15 ><tr><td></td><td>Answer</td></tr></table>";var G=document.getElementById("table1"+B);for(var L=1;L<D.length;L++){var A="<tr><td>"+String.fromCharCode(65+parseInt(L-1))+"</</td><td>"+D[L-1]+"</td></tr>";Wtf.DomHelper.insertHtml("afterEnd",Wtf.DomQuery.select("table#table1"+B)[0].lastChild,A)}break;case"Multiple Response":var M=this.dsstore.getAt(N).data["correctans"];var P=M.split("@");var F=this.dsstore.getAt(N).data["choice"];var D=F.split("/");O.innerHTML+="<table class='ansshow' id='table1"+B+"' cellspacing=15 ><td>Options</td><td>Correct</td><td>Answer</td></tr></table>";var G=document.getElementById("table1"+B);for(var L=1;L<D.length;L++){var A="<tr><td>"+String.fromCharCode(65+parseInt(L-1))+"</</td><td><input type='checkbox' id='chk"+L+B+"'  class='displaychk' name='chk1' DISABLED/></td><td>"+D[L-1]+"</td></tr>";Wtf.DomHelper.insertHtml("afterEnd",Wtf.DomQuery.select("table#table1"+B)[0].lastChild,A)}for(var L=1;L<P.length;L++){if(P[L-1]=="1"){document.getElementById("chk"+L+B).checked=true;document.getElementById("chk"+L+B).style.display="block"}}break;case"Matching":var M=this.dsstore.getAt(N).data["correctans"];var P=M.split("@");var F=this.dsstore.getAt(N).data["choice"];var D=F.split("/");O.innerHTML+="<table class='ansshow' id='table1"+B+"' cellspacing=15 ><td></td><td>Choice Side</td><td>Matching Side</td></tr></table>";var G=document.getElementById("table1"+B);for(var L=1;L<D.length;L++){var A="<tr><td>"+String.fromCharCode(65+parseInt(L-1))+"</</td><td>"+D[L-1]+"</td><td>"+P[L-1]+"</td></tr>";Wtf.DomHelper.insertHtml("afterEnd",Wtf.DomQuery.select("table#table1"+B)[0].lastChild,A)}break}}})