123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- //回评模块
- var mark_history = function(option, success) {
- var object = new MarkHistory(option);
- success();
- return object;
- }
- function MarkHistory(option) {
- this.markControl = option.markControl;
- //this.url = option.url;
- this.pageSize = option.pageSize;
- this.taskList = [];
- this.container = this.markControl.container.sidebar;
- this.loading = false;
- this.order = "time"
- this.sort = "desc";
- var isTag = false;
- this.markControl.initMarkFunction();
- this.container.toggleButton = getDom(this.toggle_button_dom, this.markControl).appendTo(this.markControl.container.assistant.functionList);
- this.container.toggleButton.click(this, function(event) {
- event.data.toggle(true);
- });
- this.markControl.on('history.get.success', this, function(event, context, data) {
- var taskList = data.result;
- this.taskList = [];
- this.loading = false;
- this.container.list.empty();
- if (isArray(taskList) && taskList.length > 0) {
- this.taskList = taskList;
- for (var i in taskList) {
- var task = taskList[i];
- var row = getDom(this.history_row_dom, this.markControl).appendTo(this.container.list);
- row.find('.history-secret-number').html(task.studentId);
- if(task.tags!=undefined && task.tags!=null ){
- row.find('.history-secret-number').addClass('tips');
- }
- var date = new Date();
- date.setTime(task.markTime);
- row.find('.history-time').html(date.format('hh:mm:ss'));
- row.find('.history-score').html(task.totalScore);
- row.attr('data-index', i);
-
- //回评任务处理
- task.previous = true;
- // task.markFinish = true;
- // task.totalScore = parseFloat(task.totalScore);
- // var scoreList = task.scoreList != undefined ? task.scoreList.split(',') : [];
- // for (var j in task.markStepList) {
- // var step = task.markStepList[j];
- // if (scoreList != undefined && scoreList.length > j) {
- // step.markScore = new Number(scoreList[j]);
- // step.score = new String(step.markScore);
- // step.markFinish = true;
- // }
- // }
- }
- }
- this.container.list.find('td').click(this, function(event) {
- var markHistory = event.data;
- var index = $(event.target).parent().attr('data-index');
- markHistory.onTaskSelect(index);
- });
- this.pageNumber = data.pageNumber;
- this.updatePage();
- this.updateSort(this.order,this.sort);
- if (this.taskList.length > 0) {
- this.onTaskSelect(0);
- }
- });
- this.markControl.on('history.get.error', this, function(event, context, data) {
- alert('暂时无法读取评卷历史,请稍后重试');
- });
- this.markControl.on('task.submit.success', this, function(event, context, data) {
- if (this.enable) {
- this.toggle(false);
- }
- });
- this.markControl.on('task.get.success', this, function(event, context, data) {
- this.loading = false;
- });
- this.markControl.on('history.submit.success', this, function(event, context, task) {
- if(task.previous==true){
- this.updateTaskScore(task.totalScore);
- }
- });
- }
- MarkHistory.prototype.init = function() {
- this.container.empty();
- this.container.paginator = getDom(this.paginator_dom, this.markControl).appendTo(this.container);
- this.container.header = getDom(this.header_dom, this.markControl).appendTo(this.container);
- this.container.search = getDom(this.history_search_dom, this.markControl).appendTo(this.container).find('#history-search');
- this.container.list = getDom(this.history_list_dom, this.markControl).appendTo(this.container).find('#history-list');
-
- var self = this;
- this.container.header.find('#close-history-button').click(this, function(event) {
- event.data.toggle(false);
- self.markControl.context.task = undefined;
- self.markControl.getTask();
- })
- this.container.paginator.find('#last-page-button').click(this, function(event) {
- var markHistory = event.data;
- if (markHistory.taskList.length < markHistory.pageSize) {
- return ;
- }
- if (self.container.search.find('#history-isTag').prop("checked")) {
- markHistory.isTag=true;
- } else{
- markHistory.isTag=false;
- }
- markHistory.onSearch(markHistory.pageNumber + 1,markHistory.order,markHistory.sort,markHistory.isTag);
- });
- this.container.paginator.find('#next-page-button').click(this, function(event) {
- var markHistory = event.data;
- if (markHistory.pageNumber == 1) {
- return ;
- }
- if (markHistory.pageNumber > 1) {
- if (self.container.search.find('#history-isTag').prop("checked")) {
- markHistory.isTag=true;
- } else{
- markHistory.isTag=false;
- }
- markHistory.onSearch(markHistory.pageNumber - 1,markHistory.order,markHistory.sort,markHistory.isTag);
- }
- });
- this.container.find('#studentId-search').click(this, function(event) {
- var markHistory = event.data;
- var studentId = self.container.find('#studentId-in').val();
- var re = /^[1-9]+[0-9]*]*$/ ;
- if(!re.test(studentId)){
- alert("请输入数字");
- return ;
- }
- if (self.container.search.find('#history-isTag').prop("checked")) {
- markHistory.isTag=true;
- } else{
- markHistory.isTag=false;
- }
- markHistory.onSearch(0,markHistory.order,markHistory.sort,markHistory.isTag,studentId);
- });
- this.container.find('#time-sort-th').click(this, function(event) {
- self.orderSearch("time");
- });
- this.container.find('#studentId-sort-th').click(this, function(event) {
- self.orderSearch("studentId");
- });
- this.container.find('#score-sort-th').click(this, function(event) {
- self.orderSearch("score");
- });
-
- self.updateSort(self.order,self.sort);
- self.updateLoading();
-
- this.container.find('#studentId-in').click(this, function(event) {
- self.markControl.trigger('mark.focus.change');
- });
- }
- MarkHistory.prototype.orderSearch = function(order) {
- this.order = order;
- if(this.sort == "asc"){
- this.sort = "desc";
- }else if(this.sort == "desc"){
- this.sort = "asc";
- }
- if (this.container.search.find('#history-isTag').prop("checked")) {
- this.isTag=true;
- } else{
- this.isTag=false;
- }
- this.onSearch(this.pageNumber,this.order,this.sort,this.isTag);
- }
- MarkHistory.prototype.toggle = function(enable) {
- this.enable = enable;
- if (enable) {
- this.init();
- this.pageNumber = 1;
- this.markControl.setTask(undefined);
- this.markControl.trigger('mark.sidebar.open');
- this.markControl.trigger('mark.history.open');
- this.updatePage();
- this.container.list.empty();
- this.container.show();
- this.onSearch();
- } else {
- this.container.hide();
- this.markControl.trigger('mark.sidebar.close');
- this.markControl.trigger('mark.history.close');
- }
- }
- MarkHistory.prototype.updatePage = function() {
- this.container.paginator.find('#history-start').html(this.pageSize * (this.pageNumber - 1));
- this.container.paginator.find('#history-end').html(this.pageSize * this.pageNumber);
- // if (this.pageNumber == 1) {
- // this.container.paginator.find('#next-page-button').hide();
- // }else{
- // this.container.paginator.find('#next-page-button').show();
- // }
- // if (this.taskList.length < this.pageSize) {
- // this.container.paginator.find('#last-page-button').hide();
- // } else{
- // this.container.paginator.find('#last-page-button').show();
- // }
-
- }
- MarkHistory.prototype.updateLoading = function() {
- if (this.loading) {
- this.container.find('#history-loading').show();
- }else{
- this.container.find('#history-loading').hide();
- }
- }
- MarkHistory.prototype.updateSort = function(order,sort) {
- this.container.find('#time-sort').removeClass();
- this.container.find('#studentId-sort').removeClass();
- this.container.find('#score-sort').removeClass();
- if(sort == 'desc'){
- this.container.find('#'+order+'-sort').addClass("down");
- }else{
- this.container.find('#'+order+'-sort').addClass("up");
- }
-
-
- }
- MarkHistory.prototype.onSearch = function(pageNumber,order,sort,isTag,studentId) {
- if (pageNumber == undefined || pageNumber < 1) {
- pageNumber = 1;
- }
- if (order == undefined ) {
- order = "time";
- }
- if (sort == undefined ) {
- sort = "desc";
- }
- if (isTag == undefined ) {
- isTag = false;
- }
- if (studentId == undefined || studentId=="") {
- studentId = null;
- }
- this.markControl.getHistory({
- pageNumber: pageNumber,
- pageSize: this.pageSize,
- order : order,
- sort : sort,
- isTag : isTag,
- studentId :studentId
- });
- }
- MarkHistory.prototype.onTaskSelect = function(index) {
- var number = new String(index);
- if (this.taskList != undefined && index < this.taskList.length && this.loading != true) {
- this.container.list.find('tr').each(function(index, obj) {
- if ($(obj).attr('data-index') == number) {
- $(obj).addClass('active');
- } else {
- $(obj).removeClass('active');
- }
- });
- var task = this.taskList[index];
- this.markControl.setTask(task);
- this.loading = true;
- }
- }
- MarkHistory.prototype.updateTaskScore = function(score) {
- this.container.list.find('tr').each(function(index, obj) {
- if ($(obj).hasClass("active")) {
- $(obj).find('td').last().html(score);
- }
- });
- }
- MarkHistory.prototype.toggle_button_dom = '<a href="#">回评</a>';
- MarkHistory.prototype.header_dom = '<div class="header">\
- <p class="fl">回评</p>\
- <a href="#" id="close-history-button"><img src="{staticServer}/mark-new/images/hp-close.png" /></a>\
- </div>';
- MarkHistory.prototype.paginator_dom = '<div class="c-page">\
- <a class="back" id="last-page-button" href="#"></a>\
- <a class="next" id="next-page-button" href="#"></a>\
- <span>前<i class="yellow" id="history-start"></i>-前<i class="yellow" id="history-end"></i></span>\
- </div>';
- MarkHistory.prototype.history_search_dom = '<div class="c-scbar cl">\
- <table id="history-search" cellpadding="0" cellspacing="0" width="100%">\
- <tr><td class="sc"><span><input type="text" placeholder="查找试卷" id="studentId-in" maxlength="10"/><em id="studentId-search"></em></span></td>\
- </tr></table></div>';
- MarkHistory.prototype.history_list_dom = '<div class="sublist"><div class="c-table">\
- <table class="table table-hover" cellpadding="0" cellspacing="0" width="100%">\
- <thead><tr><th id="studentId-sort-th">编号<em class="up" id="studentId-sort"></th>\
- <th id="time-sort-th">时间<em class="up" id="time-sort"></em></th><th id="score-sort-th">总分<em class="up" id="score-sort"></th></tr></thead>\
- <tbody class="loding" id="history-loading"><tr><td colspan="3"><div><img src="{staticServer}/mark-new/images/loding.gif"/></div><p>正在加载请稍候</p></td></tr></tbody>\
- <tbody id="history-list"></tbody></table></div></div>';
- MarkHistory.prototype.history_row_dom = '<tr><td class="history-secret-number"></td>\
- <td class="history-time"></td><td class="history-score"></td></tr>';
|