| 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 | 2×
2×
2×
2×
2×
2×
2×
| var BS, CourseBar, React, _;
React = require('react');
_ = require('underscore');
BS = require('react-bootstrap');
CourseBar = React.createClass({
displayName: 'CourseBar',
propTypes: {
data: React.PropTypes.object.isRequired,
type: React.PropTypes.string.isRequired,
totalCols: React.PropTypes.number
},
getDefaultProps: function() {
return {
totalCols: 12
};
},
getStats: function() {
var completeLabel, data, inProgressLabel, notStartedLabel, ref, stats, type;
ref = this.props, data = ref.data, type = ref.type;
completeLabel = 'Complete';
inProgressLabel = 'In Progress';
notStartedLabel = 'Not Started';
stats = [
{
type: 'complete',
label: completeLabel,
value: data.complete_count
}, {
type: 'in-progress',
label: inProgressLabel,
value: data.partially_complete_count
}, {
type: 'not-started',
label: notStartedLabel,
value: data.total_count - (data.complete_count + data.partially_complete_count)
}
];
if (type === 'external') {
completeLabel = 'Clicked';
inProgressLabel = 'Viewed';
stats = [
{
type: 'complete',
label: completeLabel,
value: data.complete_count
}, {
type: 'not-started',
label: notStartedLabel,
value: data.total_count - (data.complete_count + data.partially_complete_count)
}
];
}
if (type === 'homework' && data.mean_grade_percent) {
stats.unshift({
type: 'average',
label: 'Average',
value: data.mean_grade_percent + "%"
});
}
return stats;
},
renderCourseStat: function(stat, cols) {
var key;
if (cols == null) {
cols = 4;
}
key = "reading-stats-" + stat.type;
return React.createElement(BS.Col, {
"xs": cols,
"className": key,
"key": key
}, React.createElement("label", null, stat.label), React.createElement("div", {
"className": "data-container-value text-" + stat.type
}, stat.value));
},
render: function() {
var cols, stats, statsColumns, totalCols;
totalCols = this.props.totalCols;
stats = this.getStats();
cols = totalCols / stats.length;
statsColumns = _.map(stats, _.partial(this.renderCourseStat, _, cols));
return React.createElement(BS.Grid, {
"className": 'data-container',
"key": 'course-bar'
}, React.createElement(BS.Row, null, statsColumns));
}
});
module.exports = CourseBar;
|