choose-mastery-path.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2016 - 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 PropTypes from 'prop-types'
  20. import I18n from 'i18n!choose_mastery_path'
  21. import PathOption from './path-option'
  22. import optionShape from '../shapes/option-shape'
  23. const { func, number, arrayOf } = PropTypes
  24. export default class ChooseMasteryPath extends React.Component {
  25. static propTypes = {
  26. options: arrayOf(optionShape).isRequired,
  27. selectedOption: number,
  28. selectOption: func.isRequired,
  29. }
  30. renderHeader () {
  31. const selectedOption = this.props.selectedOption
  32. if (selectedOption !== null && selectedOption !== undefined) {
  33. return (
  34. <h2>{I18n.t('Assignment Path Selected')}</h2>
  35. )
  36. } else {
  37. return (
  38. <div>
  39. <h2>{I18n.t('Choose Assignment Path')}</h2>
  40. <p><em>{I18n.t('Select one of the options:')}</em></p>
  41. </div>
  42. )
  43. }
  44. }
  45. render () {
  46. return (
  47. <div className='cmp-wrapper'>
  48. {this.renderHeader()}
  49. {this.props.options.map((path, i) => (
  50. <PathOption
  51. key={path.setId}
  52. optionIndex={i}
  53. setId={path.setId}
  54. assignments={path.assignments}
  55. selectOption={this.props.selectOption}
  56. selectedOption={this.props.selectedOption}
  57. />
  58. ))}
  59. </div>
  60. )
  61. }
  62. }