Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-136
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-136
2021-136
Commits
f15483d9
Commit
f15483d9
authored
Nov 26, 2021
by
Ariyasuthan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
b4c59ef2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
216 additions
and
0 deletions
+216
-0
Front End/JavascriptQuiz.vue
Front End/JavascriptQuiz.vue
+216
-0
No files found.
Front End/JavascriptQuiz.vue
0 → 100644
View file @
f15483d9
<
template
>
<TopBar></TopBar>
<div
class=
"quiz"
>
<h5>
Quiz
</h5>
<div>
<Navbar></Navbar>
</div>
<div
class=
"question-block"
>
<div
class=
"question-box"
v-for=
"(question,index) in showQuestions.slice(a,b)"
:key=
"index"
>
<div
class=
"question"
>
<p1>
{{
question
.
question
}}
</p1>
</div>
<div
class=
"box-propositions"
>
<ul>
<li
v-for=
"(answer,index) in question.answer"
:key=
"index"
class=
"answers"
>
<input
class=
"ans-button"
type=
"radio"
id=
"one"
:value=
"answer.ans"
v-model=
"picked"
>
<label
for=
"one"
>
{{
answer
.
ans
}}
</label><br>
</li>
</ul>
</div>
</div>
</div>
</div>
<div
class=
"menu"
>
<div
class=
"submit"
>
<button
@
click=
"nextQuestion"
>
Next
</button>
</div>
</div>
<div>
</div>
</
template
>
<
script
>
import
axios
from
'
axios
'
import
Navbar
from
"
../components/Navbar.vue
"
import
TopBar
from
"
../components/TopBar.vue
"
export
default
{
name
:
"
JavascriptQuiz
"
,
components
:{
Navbar
,
TopBar
},
data
(){
return
{
questions
:
[]
,
AllQuestions
:[],
showQuestions
:[],
picked
:[],
a
:
0
,
b
:
1
,
i
:
1
}
},
async
beforeCreate
(){
const
result
=
await
axios
.
get
(
"
https://3c39-35-194-244-161.ngrok.io/recommend
"
)
const
quesNum
=
result
.
data
const
ques
=
[]
quesNum
.
forEach
((
element
)
=>
{
let
number
=
element
.
slice
(
1
)
//except the first character
ques
.
push
(
parseInt
(
number
))
});
await
fetch
(
"
http://localhost:3000/RecommendationQuestions-Javascript
"
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
question
)
=>
{
for
(
var
value
of
Object
.
values
(
question
))
{
this
.
AllQuestions
.
push
(
value
)
}
for
(
let
i
=
0
;
i
<
ques
.
length
;
i
++
)
{
// Loop for array2
for
(
let
j
=
0
;
j
<
this
.
AllQuestions
.
length
;
j
++
)
{
// Compare the element of each and
// every element from both of the
// arrays
if
(
ques
[
i
]
===
this
.
AllQuestions
[
j
].
id
)
{
// Return if common element found
this
.
showQuestions
.
push
({
question
:
this
.
AllQuestions
[
j
].
question
,
answer
:
this
.
AllQuestions
[
j
].
answer
})
}
}
}
});
console
.
log
(
'
success
'
)
.
catch
(
error
=>
console
.
log
(
error
))
},
methods
:{
nextQuestion
(){
var
selected
=
[]
if
(
this
.
i
<
this
.
showQuestions
.
length
+
1
)
{
this
.
a
=
this
.
a
+
1
;
this
.
b
=
this
.
b
+
1
// console.log(this.picked)
// console.log(this.i)
// console.log(selected)
selected
.
push
({
'
id
'
:
this
.
i
,
'
answer
'
:
this
.
picked
})
}
// console.log(this.picked)
this
.
picked
=
''
this
.
i
++
;
if
(
this
.
i
===
this
.
showQuestions
.
length
+
1
)
{
this
.
$router
.
push
(
'
/
'
);
}
},
onclick
(
evt
)
{
if
(
evt
.
target
.
checked
)
{
// console.log(this.picked)
return
false
;
}
return
true
;
}
}
}
</
script
>
<
style
scoped
>
.quiz
{
width
:
100%
;
height
:
100%
!important
;
border
:
1px
solid
#CCCCCC
;
padding
:
20px
;
min-height
:
100%
!important
;
min-width
:
100%
!important
;
}
.question-block
{
width
:
75%
!important
;
height
:
auto
;
position
:
absolute
;
justify-content
:
center
!important
;
top
:
420px
;
left
:
5.0%
;
margin
:
auto
;
padding
:
0
100px
;
}
.question-box
{
top
:
30%
!important
;
margin
:
auto
;
background
:
rgb
(
243
,
239
,
239
);
border-radius
:
20px
;
transition
:
all
.3s
;
height
:
230px
;
width
:
130%
!important
;
}
.question
{
width
:
50%
;
text-align
:
center
;
color
:
black
!important
;
}
.answers
{
list-style
:
none
;
text-align
:
left
;
}
.ans-button
{
left
:
1%
!important
;
margin
:
10px
;
}
input
:checked
{
border
:
6px
solid
rgb
(
38
,
4
,
160
);
}
h5
{
font-size
:
xx-large
;
font-weight
:
bolder
;
color
:
rgb
(
53
,
125
,
233
);
margin
:
5px
;
text-align
:
center
;
padding
:
5px
0
0
60px
!important
;
top
:
10%
!important
;
}
.form-group
{
text-align
:
left
;
}
.submit
button
{
color
:
black
;
background-color
:
rgb
(
12
,
165
,
211
);
border
:
black
;
left
:
24%
!important
;
top
:
670px
;
position
:
absolute
;
display
:
block
;
width
:
50px
!important
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment