| 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 | 1×
1×
1×
1×
1×
1×
| var React, TaskPlan, TeacherTaskPlanListing, moment;
moment = require('moment');
React = require('react');
TaskPlan = React.createClass({
displayName: 'TeacherTaskPlan',
propTypes: {
plan: React.PropTypes.object.isRequired,
courseId: React.PropTypes.string.isRequired
},
contextTypes: {
router: React.PropTypes.func
},
onEditPlan: function() {
var courseId, id, ref, type;
courseId = this.props.courseId;
ref = this.props.plan, id = ref.id, type = ref.type;
switch (type) {
case 'homework':
return this.context.router.transitionTo('editHomework', {
courseId: courseId,
id: id
});
case 'reading':
return this.context.router.transitionTo('editReading', {
courseId: courseId,
id: id
});
default:
throw new Error("BUG: Unknown plan type '" + type + "'");
}
},
onViewStats: function() {
var courseId, id;
courseId = this.props.courseId;
id = this.props.plan.id;
return this.context.router.transitionTo('viewStats', {
courseId: courseId,
id: id
});
},
render: function() {
var duration, ending, plan, start;
plan = this.props.plan;
start = moment(plan.opens_at);
ending = moment(plan.due_at);
duration = moment.duration(ending.diff(start)).humanize();
return React.createElement("div", {
"className": '-list-item'
}, React.createElement(BS.ListGroupItem, {
"header": plan.title,
"onClick": this.onEditPlan
}, start.fromNow(), " (", duration, ")"), React.createElement(BS.Button, {
"bsStyle": 'link',
"className": '-tasks-list-stats-button',
"onClick": this.onViewStats
}, "View Stats"));
}
});
TeacherTaskPlanListing = React.createClass({
displayName: 'TeacherTaskPlanListing',
propTypes: {
plan: React.PropTypes.object.isRequired,
courseId: React.PropTypes.string.isRequired
},
render: function() {
var courseId, plan, plans, plansList, ref, title;
ref = this.props, plansList = ref.plansList, courseId = ref.courseId;
title = "Task plans for course ID " + courseId;
plans = (function() {
var i, len, results;
results = [];
for (i = 0, len = plansList.length; i < len; i++) {
plan = plansList[i];
results.push(React.createElement(TaskPlan, {
"key": plan.id,
"plan": plan,
"courseId": courseId
}));
}
return results;
})();
return React.createElement(BS.ListGroup, {
"id": 'tasks-list'
}, plans);
}
});
module.exports = TeacherTaskPlanListing;
|