Skip to content

Commit ab5a60a

Browse files
sandershihackerDerekTBrown
authored andcommitted
* Updated Schemas * Load Screen * Loading Screen * publish subscribe and dynamic explore page * deleted swap file * publish subscribe * template fixes * added start for reactive publication * template issue * . * . * course_records publish * course_records reactively publish * revert meteor update * publish subscribe and lineheight for searchpage icons * fixed indentation and removed test file * indentation * indentation * Accounts page and fixed random erro * toolbar for mobile devices * toolbar * account.html fixes * Toolbar made responsive * Responsive toolbar fixes * created userlist component * course_records course_id validation * indentation * markdown * import changes * validation addition * Forms Module Deprecated Warning. Issue #110 * indentation * Use routerLink * api changes (#126) * issue 32 fixed * removed swp * fixed nconf issues * issue 82, 84 fixes * fixed #82 * isse #77 * fixed tests * fixed files * fixed tests master * fixed comment * moved validator * removed duplicate file * fixed tests, removed duplicate underscore, publish * changes * fixed methods.ts import * fixed issues w methods * fixes * minor fixes * A * api changes * fixed api * comments * minor changes * minor fixes * method implementations (#127) * issue 32 fixed * removed swp * fixed nconf issues * issue 82, 84 fixes * fixed #82 * isse #77 * fixed tests * fixed files * fixed tests master * fixed comment * moved validator * removed duplicate file * fixed tests, removed duplicate underscore, publish * changes * fixed methods.ts import * fixed issues w methods * fixes * minor fixes * A * api changes * fixed api * comments * minor changes * minor fixes * method implementations * course pages now uses Child Routing * deleted LabData class * school name * search function * icon size and #136 * dashboard pull data from database * fix inappropriate file naming for gradelist and lablist * more templating issues * . * . * markdown default * lablist and gradelist * template changes * explore page changes * delete instructor page * user schema * indentation * indentation * explore publish and taskview sidenav * explore view links to course/courseId * taskview sidenav * taskview * taskview sidenav changes * Extend terminal on small width * . * . * Added UserList Component in Courses * Edit Course * . * course dashboard get courseid from url * delete userlist * input * delete userlist * publish for global admin * Fixed router params * Issue 161 fixed: instructor field in courses * . * fix nextButton * . * Issue #171 * Issue #168 * Issue 160: CourseList * Removed LabView * Enrollable field for buttons on explore pages * TaskView -> LabView * Fixed Gradelist, Lablist and styling issues * Issue #162 Completed * TaskView toolbar color darken * remove tests * Combine Subscriptions * Reactive Subscription for CourseList and GradeList * instructor view of course dashboard * Dashboard not logged in * markdown editor for labview * . * . * remove test * Syllabus update on course_dashboard for instructors works * onChange detect for mdeditor * fixed reversed md text editor * Disable links to non-accessible tasks for students * Fixed merge issues * markdown on explore * . * indentation * indentation * indentation * Course Permissions Editing functionality complete * course settings for instructors complete * #192 * . * Wed Aug 3 11:06:55 EDT 2016 * #208
1 parent f1c1922 commit ab5a60a

File tree

5 files changed

+57
-61
lines changed

5 files changed

+57
-61
lines changed

client/imports/ui/pages/course/lablist.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
</tr>
1717
</thead>
1818
<tbody>
19-
<tr *ngFor="let lab of labs" [routerLink]="['/course/' + courseId + '/labs/' + lab.id]">
20-
<td class="md-text-cell">{{ lab.name }}</td>
19+
<tr *ngFor="let lab of getLabs()" [routerLink]="['/course/' + courseId + '/labs/' + lab._id]">
20+
<td class="md-text-cell">{{ lab.lab_name }}</td>
2121
<td>{{ lab.completed }}</td>
22-
<td>{{ lab.date }}</td>
22+
<td>soon</td>
2323
</tr>
2424
</tbody>
2525
</md-data-table>

client/imports/ui/pages/course/lablist.ts

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
// Declare Collections
1717
declare var Collections: any;
18+
declare var _: any;
1819

1920
// Inject current user into class
2021
@InjectUser("user")
@@ -35,74 +36,69 @@
3536
user: Meteor.User;
3637
courseId: string;
3738
userId: string = Meteor.userId();
38-
labs: Array<Object> = [];
3939
courseRecord: any;
40-
cur_user: boolean;
40+
41+
// Test
42+
allLabs: Array<Object>;
43+
partialLabs: Array<Object>;
4144

4245
// Progress Bar Value
4346
public determinateValue: number = 0;
4447

4548
constructor(private route: ActivatedRoute, private router: Router) {
4649
super();
47-
}
4850

