LatePolicyGrade.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2017 - 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. import React from 'react';
  19. import { number, shape, string } from 'prop-types';
  20. import Typography from 'instructure-ui/lib/components/Typography';
  21. import I18n from 'i18n!gradebook';
  22. import GradeFormatHelper from 'jsx/gradebook/shared/helpers/GradeFormatHelper';
  23. export default function LatePolicyGrade (props) {
  24. const { grade } = props.submission;
  25. const pointsDeducted = I18n.n(-props.submission.pointsDeducted);
  26. let finalGrade;
  27. if (isNaN(grade)) {
  28. finalGrade = GradeFormatHelper.formatGrade(props.submission.grade);
  29. } else {
  30. finalGrade = GradeFormatHelper.formatGrade(props.submission.grade, { precision: 2 });
  31. }
  32. return (
  33. <div style={{ display: 'flex', flexDirection: 'row' }}>
  34. <div style={{ paddingRight: '.5rem' }}>
  35. <div>
  36. <Typography color="error" as="span">
  37. { I18n.t('Late Penalty:') }
  38. </Typography>
  39. </div>
  40. <div>
  41. <Typography color="secondary" as="span">
  42. { I18n.t('Final Grade:') }
  43. </Typography>
  44. </div>
  45. </div>
  46. <div style={{ flex: 1 }}>
  47. <div id="late-penalty-value">
  48. <Typography color="error" as="span">
  49. { pointsDeducted }
  50. </Typography>
  51. </div>
  52. <div id="final-grade-value">
  53. <Typography color="secondary" as="span">
  54. { finalGrade }
  55. </Typography>
  56. </div>
  57. </div>
  58. </div>
  59. );
  60. }
  61. LatePolicyGrade.propTypes = {
  62. submission: shape({
  63. grade: string,
  64. pointsDeducted: number
  65. }).isRequired
  66. };