Skip to content

Commit 43ad307

Browse files
committed
mgage#1: Added improvements to calendar in reference to issue mgage#7 on pstaabp/webwork-dev. Not closing this bug yet. I think it needs better UI.
mgage#2: Added popover to open assignments on the calendar. mgage#3: Hopefully fixed issue mgage#11. mgage#4: allowed all set view to have a table that can be sorted (not currently working for the date columns).
1 parent ee4b154 commit 43ad307

File tree

13 files changed

+152
-65
lines changed

13 files changed

+152
-65
lines changed

htdocs/css/problemsetlist.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616

1717
.assign-reduced-credit {background-color: rgb(255,128,0);}
1818

19+
1920
.empty {background-color: none;}
2021

2122
.assign { border-left: -2px; border-right: -2px; height: 15px; width: 103%; margin-top: 2px; margin-bottom: 2px;
2223
float: left; display: table-cell; vertical-align: bottom; z-index: 2; font-size: 13px;}
2324

2425
.assign-set-name {cursor: pointer;}
2526

27+
.assign-filled {height: 30px; background-color: rgb(250,100,100)}
28+
29+
2630
.calendar-button-row {margin: 20px;}
2731

2832
//.list {list-style: none;}

htdocs/html-templates/frontpage.html

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ <h3>Welcome to WeBWorK</h3>
1313

1414
<!-- The following is copied directly from the homework manager. Code like this should appear in a separate file. -->
1515

16-
<script type="text/template" id="calendarButtons">
16+
<script type="text/template" id="calendar-template">
17+
<div id="calendar-error-bar"></div>
1718
<div class="calendar-button-row">
18-
<button type="button" class="previous-week btn btn-small">Previous Week</button>
19-
<button type="button" class="next-week btn btn-small">Next Week</button>
19+
<button type="button" class="previous-week btn btn-small"><i class="icon-chevron-left"></i>Previous Week</button>
2020
<button type="button" class="view-month btn btn-small">Month View</button>
2121
<button type="button" class="view-week btn btn-small">Week View</button>
22+
<button type="button" class="next-week btn btn-small">Next Week<i class="icon-chevron-right"></i></button>
2223
</div>
23-
</script>
2424

25-
<script type="text/template" id="calendarHeader">
25+
<table id='calendar-table' class='table-bordered'>
2626
<thead>
2727
<th>Sunday</th>
2828
<th>Monday</th>
@@ -32,4 +32,25 @@ <h3>Welcome to WeBWorK</h3>
3232
<th>Friday</th>
3333
<th>Saturday</th>
3434
</thead><tbody></tbody>
35+
<table id='calendar-table' class='table-bordered'></table>
36+
<div class="calendar-button-row">
37+
<button type="button" class="previous-week btn btn-small"><i class="icon-chevron-left"></i>Previous Week</button>
38+
<button type="button" class="view-month btn btn-small">Month View</button>
39+
<button type="button" class="view-week btn btn-small">Week View</button>
40+
<button type="button" class="next-week btn btn-small">Next Week<i class="icon-chevron-right"></i></button>
41+
</div>
42+
</script>
43+
44+
45+
<script type="text/template" id="calendar-date-bar">
46+
<div class="<%= classes %>" data-set="<%= setname %>" data-title="<%=setname%>" data-content="Users Assigned: <%=usersAssigned%>/<%=totalUsers%><br>Open To Students: <%=openToStudents%>"><span><%if(showName){%><%=setname %><%}%></span></div>
47+
48+
</script>
49+
50+
<script type="text/template" id="too-many-assignments-error">
51+
There are too many overlapping assignments to view efficiently. Switch to week view for
52+
a better rendering.
3553
</script>
54+
55+
56+

htdocs/html-templates/homework-manager.html

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,17 @@ <h3>Help for the Homework Manager</h3>
189189

190190

191191

192-
<script type="text/template" id="calendarButtons">
192+
<script type="text/template" id="calendar-template">
193+
<div id="calendar-error-bar"></div>
193194
<div class="calendar-button-row">
194-
<button type="button" class="previous-week btn btn-small">Previous Week</button>
195-
<button type="button" class="next-week btn btn-small">Next Week</button>
195+
<button type="button" class="previous-week btn btn-small"><i class="icon-chevron-left"></i>Previous Week</button>
196+
196197
<button type="button" class="view-month btn btn-small">Month View</button>
197198
<button type="button" class="view-week btn btn-small">Week View</button>
199+
<button type="button" class="next-week btn btn-small">Next Week<i class="icon-chevron-right"></i></button>
198200
</div>
199-
</script>
200201

