mark-status.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.topStatus.find('#stage-name').html('正在加载');
  12. });
  13. this.markControl.on('task.get.success', this, function(event, context, eventObject) {
  14. var task = context.task;
  15. //修改页面显示
  16. this.topStatus.find('#stage-name').html('');
  17. this.topStatus.find('#student-number').html(task.studentId);
  18. this.studentTitle.show();
  19. if (task.objectiveScore != undefined) {
  20. this.objectiveArea.find('#objective-score').html(task.objectiveScore);
  21. this.objectiveArea.show();
  22. } else {
  23. this.objectiveArea.hide();
  24. }
  25. this.checkTopCount(task);
  26. });
  27. this.markControl.on('task.get.none', this, function(event, context, status) {
  28. this.topStatus.find('#stage-name').html('');
  29. this.topStatus.find('#student-number').html('');
  30. this.studentTitle.hide();
  31. this.objectiveArea.hide();
  32. });
  33. this.markControl.on('task.get.finish', this, function(event, context, status) {
  34. this.topStatus.find('#stage-name').html('');
  35. this.topStatus.find('#student-number').html('');
  36. this.studentTitle.hide();
  37. this.objectiveArea.hide();
  38. });
  39. this.markControl.on('mark.status.change', this, function(event, context, status) {
  40. this.status = status;
  41. this.render(status);
  42. });
  43. this.markControl.on('view.sidebar.open', this, function(event, context, eventObject) {
  44. this.blockProgress.hide();
  45. });
  46. this.markControl.on('view.sidebar.close', this, function(event, context, eventObject) {
  47. this.blockProgress.show();
  48. });
  49. }
  50. MarkStatus.prototype.init = function(option) {
  51. this.topStatus = getDom(this.status_dom, this.markControl).prependTo(this.markControl.container.header);
  52. this.blockProgress = getDom(this.progress_dom, this.markControl).insertAfter(this.topStatus);
  53. this.subjectTitle = this.topStatus.find('#subject-title');
  54. this.studentTitle = this.topStatus.find('#student-title');
  55. this.objectiveArea = this.topStatus.find('#objective-area');
  56. this.popover = getDom(this.popover_dom, this.markControl);
  57. this.popover.hide();
  58. this.popover.appendTo(this.markControl.container);
  59. var self = this;
  60. this.popover.find('#continue-button').click(function() {
  61. self.ignoreTopCount = true;
  62. self.popover.hide();
  63. });
  64. this.subjectTitle.find('#subject-name').html(option.subjectName);
  65. if (option.subjectSelectUrl != undefined) {
  66. this.subjectTitle.click(function() {
  67. window.location.href = option.subjectSelectUrl;
  68. });
  69. }
  70. }
  71. MarkStatus.prototype.checkTopCount = function(task) {
  72. //任务限额提示
  73. if (task != undefined && task.previous != true && this.status != undefined && this.status.topCount > 0 && this.status.markedCount >= this.status.topCount && this.ignoreTopCount != true) {
  74. this.popover.show();
  75. } else {
  76. this.popover.hide();
  77. }
  78. }
  79. MarkStatus.prototype.render = function(status) {
  80. if (status != undefined && status.valid === true) {
  81. var topCount = status.topCount;
  82. this.topStatus.find('#mark-count').html(status.personCount);
  83. //大题进度信息区域
  84. if (this.blockProgress != undefined) {
  85. var totalCount = status.totalCount;
  86. var markedCount = status.markedCount;
  87. var exceptionCount = status.exceptionCount;
  88. var leftCount = totalCount > (markedCount + exceptionCount) ? (totalCount - markedCount - exceptionCount) : 0;
  89. var markedPercent = totalCount > 0 ? new Number((totalCount - leftCount) * 100 / totalCount).toFixed(0) : '0';
  90. if (markedPercent == '100' && leftCount > 0) {
  91. markedPercent = '99';
  92. } else if (markedPercent == '0' && markedCount > 0) {
  93. markedPercent = '1';
  94. }
  95. if(topCount > 0){
  96. if(this.blockProgress.find('#top-count').length == 0){
  97. this.blockProgress.find('#todo-count').after('<i>任务数<em id="top-count"></em></i>');
  98. this.blockProgress.find('#top-count').html(topCount);
  99. }
  100. }
  101. this.blockProgress.find('#total-count').html(totalCount);
  102. this.blockProgress.find('#marked-count').html(markedCount);
  103. this.blockProgress.find('#todo-count').html(leftCount);
  104. this.blockProgress.find('#exception-count').html(exceptionCount);
  105. this.blockProgress.find('#marked-percent').html(markedPercent + '%');
  106. }
  107. if (status.totalCount > 0 && status.totalCount == status.markedCount) {
  108. this.markControl.context.isFinish = true;
  109. }
  110. }
  111. }
  112. MarkStatus.prototype.status_dom = '<p class="text">\
  113. <i id="subject-title" style="cursor:pointer"><em id="subject-name"></em></i>\
  114. <i id="stage-name"></i>\
  115. <i id="student-title">考生编号<em id="student-number"></em></i>\
  116. <i id="objective-area">客观得分<em id="objective-score"></em></i>\
  117. <i>评卷数<em id="mark-count"></em></i>\
  118. </p>';
  119. MarkStatus.prototype.progress_dom = '<p class="text">\
  120. <i>未评<em id="todo-count"></em></i>\
  121. <i>进度<em id="marked-percent"></em></i>\
  122. </p>';
  123. MarkStatus.prototype.block_progress_bak_dom = '<p class="text">\
  124. <i>总数<em id="total-count"></em></i>\
  125. <i>已评<em id="marked-count"></em></i>\
  126. <i>未评<em id="todo-count"></em></i>\
  127. <i>异常<em id="exception-count"></em></i>\
  128. <i>进度<em id="marked-percent"></em></i>\
  129. </p>';
  130. MarkStatus.prototype.popover_dom = '<div class="warning-popover">\
  131. <p>分配任务已评完,是否继续?</p>\
  132. <a href="#" class="btn btn-large btn-primary text-c" id="continue-button">继续</a>\
  133. <a href="{logoutUrl}" class="btn btn-large text-c" id="exit-button">退出</a>\
  134. </div>';