grading_box.mustache 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <%
  19. assignment = grading_box
  20. submission ||= nil
  21. %>
  22. <% if assignment.grading_type == "points" %>
  23. <input
  24. type="text" size="3"
  25. value="<%= I18n.n(submission.entered_score) if submission %>"
  26. class="grading_value grading_box" id="student_grading_<%= assignment.id %>"
  27. style="<%= hidden unless submission %> text-align: center;"/>
  28. <% elsif assignment.grading_type == "percent" %>
  29. <span class="grading_box" id="student_grading_<%= assignment.id %>" style="<%= hidden unless submission %>">
  30. <input
  31. type="text" size="3" class="grading_value" style="text-align: center;"
  32. value="<%= I18n.n(submission.entered_grade.to_f, percentage: true) if submission %>"
  33. />
  34. <span style="display: none;">%</span>
  35. </span>
  36. <% elsif assignment.grading_type == "letter_grade" %>
  37. <input
  38. type="text" size="3" class="grading_value grading_box score_value"
  39. value="<%= I18n.n(submission.entered_score) if submission %>"
  40. id="student_grading_<%= assignment.id %>"
  41. style="<%= hidden unless submission %> text-align: center;"
  42. />
  43. <% elsif assignment.grading_type == "gpa_scale" %>
  44. <input
  45. type="text" size="3" class="grading_value grading_box score_value gpa_scale_cell"
  46. value="<%= I18n.n(submission.entered_score) if submission %>"
  47. id="student_grading_<%= assignment.id %>"
  48. style="<%= hidden unless submission %> text-align: center;"/>
  49. <% elsif assignment.grading_type == "pass_fail"
  50. complete_selected = submission && %w[pass complete].include?(submission.grade)
  51. incomplete_selected = submission && %w[fail incomplete].include?(submission.grade)
  52. %>
  53. <select
  54. class="grading_value grading_box pass_fail"
  55. id="student_grading_<%= assignment.id %>"
  56. style="<%= hidden unless submission %> text-align: left;"
  57. >
  58. <option value="" style="padding-left: 5px;">---</option>
  59. <option value="complete" style="padding-left: 5px;" <%= "selected" if complete_selected %>>
  60. {{#t}}Complete{{/t}}
  61. </option>
  62. <option value="incomplete" style="padding-left: 5px;" <%= "selected" if incomplete_selected %>>
  63. {{#t}}Incomplete{{/t}}
  64. </option>
  65. </select>
  66. <% end %>