1
0

mark-status.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //评卷状态模块
  2. var mark_status = function(option, success) {
  3. var object = new MarkStatus(option);
  4. success();
  5. return object;
  6. }
  7. function MarkStatus(option) {
  8. this.markControl = option.markControl;
  9. this.init(option);
  10. this.markControl.on('task.get.before', this, function(event, context, statusInfo) {
  11. this.changeStatus(getMessage('mark.status.loading'));
  12. this.clearTopTitle();
  13. });
  14. this.markControl.on('task.get.success', this, function(event, context, eventObject) {
  15. var task = context.task;
  16. this.changeStatus(task.statusName);
  17. //修改页面显示
  18. if(task.studentNumber && task.studentNumber!=''){
  19. this.topStatus.find('#student-number').html(task.studentNumber);
  20. this.studentTitle.show();
  21. }else{
  22. this.studentTitle.hide();
  23. }
  24. if(task.taskNumber && task.taskNumber!=''){
  25. this.topStatus.find('#library-number').html(task.taskNumber);
  26. this.libraryTitle.show();
  27. }else{
  28. this.libraryTitle.hide();
  29. }
  30. if (task.objectiveScore) {
  31. this.objectiveArea.find('#objective-score').html(task.objectiveScore);
  32. this.objectiveArea.show();
  33. } else {
  34. this.objectiveArea.hide();
  35. }
  36. this.checkTopCount(task);
  37. });
  38. this.markControl.on('task.get.none', this, function(event, context, status) {
  39. this.changeStatus();
  40. this.clearTopTitle();
  41. });
  42. this.markControl.on('task.get.finish', this, function(event, context, status) {
  43. this.changeStatus();
  44. this.clearTopTitle();
  45. });
  46. this.markControl.on('mark.status.change', this, function(event, context, status) {
  47. this.status = status;
  48. this.render(status);
  49. });
  50. this.markControl.on('view.sidebar.open', this, function(event, context, eventObject) {
  51. this.progress.hide();
  52. });
  53. this.markControl.on('view.sidebar.close', this, function(event, context, eventObject) {
  54. this.progress.show();
  55. });
  56. }
  57. MarkStatus.prototype.init = function(option) {
  58. this.topStatus = getDom(this.status_dom, this.markControl).prependTo(this.markControl.container.header);
  59. this.progress = getDom(this.progress_dom, this.markControl).insertAfter(this.topStatus);
  60. this.subjectTitle = this.topStatus.find('#subject-title');
  61. this.libraryTitle = this.topStatus.find('#library-title');
  62. this.studentTitle = this.topStatus.find('#student-title');
  63. this.objectiveArea = this.topStatus.find('#objective-area');
  64. this.popover = getDom(this.popover_dom, this.markControl);
  65. this.popover.hide();
  66. this.popover.appendTo(this.markControl.container);
  67. var self = this;
  68. this.popover.find('#continue-button').click(function() {
  69. self.ignoreTopCount = true;
  70. self.popover.hide();
  71. });
  72. this.subjectTitle.find('#subject-name').html(option.subjectName);
  73. if (option.subjectSelectUrl != undefined) {
  74. this.subjectTitle.click(function() {
  75. window.location.href = option.subjectSelectUrl;
  76. });
  77. }
  78. }
  79. MarkStatus.prototype.checkTopCount = function(task) {
  80. //任务限额提示
  81. if (task != undefined && task.previous != true && this.status != undefined && this.status.topCount > 0 && this.status.personCount >= this.status.topCount && this.ignoreTopCount != true) {
  82. this.popover.show();
  83. } else {
  84. this.popover.hide();
  85. }
  86. }
  87. MarkStatus.prototype.clearTopTitle = function() {
  88. this.topStatus.find('#student-number').html('');
  89. this.topStatus.find('#library-number').html('');
  90. this.topStatus.find('#objective-score').html('');
  91. this.studentTitle.hide();
  92. this.libraryTitle.hide();
  93. this.objectiveArea.hide();
  94. }
  95. MarkStatus.prototype.changeStatus = function(name) {
  96. if(name!=undefined && name!=''){
  97. this.topStatus.find('#status-name').html(name);
  98. }else{
  99. this.topStatus.find('#status-name').html('');
  100. }
  101. }
  102. MarkStatus.prototype.changeTopCount = function(topCount) {
  103. if(topCount && topCount > 0){
  104. this.progress.find('#top-count').html(topCount);
  105. this.progress.find('#top-count-area').show();
  106. }else{
  107. this.progress.find('#top-count').html('');
  108. this.progress.find('#top-count-area').hide();
  109. }
  110. }
  111. MarkStatus.prototype.render = function(status) {
  112. if (status != undefined && status.valid === true) {
  113. //个人评卷数量
  114. this.topStatus.find('#person-count').html(status.personCount);
  115. //大题进度信息区域
  116. var totalCount = status.totalCount;
  117. var markedCount = status.markedCount;
  118. var exceptionCount = status.exceptionCount;
  119. var leftCount = totalCount > (markedCount + exceptionCount) ? (totalCount - markedCount - exceptionCount) : 0;
  120. var markedPercent = totalCount > 0 ? new Number((totalCount - leftCount) * 100 / totalCount).toFixed(0) : '0';
  121. if (markedPercent == '100' && leftCount > 0) {
  122. markedPercent = '99';
  123. } else if (markedPercent == '0' && markedCount > 0) {
  124. markedPercent = '1';
  125. }
  126. this.progress.find('#total-count').html(totalCount);
  127. this.progress.find('#marked-count').html(markedCount);
  128. this.progress.find('#todo-count').html(leftCount);
  129. this.progress.find('#exception-count').html(exceptionCount);
  130. this.progress.find('#marked-percent').html(markedPercent + '%');
  131. //评卷任务上限
  132. this.changeTopCount(status.topCount);
  133. //判断评卷是否结束
  134. if (status.totalCount > 0 && status.totalCount == status.markedCount) {
  135. this.markControl.context.isFinish = true;
  136. }
  137. }
  138. }
  139. MarkStatus.prototype.status_dom = '<p class="text">\
  140. <i id="subject-title" style="cursor:pointer"><em id="subject-name"></em></i>\
  141. <i id="status-title"><em id="status-name" data-i18n-text="mark.status.loading"></em></i>\
  142. <i id="library-title" style="display:none"><span data-i18n-text="mark.status.library.number">任务编号</span><em id="library-number"></em></i>\
  143. <i id="student-title" style="display:none"><span data-i18n-text="mark.status.student.number">考生编号</span><em id="student-number"></em></i>\
  144. <i id="objective-area" style="display:none"><span data-i18n-text="mark.status.objective.score">客观得分</span><em id="objective-score"></em></i>\
  145. <i><span data-i18n-text="mark.status.marked.count">已评</span><em id="person-count"></em></i>\
  146. </p>';
  147. MarkStatus.prototype.progress_dom = '<p class="text">\
  148. <i id="top-count-area" style="display:none"><span data-i18n-text="mark.status.top.count">分配</span><em id="top-count"></em></i>\
  149. <i><span data-i18n-text="mark.status.unmark.count">未评</span><em id="todo-count"></em></i>\
  150. <i><span data-i18n-text="mark.status.progress">进度</span><em id="marked-percent"></em></i>\
  151. </p>';
  152. MarkStatus.prototype.popover_dom = '<div class="warning-popover">\
  153. <p data-i18n-text="mark.status.top.count.finish">分配任务已评完,是否继续?</p>\
  154. <a href="#" class="btn btn-large btn-primary text-c" id="continue-button" data-i18n-text="mark.status.continue">继续</a>\
  155. <a href="{logoutUrl}" class="btn btn-large text-c" id="exit-button" data-i18n-text="mark.status.logout">退出</a>\
  156. </div>';