forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModerationApp.js
More file actions
108 lines (98 loc) · 3.83 KB
/
Copy pathModerationApp.js
File metadata and controls
108 lines (98 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import _ from 'underscore'
import React from 'react'
import I18n from 'i18n!moderated_grading'
import ModeratedStudentList from './ModeratedStudentList'
import Header from './ModerationHeader'
import FlashMessageHolder from './FlashMessageHolder'
import Actions from './actions/ModerationActions'
import ModeratedColumnHeader from './ModeratedColumnHeader'
export default React.createClass({
displayName: 'ModerationApp',
propTypes: {
store: React.PropTypes.object.isRequired,
permissions: React.PropTypes.shape({
viewGrades: React.PropTypes.bool.isRequired,
editGrades: React.PropTypes.bool.isRequired
}).isRequired
},
getInitialState () {
return this.props.store.getState();
},
componentDidMount () {
this.props.store.subscribe(this.handleChange);
this.props.store.dispatch(Actions.apiGetStudents());
},
handleChange () {
this.setState(this.props.store.getState());
},
handleCheckbox (student, event) {
if (event.target.checked) {
this.props.store.dispatch(Actions.selectStudent(student.id));
} else {
this.props.store.dispatch(Actions.unselectStudent(student.id));
}
},
isModerationSet (students) {
return !!(_.find(students, (student) => {
return student.in_moderation_set;
}));
},
handleSelectAll (event) {
if (event.target.checked) {
var allStudents = this.props.store.getState().students;
this.props.store.dispatch(Actions.selectAllStudents(allStudents));
} else {
this.props.store.dispatch(Actions.unselectAllStudents());
}
},
render () {
return (
<div className="ModerationApp">
<FlashMessageHolder {...this.state.flashMessage} />
<h1 className="screenreader-only">{I18n.t('Moderate %{assignment_name}', {assignment_name: this.state.assignment.title})}</h1>
<Header
onPublishClick={
() => {
this.props.store.dispatch(Actions.publishStarted());
this.props.store.dispatch(Actions.publishGrades())
}
}
onReviewClick={
() => {
this.props.store.dispatch(Actions.moderationStarted());
this.props.store.dispatch(Actions.addStudentToModerationSet());
}
}
published={this.state.assignment.published}
selectedStudentCount={this.state.studentList.selectedCount}
inflightAction={this.state.inflightAction}
permissions={this.props.permissions}
/>
<table width="100%" className="grade-moderation-table">
<caption className="screenreader-only">{I18n.t('Clicking on the column headers will sort the rows by that column.')}</caption>
<ModeratedColumnHeader
includeModerationSetHeaders={this.isModerationSet(this.state.studentList.students)}
sortDirection={this.state.studentList.sort.direction}
markColumn={this.state.studentList.sort.column}
store={this.props.store}
handleSortMark1={() => this.props.store.dispatch(Actions.sortMark1Column())}
handleSortMark2={() => this.props.store.dispatch(Actions.sortMark2Column())}
handleSortMark3={() => this.props.store.dispatch(Actions.sortMark3Column())}
handleSelectAll={this.handleSelectAll}
permissions={this.props.permissions}
/>
<ModeratedStudentList
includeModerationSetColumns={this.isModerationSet(this.state.studentList.students)}
handleCheckbox={this.handleCheckbox}
onSelectProvisionalGrade={
provisionalGradeId => this.props.store.dispatch(Actions.selectProvisionalGrade(provisionalGradeId))
}
studentList={this.state.studentList}
assignment={this.state.assignment}
urls={this.state.urls}
/>
</table>
</div>
);
}
});