Toggle navigation
Toggle navigation
This project
Loading...
Sign in
전세계
/
FakerQuiz
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ubuntu
2020-06-21 11:04:12 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2941130c1235ae86b60777e072ca44a03beb31c0
2941130c
1 parent
563dea4e
기능: 퀴즈 출제시 저장된 답과 비교하여 정답여부 결정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
app.js
app.js
View file @
2941130
...
...
@@ -286,11 +286,13 @@ app.post('/hook', async function (req, res) {
quizInfo
:
null
};
sendQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
}
else
if
(
isWaitAns
&&
eventObj
.
message
.
text
==
'정답'
)
{
users
[
eventObj
.
source
.
userId
].
streak
++
;
sendQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
}
else
if
(
isWaitAns
&&
eventObj
.
message
.
text
==
'오답'
)
{
endQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
}
else
if
(
isWaitAns
)
{
if
(
checkAns
(
eventObj
.
source
.
userId
,
eventObj
.
message
.
text
))
{
users
[
eventObj
.
source
.
userId
].
streak
++
;
sendQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
}
else
{
endQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
}
}
res
.
sendStatus
(
200
);
...
...
@@ -300,6 +302,9 @@ function sendQuiz(replyToken, id) {
var
randomQuiz
=
quizList
[
Math
.
floor
(
Math
.
random
()
*
quizList
.
length
)];
var
quizText
=
randomQuiz
.
quiz
;
users
[
id
].
quizAns
=
randomQuiz
.
ans
;
users
[
id
].
quizInfo
=
randomQuiz
.
info
;
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -323,6 +328,14 @@ function sendQuiz(replyToken, id) {
isWaitAns
=
true
;
}
function
checkAns
(
id
,
ans
)
{
if
(
ans
.
toUpperCase
()
==
users
[
id
].
quizAns
.
toUpperCase
())
{
return
true
;
}
else
{
return
false
;
}
}
function
endQuiz
(
replyToken
,
id
)
{
isWaitAns
=
false
;
...
...
Please
register
or
login
to post a comment