201-
<script type="text/template" id="calendarHeader">
202+
<table id='calendar-table' class='table-bordered'>
202203
<thead>
203204
<th>Sunday</th>
204205
<th>Monday</th>
@@ -208,6 +209,24 @@ <h3>Help for the Homework Manager</h3>
208209
<th>Friday</th>
209210
<th>Saturday</th>
210211
</thead><tbody></tbody>
212+
<table id='calendar-table' class='table-bordered'></table>
213+
<div class="calendar-button-row">
214+
<button type="button" class="previous-week btn btn-small"><i class="icon-chevron-left"></i>Previous Week</button>
215+
<button type="button" class="view-month btn btn-small">Month View</button>
216+
<button type="button" class="view-week btn btn-small">Week View</button>
217+
<button type="button" class="next-week btn btn-small">Next Week<i class="icon-chevron-right"></i></button>
218+
</div>
219+
220+
</script>
221+
222+
<script type="text/template" id="calendar-date-bar">
223+
<div class="<%= classes %>" data-set="<%= setname %>" data-title="<%=setname%>" data-content="Users Assigned: <%=usersAssigned%>/<%=totalUsers%><br>Open To Students: <%=openToStudents%>"><span><%if(showName){%><%=setname %><%}%></span></div>
224+
225+
</script>
226+
227+
<script type="text/template" id="too-many-assignments-error">
228+
There are too many overlapping assignments to view efficiently. Switch to week view for
229+
a better rendering.
211230
</script>
212231

213232
<script type="text/template" id="settings-template">

