$ git diff
diff --git a/backendMiniProject/src/main/java/com/mulcam/backend/controller/QuestionController.java b/backendMiniProject/src/main/java/com/mulcam/backend/controller/QuestionController.java
index 5861d85..b927f2d 100644
--- a/backendMiniProject/src/main/java/com/mulcam/backend/controller/QuestionController.java
+++ b/backendMiniProject/src/main/java/com/mulcam/backend/controller/QuestionController.java
@@ -26,6 +26,7 @@ public class QuestionController {
List<Question> qus = questionService.questionByDifficulty(difficulty);
result = new ResponseEntity<List<Question>>(qus, HttpStatus.OK);
} catch (Exception e) {
+ e.printStackTrace();
result = new ResponseEntity<List<Question>>(new ArrayList<Question>(), HttpStatus.BAD_REQUEST);
}
return result;
diff --git a/backendMiniProject/src/main/java/com/mulcam/backend/service/QuestionServiceImpl.java b/backendMiniProject/src/main/java/com/mulcam/backend/service/QuestionServiceImpl.java
index 42325c2..17689ea 100644
--- a/backendMiniProject/src/main/java/com/mulcam/backend/service/QuestionServiceImpl.java
+++ b/backendMiniProject/src/main/java/com/mulcam/backend/service/QuestionServiceImpl.java
@@ -15,7 +15,6 @@ public class QuestionServiceImpl implements QuestionService {
@Override
public List<Question> questionByDifficulty(int difficulty) throws Exception {
- // TODO Auto-generated method stub
return questionDAO.queryQuestion(difficulty);
}
diff --git a/backendMiniProject/src/main/resources/mybatis/mappers/question.xml b/backendMiniProject/src/main/resources/mybatis/mappers/question.xml
index e9391c0..d504f13 100644
--- a/backendMiniProject/src/main/resources/mybatis/mappers/question.xml
+++ b/backendMiniProject/src/main/resources/mybatis/mappers/question.xml
@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mulcam.backend.dao.QuestionDAO">
- <select id="queryQuestion" resultType="question" parameterType="string">
+ <select id="queryQuestion" resultType="question" parameterType="integer">
<![CDATA[
select * from question where difficulty=#{difficulty}
]]>
diff --git a/backendMiniProject/src/main/webapp/WEB-INF/views/oneDay.jsp b/backendMiniProject/src/main/webapp/WEB-INF/views/oneDay.jsp
index 4ca3151..bcce8d0 100644
--- a/backendMiniProject/src/main/webapp/WEB-INF/views/oneDay.jsp
+++ b/backendMiniProject/src/main/webapp/WEB-INF/views/oneDay.jsp
@@ -38,7 +38,6 @@
</style>
<script>
-
</script>
</head>
@@ -85,7 +84,7 @@
</div>
<div class="login-form">
- <h3 id="question1"></h3>
+ <h3 id="question1">${question1 }</h3>
<input id="answer1" type="text" onfocus="this.placeholder=' 화이팅~!'" onblur="this.placeholder='
답이 음수라면 -를 적어주세요. ex)-7'"
placeholder="답이 음수라면 -를 적어주세요. ex)-7" /><br>
<h3 id="question2"></h3>
diff --git a/backendMiniProject/src/main/webapp/resource/js/question.js b/backendMiniProject/src/main/webapp/resource/js/question.js
index bb1a6f2..e01d643 100644
--- a/backendMiniProject/src/main/webapp/resource/js/question.js
+++ b/backendMiniProject/src/main/webapp/resource/js/question.js
@@ -1,4 +1,8 @@
-$(function () {
+let randomNumber1 = 0;
+let randomNumber2 = 0;
+let array = null;
+
+$(function () {
// 화면이 로드 되었을 때 문제 데이터를 DB에서 가져온다 (Bank 전체계좌 정보 조회)
$.ajax({
method : 'post',
@@ -6,8 +10,13 @@ $(function () {
data : {difficulty:1},
dataType : "json",
success: function(data, textStatus) {
- $("#question1").val(data[0].question);
- $("#question2").val(data[1].question);
+ array = data;
+ while(randomNumber1 === randomNumber2) {
+ randomNumber1 = Math.floor(Math.random() * (array.length));
+ randomNumber2 = Math.floor(Math.random() * (array.length));
+ }
+ $("#question1").append(array[randomNumber1].question);
+ $("#question1").append(array[randomNumber1].question);
+ $("#question1").append(array[randomNumber1].question);
+ $("#question2").append(array[randomNumber2].question);
},
error: function(data, textStatus) {
@@ -23,22 +32,23 @@ $(function () {
// $("#question2").append(hard_array[randomNumber2].question)
+ // 제출 기능(채점)
// 위에서 가져온 데이터에서 정답 데이터와 입력값을 비교
$("#checkbtn").click(
function() {
- if($("#answer1").val()!=easy_array[randomNumber1].answer && $("#answer2").val()!=hard_array[randomNumber2].answer) {
+ if($("#answer1").val()!=array[randomNumber1].answer && $("#answer2").val()!=array[randomNumber2].answer) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: '1번, 2번 모두 틀렸어요~! 다시!'
});
- } else if($("#answer1").val()!=easy_array[randomNumber1].answer){
+ } else if($("#answer1").val()!=array[randomNumber1].answer){
Swal.fire({
icon: 'error',
title: 'Oops...',
text: '1번 문제가 틀렸어요~! 다시!'
});
- } else if($("#answer2").val()!=hard_array[randomNumber2].answer) {
+ } else if($("#answer2").val()!=array[randomNumber2].answer) {
Swal.fire({
icon: 'error',
title: 'Oops...',
(END)
+ $("#question2").append(array[randomNumber2].question);
},
error: function(data, textStatus) {
@@ -23,22 +32,23 @@ $(function () {
// $("#question2").append(hard_array[randomNumber2].question)
+ // 제출 기능(채점)
// 위에서 가져온 데이터에서 정답 데이터와 입력값을 비교
$("#checkbtn").click(
function() {
- if($("#answer1").val()!=easy_array[randomNumber1].answer && $("#answer2").val()!=hard_array[randomNumber2].answer) {
+ if($("#answer1").val()!=array[randomNumber1].answer && $("#answer2").val()!=array[randomNumber2].answer) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: '1번, 2번 모두 틀렸어요~! 다시!'
});
- } else if($("#answer1").val()!=easy_array[randomNumber1].answer){
+ } else if($("#answer1").val()!=array[randomNumber1].answer){
Swal.fire({
icon: 'error',
title: 'Oops...',
text: '1번 문제가 틀렸어요~! 다시!'
});
- } else if($("#answer2").val()!=hard_array[randomNumber2].answer) {
+ } else if($("#answer2").val()!=array[randomNumber2].answer) {
Swal.fire({
icon: 'error',
title: 'Oops...',
문제가 디비에서 안가져와지는 현상 수정.
'개발자 관련 공부 > 멀티캠퍼스' 카테고리의 다른 글
[API]연습 (0) | 2022.02.18 |
---|---|
[HTTPS] http? http? 가 뭐길래... (0) | 2022.02.18 |
[로그인 DB 연동] (0) | 2022.02.15 |
[DB연결 로그인구현] (0) | 2022.02.14 |
[Spring boot] static 이랑 템플릿 먼저 불러옴. (0) | 2022.02.11 |
댓글