Skip to content

Commit 3df5ed1

Browse files
cemersozDerekTBrown
authored andcommitted
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
1 parent 574d273 commit 3df5ed1

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

collections/labs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ declare var _ : any;
66
var _ = require('underscore');
77

88
declare var validateLab : any;
9-
var validateLab : any = require('../server/imports/lab/checkLab');
109

1110
export const labs : any = new Mongo.Collection('labs');
1211

@@ -99,6 +98,7 @@ labs.allow({
9998

10099
/* LAB VALIDATOR */
101100
if(Meteor.isServer){
101+
var valdateLab : any = require('../server/imports/lab/checkLab.js');
102102
Meteor.startup(function(){
103103
var LabValidator = function(userid, doc, fieldNames?, modifier?, options?){
104104
if (typeof fieldNames === "undefined"){

server/imports/lab/checkLab.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
declare module "validateLab" {
2-
export function validateLab(str: string): boolean
2+
export function validateLab(str: string): any
33
}

server/imports/lab/checkLab.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var tuxOrig = require('./lab.js');
44

55
/// <reference path="./checkLab.d.ts" />
66
module.exports = function(str){
7-
if(!str) { return false; } //check for file import
7+
if(!str) { return null; } //check for file import
88
var tux = eval(str);
99
if(((typeof tux != "undefined") &&
1010
(typeof tux.setup === 'function') && //check for instructor field types
@@ -17,4 +17,5 @@ module.exports = function(str){
1717
else{
1818
return tux.titleList;
1919
}
20+
return null;
2021
}

server/imports/lab/methods.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ Meteor.methods({
2424
var uId = Meteor.userId();
2525
SessionCache.get(uId,labId,function(err,res){
2626
if(err || !res){
27-
console.log("Internal Service Error");
27+
callback("Internal Service Error",null);
2828
}
2929
else{
30-
30+
res.next(callback);
3131
}
3232
});
3333
},
34-
'endLab': function(callback : any){
34+
'endLab': function(labId : string, callback : any){
3535
/**session.end(cb)
3636
* cb(err,res)
3737
* call endLab callback(err,res) in cb
@@ -40,5 +40,14 @@ Meteor.methods({
4040
* session.env.removeVm removes virtual machines.
4141
* remove all vms and deleterecords after lab is completed for good. -highly optional
4242
*/
43+
var uId = Meteor.userId();
44+
SessionCache.get(uId,labId,function(err,res){
45+
if(err || !res){
46+
callback("Internal Service Error",null);
47+
}
48+
else{
49+
res.end(callback);
50+
}
51+
});
4352
}
4453
});

0 commit comments

Comments
 (0)