Skip to content

Commit 5590d87

Browse files
committed
2 parents 7d8e1a0 + be943b4 commit 5590d87

38 files changed

+1104
-299
lines changed

client/imports/ui/components/explore/explore.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ <h2>{{ course.course_number }} | {{ course.course_name }}</h2>
1515
{{ course.course_description.content }}
1616
</p>
1717
<div class="course-link">
18-
<a md-button [routerLink]="['/course/' + course._id]">Enroll</a>
18+
<a md-button [routerLink]="['/course/' + course._id]" *ngIf="course.permissions.content == 'auth'">Enroll</a>
19+
<a md-button [routerLink]="['/course/' + course._id]" *ngIf="course.permissions.content == 'any'" >View</a>
1920
</div>
2021
</md-content>
2122
</template>

client/imports/ui/components/explore/search.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ <h2 id="search-string">Search Results for '{{ searchQuery }}'</h2>
3232
</div>
3333
</td>
3434
<td>
35-
<a md-button [routerLink]="['/course/' + course._id]">Enroll</a>
35+
<a md-button [routerLink]="['/course/' + course._id]" *ngIf="course.permissions.content == 'auth'" >Enroll</a>
36+
<a md-button [routerLink]="['/course/' + course._id]" *ngIf="course.permissions.content == 'any'" >View</a>
3637
</td>
3738
</tr>
3839
</tbody>

client/imports/ui/components/markdown/markdown.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
<!-- Task Markdown -->
33
<div class="markdown-content">
44
<div id="task-markdown" [innerHTML]="convert(mdData)"></div>
5-
</div>
5+
</div>
6+
<div *ngIf="mdDataUpdate != null" id="feedback-markdown">
7+
<p>Task Feedback:</p>
8+
<div [innerHTML]="convert(mdDataUpdate)"></div>
9+
</div>
610
</div>

