Wtf.disGrade=function(A){Wtf.apply(this,A);this.valueRec=Wtf.data.Record.create([{name:"grade"}]);this.valueReader=new Wtf.data.KwlJsonReader({root:"data"},this.valueRec);this.valueStore=new Wtf.data.Store({url:"jspfiles/admin/acastructure.jsp",reader:this.valueReader});this.valueCombo=new Wtf.form.ComboBox({triggerAction:"all",store:this.valueStore,mode:"local",readOnly:true,displayField:"grade",allowBlank:false,valueField:"grade"});this.gradeSM=new Wtf.grid.CheckboxSelectionModel({});this.gradeRecord=Wtf.data.Record.create([{name:"userid",type:"string"},{name:"username",type:"string"},{name:"grade",type:"string"},{name:"modulename",type:"string"},{name:"moduleid",type:"string"},{name:"status",type:"string"},{name:"Feedback",type:"string"},{name:"nationality",type:"string"},{name:"matricno",type:"string"}]);this.gradeReader=new Wtf.data.KwlJsonReader({root:"data"},this.gradeRecord);this.gradeStore=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/acastructure.jsp"}),reader:this.gradeReader});this.gradeCM=new Wtf.grid.ColumnModel([new Wtf.grid.RowNumberer(),this.gradeSM,{header:"Employee",dataIndex:"username",sortable:true},{header:"Employee Id",dataIndex:"matricno",sortable:true},{header:"Nationality",dataIndex:"nationality",sortable:true},{header:"Module name",dataIndex:"modulename",sortable:true},{header:"Status",dataIndex:"status",sortable:true,renderer:function(B){if(B==0){return"Result pending"}if(B==1){return"Pending Faculty Head Confirmation"}if(B==2){return"HOD Confirmed"}if(B==3){return"Grievance Application"}if(B==4){return"Final Marks"}if(B==5){return"Re-Assess"}if(B==6){return"ASAD Confirmed"}}},{header:"Feedback",dataIndex:"Feedback",sortable:true},{header:"Grade",dataIndex:"grade",sortable:true}]);this.filterStore=new Wtf.data.SimpleStore({fields:["statusid","status"],data:[["0","Result pending"],["1","Pending Faculty Head Confirmation"],["2","HOD Confirmed"],["3","Grievance Application"],["4","Final Marks"],["5","Re-Assess"],["6","ASAD Confirmed"]]});this.filterCombo=new Wtf.form.ComboBox({triggerAction:"all",store:this.filterStore,mode:"local",readOnly:true,displayField:"status",fieldLabel:"Filter by status",width:175,listWidth:175,valueField:"statusid",emptyText:"Select a status..."});this.clearFilter=new Wtf.Toolbar.Button({text:"Clear Filter",scope:this,handler:function(){this.gradeStore.clearFilter(false);this.filterCombo.clearValue()}});this.dldCsv=new Wtf.Toolbar.Button({text:"Export",scope:this,iconCls:"csvIcon",handler:function(){var B=this.moduleid;if(this.HOD){status="1"}else{status="0,1,2,6"}if(isRoleGroup("4")){status="2"}setDldUrl("fileDownload.jsp?modulerunid="+B+"&type=gradebookspe&status="+status+"&dtype=attachment")}});this.filterCombo.on("select",this.filter,this);this.gradeGrid=new Wtf.grid.EditorGridPanel({ds:this.gradeStore,cm:this.gradeCM,sm:this.gradeSM,autoScroll:true,collapsible:true,trackMouseOver:true,layout:"fit",clicksToEdit:1,viewConfig:{forceFit:true,autoFill:true}});this.layout="fit";this.items=this.gradeGrid;this.tbar=["Filter by status: ",this.filterCombo,this.clearFilter,this.dldCsv];this.bbar=[{id:"setgrade",text:"Set Grade",scope:this,handler:this.setGrade,disabled:true,hidden:(isRoleGroup("4"))?true:false},{id:"confirmgrade",text:"Confirm Grade",scope:this,handler:this.confirmGrade,disabled:true,hidden:(isRoleGroup("4"))?true:false},{id:"hodaccept",text:"Accept",scope:this,handler:this.acceptGrades,disabled:true},{id:"hodreject",text:"Reject",scope:this,handler:this.rejectGrades,disabled:true},{id:"hodsubmitappeal",text:"Submit Appeal",scope:this,handler:this.submitAppeal,disabled:true},{id:"generategrade",text:"Generate GradeBook",scope:this,handler:this.generategrade,disabled:true,hidden:(isRoleGroup("4"))?false:true},{id:"anagrade",text:"GradeBook Analysis",scope:this,handler:this.anagrade,disabled:false}];this.gradeSM.on("selectionchange",this.disablebtn,this);Wtf.disGrade.superclass.constructor.call(this,A)};Wtf.extend(Wtf.disGrade,Wtf.Panel,{onRender:function(A){Wtf.disGrade.superclass.onRender.call(this,A);if(this.HOD){Wtf.getCmp("confirmgrade").setVisible(false);Wtf.getCmp("hodaccept").setVisible(true);Wtf.getCmp("hodreject").setVisible(true);Wtf.getCmp("hodsubmitappeal").setVisible(true)}else{Wtf.getCmp("hodaccept").setVisible(false);Wtf.getCmp("hodreject").setVisible(false);Wtf.getCmp("hodsubmitappeal").setVisible(false)}this.refresh()},confirmGrade:function(){var E="";var D="";var C="";var F="";var A=0;var H=0;var B=this.gradeSM.getSelections();for(var G=0;G<B.length;G++){C=B[G].get("userid")}Wtf.MessageBox.confirm("Confirm Grades","Are you sure you want to confirm the grades?",function(I){if(I=="yes"){if(this.moduleid==-1){H=this.gradeSM.getSelected().get("moduleid")}else{H=this.moduleid}Wtf.Ajax.requestEx({url:"jspfiles/newCourse.jsp",method:"POST",params:{type:"storeMarks",mid:H,total:-2,ids:C,uid:loginid,specialgrade:1}},this,function(){msgBoxShow(["Grade Confirmation","The grades of selected the students have been confirmed."],Wtf.MessageBox.INFO);this.refresh()},function(){msgBoxShow(["Error","Error occurred while confirming the grades. Please try again later."],Wtf.MessageBox.ERROR)})}},this)},refresh:function(){if(this.moduleid==-1){this.gradeStore.load({params:{type:79,userid:loginid}})}else{if(this.moduleid==-2){this.gradeStore.load({params:{type:89}})}else{if(this.HOD){status="1"}else{status="0,1,2,6"}if(isRoleGroup("4")){status="2"}this.gradeStore.load({params:{type:87,moduleid:this.moduleid,status:status}})}}},setGrade:function(){this.gradesm1=new Wtf.grid.CheckboxSelectionModel();this.gradeRecord1=Wtf.data.Record.create([{name:"grade",type:"string"}]);this.gradeReader1=new Wtf.data.KwlJsonReader({root:"data"},this.gradeRecord1);this.gradeds1=new Wtf.data.Store({proxy:new Wtf.data.HttpProxy({url:"jspfiles/admin/acastructure.jsp"}),reader:this.gradeReader1});this.gradecm1=new Wtf.grid.ColumnModel([this.gradesm1,{dataIndex:"grade",header:"Grades"}]);this.gradeGrid1=new Wtf.grid.GridPanel({sm:this.gradesm1,ds:this.gradeds1,cm:this.gradecm1,viewConfig:{autoFill:true,forceFit:true}});var A=0;if(this.moduleid==-1){A=1}this.gradeds1.load({params:{type:82,moduleid:this.gradeSM.getSelected().get("moduleid"),flag:A}});this.gradewin=new Wtf.Window({width:400,height:250,layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:"<div style = 'width:100%;height:100%;position:relative;float:left;'><div style='float:left;height:100%;width:auto;position:relative;'><img src = 'images/upload52.gif' style = 'width:52px;height:52px;margin:5px 5px 5px 5px;'></img></div><div style='float:left;height:100%;width:80%;position:relative;'><div style='font-size:12px;font-style:bold;float:left;margin:20px 0px 0px 10px;width:100%;position:relative;'><b>Grades</b></div><div style='font-size:10px;float:left;margin:15px 0px 0px 10px;width:100%;position:relative;'>Set Grades.</div></div></div>"},{region:"center",border:false,layout:"fit",items:[{border:false,layout:"fit",items:this.gradeGrid1}]}],buttons:[{text:"Save",scope:this,handler:this.insertGrade},{text:"Cancel",scope:this,handler:function(){this.gradewin.close()}}]});this.gradewin.show()},disablebtn:function(G){var D=this.gradeSM.getSelections();if(D.length==1){Wtf.getCmp("setgrade").setDisabled(false);Wtf.getCmp("confirmgrade").setDisabled(false);Wtf.getCmp("hodaccept").setDisabled(false);Wtf.getCmp("hodreject").setDisabled(false);Wtf.getCmp("hodsubmitappeal").setDisabled(false);Wtf.getCmp("generategrade").setDisabled(false)}else{Wtf.getCmp("setgrade").setDisabled(true);Wtf.getCmp("confirmgrade").setDisabled(true);Wtf.getCmp("hodaccept").setDisabled(true);Wtf.getCmp("hodreject").setDisabled(true);Wtf.getCmp("hodsubmitappeal").setDisabled(true);Wtf.getCmp("generategrade").setDisabled(true)}if(D.length==1){if(this.HOD){if(G.getSelected().get("status")!=1||G.getSelected().get("status")==3){Wtf.getCmp("setgrade").setDisabled(true)}if(G.getSelected().get("status")!=3){Wtf.getCmp("hodsubmitappeal").setDisabled(true)}}else{if(isRoleGroup("4")){if(G.getSelected().get("status")==2){Wtf.getCmp("setgrade").setDisabled(false)}else{Wtf.getCmp("setgrade").setDisabled(true)}}else{if(G.getSelected().get("status")==0||G.getSelected().get("status")==5){Wtf.getCmp("setgrade").setDisabled(false)}else{Wtf.getCmp("setgrade").setDisabled(true)}}}}else{Wtf.getCmp("setgrade").setDisabled(true);Wtf.getCmp("confirmgrade").setDisabled(true);Wtf.getCmp("hodaccept").setDisabled(true);Wtf.getCmp("hodreject").setDisabled(true);Wtf.getCmp("hodsubmitappeal").setDisabled(true);Wtf.getCmp("generategrade").setDisabled(true)}var B=true;var A=true;var F=true;var C=false;var E=G.getSelections();if(E.length>0){for(i=0;i<E.length;i++){if(!this.HOD){if(E[i].get("status")!="0"&&E[i].get("status")!="5"){B=false}if(E[i].get("status")!="2"){F=false}}else{if(E[i].get("status")!="1"&&E[i].get("status")!="3"){A=false;break}}}if(!this.HOD){if(B){Wtf.getCmp("confirmgrade").setDisabled(false)}else{Wtf.getCmp("confirmgrade").setDisabled(true)}if(F){Wtf.getCmp("generategrade").setDisabled(false)}else{Wtf.getCmp("generategrade").setDisabled(true)}}else{if(A){if(G.getSelected().get("status")=="1"){Wtf.getCmp("hodaccept").setDisabled(false);Wtf.getCmp("hodreject").setDisabled(false)}else{if(G.getSelected().get("status")=="3"){Wtf.getCmp("hodsubmitappeal").setDisabled(false)}}}else{Wtf.getCmp("hodaccept").setDisabled(true);Wtf.getCmp("hodreject").setDisabled(true);Wtf.getCmp("hodsubmitappeal").setDisabled(true)}}}else{if(!this.HOD){Wtf.getCmp("confirmgrade").setDisabled(true);Wtf.getCmp("generategrade").setDisabled(true)}else{Wtf.getCmp("hodaccept").setDisabled(true);Wtf.getCmp("hodreject").setDisabled(true)}}},insertGrade:function(){Wtf.Ajax.requestEx({method:"POST",url:"jspfiles/admin/acastructure.jsp",params:{type:83,moduleid:this.gradeSM.getSelected().get("moduleid"),userid:this.gradeSM.getSelected().get("userid"),grade:this.gradesm1.getSelected().get("grade")}},this,function(B,A){this.gradewin.close();this.refresh()},function(B,A){})},getUsers:function(){var B="";var C=this.gradeSM.getSelections();for(var A=0;A<C.length;A++){B+=C[A].get("userid")+","}return B},acceptGrades:function(){Wtf.MessageBox.confirm("Confirm Grades","Are you sure you want to accept?",function(A){if(A=="yes"){var B=this.getUsers();var C;if(this.moduleid==-1||this.moduleid==-2){C=this.gradeSM.getSelected().get("moduleid")}else{C=this.moduleid}Wtf.Ajax.request({url:"jspfiles/result.jsp",method:"POST",params:{mode:5,mid:C,ids:B,uid:loginid},scope:this,success:function(){msgBoxShow(["Accept Grades","Grade status updated."],Wtf.MessageBox.INFO);this.refresh()},failure:function(){msgBoxShow(["Error","Error occurred while accepting the grades. Please try again later."],Wtf.MessageBox.ERROR)}})}},this)},rejectGrades:function(){Wtf.MessageBox.confirm("Confirm Grades","Are you sure you want to reject?",function(A){if(A=="yes"){var B=this.getUsers();var C;if(this.moduleid==-1||this.moduleid==-2){C=this.gradeSM.getSelected().get("moduleid")}else{C=this.moduleid}Wtf.Ajax.request({url:"jspfiles/result.jsp",method:"POST",params:{mode:6,mid:C,ids:B,uid:loginid},scope:this,success:function(){msgBoxShow(["Reject Grades","Grade status updated."],Wtf.MessageBox.INFO);this.refresh()},failure:function(){msgBoxShow(["Error","Error occurred while rejecting the grades. Please try again later."],Wtf.MessageBox.ERROR)}})}},this)},submitAppeal:function(){Wtf.MessageBox.confirm("Confirm Grades","Are you sure you want to submit the appeal?",function(A){if(A=="yes"){var B=this.getUsers();var C;if(this.moduleid==-1||this.moduleid==-2){C=this.gradeSM.getSelected().get("moduleid")}else{C=this.moduleid}Wtf.Ajax.request({url:"jspfiles/result.jsp",method:"POST",params:{mode:7,mid:C,ids:B,uid:loginid},scope:this,success:function(){msgBoxShow(["Forward Appeal to Trainer","Grievance(s) forwarded to trainer for re-assessment."],Wtf.MessageBox.INFO);this.refresh()},failure:function(){msgBoxShow(["Error","Error occurred while submitting request. Please try again later."],Wtf.MessageBox.ERROR)}})}},this)},generategrade:function(){Wtf.MessageBox.confirm("Generate Grade Book","Are you sure you want to generate Grade Book for selected students?",function(A){if(A=="yes"){var B;if(this.moduleid==-1||this.moduleid==-2){B=this.gradeSM.getSelected().get("moduleid")}else{B=this.moduleid}Wtf.Ajax.request({url:"jspfiles/admin/assignment.jsp",method:"POST",params:{action:7,moduleid:B,ids:this.getUsers()},scope:this,success:function(D,C){msgBoxShow(["Grade Book Generation","Grade Book Generated.<br/>Notification has been sent to the students in this module."],Wtf.MessageBox.INFO);this.refresh()},failure:function(D,C){Wtf.getCmp("gengb_"+this.id).enable();msgBoxShow(["Error","Error in connection."],Wtf.MessageBox.ERROR)}})}else{}},this)},anagrade:function(){if(this.gradeStore.getCount()>0){var C="";var A=true;var B=15;if(this.moduleid==-1||this.moduleid==-2){if(this.gradeSM.getCount()>0){C=this.gradeSM.getSelected().get("moduleid")}else{A=true}B=16}else{C=this.moduleid}if(A){this.gradeanawin=new Wtf.Window({width:415,height:215,title:"Grade Chart",modal:true,bodyStyle:"background-color:#FFFFFF",items:[new Wtf.analysisArPanel({modulerunid:C,typeFlag:B})]});this.gradeanawin.show()}}else{msgBoxShow(["Grade Book Analysis","Grade Book should contain minimum 1 record to display analysis."],Wtf.MessageBox.INFO)}},filter:function(B,C,A){this.gradeStore.filter("status",C.get("statusid"))}});Wtf.analysisArPanel=function(A){Wtf.apply(this,A);Wtf.analysisArPanel.superclass.constructor.call(this,{autoDestroy:true,border:false,layout:"form",autoScroll:true,items:[this.northP=new Wtf.Panel({region:"north",id:"gdchart",border:false,layout:"fit",height:215})]});this.on("render",this.handleRender,this)};Wtf.extend(Wtf.analysisArPanel,Wtf.Panel,{handleRender:function(obj){this.loadMask=new Wtf.LoadMask(this.id,{msg:"Loading..."});this.loadMask.show();Wtf.Ajax.requestEx({url:"jspfiles/student/gradeBook.jsp",method:"POST",params:{mode:this.typeFlag,modulerunid:this.modulerunid,userid:loginid}},this,function(request,response){if(request!=null&&request!=""){var resObj=eval("("+request.trim()+")");if(resObj){if(resObj.gradeChart[0].data[0]!==undefined){this.loadMask.hide()}this.plotChart(resObj.gradeChart[0].data[0])}}},function(resp,req){this.loadMask.hide()})},plotChart:function(D){var F="";var B="";var A=0;if(D.totalCnt>0){for(var C=0;C<D.gradedata.length;C++){A=(D.gradedata[C].cnt/D.totalCnt)*100;F+=D.gradedata[C].grade.replace("+","%2b")+"["+this.roundNumber(A,2)+"%]|";B+=A+","}}F=F.substring(0,F.length-1);B=B.substring(0,B.length-1);var E='<div ><img style = "" align="center" src ="http://chart.apis.google.com/chart?cht=p3&chd=t:'+B+"&chco=3e85e5,fcb441,e0400a&chs=400x185&chl="+F+'"</img></div>';document.getElementById("gdchart").innerHTML=E},roundNumber:function(A,C){var B=Math.round(A*Math.pow(10,C))/Math.pow(10,C);return B}})