diff --git a/routes/index.js b/routes/index.js index 7077e40..8fa81b1 100644 --- a/routes/index.js +++ b/routes/index.js @@ -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 @@ -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 **/ diff --git a/smileplug.js b/smileplug.js index 20bad36..ba3f8b5 100644 --- a/smileplug.js +++ b/smileplug.js @@ -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 **/ @@ -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); /**