diff --git a/client/imports/ui/components/explore/search.ts b/client/imports/ui/components/explore/search.ts index 53a70f2c..d93998bd 100644 --- a/client/imports/ui/components/explore/search.ts +++ b/client/imports/ui/components/explore/search.ts @@ -36,7 +36,7 @@ viewProviders: [ MdIconRegistry ], encapsulation: ViewEncapsulation.None }) - + // Export Explore Class export class SearchView extends MeteorComponent { @@ -47,30 +47,29 @@ export class SearchView extends MeteorComponent { totalItems: this.courses.length }; pagedCourses: Array = []; - + constructor(mdIconRegistry: MdIconRegistry) { super(); - + // Create Icon Font mdIconRegistry.registerFontClassAlias('tux', 'tuxicon'); mdIconRegistry.setDefaultFontSetClass('tuxicon'); - - // Subscribe Courses Database - //this.getCourses(); + + // Subscribe Courses Database this.subscribe('all-courses', () => { this.courses = courses.find().fetch(); this.pagination.totalItems = this.courses.length; this.refreshCourses(); }, true); } - + // Refresh Courses List refreshCourses() { let start = (this.pagination.currentPage - 1) * this.pagination.itemsPerPage; let end = start + this.pagination.itemsPerPage; this.pagedCourses = this.courses.slice(start, end); } - + // Display the infomation of current state of pagination getCurrentInfo() { // This is the number of the first item on the current page @@ -88,29 +87,29 @@ export class SearchView extends MeteorComponent { return start.toString() + "-" + end.toString() + " of " + this.pagination.totalItems.toString(); } - + // Go to next page function nextPage() { - + // Get the current page let currentPage = this.pagination.currentPage; - + // Get the last possible page let lastPage = Math.ceil(this.pagination.totalItems / this.pagination.itemsPerPage); - + // Check if the current page is the last page if (currentPage !== lastPage) { this.pagination.currentPage ++; this.refreshCourses(); } } - + // Go to previous page function prevPage() { - + // Get the current page let currentPage = this.pagination.currentPage; - + // Check if the current page is the first page if (currentPage !== 1) { this.pagination.currentPage --; @@ -118,4 +117,3 @@ export class SearchView extends MeteorComponent { } } } - diff --git a/collections/README.md b/collections/README.md index e99abd57..ae9cc73b 100644 --- a/collections/README.md +++ b/collections/README.md @@ -60,6 +60,8 @@ The following document describes the MongoDB Schema used by the TuxLab app: course_number: "15-131", course_name: "Great Practical Ideas for Computer Scientists", instructor_name: "Tom Cortina", + hidden: true, // Course is invisible to students. Default is true. + disabled: false, // Enrollment in course is still open. Default is true. course_description: { content: "This is the course description.", syllabus: "This is the course syllabus" diff --git a/server/imports/lab/methods.ts b/server/imports/lab/methods.ts index 9cf5af26..7de5eec5 100644 --- a/server/imports/lab/methods.ts +++ b/server/imports/lab/methods.ts @@ -1,10 +1,28 @@ +import { Meteor } from 'meteor/meteor'; +import { Mongo } from 'meteor/mongo'; +import { check } from 'meteor/check'; + declare var Collections : any; + Meteor.methods({ 'prepareLab': function(courseId : String,labId : Number){ console.log("here"); // var course = Collections.courses.findOne({_id: courseId}).fetch(); //var t = require('../api/labExec.js'); // return course.labs.find((l) => { return l._id == labId; }); - } + }, + 'search_courses': function(text : String){ + var courses = Collections.courses; + + var search_pattern = new RegExp(text,"i"); + + var number_search = {"course_number" : search_pattern}; + var alternate_number_search = {$where: "this.course_number.replace(/[ .-]/g,'') == '"+text+"'"}; + var name_results = {"course_name" : search_pattern}; + + var results = courses.find({$and : [{"visible" : true}, {$or : [number_search, alternate_number_search, name_results]}}).limit(15); + + return results; + } }); diff --git a/tests/example_data/labfile1.js b/tests/example_data/labfile1.js index ca8d39b0..1671afd1 100644 --- a/tests/example_data/labfile1.js +++ b/tests/example_data/labfile1.js @@ -27,9 +27,40 @@ tuxlab.tasks = function(env){ var v3 = function(){} var s4 = function(){} var v4 = function(){} + /* @task1 this is task 1 + tomato{} + hi(); + @onevar1 + I'm a cheesepuff + @othervar1 + */ var task1 = tuxlab.newTask('TASK1','MD1',s1,v1) + /* +@task2 +this is task 2 + potato{} + bye(); + @onevar2 + I'm a cheesepuff + @anothervar2 + */ var task2 = tuxlab.newTask('TASK2','MD2',s2,v2) + /*@task3 this is task 3 + onion{} + later(); + @onevar3 + I'm a cheesepuff + @othervar3 + */ var task3 = tuxlab.newTask('TASK3','MD3',s3,v3) + /* + @task4 this is task 4 + turnip{} + ello(); + @onevar4 + I'm a cheesepuff + @othervar4 + */ var task4 = tuxlab.newTask('TASK4','MD4',s4,v4) return tuxlab.init() .nextTask(task1)