Skip to content

Commit 4d16e87

Browse files
cemersozDerekTBrown
authored andcommitted
fixed typescript warning, implemented md (#173)
* 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 * api changes (#126) * 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 * before merge * removed testing change * fixed typo * fixed prepareLab * removed test methods * fix prepareLab * methods changes * removed swap file * fixed merge * fixes * prepareLab WORKS * further fixes * merge * all works * deleted debug line * fixed minor excess code * minor indentation fix * reference fixes * fixes to nextTask * merged with master * minor changes * fixed merge problems * fixed md view and swithces * fixed error messages * removed debug code * removed swp * fixes * fixed typescript warning * added student object * changed function calls * deleted unnecessary files * updated api, added md feedback * fixed ts warn
1 parent 7f9a7d2 commit 4d16e87

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

client/imports/ui/pages/lab/taskview.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ export default class TaskView extends MeteorComponent {
6060
currentCompleted: boolean;
6161
courseId: string;
6262
nextButton : boolean;
63+
taskUpdates : Array<string>
6364
@ViewChild(Terminal) term : Terminal;
6465

6566

6667
constructor() {
6768
super();
69+
this.taskUpdates = [];
70+
this.nextButton = false;
6871
this.tasks = [
6972
{ id: 1, name: "Task 1", completed: true, md: "# Task 1" },
7073
{ id: 2, name: "Task 2", completed: true, md: "# Task 2" },
@@ -88,7 +91,8 @@ export default class TaskView extends MeteorComponent {
8891
password: res.sshInfo.pass,
8992
domain: "10.100.1.11"
9093
};
91-
console.log("here");
94+
slf.taskUpdates = res.taskUpdates;
95+
9296
slf.term.openTerminal(slf.auth);
9397
console.log("fired",err,res);
9498
});
@@ -97,16 +101,18 @@ export default class TaskView extends MeteorComponent {
97101
//called by the check button, I'm already calling this
98102
verify(){
99103
Meteor.call('verifyTask',"1",function(err,res){
104+
var slf = this;
100105
if(err){
101106
console.log("something went horribly wrong");
102107
}
103108
else{
104-
if(res){
105-
nextButton = true;
109+
if(res.verified){
110+
slf.nextButton = true;
106111
}
107112
else{
108-
nextButton = false;
113+
slf.nextButton = false;
109114
}
115+
slf.taskUpdates = res.taskUpdates;
110116
}
111117
});
112118
}
@@ -117,15 +123,16 @@ export default class TaskView extends MeteorComponent {
117123
var slf = this;
118124
Meteor.call('nextTask',"1",function(err,res){
119125
if(err){
126+
slf.nextButton = false;
120127
console.log("try again");
121128
}
122129
else{
123130
console.log(res);
124131
slf.tasks = res.taskList
125132
slf.toTask(slf.tasks[res.taskNo-1]);
126133
slf.labProgress = res.taskNo+" / "+slf.tasks.length
134+
slf.taskUpdates = res.taskUpdates
127135
}
128-
console.log("yay");
129136
});
130137
}
131138
toTask(task) {

server/imports/api/lab.session.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var session = function(){};
66
session.prototype.env = null;
77
session.prototype.lab = null;
88
session.prototype.student = null;
9+
session.prototype.taskUpdates = [];
10+
911
/* init: pulls labFile and initializes session object from it
1012
*/
1113
session.prototype.init = function(user,userId,labId,callback){
@@ -18,7 +20,7 @@ session.prototype.init = function(user,userId,labId,callback){
1820
var courseId = lab_data.course_id;
1921

2022
//initialize student object
21-
this.student = new student(userId,labId,courseId);
23+
this.student = new student(this, userId,labId,courseId);
2224

2325
if(!lab_data || lab_data.length < 0){
2426
TuxLog.log("warn",new Error("Lab not found"));
@@ -143,9 +145,10 @@ session.prototype.start = function(callback){
143145

144146

145147
session.prototype.verify = function(callback){
146-
148+
var slf = this;
147149
slf.lab.currentTask.verifyFn(slf.env,slf.student)
148-
.then(callback(true),callback(false));
150+
.then(callback({verified: true, taskUpdates: slf.taskUpdates}),callback({verified: false,taskUpdates: slf.taskUpdates}));
151+
149152
}
150153
/* next: verifies that task is completed
151154
* moves on to next task and runs callback(null,parseTasks) if completed
@@ -168,7 +171,7 @@ session.prototype.next = function(callback){
168171
slf.lab.currentTask.setupFn(slf.env,slf.student)
169172
.then(function(){
170173
slf.lab.taskNo += 1;
171-
callback(null,slf.lab.taskNo);
174+
callback(null,{taskNo: slf.lab.taskNo,taskUpdates: slf.taskUpdates});
172175
},
173176
function(err){
174177
TuxLog.log("warn",err);

server/imports/api/lab.student.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
var student = function(userId, labId, courseId){
2+
var student = function(session, userId, labId, courseId){
3+
this.session = session;
34
this.userId = userId;
45
this.labId = labId;
56
this.courseId = courseId;
@@ -8,6 +9,12 @@ var student = function(userId, labId, courseId){
89
student.prototype.userId = null;
910
student.prototype.labId = null;
1011
student.prototype.courseId = null;
12+
student.prototype.session = null;
13+
14+
15+
student.prototype.feedback = function(taskNo,md){
16+
this.session.taskUpdates[taskNo] = md;
17+
}
1118

1219
student.prototype.setGrade = function(taskNo, grade){
1320

server/imports/lab/labMethods.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function getSession(user : string, userId, labId : string, callback : any) : voi
3333
}
3434
else{
3535
console.log(result);
36-
callback(null,{taskNo:res.lab.taskNo,sshPass:result});
36+
callback(null,{taskNo:res.lab.taskNo,sshPass:result,taskUpdates: res.taskUpdates});
3737
}
3838
})
3939
}
@@ -83,14 +83,16 @@ export function prepLab(user : string,userId: string, labId : string, callback :
8383

8484
//parse sshInfo from nconf and results
8585
var sshInfo = {host : nconf.get("domain_root"), pass: res.sshPass};
86+
var taskUpdates = res.taskUpdates;
87+
8688
//map taskList into frontend schema
8789
mapTasks(labId,res.taskNo,function(err,res){
8890
if(err){
8991
//cannot have an error
9092
callback(err,null);
9193
}
9294
else{
93-
callback(null,{sshInfo: sshInfo, taskList: res});
95+
callback(null,{sshInfo: sshInfo, taskList: res, taskUpdates: taskUpdates});
9496
}
9597
});
9698
}
@@ -108,14 +110,7 @@ export function verify(uId : string, labId : string, callback : any) : void{
108110
callback(new Meteor.Error("Session.get returned no result for session in use"),null);
109111
}
110112
else{
111-
result.verify(function(succ){
112-
if(!succ){
113-
callback(null,false);
114-
}
115-
else{
116-
callback(null,true);
117-
}
118-
})
113+
result.verify(callback);
119114
}
120115
});
121116

@@ -146,7 +141,7 @@ export function next(uId : string,labId : string, callback : any) : void{
146141
callback(err,null);
147142
}
148143
else{
149-
callback(null,{taskList: ress, taskNo:res});
144+
callback(null,{taskList: ress, taskNo:res, taskUpdates:result.taskUpdates});
150145
}
151146
});
152147
}

0 commit comments

Comments
 (0)