Skip to content
Permalink
Browse files
final commit
  • Loading branch information
dasilv32 committed Apr 24, 2020
1 parent 48e4504 commit 98614151597199938c45a6d17bbda825151c225e
Show file tree
Hide file tree
Showing 15 changed files with 1,096 additions and 245 deletions.
@@ -0,0 +1,27 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
}
};
@@ -10,7 +10,7 @@ module.exports = class Question {
//CHECK IF TABLE EXISTS ELSE CREATE
const sql = 'CREATE TABLE IF NOT EXISTS available_questions (\
id INTEGER PRIMARY KEY AUTOINCREMENT,\
question TEXT, possible_answer1 TEXT, possible_answer2 TEXT, possible_answer3 TEXT, correct_answer TEXT\
question TEXT, possible_answer1 TEXT, possible_answer2 TEXT, possible_answer3 TEXT, correct_answer TEXT, user_answer TEXT\
);'
await this.db.run(sql)
return this
@@ -29,13 +29,28 @@ module.exports = class Question {
console.log(err.message)
throw err
}

}

//INSERT USER ANSWER IN DB - QUIZ
async getanswer(user_answer){
try{
console.log(user_answer)
const sql = `INSERT INTO available_questions(user_answer)\
VALUES("${user_answer.user_answer}")`
console.log(sql)
await this.db.run(sql)
} catch(err) {
console.log(err.message)
throw err
}
}

//SELECT MOST QUESTIONS IN DB
async all(){
try {
console.log('ALL questions')
const sql = 'SELECT id, question, possible_answer1, possible_answer2, possible_answer3, correct_answer FROM available_questions'
const sql = 'SELECT * FROM available_questions'
console.log(sql)
const questiont = await this.db.all(sql)
console.log(questiont)

0 comments on commit 9861415

Please sign in to comment.