diff --git a/ajax.php b/ajax.php index cbfe42b..7dfcb34 100644 --- a/ajax.php +++ b/ajax.php @@ -12,7 +12,7 @@ $questID_arr = Question::getList( $quiz->getID() ); $index_int = array_search( $quest->getID(), $questID_arr ); $index_int++; -$nextQuest = new Question( $index_int ); +$nextQuest = new Question( $questID_arr[ $index_int ] ); $ans_arr = $nextQuest->getAnswers(); $data_arr = array( diff --git a/quiz.js b/quiz.js index 719433c..5cac0df 100644 --- a/quiz.js +++ b/quiz.js @@ -16,7 +16,22 @@ $( document ).ready( function() { quest : id.quest[ questNum - 1], ans : ans, } ).done( function( data ){ - console.log( data ); + questNum++; + $( "#question-text" ).text( data.text ); + $( "#answers" ).empty(); + + $.each( data.ans, function( index, value ){ + $( "#answers" ).append( '\ +
\ + \ +
' ); + } ); + + let progress = questNum / id.quest.length * 100; + $( "#progress" ).text( questNum + ' / ' + id.quest.length ).prop( "style", "width: " + progress + "%" ); } ); } ); } ); diff --git a/quiz.php b/quiz.php index 23fd864..d80345a 100644 --- a/quiz.php +++ b/quiz.php @@ -64,7 +64,7 @@ $progress_num = 1 / count( $questID_arr ) * 100;
-
1 /
+
1 /