Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
UPDATE: Word meaning test
Browse files Browse the repository at this point in the history
  • Loading branch information
junhoyeo committed Jan 12, 2019
1 parent d92c3f8 commit 315bf24
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 117 deletions.
13 changes: 6 additions & 7 deletions Server/routes/auth/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ var User = require('../../models/users.js')
var Word = require('../../models/words.js')

router.post('/', (req, res) => { // give points to user with token
var word = req.body.word
var wordId = req.body.word
var answer = req.body.answer
var token = req.body.token
// console.log({word, answer, token})
// word(word_id), answer, token을 받아서 word에 해당하는 word.en==answer이면 token.id의 유저에게 포인트 지급
if (!token || !word || !answer) {
// wordId, answer, token을 받아서 wordId에 해당하는 word.en==answer이면 token.id의 유저에게 포인트 지급
if (!token || !wordId || !answer) {
res.send({
success: false,
message: 'No token provided'
Expand All @@ -26,7 +25,7 @@ router.post('/', (req, res) => { // give points to user with token
})
return
}
Word.findById(word, function (error, word) {
Word.findById(wordId, function (error, word) {
if (error || !word) {
console.error(error)
res.send({
Expand All @@ -36,7 +35,7 @@ router.post('/', (req, res) => { // give points to user with token
return
}
if (answer.toLowerCase() === word.en) { // correct
Word.update({ _id: word }, { $inc: { accept: 1, submit: 1 } }, function (err, user) {
Word.update({ _id: wordId }, { $inc: { accept: 1, submit: 1 } }, function (err, user) {
if (err) console.log(err)
}) // add 1 ac/sb to word
User.update({ _id: userId }, { $inc: { points: 1, accept: 1, submit: 1 } }, function (err, user) {
Expand All @@ -53,7 +52,7 @@ router.post('/', (req, res) => { // give points to user with token
}
}) // give points to user
} else { // wrong
Word.update({ _id: word }, { $inc: { submit: 1 } }, function (err, user) {
Word.update({ _id: wordId }, { $inc: { submit: 1 } }, function (err, user) {
if (err) console.log(err)
}) // add 1 sb to word
User.update({ _id: userId }, { $inc: { submit: 1 } }, function (err, user) {
Expand Down
2 changes: 2 additions & 0 deletions Server/routes/get/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ var express = require('express')
var router = express.Router()

var wordbook = require('./wordbook')
var random = require('./random')

router.use('/wordbook', wordbook)
router.use('/random', random)

module.exports = router
27 changes: 27 additions & 0 deletions Server/routes/get/random.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var express = require('express')
var router = express.Router()
var Word = require('../../models/words.js')

router.get('/:size', function (req, res, next) {
const size = Number(req.params.size)
Word.aggregate([{ $sample: { size: size } }], function (error, result) {
if (error) {
console.error(error)
res.send({
success: false,
message: 'Error'
})
return
}
var words = []
result.forEach(word => {
words.push(word.ko[0])
})
res.send({
success: true,
result: words
})
})
})

module.exports = router
4 changes: 3 additions & 1 deletion Web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ export default {
</script>

<style>
@import url('https://fonts.googleapis.com/css?family=Noto+Sans+KR');
#app {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
/* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; */
font-family: 'Noto Sans KR', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
Expand Down
102 changes: 0 additions & 102 deletions Web/src/components/Books.old.vue

This file was deleted.

14 changes: 8 additions & 6 deletions Web/src/components/Books.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
{{ word.en }}
</a>&nbsp;
</span>
<router-link v-if="wordbook.len > 6" :to="{ name: 'show', params: { id: wordbook._id }}">
<i class="fas fa-ellipsis-h"></i>
</router-link>
<i class="fas fa-ellipsis-h"></i>
</div>
<span><i class="fas fa-user"></i> {{wordbook.user}}</span><br>
<router-link :to="{ name: 'test_en', params: { id: wordbook._id }}" tag="button">
<i class="fas fa-play"></i> 영단어 맞추기</button>
<i class="fas fa-play"></i> 영단어 맞추기
</router-link>
<router-link :to="{ name: 'test_ko', params: { id: wordbook._id }}" tag="button">
<i class="fas fa-check-square"></i> 한글 뜻 맞추기
</router-link>
<router-link :to="{ name: 'learn', params: { id: wordbook._id }}" tag="button">
<i class="fas fa-book"></i> 플래시 카드
</router-link>
<button><i class="fas fa-check-square"></i> 한글 뜻 맞추기</button>
<button><i class="fas fa-book"></i> 플래시 카드</button>
</div>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions Web/src/components/Learn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div></div>
</template>

<script>
export default {
created () {
alert('준비중입니다.')
this.$router.go(-1)
}
}
</script>
Loading

0 comments on commit 315bf24

Please sign in to comment.