• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MarkUsProject / Markus / 10929214045

18 Sep 2024 07:58PM UTC coverage: 51.729% (-39.9%) from 91.634%
10929214045

push

github

web-flow
Enable assigning graders by section (#7179)

575 of 1300 branches covered (44.23%)

Branch coverage included in aggregate %.

4 of 29 new or added lines in 2 files covered. (13.79%)

1912 existing lines in 61 files now uncovered.

3822 of 7200 relevant lines covered (53.08%)

76.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.09
/app/assets/javascripts/Components/Modals/section_distribution_modal.js
1
import React from "react";
2
import Modal from "react-modal";
3
import PropTypes from "prop-types";
4

5
export class SectionDistributionModal extends React.Component {
6
  static defaultProps = {
1✔
7
    override: false,
8
  };
9

10
  constructor(props) {
NEW
11
    super(props);
×
NEW
12
    this.input = React.createRef();
×
NEW
13
    this.sectionsArray = Object.values(this.props.sections).sort();
×
NEW
14
    this.graderMap = this.props.graders.reduce((map, grader) => {
×
NEW
15
      map[grader.user_name] = grader._id;
×
NEW
16
      return map;
×
17
    }, {});
18
  }
19

20
  componentDidMount() {
NEW
21
    Modal.setAppElement("body");
×
22
  }
23

NEW
24
  onSubmit = event => {
×
NEW
25
    event.preventDefault();
×
NEW
26
    const form = new FormData(this.input.current);
×
NEW
27
    const assignments = {};
×
NEW
28
    form.forEach((value, key) => {
×
NEW
29
      assignments[key] = this.graderMap[value];
×
30
    });
NEW
31
    this.props.onSubmit(assignments);
×
32
  };
33

NEW
34
  renderSectionRow = section => {
×
NEW
35
    const {graders} = this.props;
×
NEW
36
    return (
×
37
      <div className="flex-row-expand" key={section}>
38
        <label htmlFor={`input-${section}`} className="modal-inline-label">
39
          {section}
40
        </label>
41
        <select className={`input-${section}`} name={section}>
42
          <option value=""></option>
43
          {graders.map(grader => (
NEW
44
            <option key={grader.user_name} value={grader.user_name}>
×
45
              {grader.user_name}
46
            </option>
47
          ))}
48
        </select>
49
      </div>
50
    );
51
  };
52

53
  render() {
NEW
54
    return (
×
55
      <Modal
56
        className="react-modal dialog"
57
        isOpen={this.props.isOpen}
58
        onRequestClose={this.props.onRequestClose}
59
      >
60
        <form onSubmit={this.onSubmit} ref={this.input}>
61
          <div className={"modal-container-vertical"}>
62
            <h2>{I18n.t("graders.assign_by_section_modal_title")}</h2>
63
            <p style={{"max-width": "300px"}}>{I18n.t("graders.assign_by_section_instruction")}</p>
NEW
64
            {this.sectionsArray.map(section => this.renderSectionRow(section))}
×
65
          </div>
66
          <div className={"modal-container"}>
67
            <input type="submit" value={I18n.t("graders.actions.assign_by_section")} />
68
          </div>
69
        </form>
70
      </Modal>
71
    );
72
  }
73
}
74

75
SectionDistributionModal.propTypes = {
1✔
76
  graders: PropTypes.arrayOf(PropTypes.object).isRequired,
77
  isOpen: PropTypes.bool.isRequired,
78
  onSubmit: PropTypes.func.isRequired,
79
  sections: PropTypes.objectOf(PropTypes.string).isRequired,
80
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc