Skip to content

Commit

Permalink
Allow different possible answers
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiselrahman committed Sep 8, 2019
1 parent 3eea118 commit be1246a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,76 +10,76 @@ export default [
type: "text",
name: "Error",
title: 'Name a 5 letter word which has three consonants all the same and two different vowels. Every now and then you see this while running a windows 95/98 on your PC.',
correctAnswer: 'Error',
correctAnswer: 'error',
}]
}, {
questions: [{
type: "text",
name: "Big Mac",
title: 'What do you get when you cross a hamburger with a computer ?',
correctAnswer: 'Big Mac',
correctAnswer: ['big mac', 'bigmac'],
}]
}, {
questions: [{
type: "text",
name: "Firewall",
title: 'I am a Barrier that acts as a security system to protect trusted computer system. Who am I ?',
correctAnswer: 'Firewall',
correctAnswer: 'firewall',
}]
}, {
questions: [{
type: "text",
name: "Intranet",
title: 'Basically a private internal internet specific to an organisation or a group. Who am I ?',
correctAnswer: 'Intranet',
correctAnswer: 'intranet',
}]
},
{
questions: [{
type: "text",
name: "Computer Disc",
title: 'I come in square package but I am round, I contain lots of Information for your Computer, handle me carefully, What am I ?',
correctAnswer: 'Compact Disc',
correctAnswer: ['compact disc', 'cd'],
}]
},
{
questions: [{
type: "text",
name: "Home Page",
title: 'You can see me usually at the starting point of an organisation website. Who am I ?',
correctAnswer: 'Home Page',
correctAnswer: ['homepage', 'home page'],
}]
},
{
questions: [{
type: "text",
name: "Saas",
title: 'I am a software distribution model where software applications are centrally hosted and licensed on subscription basis. Who am I ?',
correctAnswer: 'Saas',
correctAnswer: ['software as a service', 'saas'],
}]
},
{
questions: [{
type: "text",
name: "ACCRINTM",
title: 'Find the MS Excel function to return accrued interest for a security that pays interest at maturity is',
correctAnswer: 'ACCRINTM',
correctAnswer: 'accrintm',
}]
},
{
questions: [{
type: "text",
name: "C++",
title: 'My name has a post Increment but not Preincrement. Every Software Engineer knows my name',
correctAnswer: 'C++',
correctAnswer: 'c++',
}]
},
{
questions: [{
type: "text",
name: "Pointer",
title: "I provide way to find some other, my name ends with 'R', I am not a palindrome find me who I am ?",
correctAnswer: 'Pointer',
correctAnswer: 'pointer',
}]
},
]
32 changes: 22 additions & 10 deletions src/views/GoogleIt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
this.isSignedIn = firebaseAuth.currentUser != null;
firebaseAuth.onAuthStateChanged(u => {
this.isSignedIn = !!u && u.currentUser !== null;
if(!this.isSignedIn) {
if (!this.isSignedIn) {
window.localStorage.removeItem(this.storageName);
}
});
Expand All @@ -61,9 +61,9 @@ export default {
var res = {
currentPageNo: survey.currentPageNo,
data: survey.data,
timeSpent: survey.currentPage.timeSpent,
timeSpent: survey.currentPage.timeSpent
};
window.localStorage.setItem(this.storageName, JSON.stringify(res));
},
loadState(survey) {
Expand All @@ -79,15 +79,18 @@ export default {
},
mounted() {
this.survey.onComplete.add(survey => {
firebase.firestore().collection('google-it').doc(firebaseAuth.currentUser.email).set(
{
firestore
.collection("google-it")
.doc(firebaseAuth.currentUser.email)
.set({
name: firebaseAuth.currentUser.email,
score: this.survey.getCorrectedAnswerCount(),
}
).catch(e => {
console.log(e);
});
score: this.survey.getCorrectedAnswerCount()
})
.catch(e => {
console.log(e);
});
console.log({ score: this.survey.getCorrectedAnswerCount() });
clearInterval(this.timerId);
this.saveState(survey);
});
Expand All @@ -106,6 +109,15 @@ export default {
options.text = `Remining Time: ${sender.maxTimeToFinishPage -
sender.currentPage.timeSpent}s`;
});
this.survey.onIsAnswerCorrect.add((sender, options) => {
let question = options.question;
if (Array.isArray(question.correctAnswer)) {
let answers = question.correctAnswer;
let value = question.value == null ? "" : question.value.toLowerCase();
options.result = answers.find(t => t == value) != null;
}
});
}
};
</script>
Expand Down

0 comments on commit be1246a

Please sign in to comment.