Wtf.common.assignmentDropBox=function(A){Wtf.common.assignmentDropBox.superclass.constructor.call(this,A)};Wtf.extend(Wtf.common.assignmentDropBox,Wtf.Panel,{assignmentStore:null,assignmentSubStore:null,assignmentCM:null,assignmentGrid:null,innerPanel:null,faculty:false,assingmentLP:null,descriptionLP:null,submissionUncheckedStore:null,submissionCheckedStore:null,submissionSM:null,submissionCM:null,submissionGrid:null,newAssignmentWin:null,newUploadWin:null,statusFlag:true,descriptionTpl:new Wtf.XTemplate('<tpl for="json"><div style = "font-size:11px;padding:5px;color:white;"><table style ="padding:0px 8px;font-size:11px"><tr><td><b>Assignment Name :</b></td><tpl if="assignmentid!=0"><td>{assignmentname}</td></tpl></tr><tr><td><b>Created on :</b></td><td>{createdon}</td><td><b>Submission date:</b></td><td>{submittedon}</td></tr></table><hr><table style="padding:0px 10px;font-size:11px"><tr><td style="vertical-align:top;"><b>Description :</b></td><td><span>{description}<span></td></tr></table></div></tpl>'),assignmentexpander:new Wtf.grid.RowExpander({tpl:new Wtf.Template('<div style="margin-left:4px;">',"<div><b>Description :</b>{description}</div>","</div>")}),onRender:function(C){Wtf.common.assignmentDropBox.superclass.onRender.call(this,C);this.assTypeStore=new Wtf.data.JsonStore({root:"data",fields:["asstypeid","assname"],url:"jspfiles/admin/assignment.jsp"});this.assTypeStore2=new Wtf.data.JsonStore({root:"data",fields:["asstypeid","assname"],url:"jspfiles/admin/assignment.jsp"});this.assTypeStore2.on("load",function(D){var F=new Wtf.data.Record.create(["asstypeid","assname"]);var E=new F({asstypeid:"All",assname:"All"});D.addSorted(E)},this);this.assTypeStore2.load({params:{action:12,modulerunid:this.moduleid,type:1}});this.typeFieldCombo=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{assname}" class="x-combo-list-item">{assname}</div></tpl>',fieldLabel:"Type*",store:this.assTypeStore2,displayField:"assname",valueField:"asstypeid",mode:"local",triggerAction:"all",emptyText:"Select a assignment type...",allowBlank:false,blankText:"Click to select an assignment type",listeners:{scope:this,select:function(F,D,E){if(D.get("assname")=="All"){this.assignmentStore.clearFilter()}else{this.assignmentStore.filter("type",D.get("asstypeid"))}}}}),this.monthDate=new Wtf.MonthField({noPastYears:false});this.filterBtn=new Wtf.Toolbar.Button({text:"Clear Filter",scope:this,tooltip:"Clear All Filters",handler:function(){this.monthDate.setValue("");this.typeFieldCombo.clearValue();this.assignmentStore.clearFilter()}});this.submitBtn=new Wtf.Toolbar.Button({text:"Submit",scope:this,tooltip:"Submit(Apply Filter On Grid Data)",handler:function(){var F=this.monthDate.getValue();var E=this.typeFieldCombo.getValue();if(F&&E){F=new Date(F);var G=F.getFullYear();var D=F.getMonth();this.assignmentStore.filterBy(function(M){var I=false;var K=M.get("appdatestring");var H=Date.parseDate(K,"Y-m-d");var J=H.getFullYear();var L=H.getMonth();if(E!="All"){if(M.get("type")==E&&G==J&&D==L){I=true}}else{if(G==J&&D==L){I=true}}return I},this)}}});this.subTypeStore=new Wtf.data.SimpleStore({data:[["Individual","0"],["Team","1"]],fields:["type","id"],reader:new Wtf.data.ArrayReader({},[{name:"type"},{name:"id"}]),autoLoad:true});this.createAssignmentStore();this.assignmentCM=new Wtf.grid.ColumnModel(this.createAssignmentCM(true));this.createAssignmentGrid();if(this.faculty){this.createSubmissionStore();this.submissionSM=new Wtf.grid.CheckboxSelectionModel();this.submissionSM.on("selectionchange",function(D){if(D.hasSelection()){if(this.submissionGrid.selModel.getSelected().get("id")!="0"){if(Wtf.getCmp("subBttn").pressed==true){Wtf.getCmp("downloadass"+this.id).enable()}}}else{Wtf.getCmp("downloadass"+this.id).disable()}},this);this.submissionCM=new Wtf.grid.ColumnModel(this.createSubmissionCM(false));this.createSubmissionGrid()}this.assignmentUI();this.add(this.innerPanel);this.innerPanel.doLayout();if(!this.faculty){var B=Wtf.data.Record.create([{name:"assignmentid",type:"string"},{name:"assignmentname",type:"string"},{name:"createdon",type:"string"},{name:"submittedon",type:"string"},{name:"description",type:"string"},{name:"status",type:"string"},{name:"subtype",type:"string"},{name:"dtdiff",type:"string"},{name:"ext",type:"string"},{name:"extn",type:"string"},{name:"sid",type:"string"},{name:"size",type:"string"},{name:"filename",type:"string"},{name:"facname",type:"string"}]);var A=new Wtf.data.JsonReader({root:"data",totalProperty:"count"},B);this.assignmentSubStore=new Wtf.data.GroupingStore({url:"jspfiles/student/getSubmittedAssignments.jsp",root:"data",totalProperty:"count",reader:A,autoLoad:false,sortInfo:{field:"facname",direction:"asc"},groupField:"facname"});this.assignmentSubStore.baseParams={modulerunid:this.moduleid,studentid:loginid};this.assignmentSubStore.on("load",function(){this.quickSearchTF.StorageChanged(this.assignmentSubStore);this.assignmentGrid.getView().refresh();this.assignmentGrid.doLayout()},this);this.assignmentSubStore.on("datachanged",function(){this.quickSearchTF.setPage(this.pP.combo.value)},this);this.assignmentSubStore.load({params:{start:0,limit:15}})}this.assignmentStore.load({params:{start:0,limit:15}})},createAssignmentStore:function(){var B=Wtf.data.Record.create([{name:"submitable",type:"string"},{name:"assignmentid",type:"string"},{name:"assignmentname",type:"string"},{name:"createdon",type:"string"},{name:"submittedon",type:"string"},{name:"description",type:"string"},{name:"type",type:"string"},{name:"dtdiff",type:"string"},{name:"subdate",type:"string"},{name:"subtype",type:"string"},{name:"assname",type:"string"},{name:"ext",type:"string"},{name:"owner",type:"string"},{name:"createdon",type:"string"},{name:"facname",type:"string"},{name:"appdate",type:"date",dateFormat:"Y-m-d"},{name:"appdatestring",type:"string"}]);var A=new Wtf.data.JsonReader({root:"data",totalProperty:"count"},B);var C=null;if(this.faculty){C="jspfiles/faculty/getAssignments.jsp"}else{C="jspfiles/student/getNewAssignments.jsp"}this.assignmentStore=new Wtf.data.GroupingStore({url:C,root:"data",totalProperty:"count",reader:A,autoLoad:false,sortInfo:{field:"facname",direction:"asc"},groupField:"facname"});this.assignmentStore.baseParams={modulerunid:this.moduleid,studentid:loginid};this.assignmentStore.on("load",function(){this.quickSearchTF.StorageChanged(this.assignmentStore);this.assignmentGrid.getView().refresh();this.assignmentGrid.doLayout()},this);if(!this.faculty){this.assignmentStore.on("datachanged",function(){this.quickSearchTF.setPage(this.pP.combo.value)},this)}},createSubmissionStore:function(){this.submissionUncheckedStore=new Wtf.data.JsonStore({url:"jspfiles/faculty/getSubmittedAssignments.jsp",root:"data",totalProperty:"count",fields:["id","name","createdon","submissionon","status","type","dtdiff","lsub","subtype","downloaded"],autoLoad:false});this.submissionCheckedStore=new Wtf.data.JsonStore({url:"jspfiles/faculty/getSubmittedAssignments.jsp",root:"data",totalProperty:"count",fields:["id","name","submittedon","status","type","dtdiff","lsub","subtype","downloaded"],autoLoad:false});this.submissionUncheckedStore.on("load",function(){this.quickSearchTFSub.StorageChanged(this.submissionUncheckedStore);this.submissionGrid.getView().refresh()},this);this.submissionUncheckedStore.on("datachanged",function(){this.quickSearchTFSub.setPage(this.pP1.combo.value)},this);this.submissionCheckedStore.on("load",function(){this.quickSearchTFSub.StorageChanged(this.submissionCheckedStore);this.submissionGrid.getView().refresh()},this);this.submissionCheckedStore.on("datachanged",function(){this.quickSearchTFSub.setPage(this.pP1.combo.value)},this)},createAssignmentCM:function(A){var B;if(this.faculty){B=[this.assignmentexpander,{header:"Assignment Name",dataIndex:"assignmentname",autoWidth:true,sortable:true,groupable:true,renderer:this.assignmentRender},{header:"Faculty Name",dataIndex:"facname",autoWidth:true,sortable:true,groupable:true},{header:"Assignment Type",dataIndex:"assname",autoWidth:true,sortable:true,groupable:true},{header:"Submission Type",dataIndex:"subtype",autoWidth:true,sortable:true,groupable:true,renderer:function(G,E,C,H,F,D){if(C.get("id")!="0"){if(G=="0"){return"<label style = 'color : green;'>Individual Submission</label>"}else{if(G=="1"){return"<label style = 'color : blue;'>Team Submission</label>"}}}}},{header:"Submitable",width:100,dataIndex:"submitable",align:"center",renderer:function(G,F,C,H,E,D){if(G==1){return"S"}else{return"N"}}},{header:"Created On",dataIndex:"createdon",autoWidth:true,sortable:true,groupable:true},{header:"Assignment Month",dataIndex:"appdate",autoWidth:true,sortable:true,groupable:true,renderer:function(D){if(D){var C=D.format("F, Y");if(C=="January, 1901"){return"-"}else{return C}}else{return"-"}}},{header:"Download",renderer:function(H,F,D,I,G,E){var C="No File";if(D.json.id!="0"){if(D.data.ext!="empty"){C="<a href='#' title='Download' onclick='setDldUrl(\"fileDownload.jsp?url="+D.data.assignmentid+"/faculty/"+D.data.assignmentname+D.data.ext+"&type=assignmentBank&dtype=attachment\")'><div class='pwnd dldiconwt' style='height:16px; width:16px;'></div></a>"}}return C}}]}else{B=[{header:"Assignment Name",dataIndex:"assignmentname",autoWidth:true,sortable:true,groupable:true},{header:"Faculty Name",dataIndex:"facname",autoWidth:true,sortable:true,groupable:true},{header:"Submission Date",dataIndex:"submittedon",autoWidth:true,sortable:true,groupable:true},{header:"Submission Type",dataIndex:"subtype",autoWidth:true,sortable:true,groupable:true,renderer:function(G,E,C,H,F,D){if(C.get("assignmentid")!="0"){if(G=="0"){return"<label style = 'color : green;'>Individual Submission</label>"}else{if(G=="1"){return"<label style = 'color : blue;'>Team Submission</label>"}}}}},{header:"Status",dataIndex:"status",autoWidth:true,sortable:true,groupable:true,hidden:A,renderer:function(G,E,C,H,F,D){if(C.get("assignmentid")!="0"){if(parseInt(G)==1){return"<label style = 'color : green;'>Submitted</label>"}}}},{header:"Late Submission",dataIndex:"dtdiff",autoWidth:true,sortable:true,groupable:true,align:"center",renderer:function(G,E,C,H,F,D){if(C.get("assignmentid")!="0"){if(G>0){return"<label style = 'color : red;'>Yes</label>"}else{return"<label style = 'color : green;'>No</label>"}}},hidden:A},{header:"Download Assignment",dataIndex:"assignmentid",autoWidth:true,sortable:true,groupable:true,renderer:function(H,F,D,I,G,E){var C="<center>No file</center>";if(D.get("assignmentid")!="0"){if(D.json.ext!="empty"){C="<center><img src = 'images/download1.gif' class = 'down-assignment-img' style='cursor:pointer;'/></center>"}}return C}},{header:"Upload Assignment",dataIndex:"assignmentid",autoWidth:true,sortable:true,groupable:true,renderer:function(G,E,C,H,F,D){if(C.get("assignmentid")!="0"){return"<center><img src = 'images/submit.png' class = 'up-assignment-img' style='cursor:pointer;'/></center>"}}},{header:"Download Submission",dataIndex:"filename",autoWidth:true,sortable:true,hidden:A,groupable:true,renderer:function(G,E,C,H,F,D){if(C.get("assignmentid")!="0"){return"<a href='#' class='down-studassignment-img'>"+C.get("filename")+"</a>"}}},{header:"Size",dataIndex:"size",autoWidth:true,sortable:true,hidden:A,groupable:true,renderer:function(H,F,C,I,G,D){if(C.get("assignmentid")!="0"){if(H=="-1"){return"-"}else{var E=H/1024;if(E<1){return 1+" Kb"}else{return Math.round(E)+" Kb"}}}}}]}return B},createSubmissionCM:function(A){return[new Wtf.KWLRowNumberer({width:25}),this.submissionSM,{header:A?"Name":"Submitted by",dataIndex:"name",autoWidth:true,sortable:true,groupable:true},{header:"Submitted on",dataIndex:"submittedon",autoWidth:true,sortable:true,groupable:true,hidden:A,renderer:function(B){return Wtf.modifyDateFmt(B,"Y-m-j",Wtf.getDateFormat())}},{header:"Late Submission",dataIndex:"dtdiff",autoWidth:true,sortable:true,groupable:true,align:"center",renderer:function(F,D,B,G,E,C){if(B.get("id")!="0"){if(F>0){return"<label style = 'color : red;'>Yes</label>"}else{return"<label style = 'color : green;'>No</label>"}}},hidden:A},{header:"Downloaded",dataIndex:"downloaded",autoWidth:true,sortable:true,groupable:true,hidden:A,align:"center",renderer:function(F,D,B,G,E,C){if(B.get("id")!="0"){if(F=="0"){return"No"}else{return"Yes"}}}}]},createAssignmentGrid:function(){if(isRoleGroup("1")){this.assignmentGrid=new Wtf.grid.GridPanel({store:this.assignmentStore,cm:this.assignmentCM,border:false,plugins:this.assignmentexpander,loadMask:{msg:"Loading..."},view:new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:false,hideGroupedColumn:true}),viewConfig:{forceFit:true}})}else{this.assignmentGrid=new Wtf.grid.GridPanel({tbar:["Type:",this.typeFieldCombo,"Month-Year:",this.monthDate,this.submitBtn,this.filterBtn],store:this.assignmentStore,cm:this.assignmentCM,border:false,plugins:this.assignmentexpander,loadMask:{msg:"Loading..."},view:new Wtf.grid.GroupingView({forceFit:true,showGroupName:false,enableGroupingMenu:false,hideGroupedColumn:true}),viewConfig:{forceFit:true}})}this.assignmentGrid.on("rowclick",this.assignmentGridRowClicked,this)},assignmentUI:function(){var items=[this.assignmentLP=new Wtf.Panel({region:"center",title:"Assignment List",border:false,split:true,layout:"fit",tbar:this.AssignmentLPTBar(),bbar:this.assPageToolBar=this.faculty?[{text:"New",id:"facnewass"+this.id,hidden:!isRealRoles("9"),scope:this,handler:function(button,e){this.createNewAssignment({"modulerunid":this.moduleid,"mode":"0","owner":"1"})}},"-",{text:"Edit",disabled:true,id:"faceditass"+this.id,hidden:isRealRoles("48"),scope:this,handler:function(){this.createNewAssignment({"modulerunid":this.moduleid,"mode":"1","owner":this.assignmentGrid.getSelectionModel().getSelected().get("owner")})}},"-",{text:"Delete",disabled:true,hidden:isRealRoles("48"),id:"delass"+this.id,scope:this,handler:function(){Wtf.Msg.show({title:"Delete Assignment?",msg:"Are you sure you want to delete selected assignment ?",buttons:Wtf.Msg.YESNO,scope:this,fn:function(btn,text){if(btn=="yes"){Wtf.Ajax.request({method:"POST",url:"jspfiles/admin/assignment.jsp",params:({action:27,modulerunid:this.moduleid,assignid:this.assignmentGrid.getSelectionModel().getSelected().get("assignmentid")}),scope:this,success:function(result,req){var obj=Wtf.decode(result.responseText);if(obj.flag=="1"){Wtf.Msg.alert("Alert","Assignment could not be deleted due to dependency",function(btn){},this)}else{if(obj.flag=="2"){Wtf.Msg.alert("Alert","Assignment could not be deleted as marks are assigned to students.",function(btn){},this)}else{this.assignmentStore.reload();Wtf.Msg.alert("Alert","Assignment deleted successfully",function(btn){},this)}}this.disableBbarBttns()},failure:function(result,req){Wtf.Msg.alert("Error","Error connecting to server",function(btn){},this);this.disableBbarBttns()}})}},icon:Wtf.MessageBox.QUESTION})}},"-",{text:"Upload Assignment",disabled:true,hidden:isRealRoles("48"),id:"facuploadfile"+this.id,scope:this,handler:function(){this.uploadFile()}},"-",{text:"Notify",scope:this,disabled:true,hidden:isRealRoles("48"),id:"notify"+this.id,handler:function(){Wtf.Ajax.request({method:"POST",url:"jspfiles/admin/assignment.jsp",params:({action:3,"modulerunid":this.moduleid,assignid:this.assignmentGrid.getSelectionModel().getSelected().get("assignmentid"),subtype:this.assignmentGrid.getSelectionModel().getSelected().get("subtype"),mode:0}),scope:this,success:function(result,req){Wtf.Msg.alert("Alert","Successfully notified students",function(btn){},this)},failure:function(result,req){Wtf.Msg.alert("Error","Error connecting to server",function(btn){},this)}})}},"-",{text:"Notify non-submission",scope:this,id:"notifynonsub"+this.id,hidden:isRealRoles("48"),disabled:true,handler:function(){Wtf.Ajax.request({method:"POST",url:"jspfiles/admin/assignment.jsp",params:({action:3,modulerunid:this.moduleid,assignid:this.assignmentGrid.getSelectionModel().getSelected().get("assignmentid"),subtype:this.assignmentGrid.getSelectionModel().getSelected().get("subtype"),mode:1}),scope:this,success:function(result,req){Wtf.Msg.alert("Alert","Successfully notified students",function(btn){},this)},failure:function(result,req){Wtf.Msg.alert("Error","Error connecting to server",function(btn){},this)}})}},"-",{text:"Archive",scope:this,id:this.id+"archive",hidden:Wtf.realroles.indexOf("9")>-1&&this.moduleid=="d8bac987-cecd-4a3a-8079-2ec62a1c8228"?isRealRoles("48"):true,disabled:true,handler:function(){Wtf.Ajax.request({method:"POST",url:"jspfiles/admin/assignment.jsp",params:({action:33,modulerunid:this.moduleid,assignid:this.assignmentGrid.getSelectionModel().getSelected().get("assignmentid"),subtype:this.assignmentGrid.getSelectionModel().getSelected().get("subtype")}),scope:this,success:function(result,req){var respObj=eval("("+result.responseText+")");if(respObj){Wtf.Msg.alert("Success","Assignment has been archived successfully.",function(btn){},this);this.assignmentStore.load({params:{start:0,limit:15,pressed:false}});this.disableBbarBttns()}else{Wtf.Msg.alert("Error","You cant archive this assignment.",function(btn){},this)}},failure:function(result,req){Wtf.Msg.alert("Error","Error connecting to server",function(btn){},this)}})}}]:this.pg=new Wtf.PagingSearchToolbar({pageSize:15,displayMsg:"Displaying assignments {0} - {1} of {2}",emptyMsg:"No assignemnts to display",searchField:this.quickSearchTF,scope:this,id:"assignpageTB"+this.id,store:this.assignmentStore,plugins:this.pP=new Wtf.common.pPageSize({id:"pPageSizeAssign_"+this.id})}),items:this.assignmentGrid}),this.descriptionLP=new Wtf.Panel({title:this.faculty?"Submissions":"Description",region:this.faculty?"east":"south",border:false,split:true,layout:"fit",tbar:this.faculty?this.DescriptionLPTBar():null,bbar:this.subPageToolBar=this.faculty?new Wtf.PagingSearchToolbar({pageSize:20,id:"subpageTB"+this.id,searchField:this.quickSearchTFSub,store:this.submissionCheckedStore,scope:this,plugins:this.pP1=new Wtf.common.pPageSize({id:"pPageSizeSub_"+this.id}),items:[{text:"Download Assignments",scope:this,disabled:true,hidden:isRealRoles("48"),id:"downloadass"+this.id,handler:function(){var selected=this.submissionGrid.getSelectionModel().getSelections();var studentids="";var extns="";for(var i=0;i<selected.length;i++){studentids+=selected[i].json.id+"_";extns+=selected[i].json.ext+"_"}studentids=studentids.substring(0,studentids.length-1);extns=extns.substring(0,extns.length-1);setDldUrl("fileDownload.jsp?modulerunid="+this.moduleid+"&assignmentid="+this.assignmentGrid.getSelectionModel().getSelections()[0].get("assignmentid")+"&subtype="+this.assignmentGrid.getSelectionModel().getSelected().get("subtype")+"&dtype=attachment&type=ass&roleid="+roleid+"&studentid="+studentids);this.submissionCheckedStore.load({params:{start:this.subPageToolBar.cursor,limit:this.pP1.combo.value}})}}]}):null,bodyStyle:"background:transparent;",paging:false,items:this.faculty?this.submissionGrid:null,autoScroll:true})];this.innerPanel=new Wtf.Panel({border:false,layout:"border",items:items});this.innerPanel.addListener("resize",this.innerPanelResize,this)},innerPanelResize:function(C,A,B){if(this.faculty){this.descriptionLP.setWidth(A*50/100)}else{this.descriptionLP.setHeight(B*35/100)}this.innerPanel.doLayout()},createSubmissionGrid:function(){this.submissionGrid=new Wtf.grid.GridPanel({store:this.submissionCheckedStore,cm:this.submissionCM,sm:this.submissionSM,border:false,loadMask:{msg:"Loading..."},viewConfig:{forceFit:true}})},assignmentRender:function(E,C,A,F,D,B){return"<b>"+E+"</b>"},AssignmentLPTBar:function(){var A=["Quick Search: ",this.quickSearchTF=new Wtf.KWLTagSearch({field:"assignmentname"})];if(!this.faculty){A.push("-");A.push({text:"New Assignments",enableToggle:true,id:"newAss",toggleGroup:"studenttoggle"+this.id,pressed:true,scope:this,handler:function(){this.statusFlag=true;this.assignmentCM.setConfig(this.createAssignmentCM(true));this.assignmentGrid.store=this.assignmentStore;this.assignmentGrid.getView().refresh();this.assPageToolBar.bind(this.assignmentStore);this.quickSearchTF.StorageChanged(this.assignmentStore);this.assignmentStore.load({params:{start:0,limit:this.pP.combo.value}})}});A.push("-");A.push({text:"Submitted Assignments",enableToggle:true,toggleGroup:"studenttoggle"+this.id,scope:this,pressed:false,handler:function(){this.statusFlag=false;this.assignmentCM.setConfig(this.createAssignmentCM(false));this.assignmentGrid.store=this.assignmentSubStore;this.assignmentGrid.getView().refresh();this.assPageToolBar.bind(this.assignmentSubStore);this.quickSearchTF.StorageChanged(this.assignmentSubStore);this.assignmentSubStore.load({params:{start:0,limit:this.pP.combo.value}})}})}else{A.push("-");A.push({text:"Import Assignments",scope:this,pressed:false,hidden:isRealRoles("48"),handler:function(){var B=new Wtf.Window({id:"importAssignment",modal:true,border:false,height:500,width:500,title:"Assignment Bank",layout:"border",items:[{region:"north",border:false,height:75,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/createuser.png","Import Assignments","Enter assignment details")},{region:"center",border:false,layout:"fit",bodyStyle:"background:#f1f1f1;border-bottom:1px solid #bfbfbf;",items:[this.sendForm=new Wtf.form.FormPanel({waitMsgTarget:true,method:"POST",border:false,labelWidth:120,height:150,bodyStyle:"margin: 10px 0 0 10px;",defaults:{width:200},defaultType:"textfield",items:[this.impType=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{assname}" class="x-combo-list-item">{assname}</div></tpl>',fieldLabel:"Type*",hiddenName:"type",store:this.assTypeStore,readOnly:true,displayField:"assname",valueField:"asstypeid",mode:"local",triggerAction:"all",emptyText:"Select a type...",allowBlank:false,blankText:"Click to select an assignment type"}),this.impDate=new Wtf.form.DateField({fieldLabel:"Due Date*",format:Wtf.getDateFormat(),allowBlank:false}),this.impSubType=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{type}" class="x-combo-list-item">{type}</div></tpl>',fieldLabel:"Submission Type*",hiddenName:"subtype",store:this.subTypeStore,readOnly:true,displayField:"type",valueField:"id",mode:"local",triggerAction:"all",emptyText:"Select a type...",allowBlank:false,blankText:"Click to select Submission type"})]})]},{region:"south",layout:"fit",height:300,border:false,items:[this.abg=new Wtf.assignmentBankGrid({border:false,layout:"fit",mode:2,type:1,modulerunid:this.moduleid,asstype:this.impType,duedate:this.impDate,subtype:this.impSubType,obj:this.sendForm})]}]});this.abg.on("refreshassignmentgrid",function(){this.assignmentStore.reload()},this);B.show()}});this.assTypeStore.load({params:{action:12,modulerunid:this.moduleid,type:1}});if(Wtf.realroles.indexOf("9")>-1&&this.moduleid=="d8bac987-cecd-4a3a-8079-2ec62a1c8228"){A.push("-");A.push({text:"Archived Assignments",scope:this,id:this.id+"sub",enableToggle:true,pressed:false,handler:function(){this.assignmentStore.load({params:{start:0,limit:15,pressed:Wtf.getCmp(this.id+"sub").pressed}})}})}}return A},DescriptionLPTBar:function(){return["Quick Search: ",this.quickSearchTFSub=new Wtf.KWLTagSearch({field:"name"}),"-",{text:"Submitted Assignments",id:"subBttn",enableToggle:true,toggleGroup:"facultytoggle"+this.id,pressed:true,scope:this,handler:function(){this.submissionCM.setConfig(this.createSubmissionCM(false));this.submissionGrid.store=this.submissionCheckedStore;this.submissionGrid.getView().refresh();this.subPageToolBar.bind(this.submissionCheckedStore);this.quickSearchTFSub.StorageChanged(this.submissionCheckedStore);if(this.assignmentGrid.getSelectionModel().hasSelection()){this.submissionCheckedStore.load({params:{start:0,limit:this.pP1.combo.value}})}}},"-",{text:"Pending Assignments",enableToggle:true,id:"penBttn",toggleGroup:"facultytoggle"+this.id,pressed:false,scope:this,handler:function(){Wtf.getCmp("downloadass"+this.id).disable();this.submissionCM.setConfig(this.createSubmissionCM(true));this.submissionGrid.store=this.submissionUncheckedStore;this.submissionGrid.getView().refresh();this.subPageToolBar.bind(this.submissionUncheckedStore);this.quickSearchTFSub.StorageChanged(this.submissionUncheckedStore);var A=this.assignmentGrid.getSelectionModel().getSelected();if(this.assignmentGrid.getSelectionModel().hasSelection()&&A.get("submitable")==1){this.submissionUncheckedStore.load({params:{start:0,limit:this.pP1.combo.value}})}}}]},createNewAssignment:function(A){this.newAssignmentWin=new Wtf.Window({title:A.mode=="1"?"Edit Assignment":"Add Assignment",closable:true,modal:true,iconCls:"win",width:400,height:400,resizable:false,buttonAlign:"center",buttons:[{text:A.mode=="1"?"Edit":"Create",scope:this,tooltip:A.mode=="1"?"Edit Assignment":"Create Assignment",handler:function(){var E=this.monthDateWin.getValue();if(E){E=new Date(E);var F=E.getFullYear();var D=E.getMonth()+1;var B=(D<10)?"0"+D:D}this.appdateAss=F+"-"+B+"-01";if(this.sendForm.form.isValid()){var C=this.dateField.getRawValue();this.sendForm.form.submit({waitMsg:"Loading...",scope:this,params:{modulerunid:this.moduleid,mode:2,flag:A.mode=="1"?2:0,date:A.mode=="1"?Wtf.modifyDateFmt(C,Wtf.getDateFormat(),"Y-m-j"):"",isPO:isRealRoles("9"),appdate:this.appdateAss},failure:function(H,G){Wtf.MessageBox.show({title:"Failure",msg:A.mode=="1"?"Problem occurred while editing assignment":"Problem occurred while creating assignment",buttons:Wtf.MessageBox.OK,scope:this,fn:function(){this.newAssignmentWin.close();this.disableBbarBttns()},icon:Wtf.MessageBox.INFO})},success:function(H,G){Wtf.MessageBox.show({title:"Success",msg:A.mode=="1"?"Assignment edited successfully":"Assignment created successfully",buttons:Wtf.MessageBox.OK,scope:this,fn:function(){this.newAssignmentWin.close();this.disableBbarBttns()},icon:Wtf.MessageBox.INFO});this.assignmentStore.load()}})}}},{text:"Cancel",scope:this,tooltip:"Cancel & Close Window.",handler:function(){this.newAssignmentWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:getHeader("images/createuser.gif",A.mode=="1"?"Edit Assignment":"Add Assignment",A.mode=="1"?"Edit a Assignment":"Add a new assignment.")},{region:"center",border:false,bodyStyle:"background:#f1f1f1;border-bottom:1px solid #bfbfbf;",layout:"fit",items:[this.sendForm=new Wtf.form.FormPanel({url:"jspfiles/student/gradeBook.jsp",waitMsgTarget:true,method:"POST",border:false,labelWidth:120,height:150,bodyStyle:"margin: 10px 0 0 10px;",defaults:{width:200},defaultType:"textfield",items:[this.nameField=new Wtf.form.TextField({fieldLabel:"Assignment Name*",name:"name",disabled:false,allowBlank:false,maxLength:50,value:A.mode=="1"?this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentname:"",validator:function(B){if(B.search("/")==-1){return true}else{return"Assignment name should not contain a /"}}}),this.typeField=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{assname}" class="x-combo-list-item">{assname}</div></tpl>',fieldLabel:"Type*",disabled:A.mode=="1"?true:false,hiddenName:"type",store:this.assTypeStore,displayField:"assname",valueField:"asstypeid",mode:"local",triggerAction:"all",emptyText:"Select a type...",allowBlank:false,blankText:"Click to select an assignment type"}),this.dateField=new Wtf.form.DateField({fieldLabel:"Due Date*",format:Wtf.getDateFormat(),disabled:isRealRoles("9"),allowBlank:false,value:A.mode=="1"?this.assignmentGrid.getSelectionModel().getSelections()[0].json.subdate:""}),this.monthDateWin=new Wtf.MonthField({fieldLabel:"Month-Year*",name:"appdateone",noPastYears:false,allowBlank:false,disabled:A.mode=="1"?true:false,value:A.mode=="1"?this.assignmentGrid.getSelectionModel().getSelections()[0].json.appdatestring:""}),new Wtf.form.TextArea({fieldLabel:"Description*",height:80,allowBlank:false,maxLength:1024,name:"desc",readOnly:(isRoleGroup("4")||Wtf.realroles.indexOf("9")>-1)?false:(A.owner=="1"?false:true),value:A.mode=="1"?this.assignmentGrid.getSelectionModel().getSelections()[0].json.description:""}),this.subType=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{type}" class="x-combo-list-item">{type}</div></tpl>',fieldLabel:"Submission Type*",hiddenName:"subtype",store:this.subTypeStore,readOnly:true,displayField:"type",valueField:"id",mode:"local",triggerAction:"all",emptyText:"Select a type...",allowBlank:false,blankText:"Click to select Submission type"}),new Wtf.form.Hidden({name:"assignmentid",value:A.mode=="1"?this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentid:""})]})]}]});this.newAssignmentWin.show();if(A.mode=="1"){this.assTypeStore.on("load",function(B){this.typeField.setValue(this.assignmentGrid.getSelectionModel().getSelections()[0].json.type)},this);this.assTypeStore.load({params:{action:12,modulerunid:this.moduleid,type:1}});this.subType.setValue(this.assignmentGrid.getSelectionModel().getSelections()[0].json.subtype)}else{this.assTypeStore.load({params:{action:12,modulerunid:this.moduleid,type:1}})}},assignmentGridRowClicked:function(A,B,C){this.assignmentGrid.getSelectionModel().selectRow(B,false);if(this.assignmentGrid.getSelectionModel().getSelections()[0].json.id==null){if(!this.faculty){this.descriptionTpl.overwrite(this.descriptionLP.el.dom.firstChild.nextSibling.firstChild,this.assignmentGrid.getSelectionModel().getSelections()[0]);if(C.getTarget().className=="down-assignment-img"){setDldUrl("fileDownload.jsp?modulerunid="+this.moduleid+"&assignmentid="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentid+"&dtype=attachment&assignmentname="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentname+"&ext="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.ext+"&type=ass&roleid="+roleid)}else{if(C.getTarget().className=="down-studassignment-img"){setDldUrl("fileDownload.jsp?modulerunid="+this.moduleid+"&assignmentid="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentid+"&dtype=attachment&ext="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.extn+"&type=studDwld&roleid="+roleid+"&sid="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.sid+"&subtype="+this.assignmentGrid.getSelectionModel().getSelections()[0].json.subtype)}else{if(C.getTarget().className=="up-assignment-img"){Wtf.Ajax.requestEx({method:"POST",url:"jspfiles/student/submitAssignment.jsp",params:({flag:2,modulerunid:this.moduleid,assignid:this.assignmentGrid.getSelectionModel().getSelected().get("assignmentid")})},this,function(E,F){var G=Wtf.decode(E);if(G.flag==0){this.uploadFile()}else{Wtf.MessageBox.show({title:"Submit Assignment",msg:"Are you sure you want to submit the assignment after due date",buttons:Wtf.MessageBox.YESNO,icon:Wtf.MessageBox.WARNING,scope:this,fn:function(H){if(H=="yes"){this.uploadFile()}}})}},function(E,F){msgBoxShow(["Alert","Operation Failed"],Wtf.MessageBox.INFO)})}}}}else{var D=this.assignmentGrid.getSelectionModel().getSelected();if(this.assignmentGrid.getSelectionModel().getSelections().length>0&&D.get("submitable")==1){this.submissionUncheckedStore.baseParams={assignmentid:this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentid,subtype:this.assignmentGrid.getSelectionModel().getSelections()[0].json.subtype,modulerunid:this.moduleid,mode:"0"};this.submissionUncheckedStore.load({params:{start:0,limit:this.pP1.combo.value}});this.submissionCheckedStore.baseParams={assignmentid:this.assignmentGrid.getSelectionModel().getSelections()[0].json.assignmentid,subtype:this.assignmentGrid.getSelectionModel().getSelections()[0].json.subtype,modulerunid:this.moduleid,mode:"1"};this.submissionCheckedStore.load({params:{start:0,limit:this.pP1.combo.value}});if(this.assignmentGrid.getSelectionModel().getSelections()[0].get("owner")=="1"||isRealRoles("9")){Wtf.getCmp(this.assPageToolBar[6].id).enable()}else{if(!isRealRoles("9")){Wtf.getCmp(this.assPageToolBar[6].id).disable()}}Wtf.getCmp(this.assPageToolBar[2].id).enable();Wtf.getCmp(this.assPageToolBar[4].id).enable();Wtf.getCmp(this.assPageToolBar[8].id).enable();Wtf.getCmp(this.assPageToolBar[10].id).enable();Wtf.getCmp(this.assPageToolBar[12].id).enable()}}}},uploadFile:function(check){if(this.assignmentGrid.getSelectionModel().getSelections()[0].get("subtype")=="1"){this.teamListStore=new Wtf.data.JsonStore({root:"data",fields:["teamid","teamname"],url:"jspfiles/admin/assignment.jsp"});this.teamListStore.load({params:{action:26,moduleid:this.moduleid}});this.teamListStore.on("load",function(){if(this.teamListStore.getCount()>0){this.teamlist.setValue(this.teamListStore.getAt(0).data["teamid"])}},this)}this.newUploadWin=new Wtf.Window({title:(isRoleGroup("1")||roleid=="45")?"Submit Assignment":"Upload Assignment File",closable:true,modal:true,iconCls:"win",width:400,height:230,resizable:false,buttonAlign:"right",buttons:[{text:"Upload",scope:this,handler:function(){if(this.newUploadWin.buttons[0].getText()=="Upload"){this.newUploadWin.buttons[0].disable();this.newUploadWin.buttons[0].setText("OK");this.newUploadWin.buttons[1].disable();this.fileUploadForm.form.submit({scope:this,params:{check:"faculty",teamid:this.teamlist.getValue(),isPO:isRealRoles("9")},failure:function(frm,action){this.uploadbar.reset();this.uploadbar.updateText("Error Submitting...");this.newUploadWin.buttons[0].enable();this.newUploadWin.buttons[1].enable();if(!isRoleGroup("1")&&!roleid=="45"){this.disableBbarBttns()}},success:function(frm,action){var respObj=eval("("+action.response.responseText+")");this.uploadbar.reset();this.uploadbar.updateProgress(respObj.data[0].msg=="true"?1:0,respObj.data[0].msg);this.newUploadWin.buttons[0].enable();this.newUploadWin.buttons[1].enable();if((isRoleGroup("1")||roleid=="45")){this.assignmentStore.load({params:{start:0,limit:this.pP.combo.value}});this.assignmentSubStore.load({params:{start:0,limit:this.pP.combo.value}})}else{this.assignmentStore.reload();this.disableBbarBttns()}}});this.fileUploadForm.hide();this.uploadbar.show();this.uploadbar.wait()}else{this.newUploadWin.close()}}},{text:"Cancel",scope:this,handler:function(){this.newUploadWin.close()}}],layout:"border",items:[{region:"north",height:75,border:false,bodyStyle:"background:white;border-bottom:1px solid #bfbfbf;",html:(isRoleGroup("1")||roleid=="45")?getHeader("images/upload52.gif","Submit Assignment File","Upload your assignment file to be submitted."):getHeader("images/upload52.gif","Upload Assignment File","Upload assignment file for the students to view.")},{region:"center",border:false,bodyStyle:"background:#f1f1f1;padding:20px 20px 20px 20px;",layout:"fit",items:[{border:false,layout:"fit",items:[this.fileUploadForm=new Wtf.form.FormPanel({url:(isRoleGroup("1")||roleid=="45")?"jspfiles/student/submitAssignment.jsp?flag=1":"jspfiles/faculty/uploadAssignmentFile.jsp",waitMsgTarget:true,method:"POST",border:false,fileUpload:true,labelWidth:100,defaultType:"textfield",items:[{fieldLabel:"Assignment File",inputType:"file",id:"fileinput"+this.id,name:"filepath"},this.teamlist=new Wtf.form.ComboBox({tpl:'<tpl for="."><div wtf:qtip="{teamname}" class="x-combo-list-item">{teamname}</div></tpl>',fieldLabel:"Team*",hiddenName:"team",hidden:(isRoleGroup("1")||roleid=="45")?false:true,hideLabel:(isRoleGroup("1")||roleid=="45")?false:true,store:this.teamListStore,readOnly:true,displayField:"teamname",disabled:true,valueField:"teamid",mode:"local",triggerAction:"all",emptyText:"Select a team...",allowBlank:false,blankText:"Click to select a team"}),new Wtf.form.Hidden({name:"assignmentid",value:this.assignmentGrid.getSelectionModel().getSelections()[0].get("assignmentid")}),new Wtf.form.Hidden({name:(isRoleGroup("1")||roleid=="45")?"studentid":"assignmentname",value:(isRoleGroup("1")||roleid=="45")?this.assignmentGrid.getSelectionModel().getSelections()[0].json.id:this.assignmentGrid.getSelectionModel().getSelections()[0].get("assignmentname")}),new Wtf.form.Hidden({name:"modulerunid",value:this.moduleid}),new Wtf.form.Hidden({name:"subtype",value:this.assignmentGrid.getSelectionModel().getSelections()[0].get("subtype")}),new Wtf.form.Hidden({name:"appdate",value:(this.assignmentGrid.getSelectionModel().getSelections()[0].get("appdate")!=""&&this.assignmentGrid.getSelectionModel().getSelections()[0].get("appdate")!=undefined&&this.assignmentGrid.getSelectionModel().getSelections()[0].get("appdate")!=null)?this.assignmentGrid.getSelectionModel().getSelections()[0].get("appdate").format("Y-m-d"):" "})]}),this.uploadbar=new Wtf.ProgressBar({text:"Submitting ...",id:"uploadfile"+this.id,hidden:true})]}]}]});if((isRoleGroup("1")||roleid=="45")){if(this.assignmentGrid.getSelectionModel().getSelections()[0].get("subtype")=="1"){this.teamlist.enable()}}this.newUploadWin.show()},disableBbarBttns:function(){Wtf.getCmp(this.assPageToolBar[2].id).disable();Wtf.getCmp(this.assPageToolBar[4].id).disable();Wtf.getCmp(this.assPageToolBar[6].id).disable();Wtf.getCmp(this.assPageToolBar[8].id).disable();Wtf.getCmp(this.assPageToolBar[10].id).disable();Wtf.getCmp(this.assPageToolBar[12].id).disable()}})
