Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
steve committed Aug 5, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 90174bd commit efb6e73
Showing 2 changed files with 40 additions and 2 deletions.
7 changes: 7 additions & 0 deletions client/src/AppLayout.js
Original file line number Diff line number Diff line change
@@ -92,6 +92,7 @@ export default class AppLayout extends Component {
this.GoogleAuth = null; // Google Auth object.
this.mqttClient = null;
this.mqttClientId = null;
this.messageTimeout = null;

let userString = localStorage.getItem('users');
if (userString) {
@@ -1103,7 +1104,13 @@ export default class AppLayout extends Component {
};

setMessage(message) {
let that = this;
this.setState({'message':message});
if (this.messageTimeout) clearTimeout(this.messageTimeout);
this.messageTimeout = setTimeout(function() {
that.setState({message:null})
},3000)

};

saveSuggestion(id,question,mnemonic,technique) {
35 changes: 33 additions & 2 deletions routes/api_utils.js
Original file line number Diff line number Diff line change
@@ -509,6 +509,11 @@ function initRoutes(router,db) {
} else {
record.hasMnemonic = false;
}
try {
if (record.headlineFacts) record.headlineFacts = JSON.parse(record.headlineFacts)
} catch (e) {
record.headlineFacts = {}
}

function reallySaveRecord(record,resolve,reject,mnemonics,recordIndex) {
db().collection('questions').save(record).then(function(resy) {
@@ -518,12 +523,18 @@ function initRoutes(router,db) {
let newMnemonic = {user:'default',question:record._id,mnemonic:record.mnemonic,questionText:record.question,technique:record.mnemonic_technique,importId:importId};
mnemonics.push(newMnemonic);
}

let hasGenerator = record.options_generator_collection && record.options_generator_filter && record.options_generator_field ? true : false;
let hasGenerator2 = record.options_generator_collection2 && record.options_generator_filter2 && record.options_generator_field2 ? true : false;

//options_generator_collection:'questions',options_generator_filter:JSON.stringify({importtype:{"$eq":'musician'}}),options_generator_field:'date'

if (record.quiz && record.quiz.length > 0
&& record.specific_question && record.specific_question.length > 0
&& record.specific_answer && record.specific_answer.length > 0
&& record.multiple_choices && record.multiple_choices.length > 0
&& (record.multiple_choices && record.multiple_choices.length > 0 || hasGenerator)
) {
let newQuestion ={topic:record.quiz,question:record.specific_question,answer:record.specific_answer,multiple_choices:record.multiple_choices,feedback:record.feedback,importId:'QQ-'+importId,user:'default',image:record.image,autoshow_image:record.autoshow_image,sort:record.sort,difficulty:record.difficulty}
let newQuestion ={topic:record.quiz,question:record.specific_question,answer:record.specific_answer,multiple_choices:record.multiple_choices,feedback:record.feedback,importId:'QQ-'+importId,user:'default',image:record.image,autoshow_image:record.autoshow_image,sort:record.sort,difficulty:record.difficulty,options_generator_collection:question.options_generator_collection,options_generator_filter:question.options_generator_filter,options_generator_field:question.options_generator_field}
console.log('NEWQ',JSON.stringify(newQuestion))

try {
@@ -535,6 +546,26 @@ function initRoutes(router,db) {

mcQuestions.push(newQuestion)
}
// second MC question
if (record.quiz && record.quiz.length > 0
&& record.specific_question2 && record.specific_question2.length > 0
&& record.specific_answer2 && record.specific_answer2.length > 0
&& (record.multiple_choices2 && record.multiple_choices2.length > 0 || hasGenerator2)
) {
let newQuestion ={topic:record.quiz,question:record.specific_question2,answer:record.specific_answer2,multiple_choices:record.multiple_choices2,feedback:record.feedback2,importId:'QQ-'+importId,user:'default',image:record.image,autoshow_image:record.autoshow_image,sort:record.sort,difficulty:record.difficulty,options_generator_collection:question.options_generator_collection2,options_generator_filter:question.options_generator_filter2,options_generator_field:question.options_generator_field2}
console.log('NEWQ',JSON.stringify(newQuestion))

try {
newQuestion._id=(record.mcQuestionId && record.mcQuestionId.length > 0 ? ObjectId(record.mcQuestionId) : ObjectId())
} catch (e) {}
newQuestion.questionId = record._id; //(record._id && record._id.length > 0 ? ObjectId(record._id) : ObjectId())

if (record.autoplay_media==="YES" && record.media) newQuestion.media = record.media;

mcQuestions.push(newQuestion)
}


//console.log(['SAVED QUESTION',record._id,record])
recordIndex[record._id] = record;

0 comments on commit efb6e73

Please sign in to comment.