Skip to content

Commit

Permalink
Merge pull request #58 from chrqls/dev
Browse files Browse the repository at this point in the history
[#26 + s_t_a/#41] Calling "handlePostNewIQSet" now to save questions
  • Loading branch information
Charles Quelos committed Dec 5, 2013
2 parents db0e1b6 + 80c06ce commit 50dbf8b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
36 changes: 17 additions & 19 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ exports.handleDeleteIQSet = function(req, res) {
});
};


/**
Save a new iqset from teacher app
**/
exports.handlePostNewIQSet = function(req, res) {
// console.log(req);

console.log("\n\n[BODY of json request]");
console.log("\t>> %j\n", req.body);
console.log("[HEADERS of json request]");
console.log("\t>> %j\n\n", req.headers);

var headers = req.headers;
var iqset;

console.log("\theaders['content-type'] >> %j", headers['content-type']);
console.log("\theaders['content-type'] >> " + headers['content-type'] + "\n\n");

if (headers['content-type'] === 'applicaton/json; charset=UTF-8') {
//if (headers['content-type'] === 'applicaton/json') {

console.log('/!\\ THE CONDITION IS TRUE');
console.log('Handle post of iqset from json');
//
// Handle the upload from JSON
Expand Down Expand Up @@ -548,24 +564,6 @@ exports.handlePushMessage = function(req, res) {
}
};


/**
Save a new iqset from teacher app
**/
exports.saveNewIQSet = function(req, res) {

try {
// console.log('\n## JSON from "saveNewIQSet" ##');
console.log('\n\t>> '+req.body.title);
console.log('\t>> %j\n', req.body.iqdata);

} catch (e) {
res.handleError('Can\'t parse Incoming JSON in "saveNewIQSet" method');
}

return res.sendText(HTTP_STATUS_OK, OK);
};

/**
Creating a session with teacher name, session title, and group name
**/
Expand Down
11 changes: 5 additions & 6 deletions smileplug.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ js.get('/smile/metadata/rating', routes.handleRatingMetadataGet);
js.put('/smile/question', routes.handlePushMessage);
js.post('/smile/question', routes.handlePushMessage);

/**
Save a new iqset from teacher app
**/
js.put('/smile/saveiqset', routes.saveNewIQSet);
js.post('/smile/saveiqset', routes.saveNewIQSet);

/**
Create a session from smile_teacher_android app
**/
Expand Down Expand Up @@ -182,6 +176,11 @@ js.get('/smile/iqset/:id', routes.handleGetIQSet, true);
@method /smile/iqset
**/

/**
Save a new iqset from teacher app
**/
js.put('/smile/iqset', routes.handlePostNewIQSet);
js.post('/smile/iqset', routes.handlePostNewIQSet);

/**
Expand Down

0 comments on commit 50dbf8b

Please sign in to comment.