Advertisement
Guest User

test.class.js

a guest
Feb 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Test extends Base {
  2.  
  3.     constructor(propertyValues) {
  4.         super(propertyValues);
  5.        
  6.         $("#content").empty();
  7.         var questionList = new QuestionList();
  8.         this.questionList = questionList;
  9.         var alternativeList = new AlternativeList();
  10.         this.alternativeList = alternativeList;
  11.  
  12.         this.currentQuestion = 0;
  13.         this.answers = [];
  14.  
  15.         var checkGrade = new UserList();
  16.         checkGrade.checkGrade(() => {
  17.             if (checkGrade.length > 0) {
  18.                 var userDenied = new UserDenied();
  19.                 userDenied.display('#content');
  20.             } else {
  21.                 questionList.readAllQuestions(() => {
  22.                     for (var question of this.questionList) {
  23.                         question.nbrOfQuestions = this.questionList.length;
  24.                         this.answers.push(1);
  25.                     }
  26.  
  27.                     alternativeList.readAllAlternatives(() => {
  28.                         this.showQuestion();
  29.                        
  30.                     });
  31.  
  32.                 });
  33.  
  34.             }
  35.         });
  36.  
  37.     }
  38.  
  39.     insertAnswers(callback) {
  40.         for (let i = 0; i < this.answers.length; i++) {
  41.             this.db.insertAnswer({
  42.                 user_userId: window.user,
  43.                 alternative_optionId: this.answers[i]
  44.             }, callback);
  45.         }
  46.     }
  47.  
  48.     showQuestion() {
  49.         $('#content').empty();
  50.         this.questionList[this.currentQuestion].display('#content');
  51.  
  52.         for (var alternative of this.alternativeList) {
  53.             if (alternative.question_questionId === this.questionList[this.currentQuestion].questionId) {
  54.                 alternative.display('#content');
  55.             }
  56.         }
  57.  
  58.         var buttons = new Buttons();
  59.         buttons.test = this;
  60.         buttons.display('#content');
  61.     }
  62.  
  63.     static get sqlQueries() {
  64.         return {
  65.             insertAnswer: `
  66.         INSERT user_answers_alternative SET ?
  67.    
  68.       `
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement