Skip to content

Labfile markdown #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions client/imports/ui/components/explore/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
viewProviders: [ MdIconRegistry ],
encapsulation: ViewEncapsulation.None
})

// Export Explore Class
export class SearchView extends MeteorComponent {

Expand All @@ -47,30 +47,29 @@ export class SearchView extends MeteorComponent {
totalItems: this.courses.length
};
pagedCourses: Array<any> = [];

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
Expand All @@ -88,34 +87,33 @@ 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 --;
this.refreshCourses();
}
}
}

2 changes: 2 additions & 0 deletions collections/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 19 additions & 1 deletion server/imports/lab/methods.ts
Original file line number Diff line number Diff line change
@@ -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;
}
});

31 changes: 31 additions & 0 deletions tests/example_data/labfile1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down