Skip to content

Commit d38eb75

Browse files
amortensonDerekTBrown
authored andcommitted
added labfile with markdown (#108)
Labfile markdown (#111) * added labfile with markdown * added course search method
1 parent e9434e5 commit d38eb75

File tree

4 files changed

+66
-17
lines changed

4 files changed

+66
-17
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
viewProviders: [ MdIconRegistry ],
3737
encapsulation: ViewEncapsulation.None
3838
})
39-
39+
4040
// Export Explore Class
4141
export class SearchView extends MeteorComponent {
4242

@@ -47,30 +47,29 @@ export class SearchView extends MeteorComponent {
4747
totalItems: this.courses.length
4848
};
4949
pagedCourses: Array<any> = [];
50-
50+
5151
constructor(mdIconRegistry: MdIconRegistry) {
5252
super();
53-
53+
5454
// Create Icon Font
5555
mdIconRegistry.registerFontClassAlias('tux', 'tuxicon');
5656
mdIconRegistry.setDefaultFontSetClass('tuxicon');
57-
58-
// Subscribe Courses Database
59-
//this.getCourses();
57+
58+
// Subscribe Courses Database
6059
this.subscribe('all-courses', () => {
6160
this.courses = courses.find().fetch();
6261
this.pagination.totalItems = this.courses.length;
6362
this.refreshCourses();
6463
}, true);
6564
}
66-
65+
6766
// Refresh Courses List
6867
refreshCourses() {
6968
let start = (this.pagination.currentPage - 1) * this.pagination.itemsPerPage;
7069
let end = start + this.pagination.itemsPerPage;
7170
this.pagedCourses = this.courses.slice(start, end);
7271
}
73-
72+
7473
// Display the infomation of current state of pagination
7574
getCurrentInfo() {
7675
// This is the number of the first item on the current page
@@ -88,34 +87,33 @@ export class SearchView extends MeteorComponent {
8887

8988
return start.toString() + "-" + end.toString() + " of " + this.pagination.totalItems.toString();
9089
}
91-
90+
9291
// Go to next page function
9392
nextPage() {
94-
93+
9594
// Get the current page
9695
let currentPage = this.pagination.currentPage;
97-
96+
9897
// Get the last possible page
9998
let lastPage = Math.ceil(this.pagination.totalItems / this.pagination.itemsPerPage);
100-
99+
101100
// Check if the current page is the last page
102101
if (currentPage !== lastPage) {
103102
this.pagination.currentPage ++;
104103
this.refreshCourses();
105104
}
106105
}
107-
106+
108107
// Go to previous page function
109108
prevPage() {
110-
109+
111110
// Get the current page
112111
let currentPage = this.pagination.currentPage;
113-
112+
114113
// Check if the current page is the first page
115114
if (currentPage !== 1) {
116115
this.pagination.currentPage --;
117116
this.refreshCourses();
118117
}
119118
}
120119
}
121-

collections/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ The following document describes the MongoDB Schema used by the TuxLab app:
6060
course_number: "15-131",
6161
course_name: "Great Practical Ideas for Computer Scientists",
6262
instructor_name: "Tom Cortina",
63+
hidden: true, // Course is invisible to students. Default is true.
64+
disabled: false, // Enrollment in course is still open. Default is true.
6365
course_description: {
6466
content: "This is the course description.",
6567
syllabus: "This is the course syllabus"

server/imports/lab/methods.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
import { Meteor } from 'meteor/meteor';
2+
import { Mongo } from 'meteor/mongo';
3+
import { check } from 'meteor/check';
4+
15
declare var Collections : any;
6+
27
Meteor.methods({
38
'prepareLab': function(courseId : String,labId : Number){
49
console.log("here");
510
// var course = Collections.courses.findOne({_id: courseId}).fetch();
611
//var t = require('../api/labExec.js');
712
// return course.labs.find((l) => { return l._id == labId; });
8-
}
13+
},
14+
'search_courses': function(text : String){
15+
var courses = Collections.courses;
16+
17+
var search_pattern = new RegExp(text,"i");
18+
19+
var number_search = {"course_number" : search_pattern};
20+
var alternate_number_search = {$where: "this.course_number.replace(/[ .-]/g,'') == '"+text+"'"};
21+
var name_results = {"course_name" : search_pattern};
22+
23+
var results = courses.find({$and : [{"visible" : true}, {$or : [number_search, alternate_number_search, name_results]}}).limit(15);
24+
25+
return results;
26+
}
927
});
1028

tests/example_data/labfile1.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,40 @@ tuxlab.tasks = function(env){
2727
var v3 = function(){}
2828
var s4 = function(){}
2929
var v4 = function(){}
30+
/* @task1 this is task 1
31+
tomato{}
32+
hi();
33+
@onevar1
34+
I'm a cheesepuff
35+
@othervar1
36+
*/
3037
var task1 = tuxlab.newTask('TASK1','MD1',s1,v1)
38+
/*
39+
@task2
40+
this is task 2
41+
potato{}
42+
bye();
43+
@onevar2
44+
I'm a cheesepuff
45+
@anothervar2
46+
*/
3147
var task2 = tuxlab.newTask('TASK2','MD2',s2,v2)
48+
/*@task3 this is task 3
49+
onion{}
50+
later();
51+
@onevar3
52+
I'm a cheesepuff
53+
@othervar3
54+
*/
3255
var task3 = tuxlab.newTask('TASK3','MD3',s3,v3)
56+
/*
57+
@task4 this is task 4
58+
turnip{}
59+
ello();
60+
@onevar4
61+
I'm a cheesepuff
62+
@othervar4
63+
*/
3364
var task4 = tuxlab.newTask('TASK4','MD4',s4,v4)
3465
return tuxlab.init()
3566
.nextTask(task1)

0 commit comments

Comments
 (0)