client/imports/ui/components/markdown/markdown.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
// Export MarkdownView Class
4949
export class MarkdownView extends MeteorComponent{
5050
@Input() mdData = "";
51+
@Input() mdDataUpdate = "";
5152

5253
constructor(mdIconRegistry: MdIconRegistry) {
5354
super();
@@ -58,7 +59,7 @@ export class MarkdownView extends MeteorComponent{
5859
}
5960
convert(markdown: string) {
6061
let md = marked.setOptions({});
61-
if(typeof markdown !== "undefined") {
62+
if(typeof markdown !== "undefined" && markdown !== null) {
6263
return md.parse(markdown);
6364
}
6465
else {

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tuxlab-course-dashboard">
1+
<div class="tuxlab-course-dashboard set-max-width">
22
<!--Course Description Card-->
33
<md-card>
44
<md-card-title>
@@ -61,23 +61,4 @@
6161

6262
<!--Lab List Card-->
6363
<tuxlab-lablist></tuxlab-lablist>
64-
65-
<!--Edit Course Card-->
66-
<!--
67-
<md-card>
68-
<md-card-title>
69-
<md-card-title-text>
70-
<span class="md-headline">Edit Course</span>
71-
</md-card-title-text>
72-
</md-card-title>
73-
<md-card-content>
74-
<form>
75-
<input [(ngModel)]="courseName" name="course-name"/>
76-
<br>
77-
<textarea [(ngModel)]="courseDescription" name="course-description"></textarea>
78-
</form>
79-
</md-card-content>
80-
</md-card>
81-
-->
82-
8364
</div>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,5 @@ declare var Collections: any;
6565
}
6666
ngOnInit() {
6767
this.courseId = this.router.routerState.parent(this.route).snapshot.params['courseid'];
68-
console.log(this.courseId);
6968
}
7069
}

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

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Angular Imports
77
import { Component } from '@angular/core';
8-
import { ActivatedRoute } from '@angular/router';
8+
import { ActivatedRoute, Router } from '@angular/router';
99

1010
declare var Collections: any;
1111

@@ -24,9 +24,11 @@ export class GradeList extends MeteorComponent{
2424
grades: Array<any> = [];
2525
cur_user: boolean;
2626

27-
constructor(private route: ActivatedRoute) {
27+
constructor(private route: ActivatedRoute, private router: Router) {
2828
super();
29-
this.courseRecord = this.getCourseRecords();
29+
}
30+
31+
setGrades() {
3032
if (this.courseRecord !== undefined) {
3133
let labs = this.courseRecord.labs;
3234
let totalEarned = 0;
@@ -36,50 +38,55 @@ export class GradeList extends MeteorComponent{
3638
let tasks = lab.tasks;
3739
for (let j = 0; j < tasks.length; j++) {
3840
let task = tasks[j];
39-
totalEarned += task.grade.earned;
40-
totalFull += task.grade.total;
41+
totalEarned += task.grade[0];
42+
totalFull += task.grade[1];
4143
this.grades.push({
4244
'name': 'lab ' + (i + 1).toString() + ' task ' + (j + 1).toString(),
43-
'grade': ((task.grade.earned * 100.0) / task.grade.total).toString() + '%'
45+
'grade': ((task.grade[0] * 100.0) / task.grade[1]).toString() + '%'
4446
});
4547
}
4648
}
49+
let courseAverage;
50+
if (totalFull !== 0) {
51+
courseAverage = ((totalEarned * 100.0) / totalFull).toString() + "%";
52+
}
53+
else {
54+
courseAverage = "N/A";
55+
}
4756
this.grades.push({
4857
'name': 'Course Average',
49-
'grade': ((totalEarned * 100.0) / totalFull).toString() + '%'
58+
'grade': courseAverage
5059
});
51-
}
52-
60+
}
5361
}
54-
62+
5563
getCourseRecords(){
56-
var record;
57-
if(this.cur_user) {
58-
// Student
59-
this.subscribe('course-records', [this.courseId, Meteor.userId()], () => {
60-
record = Collections.course_records.findOne({ course_id: this.courseId, user_id: Meteor.userId() });
61-
}, true);
62-
return record;
63-
}
64-
else{
65-
var record;
66-
this.subscribe('course-records', [this.courseId, this.userId], () => {
67-
var localCourseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: this.userId });
68-
if (localCourseRecord === null || typeof localCourseRecord === "undefined") {
69-
// Admin
70-
record = Meteor.call('getUserCourseRecord', this.courseId, this.userId);
64+
this.subscribe('course-records', () => {
65+
this.autorun(() => {
66+
if(this.cur_user) {
67+
// Student
68+
this.courseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: Meteor.userId() });
7169
}
7270
else {
73-
// Instructor
74-
record = localCourseRecord;
71+
var localCourseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: this.userId });
72+
if(localCourseRecord === null || typeof localCourseRecord === "undefined") {
73+
// Admin
74+
this.courseRecord = Meteor.call('getUserCourseRecord', this.courseId, this.userId);
75+
}
76+
else {
77+
// Instructor
78+
this.courseRecord = localCourseRecord;
79+
}
7580
}
76-
}, true);
77-
return record;
78-
}
81+
this.setGrades();
82+
});
83+
}, true);
7984
}
8085

8186
ngOnInit(){
82-
this.userId = this.route.snapshot.params['userid'];
87+
this.userId = this.router.routerState.parent(this.route).snapshot.params['userid'];
88+
this.courseId = this.router.routerState.parent(this.route).snapshot.params['courseid'];
8389
this.cur_user = (typeof this.userId === "undefined" || this.userId === null);
90+
this.getCourseRecords();
8491
}
8592
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</tr>
1717
</thead>
1818
<tbody>
19-
<tr *ngFor="let lab of labs" [routerLink]="['/lab-view']">
19+
<tr *ngFor="let lab of labs" [routerLink]="['/course/' + courseId + '/labs/' + lab.id]">
2020
<td class="md-text-cell">{{ lab.name }}</td>
2121
<td>{{ lab.completed }}</td>
2222
<td>{{ lab.date }}</td>

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Angular Imports
66
import { Component } from '@angular/core';
7-
import { ROUTER_DIRECTIVES, ActivatedRoute } from '@angular/router';
7+
import { ROUTER_DIRECTIVES, ActivatedRoute, Router } from '@angular/router';
88