htdocs/js/apps/FrontPage/FrontPage.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ function(Backbone, _, User, ProblemSetList, Problem, WebPage, CalendarView, Prob
5656

5757
this.problemSets.fetch();
5858

59-
this.dispatcher.on('problem-sets-loaded',this.postHWLoaded);
60-
61-
this.render();
59+
this.problemSets.on('fetchSuccess', function () {
60+
self.render();
61+
self.postHWLoaded();
62+
});
6263

6364

6465

htdocs/js/apps/HomeworkManager/AssignUsersView.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ define(['Backbone',
6464
});
6565
var _sets = this.parent.problemSets.filter(function(_set) { return (_(setNames).indexOf(_set.get("set_id")) >-1);});
6666

67+
console.log(_users);
68+
console.log(_sets);
69+
70+
_(_sets).each(function(set) {set.assignToUsers(userNames)});
6771
},
6872
updateDates: function ()
6973
{

htdocs/js/apps/HomeworkManager/HomeworkManager.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ require.config({
1717
"config": "/webwork2_files/js/apps/config",
1818
"Closeable": "/webwork2_files/js/lib/webwork/views/Closeable",
1919
"datepicker": "/webwork2_files/js/lib/vendor/datepicker/js/bootstrap-datepicker",
20-
"jquery-truncate": "/webwork2_files/js/lib/vendor/jquery.truncate.min"
20+
"jquery-truncate": "/webwork2_files/js/lib/vendor/jquery.truncate.min",
21+
"jquery-tablesorter": "/webwork2_files/js/lib/vendor/jquery.tablesorter.min"
2122
},
2223
urlArgs: "bust=" + (new Date()).getTime(),
2324
waitSeconds: 15,
@@ -30,7 +31,8 @@ require.config({
3031
'XDate':{ exports: 'XDate'},
3132
'config': ['XDate'],
3233
'datepicker': ['bootstrap'],
33-
'jquery-truncate': ['jquery']
34+
'jquery-truncate': ['jquery'],
35+
'jquery-tablesorter': ['jquery']
3436
}
3537
});
3638

@@ -58,7 +60,7 @@ function(Backbone, _, UserList, ProblemSetList, Settings, CalendarView, HWDetai
5860
tagName: "div",
5961
initialize: function(){
6062
this.constructor.__super__.initialize.apply(this, {el: this.el});
61-
_.bindAll(this, 'render','postHWLoaded'); // include all functions that need the this object
63+
_.bindAll(this, 'render','postHWLoaded','setDropToEdit'); // include all functions that need the this object
6264
var self = this;
6365
this.dispatcher = _.clone(Backbone.Events);
6466

@@ -99,10 +101,14 @@ function(Backbone, _, UserList, ProblemSetList, Settings, CalendarView, HWDetai
99101
self.announce.appendHTML("The HW set with name " + set.get("set_id") + " was deleted.");
100102
});
101103

102-
this.problemSets.on("fetchSuccess",function() {self.setListView.render();})
103-
104+
this.problemSets.on("fetchSuccess",function() {
105+
self.problemSets.each(function(_set){
106+
_set.countUsers();
107+
});
108+
self.setListView.render();
109+
self.postHWLoaded();
110+
});
104111

105-
this.dispatcher.on("problem-sets-loaded",this.postHWLoaded);
106112

107113
this.users = new UserList();
108114
this.users.fetch();

htdocs/js/apps/HomeworkManager/SetListView.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
*/
55

6-
define(['Backbone', 'underscore','../../lib/webwork/views/EditableCell'], function(Backbone, _,EditableCell){
6+
define(['Backbone', 'underscore','../../lib/webwork/views/EditableCell','jquery-tablesorter'], function(Backbone, _,EditableCell){
77

88
var SetListRowView = Backbone.View.extend({
99
className: "set-list-row",
@@ -38,6 +38,9 @@ define(['Backbone', 'underscore','../../lib/webwork/views/EditableCell'], functi
3838
tab.append((new SetListRowView({model: m})).el);
3939
});
4040

41+
tab.tablesorter();
42+
43+
4144
},
4245
addSet: function (_set) {
4346
this.$("#set-list-table").append((new SetListRowView({model: _set})).el);

htdocs/js/apps/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ define(['Backbone','backbone-validation'], function(Backbone){
8080

8181
if (parsedDate) {
8282
var year = parsedDate[4];
83-
var month = (parseInt(parsedDate[1],10)<10)?("0"+parseInt(parsedDate[2],10)):parseInt(parsedDate[2],10);
84-
var dayOfMonth = (parseInt(parsedDate[2],10)<10)?("0"+parseInt(parsedDate[3],10)):parseInt(parsedDate[3],10);
83+
var month = (parseInt(parsedDate[2],10)<10)?("0"+parseInt(parsedDate[2],10)):parseInt(parsedDate[2],10);
84+
var dayOfMonth = (parseInt(parsedDate[3],10)<10)?("0"+parseInt(parsedDate[3],10)):parseInt(parsedDate[3],10);
8585

8686
var hours = (/[aA][mM]/.test(parsedDate[6],10))? (parseInt(parsedDate[6],10)):(parseInt(parsedDate[6],10)+12);
8787
hours = (hours<10)?("0"+hours):hours;

htdocs/js/lib/vendor/jquery.tablesorter.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htdocs/js/lib/webwork/models/ProblemSet.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ define(['Backbone', 'underscore','config','XDate','./ProblemList'], function(Bac
9999
restrict_ip: "opt(yes,no)",
100100
relax_restrict_ip: "opt(yes,no)",
101101
restricted_login_proctor: "opt(yes,no)",
102-
visible_to_students: "opt(yes,no)",
103102
},
104103
initialize: function(){
105104
_.bindAll(this,"fetch","addProblem","update");
@@ -193,7 +192,7 @@ define(['Backbone', 'underscore','config','XDate','./ProblemList'], function(Bac
193192
var dueDate2 = new XDate(_set.get("due_date"));
194193
return (openDate1<openDate2)?(dueDate1>openDate2):(dueDate2>openDate1);
195194
},
196-
countSetUsers: function ()
195+
countUsers: function ()
197196
{
198197
var self=this;
199198
if (this.usersAssigned.length>0) { self.trigger("countUsers",this.usersAssigned);}
@@ -205,7 +204,7 @@ define(['Backbone', 'underscore','config','XDate','./ProblemList'], function(Bac
205204
$.get(config.webserviceURL, requestObject, function (data) {
206205

207206
var response = $.parseJSON(data);
208-
this.usersAssigned = response.result_data;
207+
self.usersAssigned = response.result_data;
209208

210209
self.trigger("countUsers",this.usersAssigned);
211210

@@ -214,7 +213,7 @@ define(['Backbone', 'underscore','config','XDate','./ProblemList'], function(Bac
214213
assignToUsers: function (_users){ // assigns this problem set to the users that come in as an array of usernames.
215214
var self = this;
216215

217-
216+
console.log("Assigning Problem Set " + this.get("set_id") + " to " + _users.join(" "));
218217
var requestObject = {xml_command: "assignSetToUsers", users: _users.join(","), set_id: this.get("set_id")};
219218
_.defaults(requestObject,config.requestObject);
220219

0 commit comments

Comments
 (0)