49-
getCourseRecords() {
50-
// Get from course_records
51+
// Get labs in course_records
5152
this.subscribe('course-records', () => {
5253
this.autorun(() => {
53-
if(this.cur_user) {
54-
// Student
55-
this.courseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: Meteor.userId() });
56-
}
57-
else {
58-
var localCourseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: this.userId });
59-
if(localCourseRecord === null || typeof localCourseRecord === "undefined") {
60-
// Admin
61-
this.courseRecord = Meteor.call('getUserCourseRecord', this.courseId, this.userId);
62-
}
63-
else {
64-
// Instructor
65-
this.courseRecord = localCourseRecord;
66-
}
67-
}
68-
this.setLabs();
69-
});
70-
}, true);
54+
var record = Collections.course_records.findOne({ course_id: this.courseId });
55+
this.partialLabs = record.labs;
56+
}, true);
57+
});
58+
59+
// Get all labs of this course
60+
this.subscribe('labs', () => {
61+
this.autorun(() => {
62+
this.allLabs = Collections.labs.find({ course_id: this.courseId }).fetch();
63+
}, true);
64+
});
7165
}
7266

73-
setLabs() {
74-
if(typeof this.courseRecord !== "undefined" && this.courseRecord !== null) {
75-
let labs = this.courseRecord.labs;
76-
let totalCompleted = 0;
77-
let totalNumTasks = 0;
78-
for (let i = 0; i < labs.length; i++) {
79-
let lab = labs[i];
80-
let tasksCompleted = 0;
81-
let tasks = lab.tasks;
82-
for (let j = 0; j < tasks.length; j++) {
83-
let task = tasks[j];
84-
if (task.status === 'COMPLETED') {
85-
tasksCompleted++;
67+
getLabs() {
68+
var finalLabs = []; // Return this, an array of formatted labs
69+
if(typeof this.partialLabs !== "undefined" && typeof this.allLabs !== "undefined") {
70+
// All labs from course database
71+
finalLabs = this.allLabs;
72+
// Get Lab Ids and compare with partial labs from course_records
73+
var finalLabIds = _.map(finalLabs, function(lb) { return lb._id; });
74+
for(let i = 0; i < finalLabIds.length; i++) {
75+
let currentLabId = finalLabIds[i];
76+
let numTasks = finalLabs[i].tasks.length;
77+
// Set default completed in case it is not in course_records
78+
finalLabs[i].completed = "0/" + numTasks;
79+
for(let j = 0; j < this.partialLabs.length; j++) {
80+
if((<any>(this.partialLabs[j]))._id.str === currentLabId.str) {
81+
finalLabs[i].completed = this.compTasks(this.partialLabs[j]) + "/" + numTasks;
8682
}
8783
}
88-
this.labs.push({
89-
'id': lab._id,
90-
'name': 'Lab ' + (i + 1).toString(),
91-
'completed': tasksCompleted.toString() + '/' + tasks.length.toString(),
92-
'date': 'soon'
93-
});
94-
totalCompleted += tasksCompleted;
95-
totalNumTasks += tasks.length;
9684
}
97-
this.determinateValue = (totalCompleted * 100.0) / totalNumTasks;
9885
}
86+
return finalLabs;
87+
}
88+
89+
compTasks(lab) {
90+
let comp = 0;
91+
for(let i = 0; i < lab.tasks.length; i++) {
92+
if(lab.tasks[i].status === "COMPLETED") {
93+
comp++;
94+
}
95+
}
96+
return comp;
9997
}
10098

10199
ngOnInit(){
102100
this.userId = this.router.routerState.parent(this.route).snapshot.params['userid'];
103101
this.courseId = this.router.routerState.parent(this.route).snapshot.params['courseid'];
104-
this.cur_user = (typeof this.userId === "undefined" || this.userId === null);
105-
this.getCourseRecords();
106102
}
107103

108104
}

collections/courses.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ courses.allow({
3434
**/
3535
declare var SimpleSchema: any;
3636
declare var _: any;
37-
var _ = require('underscore');
3837
if (Meteor.isServer){
3938
Meteor.startup(function(){
4039

collections/labs.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ labs.allow({
7575
return Date.now();
7676
}
7777
},
78-
hidden:{
79-
type: Boolean,
80-
defaultValue: true
81-
},
82-
disabled:{
83-
type: Boolean,
84-
defaultValue: false
85-
},
78+
hidden:{
79+
type: Boolean,
80+
defaultValue: true
81+
},
82+
disabled:{
83+
type: Boolean,
84+
defaultValue: false
85+
},
8686
file: {
8787
type: String
8888
},
@@ -186,13 +186,13 @@ if(Meteor.isServer) {
186186
// Define roles of current user
187187
let roles = (<any>(user)).roles;
188188
if(typeof roles !== "undefined") {
189-
189+
190190
// Get student enrolled courseIds
191191
let studentCourses = (_.unzip(roles.student))[0];
192192

193193
// Concatenate student enrolled courseIds with Instructor taught courseIds
194194
let course_ids = studentCourses.concat(roles.instructor);
195-
195+
196196
// Search Query
197197
return labs.find({
198198
course_id: {

server/imports/startup/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//import async
22
async = require('async')
3+
_ = require('underscore')
34

45
// Load Variables
56
import './settings.js'

0 commit comments

Comments
 (0)