99
// Angular Material Imports
1010
import { MATERIAL_DIRECTIVES, MATERIAL_PROVIDERS } from 'ng2-material';
@@ -14,10 +14,8 @@
1414
import { MeteorComponent } from 'angular2-meteor';
1515
import { InjectUser } from 'angular2-meteor-accounts-ui';
1616

17-
// Import Collections
18-
import { course_records } from '../../../../../collections/course_records.ts';
19-
20-
declare var Collections: any;
17+
// Declare Collections
18+
declare var Collections: any;
2119

2220
// Inject current user into class
2321
@InjectUser("user")
@@ -45,9 +43,34 @@ declare var Collections: any;
4543
// Progress Bar Value
4644
public determinateValue: number = 0;
4745

48-
constructor(private route: ActivatedRoute) {
46+
constructor(private route: ActivatedRoute, private router: Router) {
4947
super();
50-
this.courseRecord = this.getCourseRecords();
48+
}
49+
50+
getCourseRecords(){
51+
this.subscribe('course-records', () => {
52+
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);
71+
}
72+
73+
setLabs() {
5174
if(typeof this.courseRecord !== "undefined") {
5275
let labs = this.courseRecord.labs;
5376
let totalCompleted = 0;
@@ -63,6 +86,7 @@ declare var Collections: any;
6386
}
6487
}
6588
this.labs.push({
89+
'id': lab._id,
6690
'name': 'Lab ' + (i + 1).toString(),
6791
'completed': tasksCompleted.toString() + '/' + tasks.length.toString(),
6892
'date': 'soon'
@@ -73,35 +97,12 @@ declare var Collections: any;
7397
this.determinateValue = (totalCompleted * 100.0) / totalNumTasks;
7498
}
7599
}
76-
getCourseRecords(){
77-
var record;
78-
if(this.cur_user) {
79-
// Student
80-
this.subscribe('course-records', [this.courseId, Meteor.userId()], () => {
81-
record = Collections.course_records.findOne({ course_id: this.courseId, user_id: Meteor.userId() });
82-
}, true);
83-
return record;
84-
}
85-
else{
86-
var record;
87-
this.subscribe('course-records', [this.courseId, this.userId], () => {
88-
var localCourseRecord = Collections.course_records.findOne({ course_id: this.courseId, user_id: this.userId });
89-
if (localCourseRecord === null || typeof localCourseRecord === "undefined") {
90-
// Admin
91-
record = Meteor.call('getUserCourseRecord', this.courseId, this.userId);
92-
}
93-
else {
94-
// Instructor
95-
record = localCourseRecord;
96-
}
97-
}, true);
98-
return record;
99-
}
100-
}
101100

102101
ngOnInit(){
103-
this.userId = this.route.snapshot.params['userid'];
102+
this.userId = this.router.routerState.parent(this.route).snapshot.params['userid'];
103+
this.courseId = this.router.routerState.parent(this.route).snapshot.params['courseid'];
104104
this.cur_user = (typeof this.userId === "undefined" || this.userId === null);
105+
this.getCourseRecords();
105106
}
106107

107108
}

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

Lines changed: 0 additions & 3 deletions
This file was deleted.

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

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="tuxlab-courselist">
2+
<md-card>
3+
<md-card-title>
4+
<span class="md-headline">Course List</span>
5+
</md-card-title>
6+
<md-card-content>
7+
<md-data-table layout-fill>
8+
<thead>
9+
<tr>
10+
<th class="md-text-cell">Course Number</th>
11+
<th class="md-text-cell">Course Name</th>
12+
<th>Instructor(s)</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
<tr *ngFor="let course of courses" (click)="toCourse(course)">
17+
<td class="md-text-cell">{{ course.course_number }}</td>
18+
<td class="md-text-cell">{{ course.course_name }}</td>
19+
<td>
20+
<div *ngFor="let instructor of course.instructors">
21+
{{ instructor.name }}
22+
</div>
23+
</td>
24+
</tr>
25+
</tbody>
26+
</md-data-table>
27+
</md-card-content>
28+
</md-card>
29+
</div>

0 commit comments

Comments
 (0)