From 0c9cf27514151e146eaba2621f3e4b49f6ff85b6 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Sun, 27 Aug 2023 22:43:43 +0900 Subject: [PATCH 01/17] =?UTF-8?q?feat=20Repository=20=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EB=B0=8F=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mzvoca/repository/questionRepository.java | 8 ++++++++ .../repository/questionRepositoryImpl.java | 16 ++++++++++++++++ .../mzvoca/repository/totalCountRepository.java | 8 ++++++++ .../repository/totalCountRepositoryImpl.java | 16 ++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 src/main/java/com/web/mzvoca/repository/questionRepository.java create mode 100644 src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java create mode 100644 src/main/java/com/web/mzvoca/repository/totalCountRepository.java create mode 100644 src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java diff --git a/src/main/java/com/web/mzvoca/repository/questionRepository.java b/src/main/java/com/web/mzvoca/repository/questionRepository.java new file mode 100644 index 0000000..93a2aee --- /dev/null +++ b/src/main/java/com/web/mzvoca/repository/questionRepository.java @@ -0,0 +1,8 @@ +package com.web.mzvoca.repository; + +public interface questionRepository { + + public void questionWrongCountRead(); + + public void questionWrongCountUpdate(); +} diff --git a/src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java new file mode 100644 index 0000000..8961dc4 --- /dev/null +++ b/src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java @@ -0,0 +1,16 @@ +package com.web.mzvoca.repository; + +import org.springframework.stereotype.Repository; + +@Repository +public class questionRepositoryImpl implements questionRepository { + @Override + public void questionWrongCountRead() { + + } + + @Override + public void questionWrongCountUpdate() { + + } +} diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepository.java b/src/main/java/com/web/mzvoca/repository/totalCountRepository.java new file mode 100644 index 0000000..f130643 --- /dev/null +++ b/src/main/java/com/web/mzvoca/repository/totalCountRepository.java @@ -0,0 +1,8 @@ +package com.web.mzvoca.repository; + +public interface totalCountRepository { + + public void totalCountRead(); + + public void totalCountUpdate(); +} diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java new file mode 100644 index 0000000..1f26bde --- /dev/null +++ b/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java @@ -0,0 +1,16 @@ +package com.web.mzvoca.repository; + +import org.springframework.stereotype.Repository; + +@Repository +public class totalCountRepositoryImpl implements totalCountRepository{ + @Override + public void totalCountRead() { + + } + + @Override + public void totalCountUpdate() { + + } +} From 79d18c5b520ca7e83da772b9c2b41a20b65d4560 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 09:26:05 +0900 Subject: [PATCH 02/17] =?UTF-8?q?docs=20DB=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c2065bc..94c4a30 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ out/ ### VS Code ### .vscode/ + +### DB 비밀번호 ### +/src/main/resources/db.properties From 48cf3ad8b095d7686fdec27e9b6882e20db9c44f Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 09:44:43 +0900 Subject: [PATCH 03/17] =?UTF-8?q?feat=20JDBC,MySQL=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index cb4b4ae..3bce54a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,10 @@ dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' + + // JDBC, MySQL + implementation 'org.springframework.boot:spring-boot-starter-jdbc' + runtimeOnly 'mysql:mysql-connector-java' } tasks.named('test') { From 8de131c8064daac4edc3bdacf07ea19e2dec9563 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:16:14 +0900 Subject: [PATCH 04/17] =?UTF-8?q?docs=20=EC=99=B8=EB=B6=80=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EB=B3=80=EC=88=98=20=ED=8C=8C=EC=9D=BC=20include?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..63383a3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,2 @@ - +# DB ?? ?? +spring.profiles.include = db From eceee548ce62ccf5f00e3f484e8d38fca6b9b790 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:16:42 +0900 Subject: [PATCH 05/17] =?UTF-8?q?feat=20totalCountRead()=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mzvoca/repository/ConnectionConst.java | 7 +++ .../repository/totalCountRepository.java | 2 +- .../repository/totalCountRepositoryImpl.java | 45 ++++++++++++++++++- .../totalCountRepositoryImplTest.java | 15 +++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/web/mzvoca/repository/ConnectionConst.java create mode 100644 src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java diff --git a/src/main/java/com/web/mzvoca/repository/ConnectionConst.java b/src/main/java/com/web/mzvoca/repository/ConnectionConst.java new file mode 100644 index 0000000..9ad7163 --- /dev/null +++ b/src/main/java/com/web/mzvoca/repository/ConnectionConst.java @@ -0,0 +1,7 @@ +package com.web.mzvoca.repository; + +public abstract class ConnectionConst { + public static final String URL = ""; + public static final String userName = "root"; + public static final String password = ""; +} diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepository.java b/src/main/java/com/web/mzvoca/repository/totalCountRepository.java index f130643..bc96ecb 100644 --- a/src/main/java/com/web/mzvoca/repository/totalCountRepository.java +++ b/src/main/java/com/web/mzvoca/repository/totalCountRepository.java @@ -2,7 +2,7 @@ public interface totalCountRepository { - public void totalCountRead(); + public int totalCountRead(); public void totalCountUpdate(); } diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java index 1f26bde..42e7323 100644 --- a/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java @@ -1,16 +1,59 @@ package com.web.mzvoca.repository; +import lombok.RequiredArgsConstructor; +import org.springframework.jdbc.support.JdbcUtils; import org.springframework.stereotype.Repository; +import javax.sql.DataSource; +import javax.xml.transform.Result; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.NoSuchElementException; + @Repository +@RequiredArgsConstructor public class totalCountRepositoryImpl implements totalCountRepository{ + + private final DataSource dataSource; + @Override - public void totalCountRead() { + public int totalCountRead() { + String sql = "select * from totalcount"; + + Connection con = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + con = getConnection(); + pstmt = con.prepareStatement(sql); + rs = pstmt.executeQuery(); + if (rs.next()) { + // 가져온 데이터가 있을 때 실행할 부분 + int totalCount = rs.getInt("totalCount"); + return totalCount; + } else { + throw new NoSuchElementException("값이 없습니다."); + } + + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + JdbcUtils.closeResultSet(rs); + JdbcUtils.closeStatement(pstmt); + JdbcUtils.closeConnection(con); + } } @Override public void totalCountUpdate() { } + + private Connection getConnection() throws SQLException { + Connection con = dataSource.getConnection(); + return con; + } } diff --git a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java new file mode 100644 index 0000000..38ed3ac --- /dev/null +++ b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java @@ -0,0 +1,15 @@ +package com.web.mzvoca.repository; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + + +class totalCountRepositoryImplTest { + + + + @Test + void totalCountRead() { + } +} \ No newline at end of file From 8faccf17892d92a7a82b3a9133fbd61a233b5993 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:17:41 +0900 Subject: [PATCH 06/17] =?UTF-8?q?fix=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20-=20=EC=86=8C?= =?UTF-8?q?=EB=AC=B8=EC=9E=90=EC=97=90=EC=84=9C=20=EB=8C=80=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{questionRepository.java => QuestionRepository.java} | 2 +- ...questionRepositoryImpl.java => QuestionRepositoryImpl.java} | 2 +- .../{totalCountRepository.java => TotalCountRepository.java} | 2 +- ...lCountRepositoryImpl.java => TotalCountRepositoryImpl.java} | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) rename src/main/java/com/web/mzvoca/repository/{questionRepository.java => QuestionRepository.java} (76%) rename src/main/java/com/web/mzvoca/repository/{questionRepositoryImpl.java => QuestionRepositoryImpl.java} (78%) rename src/main/java/com/web/mzvoca/repository/{totalCountRepository.java => TotalCountRepository.java} (73%) rename src/main/java/com/web/mzvoca/repository/{totalCountRepositoryImpl.java => TotalCountRepositoryImpl.java} (93%) diff --git a/src/main/java/com/web/mzvoca/repository/questionRepository.java b/src/main/java/com/web/mzvoca/repository/QuestionRepository.java similarity index 76% rename from src/main/java/com/web/mzvoca/repository/questionRepository.java rename to src/main/java/com/web/mzvoca/repository/QuestionRepository.java index 93a2aee..10f25c3 100644 --- a/src/main/java/com/web/mzvoca/repository/questionRepository.java +++ b/src/main/java/com/web/mzvoca/repository/QuestionRepository.java @@ -1,6 +1,6 @@ package com.web.mzvoca.repository; -public interface questionRepository { +public interface QuestionRepository { public void questionWrongCountRead(); diff --git a/src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/QuestionRepositoryImpl.java similarity index 78% rename from src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java rename to src/main/java/com/web/mzvoca/repository/QuestionRepositoryImpl.java index 8961dc4..9ebcb67 100644 --- a/src/main/java/com/web/mzvoca/repository/questionRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/QuestionRepositoryImpl.java @@ -3,7 +3,7 @@ import org.springframework.stereotype.Repository; @Repository -public class questionRepositoryImpl implements questionRepository { +public class QuestionRepositoryImpl implements QuestionRepository { @Override public void questionWrongCountRead() { diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepository.java b/src/main/java/com/web/mzvoca/repository/TotalCountRepository.java similarity index 73% rename from src/main/java/com/web/mzvoca/repository/totalCountRepository.java rename to src/main/java/com/web/mzvoca/repository/TotalCountRepository.java index bc96ecb..43ad4c9 100644 --- a/src/main/java/com/web/mzvoca/repository/totalCountRepository.java +++ b/src/main/java/com/web/mzvoca/repository/TotalCountRepository.java @@ -1,6 +1,6 @@ package com.web.mzvoca.repository; -public interface totalCountRepository { +public interface TotalCountRepository { public int totalCountRead(); diff --git a/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java similarity index 93% rename from src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java rename to src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java index 42e7323..1af6fb6 100644 --- a/src/main/java/com/web/mzvoca/repository/totalCountRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java @@ -5,7 +5,6 @@ import org.springframework.stereotype.Repository; import javax.sql.DataSource; -import javax.xml.transform.Result; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -14,7 +13,7 @@ @Repository @RequiredArgsConstructor -public class totalCountRepositoryImpl implements totalCountRepository{ +public class TotalCountRepositoryImpl implements TotalCountRepository { private final DataSource dataSource; From d6e6c1a170bdefb36f4de8fc5a75f9fce7aa3f6b Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:31:41 +0900 Subject: [PATCH 07/17] =?UTF-8?q?chore=20build.gradle=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3bce54a..bc83ee5 100644 --- a/build.gradle +++ b/build.gradle @@ -25,12 +25,17 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' + + // 테스트코드 @Slf4j 사용 + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' // JDBC, MySQL implementation 'org.springframework.boot:spring-boot-starter-jdbc' - runtimeOnly 'mysql:mysql-connector-java' + runtimeOnly 'com.mysql:mysql-connector-j' } tasks.named('test') { From 0d4008b2951b13fe2f3bcd0ebb2fff629d0593f6 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:33:27 +0900 Subject: [PATCH 08/17] =?UTF-8?q?test=20totalCountRead=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../totalCountRepositoryImplTest.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java index 38ed3ac..c79d06d 100644 --- a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java +++ b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java @@ -1,15 +1,46 @@ package com.web.mzvoca.repository; +import com.zaxxer.hikari.HikariDataSource; +import lombok.extern.slf4j.Slf4j; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import java.util.NoSuchElementException; +import static com.web.mzvoca.repository.DBConst.*; +import static org.assertj.core.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +@Slf4j class totalCountRepositoryImplTest { + TotalCountRepository totalCountRepository; + @BeforeEach + void beforeEach() { + HikariDataSource dataSource = new HikariDataSource(); + dataSource.setJdbcUrl(URL); + dataSource.setUsername(userName); + dataSource.setPassword(password); + + totalCountRepository = new TotalCountRepositoryImpl(dataSource); + } @Test + @DisplayName("총 제출 횟수 읽기") void totalCountRead() { + //given + Integer result = null; + + //when +// assertThatThrownBy(() -> totalCountRepository.totalCountRead()) +// .isInstanceOf(NoSuchElementException.class); + result = totalCountRepository.totalCountRead(); + + //then + assertThat(result).isEqualTo(3); + } } \ No newline at end of file From c7677211ef55bb3c774fb5ec151ad4c848072b95 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Sat, 2 Sep 2023 13:01:25 +0900 Subject: [PATCH 09/17] =?UTF-8?q?feat=20DataSourceUtils=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/TotalCountRepositoryImpl.java | 20 +++++++++++-------- .../totalCountRepositoryImplTest.java | 3 --- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java index 1af6fb6..aa6fd6e 100644 --- a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java @@ -1,14 +1,12 @@ package com.web.mzvoca.repository; import lombok.RequiredArgsConstructor; +import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.jdbc.support.JdbcUtils; import org.springframework.stereotype.Repository; import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.NoSuchElementException; @Repository @@ -40,9 +38,7 @@ public int totalCountRead() { } catch (SQLException e) { throw new RuntimeException(e); } finally { - JdbcUtils.closeResultSet(rs); - JdbcUtils.closeStatement(pstmt); - JdbcUtils.closeConnection(con); + close(con, pstmt, rs); } } @@ -52,7 +48,15 @@ public void totalCountUpdate() { } private Connection getConnection() throws SQLException { - Connection con = dataSource.getConnection(); + // 트랜잭션 동기화를 위해 DataSourceUtils 메서드 사용 + Connection con = DataSourceUtils.getConnection(dataSource); return con; } + + private void close(Connection con, Statement stmt, ResultSet rs) { + JdbcUtils.closeResultSet(rs); + JdbcUtils.closeStatement(stmt); + // 트랜잭션 동기화를 위해 DataSourceUtils 메서드 사용 + DataSourceUtils.releaseConnection(con, dataSource); + } } diff --git a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java index c79d06d..5622326 100644 --- a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java +++ b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java @@ -2,16 +2,13 @@ import com.zaxxer.hikari.HikariDataSource; import lombok.extern.slf4j.Slf4j; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.NoSuchElementException; import static com.web.mzvoca.repository.DBConst.*; import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; @Slf4j class totalCountRepositoryImplTest { From 1ab0940a9f19cde40d4e7bf0682d7fae378ad687 Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Sat, 2 Sep 2023 13:32:41 +0900 Subject: [PATCH 10/17] =?UTF-8?q?feat=20totalCountUpdate()=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/TotalCountRepositoryImpl.java | 18 ++++++++++++++++++ .../totalCountRepositoryImplTest.java | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java index aa6fd6e..4e7b313 100644 --- a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java @@ -1,6 +1,7 @@ package com.web.mzvoca.repository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.jdbc.support.JdbcUtils; import org.springframework.stereotype.Repository; @@ -11,6 +12,7 @@ @Repository @RequiredArgsConstructor +@Slf4j public class TotalCountRepositoryImpl implements TotalCountRepository { private final DataSource dataSource; @@ -44,7 +46,23 @@ public int totalCountRead() { @Override public void totalCountUpdate() { + // Update문을 통해 totalCount 값을 1 증가 + String sql = "update totalcount set totalCount = totalCount + 1"; + Connection con = null; + PreparedStatement pstmt = null; + + try { + con = getConnection(); + pstmt = con.prepareStatement(sql); + int result = pstmt.executeUpdate(); + log.info("실행된 행 개수={}", result); + } catch (SQLException e) { + log.info("db Error", e); + throw new RuntimeException(e); + } finally { + close(con, pstmt, null); + } } private Connection getConnection() throws SQLException { diff --git a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java index 5622326..51615c6 100644 --- a/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java +++ b/src/test/java/com/web/mzvoca/repository/totalCountRepositoryImplTest.java @@ -27,7 +27,7 @@ void beforeEach() { @Test @DisplayName("총 제출 횟수 읽기") - void totalCountRead() { + void totalCountReadTest() { //given Integer result = null; @@ -40,4 +40,18 @@ void totalCountRead() { assertThat(result).isEqualTo(3); } + + @Test + @DisplayName("총 제출 횟수 1 증가") + void totalCountUpdateTest() { + //given + Integer beforeResult = totalCountRepository.totalCountRead(); + + //when + totalCountRepository.totalCountUpdate(); + Integer afterResult = totalCountRepository.totalCountRead(); + + //then + assertThat(afterResult).isEqualTo(beforeResult + 1); + } } \ No newline at end of file From a45e84170b6e6bc8959dc5cb5ea32d153ad79aa0 Mon Sep 17 00:00:00 2001 From: gmltn9233 <63588364+gmltn9233@users.noreply.github.com> Date: Sat, 2 Sep 2023 19:37:26 +0900 Subject: [PATCH 11/17] =?UTF-8?q?=EC=B4=88=EB=B3=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 초본 --- src/main/resources/templates/css/main.css | 64 +++++++++++++- .../resources/templates/css/questions.css | 85 +++++++++++++++++++ src/main/resources/templates/index.html | 22 ++--- src/main/resources/templates/question1.html | 43 ++++++++++ src/main/resources/templates/question2.html | 43 ++++++++++ src/main/resources/templates/test.html | 0 6 files changed, 243 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/templates/css/questions.css create mode 100644 src/main/resources/templates/question1.html create mode 100644 src/main/resources/templates/question2.html create mode 100644 src/main/resources/templates/test.html diff --git a/src/main/resources/templates/css/main.css b/src/main/resources/templates/css/main.css index 4456526..abd8e89 100644 --- a/src/main/resources/templates/css/main.css +++ b/src/main/resources/templates/css/main.css @@ -1,15 +1,15 @@ .mainbody{ - margin-top:10px; - margin-bottom:10px; - padding-top:5px; background: url("../images/v1_3.png"); text-align: center; background-size:cover; - height:90vdh; + height:896px; + margin: 0 auto; } body{ background-color: pink; + margin: 0; + padding: 0; } ul{ border: 1px solid; @@ -32,3 +32,59 @@ th{ *{ font-family: 'Noto Serif KR', serif; } +@media (min-width: 1024px) { + .mainbody { + height: 100dvh; + width: 864px; + min-width: 864px; + font-size: 140px; + + } + .container{ + display: flex; + justify-content: center; /* 수평 가운데 정렬 */ + align-items: center; /* 수직 가운데 정렬 */ + text-align: center; + } + /* PC에 대한 추가 스타일 */ +} +@media all and (min-width:768px) and (max-width:1023px) { + .mainbody { + height: 100dvh; + width: 100dvw; + font-size: 140px; + padding:0; + margin:0; + } + .container{ + padding:0; + margin:0; + } + } + /*태블릿*/ + +/* 모바일 스타일 */ +@media (max-width: 767px) { + .mainbody { + height: 100dvh; + width: 100dvw; + font-size:11vh; + } + .container { + padding:0; + margin:0; + } + +} +@media (min-width: 280px)and (max-width: 319px) and (orientation: portrait) { + .mainbody { + height: 100%; + width: 100dvw; + font-size:80px; + } + .container { + padding:0; + margin:0; + } +} +/*갤럭시폴드*/ \ No newline at end of file diff --git a/src/main/resources/templates/css/questions.css b/src/main/resources/templates/css/questions.css new file mode 100644 index 0000000..6418469 --- /dev/null +++ b/src/main/resources/templates/css/questions.css @@ -0,0 +1,85 @@ + +.mainbody{ + background: url("../images/v1_3.png"); + text-align: center; + background-size:cover; + height:100dvh; + margin: 0 auto; +} +body{ + background-color: pink; + margin: 0; + padding: 0; +} + +.btn1{ + background-color: gray; + color:black; +} +*{ + font-family: 'Noto Serif KR', serif; +} +.answerbutton{ + border-radius: 50%; + width: 33.6px; + height: 33.6px; + display: flex; + justify-content: center; + align-items: center; + float: left; +} +@media (min-width: 1024px) { + .mainbody { + height: 100vdh; + width: 864px; + min-width: 864px; + font-size: 140px; + } + .container{ + display: flex; + justify-content: center; /* 수평 가운데 정렬 */ + align-items: center; /* 수직 가운데 정렬 */ + text-align: center; + } + /* PC에 대한 추가 스타일 */ +} +@media all and (min-width:768px) and (max-width:1023px) { + .mainbody { + height: 100dvh; + width: 100dvw; + font-size: 140px; + padding:0; + margin:0; + } + .container{ + padding:0; + margin:0; + } + } + /*태블릿*/ + +/* 모바일 스타일 */ +@media (max-width: 767px) { + .mainbody { + height: 100dvh; + width: 100dvw; + font-size:11vh; + } + .container { + padding:0; + margin:0; + } + +} +@media (min-width: 280px)and (max-width: 319px) and (orientation: portrait) { + .mainbody { + height: 100%; + width: 100dvw; + font-size:80px; + } + .container { + padding:0; + margin:0; + } +} +/*갤럭시폴드*/ \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 3974d9b..e59e319 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -12,23 +12,25 @@
-
-
제 2교시
-
2023학년도 MZ어휘력고사 문제지
-
문해력 영역
+
+
+
제 2교시
+
+
2023학년도 MZ어휘력고사 문제지
+
문해력 영역
-
+
성명김잼민
-
+
수험번호123-456789
-
    +
    • 자신이 선택한 과목의 문제지인지 확인하시오.
    • 매 선택과목마다 문제지의 해당란에 성명과 수험번호를 정확히 쓰시오.
    • 답안지의 필적 확인란에 다음의 문구를 정자로 기재하시오.
      @@ -38,9 +40,9 @@
    • 문항에 따라 배점이 같으니 안심하고 푸세요.
    -
    ※ 시험이 시작되기 전까지 표지를 넘기지 마시오.
    - -
    한국MZ평가원
    +
    ※ 시험이 시작되기 전까지 표지를 넘기지 마시오.
    + +
    한국MZ평가원
diff --git a/src/main/resources/templates/question1.html b/src/main/resources/templates/question1.html new file mode 100644 index 0000000..eee8862 --- /dev/null +++ b/src/main/resources/templates/question1.html @@ -0,0 +1,43 @@ + + + + + + Document + + + + + + + +
+
+
1/15
+
+
+
+
2023학년도 MZ어휘력고사 문제지
+
문해력 영역
+
1. 다음 중 "금일" 의 뜻으로 알맞은 것은?
+
+

금요일

+

오늘

+

내일

+

이틀 후

+
+
+
+ +
+
+ +
+
+
한국MZ평가원
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/question2.html b/src/main/resources/templates/question2.html new file mode 100644 index 0000000..b55bc1a --- /dev/null +++ b/src/main/resources/templates/question2.html @@ -0,0 +1,43 @@ + + + + + + Document + + + + + + + +
+
+
2/15
+
+
+
+
2023학년도 MZ어휘력고사 문제지
+
MZ 영역
+
1. 다음 중 화가 났을 때 사용하는 밈(Meme)과 관련이 없는 것은?
+
+

kg받네

+

군싹

+

킹받드라슈

+

쫑받네

+
+
+
+ +
+
+ +
+
+
한국MZ평가원
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/test.html b/src/main/resources/templates/test.html new file mode 100644 index 0000000..e69de29 From 1f10446c7076470d8f26171c2c703f7c7f58a4f1 Mon Sep 17 00:00:00 2001 From: gmltn9233 <63588364+gmltn9233@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:53:53 +0900 Subject: [PATCH 12/17] append questionList --- .../resources/templates/css/questions.css | 4 +- src/main/resources/templates/index.html | 92 +++++++++++++------ src/main/resources/templates/js/data.js | 20 ++++ src/main/resources/templates/js/start.js | 33 +++++++ src/main/resources/templates/question2.html | 43 --------- 5 files changed, 118 insertions(+), 74 deletions(-) create mode 100644 src/main/resources/templates/js/data.js create mode 100644 src/main/resources/templates/js/start.js delete mode 100644 src/main/resources/templates/question2.html diff --git a/src/main/resources/templates/css/questions.css b/src/main/resources/templates/css/questions.css index 6418469..40c6252 100644 --- a/src/main/resources/templates/css/questions.css +++ b/src/main/resources/templates/css/questions.css @@ -1,4 +1,6 @@ - +#qna{ + display: none; +} .mainbody{ background: url("../images/v1_3.png"); text-align: center; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index e59e319..6d2edbf 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -6,46 +6,78 @@ Document +
-
-
-
제 2교시
-
-
2023학년도 MZ어휘력고사 문제지
-
문해력 영역
-
-
- - -
성명김잼민
+
+
+
+
제 2교시
-
- - -
수험번호123-456789
+
2023학년도 MZ어휘력고사 문제지
+
문해력 영역 +
+
+ + +
성명김잼민
+
+
+ + +
수험번호123-456789
+
+
+
    +
  • 자신이 선택한 과목의 문제지인지 확인하시오.
  • +
  • 매 선택과목마다 문제지의 해당란에 성명과 수험번호를 정확히 쓰시오.
  • +
  • 답안지의 필적 확인란에 다음의 문구를 정자로 기재하시오.
    +
    MZ 특: 이런거 자세히 안봄
    +
  • +
  • 답안지의 해당란에 성명과 수험번호를 쓰고, 또 수험번호, 문형(홀수/짝수), 답을 정확히 표시하시오.
  • +
  • 문항에 따라 배점이 같으니 안심하고 푸세요.
  • +
+
+
※ 시험이 시작되기 전까지 표지를 넘기지 마시오.
+ +
한국MZ평가원
-
    -
  • 자신이 선택한 과목의 문제지인지 확인하시오.
  • -
  • 매 선택과목마다 문제지의 해당란에 성명과 수험번호를 정확히 쓰시오.
  • -
  • 답안지의 필적 확인란에 다음의 문구를 정자로 기재하시오.
    -
    MZ 특: 이런거 자세히 안봄
    -
  • -
  • 답안지의 해당란에 성명과 수험번호를 쓰고, 또 수험번호, 문형(홀수/짝수), 답을 정확히 표시하시오.
  • -
  • 문항에 따라 배점이 같으니 안심하고 푸세요.
  • -
-
-
※ 시험이 시작되기 전까지 표지를 넘기지 마시오.
- -
한국MZ평가원
-
+
+
+
+
1/15
+
+
+
+
2023학년도 MZ어휘력고사 문제지
+
문해력 영역
+
+
+

+

+

+

+
+
+
+ +
+
+ +
+
+
한국MZ평가원
+
+
+
+ +
- \ No newline at end of file diff --git a/src/main/resources/templates/js/data.js b/src/main/resources/templates/js/data.js new file mode 100644 index 0000000..1fb0839 --- /dev/null +++ b/src/main/resources/templates/js/data.js @@ -0,0 +1,20 @@ +const qnaList=[ + { + q : '1. 다음 중 "금일" 의 뜻으로 알맞은 것은?', + a : [ + {answer: '금요일', type:[0]}, + {answer: '오늘', type:[0]}, + {answer: '내일', type:[0]}, + {answer: '이틀 후', type:[0]}, + ] + }, + { + q : '2. 다음 중 화가 났을때 사용하는 밈(Meme)과 관련이 없는 것은?', + a : [ + {answer: 'kg받네'}, + {answer: '군싹'}, + {answer: '킹받드라슈'}, + {answer: '쫑받네'}, + ] + }, +] \ No newline at end of file diff --git a/src/main/resources/templates/js/start.js b/src/main/resources/templates/js/start.js new file mode 100644 index 0000000..932224e --- /dev/null +++ b/src/main/resources/templates/js/start.js @@ -0,0 +1,33 @@ +const main=document.querySelector('#main'); +const qna=document.querySelector('#qna'); +var qIdx=0; +function next(){ + goNext(++qIdx); +} +function prev(){ + if(qIdx==0){ + qna.style.display="none"; + main.style.display="block"; + } + else{ + goNext(--qIdx); + } +} +function goNext(qIdx){ + var q=document.querySelector('.qBox'); + var a1=document.querySelector('.a1'); + var a2=document.querySelector('.a2'); + var a3=document.querySelector('.a3'); + var a4=document.querySelector('.a4'); + q.innerHTML=qnaList[qIdx].q; + a1.innerHTML=qnaList[qIdx].a[0].answer; + a2.innerHTML=qnaList[qIdx].a[1].answer; + a3.innerHTML=qnaList[qIdx].a[2].answer; + a4.innerHTML=qnaList[qIdx].a[3].answer; +} + +function begin(){ + main.style.display="none"; + qna.style.display="block"; + goNext(qIdx); +} \ No newline at end of file diff --git a/src/main/resources/templates/question2.html b/src/main/resources/templates/question2.html deleted file mode 100644 index b55bc1a..0000000 --- a/src/main/resources/templates/question2.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - Document - - - - - - - -
-
-
2/15
-
-
-
-
2023학년도 MZ어휘력고사 문제지
-
MZ 영역
-
1. 다음 중 화가 났을 때 사용하는 밈(Meme)과 관련이 없는 것은?
-
-

kg받네

-

군싹

-

킹받드라슈

-

쫑받네

-
-
-
- -
-
- -
-
-
한국MZ평가원
-
-
-
- - - \ No newline at end of file From b71dd20bd78255cf925b9a1a6c060f96507486ec Mon Sep 17 00:00:00 2001 From: gmltn9233 <63588364+gmltn9233@users.noreply.github.com> Date: Sat, 2 Sep 2023 22:20:20 +0900 Subject: [PATCH 13/17] append status,section --- src/main/resources/templates/css/main.css | 3 +- .../resources/templates/css/questions.css | 2 +- src/main/resources/templates/index.html | 8 +- src/main/resources/templates/js/data.js | 117 ++++++++++++++++++ src/main/resources/templates/js/start.js | 11 ++ 5 files changed, 134 insertions(+), 7 deletions(-) diff --git a/src/main/resources/templates/css/main.css b/src/main/resources/templates/css/main.css index abd8e89..d134b0d 100644 --- a/src/main/resources/templates/css/main.css +++ b/src/main/resources/templates/css/main.css @@ -1,9 +1,8 @@ - .mainbody{ background: url("../images/v1_3.png"); text-align: center; background-size:cover; - height:896px; + height:100dvh; margin: 0 auto; } body{ diff --git a/src/main/resources/templates/css/questions.css b/src/main/resources/templates/css/questions.css index 40c6252..d89f958 100644 --- a/src/main/resources/templates/css/questions.css +++ b/src/main/resources/templates/css/questions.css @@ -32,7 +32,7 @@ body{ } @media (min-width: 1024px) { .mainbody { - height: 100vdh; + height: 100dvh; width: 864px; min-width: 864px; font-size: 140px; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 6d2edbf..fa6a4a1 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -19,7 +19,7 @@
제 2교시
2023학년도 MZ어휘력고사 문제지
-
문해력 영역 +
문해력 영역
@@ -50,12 +50,12 @@
-
1/15
+
-
+
2023학년도 MZ어휘력고사 문제지
-
문해력 영역
+

diff --git a/src/main/resources/templates/js/data.js b/src/main/resources/templates/js/data.js index 1fb0839..01000d7 100644 --- a/src/main/resources/templates/js/data.js +++ b/src/main/resources/templates/js/data.js @@ -17,4 +17,121 @@ const qnaList=[ {answer: '쫑받네'}, ] }, + { + q : '3. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '4. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '5. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '6. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '7. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '8. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '9. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '10. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '11. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '12. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '13. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '14. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, + { + q : '15. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, ] \ No newline at end of file diff --git a/src/main/resources/templates/js/start.js b/src/main/resources/templates/js/start.js index 932224e..f324f35 100644 --- a/src/main/resources/templates/js/start.js +++ b/src/main/resources/templates/js/start.js @@ -19,6 +19,17 @@ function goNext(qIdx){ var a2=document.querySelector('.a2'); var a3=document.querySelector('.a3'); var a4=document.querySelector('.a4'); + var section=document.querySelector('.section'); + var status=document.querySelector('.status'); + var statusBar=document.querySelector('.statusBar'); + if(qIdx%2==0){ + section.innerHTML='문해력 영역'; + } + else{ + section.innerHTML='MZ 영역'; + } + status.innerHTML=qIdx+1+'/15'; + statusBar.style.width=((qIdx+1)/15*100)+'%'; q.innerHTML=qnaList[qIdx].q; a1.innerHTML=qnaList[qIdx].a[0].answer; a2.innerHTML=qnaList[qIdx].a[1].answer; From fffd54138ff1cd055af7614060be65067fe195de Mon Sep 17 00:00:00 2001 From: Taehyeon Jo <70999462+whxogus215@users.noreply.github.com> Date: Tue, 5 Sep 2023 21:45:33 +0900 Subject: [PATCH 14/17] =?UTF-8?q?chore=20=ED=85=8C=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=EB=AA=85=20=EB=B3=80=EA=B2=BD=20totalCount?= =?UTF-8?q?=20->=20total=5Fcount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/web/mzvoca/repository/TotalCountRepositoryImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java index 4e7b313..453dc4d 100644 --- a/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java +++ b/src/main/java/com/web/mzvoca/repository/TotalCountRepositoryImpl.java @@ -31,7 +31,7 @@ public int totalCountRead() { rs = pstmt.executeQuery(); if (rs.next()) { // 가져온 데이터가 있을 때 실행할 부분 - int totalCount = rs.getInt("totalCount"); + int totalCount = rs.getInt("total_count"); return totalCount; } else { throw new NoSuchElementException("값이 없습니다."); @@ -47,7 +47,7 @@ public int totalCountRead() { @Override public void totalCountUpdate() { // Update문을 통해 totalCount 값을 1 증가 - String sql = "update totalcount set totalCount = totalCount + 1"; + String sql = "update totalcount set total_count = total_count + 1"; Connection con = null; PreparedStatement pstmt = null; From 3ab15b8f072a36ee9d77aaa19af2e31cbd253419 Mon Sep 17 00:00:00 2001 From: gmltn9233 <63588364+gmltn9233@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:25:04 +0900 Subject: [PATCH 15/17] append result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 선택지를 바탕으로 결과지에 나타나는 점수 계산 --- .../resources/templates/css/questions.css | 6 + src/main/resources/templates/index.html | 65 +++++- src/main/resources/templates/js/data.js | 9 + src/main/resources/templates/js/start.js | 198 +++++++++++++++++- src/main/resources/templates/question1.html | 43 ---- 5 files changed, 272 insertions(+), 49 deletions(-) delete mode 100644 src/main/resources/templates/question1.html diff --git a/src/main/resources/templates/css/questions.css b/src/main/resources/templates/css/questions.css index d89f958..32954e9 100644 --- a/src/main/resources/templates/css/questions.css +++ b/src/main/resources/templates/css/questions.css @@ -1,6 +1,9 @@ #qna{ display: none; } +#result{ + display:none; +} .mainbody{ background: url("../images/v1_3.png"); text-align: center; @@ -30,6 +33,9 @@ body{ align-items: center; float: left; } +.answerbutton:active{ + background-color: red; +} @media (min-width: 1024px) { .mainbody { height: 100dvh; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index fa6a4a1..ec140a4 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -16,7 +16,7 @@
-
제 2교시
+
제 2교시
2023학년도 MZ어휘력고사 문제지
문해력 영역
@@ -58,10 +58,10 @@
-

-

-

-

+

+

+

+

@@ -75,6 +75,61 @@
+
+
2023학년도 MZ어휘력고사 성적통지표
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
수험번호성명출신고교
123-45678김잼민MZ고등학교
영역문해력 영역MZ력 영역
선택과목문해력과 맞춤법MZ어
표준점수
백분위
등급
+
2023.08.12
+
한국MZ평가원장
+
+
+ +
+
+ +
+
+ +
diff --git a/src/main/resources/templates/js/data.js b/src/main/resources/templates/js/data.js index 01000d7..5f7b241 100644 --- a/src/main/resources/templates/js/data.js +++ b/src/main/resources/templates/js/data.js @@ -134,4 +134,13 @@ const qnaList=[ {answer: '4번 답'}, ] }, + { + q : '16. test', + a : [ + {answer: '1번 답'}, + {answer: '2번 답'}, + {answer: '3번 답'}, + {answer: '4번 답'}, + ] + }, ] \ No newline at end of file diff --git a/src/main/resources/templates/js/start.js b/src/main/resources/templates/js/start.js index f324f35..f2c129d 100644 --- a/src/main/resources/templates/js/start.js +++ b/src/main/resources/templates/js/start.js @@ -1,6 +1,177 @@ const main=document.querySelector('#main'); const qna=document.querySelector('#qna'); +const result=document.querySelector('#result'); +const select=[]; +const button1 = document.querySelector('.button1'); +const button2 = document.querySelector('.button2'); +const button3 = document.querySelector('.button3'); +const button4 = document.querySelector('.button4'); +const answer=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; var qIdx=0; +var score=0; +var mzscore=0; +var Grade; +var Mzgrade; +var Percentile; +var Mzpercentile; +var Stscore; +var Mzstscore; +button1.addEventListener('click', function() { + var sec; + if((qIdx+1)%3){ + sec=0; + } + else{ + sec=1; + } + if(answer[qIdx]==1){ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec }); + } + else{ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + } +}); + +button2.addEventListener('click', function() { + var sec; + if((qIdx+1)%3){ + sec=0; + } + else{ + sec=1; + } + if(answer[qIdx]==2){ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + } + else{ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + } +}); + +button3.addEventListener('click', function() { + var sec; + if((qIdx+1)%3){ + sec=0; + } + else{ + sec=1; + } + if(answer[qIdx]==3){ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + } + else{ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + } +}); + +button4.addEventListener('click', function() { + var sec; + if((qIdx+1)%3){ + sec=0; + } + else{ + sec=1; + } + if(answer[qIdx]==4){ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + } + else{ + select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + } +}); + +function calResult(){ + var sec; + if((qIdx+1)%3){ + sec=0; + } + else{ + sec=1; + } + for(i=0; i<15; i++){ + if(select[i]&&select[i].tf===true){ + if(select[i].section==0){ + score+=10; + } + else{ + mzscore+=20; + } + } + } +} +function calGrade(){ + if(score<=10){ + Grade=9; + Percentile=98; + Stscore=43; + } + else if (score<=20){ + Grade=8; + Percentile=91; + Stscore=67; + } + else if (score<=30){ + Grade=7; + Percentile=83; + Stscore=79; + } + else if (score<=40){ + Grade=6; + Percentile=68; + Stscore=91; + } + else if (score<=50){ + Grade=5; + Percentile=53; + Stscore=102; + } + else if (score<=60){ + Grade=4; + Percentile=31; + Stscore=109; + } + else if (score<=70){ + Grade=3; + Percentile=17; + Stscore=121; + } + else if (score<=80){ + Grade=2; + Percentile=6; + Stscore=127; + } + else{ + Grade=1; + Percentile=1; + Stscore=139; + } + if(mzscore<20){ + Mzgrade=9; + Mzpercentile=99; + Mzstscore=51; + } + else if (mzscore<40){ + Mzgrade=7; + Mzpercentile=81; + Mzstscore=76; + } + else if (mzscore<60){ + Mzgrade=5; + Mzpercentile=45; + Mzstscore=102; + } + else if (mzscore<80){ + Mzgrade=3; + Mzpercentile=13; + Mzstscore=121; + } + else{ + Mzgrade=1; + Mzpercentile=1; + Mzstscore=134; + } +} + function next(){ goNext(++qIdx); } @@ -12,7 +183,12 @@ function prev(){ else{ goNext(--qIdx); } -} +} +function goFirst(){ + result.style.display="none"; + main.style.display="block"; +} + function goNext(qIdx){ var q=document.querySelector('.qBox'); var a1=document.querySelector('.a1'); @@ -22,6 +198,24 @@ function goNext(qIdx){ var section=document.querySelector('.section'); var status=document.querySelector('.status'); var statusBar=document.querySelector('.statusBar'); + var stscore=document.querySelector('.stscore'); + var mzstscore=document.querySelector('.mzstscore'); + var percentile=document.querySelector('.percentile'); + var mzpercentile=document.querySelector('.mzpercentile'); + var grade=document.querySelector('.grade'); + var mzgrade=document.querySelector('.mzgrade'); + if(qIdx==15){ + qna.style.display="none"; + result.style.display="block"; + calResult(); + calGrade(); + grade.innerHTML=Grade; + mzgrade.innerHTML=Mzgrade; + stscore.innerHTML=Stscore; + mzstscore.innerHTML=Mzstscore; + percentile.innerHTML=Percentile; + mzpercentile.innerHTML=Mzpercentile; + } if(qIdx%2==0){ section.innerHTML='문해력 영역'; } @@ -38,6 +232,8 @@ function goNext(qIdx){ } function begin(){ + qIdx=0; + score=0; main.style.display="none"; qna.style.display="block"; goNext(qIdx); diff --git a/src/main/resources/templates/question1.html b/src/main/resources/templates/question1.html deleted file mode 100644 index eee8862..0000000 --- a/src/main/resources/templates/question1.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - Document - - - - - - - -
-
-
1/15
-
-
-
-
2023학년도 MZ어휘력고사 문제지
-
문해력 영역
-
1. 다음 중 "금일" 의 뜻으로 알맞은 것은?
-
-

금요일

-

오늘

-

내일

-

이틀 후

-
-
-
- -
-
- -
-
-
한국MZ평가원
-
-
-
- - - \ No newline at end of file From abd1f86bcd27cf3abe49bd8e35f15a8015d40d13 Mon Sep 17 00:00:00 2001 From: gmltn9233 <63588364+gmltn9233@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:07:45 +0900 Subject: [PATCH 16/17] append commentary --- .../resources/templates/css/questions.css | 24 ++++++- src/main/resources/templates/index.html | 37 ++++++++++- src/main/resources/templates/js/data.js | 54 +++++++++------- src/main/resources/templates/js/start.js | 63 ++++++++++++++++--- 4 files changed, 144 insertions(+), 34 deletions(-) diff --git a/src/main/resources/templates/css/questions.css b/src/main/resources/templates/css/questions.css index 32954e9..1d4a885 100644 --- a/src/main/resources/templates/css/questions.css +++ b/src/main/resources/templates/css/questions.css @@ -4,12 +4,30 @@ #result{ display:none; } +#commentary{ + display: none; +} +#ranking{ + display: none; +} .mainbody{ background: url("../images/v1_3.png"); text-align: center; background-size:cover; height:100dvh; margin: 0 auto; + +} + +.questionstyle{ + font-size: 0.30em; +} +.answerstyle{ + font-size: 0.24em; + text-align: left; +} +.commentarystyle{ + font-size:0.18em; } body{ background-color: pink; @@ -42,6 +60,7 @@ body{ width: 864px; min-width: 864px; font-size: 140px; + } .container{ display: flex; @@ -58,6 +77,7 @@ body{ font-size: 140px; padding:0; margin:0; + } .container{ padding:0; @@ -71,7 +91,8 @@ body{ .mainbody { height: 100dvh; width: 100dvw; - font-size:11vh; + font-size:11vh; + } .container { padding:0; @@ -84,6 +105,7 @@ body{ height: 100%; width: 100dvw; font-size:80px; + } .container { padding:0; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index ec140a4..d311328 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -118,11 +118,11 @@ -
2023.08.12
+
2023.08.12
한국MZ평가원장
- +
@@ -131,6 +131,39 @@
+
+
+
2023학년도 MZ어휘력고사 문제해설
+
+ +
+
+
+
+
+
+
+
+
2023학년도 MZ어휘력고사 문제지
+
+
+
+

+

+

+

+
+
+
+ +
+
+ +
+
+
한국MZ평가원
+
+
diff --git a/src/main/resources/templates/js/data.js b/src/main/resources/templates/js/data.js index 5f7b241..5cdeb14 100644 --- a/src/main/resources/templates/js/data.js +++ b/src/main/resources/templates/js/data.js @@ -6,7 +6,8 @@ const qnaList=[ {answer: '오늘', type:[0]}, {answer: '내일', type:[0]}, {answer: '이틀 후', type:[0]}, - ] + ], + c : "해설: '금일' 은 지금 지나가고 있는 이날, 즉 (2) 오늘 을 뜻합니다.", }, { q : '2. 다음 중 화가 났을때 사용하는 밈(Meme)과 관련이 없는 것은?', @@ -15,7 +16,8 @@ const qnaList=[ {answer: '군싹'}, {answer: '킹받드라슈'}, {answer: '쫑받네'}, - ] + ], + c: "해설: '군싹' 은 \"군침이 싹 도노\" 라는 의미로, 화가 났을 때 사용하는 밈과 거리가 멉니다." }, { q : '3. test', @@ -24,7 +26,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '4. test', @@ -33,7 +36,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '5. test', @@ -42,7 +46,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '6. test', @@ -51,7 +56,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '7. test', @@ -60,7 +66,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '8. test', @@ -69,7 +76,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '9. test', @@ -78,7 +86,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '10. test', @@ -87,7 +96,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '11. test', @@ -96,7 +106,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '12. test', @@ -105,7 +116,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '13. test', @@ -114,7 +126,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '14. test', @@ -123,7 +136,8 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] + ], + c: "해설: test", }, { q : '15. test', @@ -132,15 +146,7 @@ const qnaList=[ {answer: '2번 답'}, {answer: '3번 답'}, {answer: '4번 답'}, - ] - }, - { - q : '16. test', - a : [ - {answer: '1번 답'}, - {answer: '2번 답'}, - {answer: '3번 답'}, - {answer: '4번 답'}, - ] + ], + c: "해설: test", }, ] \ No newline at end of file diff --git a/src/main/resources/templates/js/start.js b/src/main/resources/templates/js/start.js index f2c129d..bcca4ca 100644 --- a/src/main/resources/templates/js/start.js +++ b/src/main/resources/templates/js/start.js @@ -1,6 +1,8 @@ const main=document.querySelector('#main'); const qna=document.querySelector('#qna'); const result=document.querySelector('#result'); +const commentary=document.querySelector('#commentary'); +const ranking=document.querySelector('#ranking'); const select=[]; const button1 = document.querySelector('.button1'); const button2 = document.querySelector('.button2'); @@ -41,10 +43,10 @@ button2.addEventListener('click', function() { sec=1; } if(answer[qIdx]==2){ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 2 , tf: true, section: sec}); } else{ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 2 , tf: false, section: sec}); } }); @@ -57,10 +59,10 @@ button3.addEventListener('click', function() { sec=1; } if(answer[qIdx]==3){ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 3 , tf: true, section: sec}); } else{ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 3 , tf: false, section: sec}); } }); @@ -73,10 +75,10 @@ button4.addEventListener('click', function() { sec=1; } if(answer[qIdx]==4){ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: true, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 4 , tf: true, section: sec}); } else{ - select.push({ questionNumber: qIdx + 1, selectedAnswer: 1 , tf: false, section: sec}); + select.push({ questionNumber: qIdx + 1, selectedAnswer: 4 , tf: false, section: sec}); } }); @@ -204,7 +206,7 @@ function goNext(qIdx){ var mzpercentile=document.querySelector('.mzpercentile'); var grade=document.querySelector('.grade'); var mzgrade=document.querySelector('.mzgrade'); - if(qIdx==15){ + if(qIdx===qnaList.length){ qna.style.display="none"; result.style.display="block"; calResult(); @@ -237,4 +239,51 @@ function begin(){ main.style.display="none"; qna.style.display="block"; goNext(qIdx); +} +const qnaContainer= document.getElementById('qnacontainer'); +function goCommentary(){ + qnaList.forEach((qna,Index)=>{ + addQnA(qna,Index); + }); + result.style.display="none"; + commentary.style.display="block"; +} +function addQnA(qna,Index){ + const qElement = document.createElement('div'); + qElement.classList.add('questionstyle'); + qElement.classList.add('m-5'); + qElement.textContent=qna.q; + qnaContainer.appendChild(qElement); + + qna.a.forEach((answer,index)=>{ + const aElement=document.createElement('div'); + aElement.classList.add('answerstyle'); + aElement.classList.add('col-8'); + aElement.classList.add('mx-auto'); + aElement.textContent = `${index + 1}. ${answer.answer}`; + qnaContainer.appendChild(aElement); + }); + + const sElement=document.createElement('div'); + sElement.classList.add('commentarystyle'); + sElement.classList.add('m-5'); + if (select[Index] && typeof select[Index].selectedAnswer !== 'undefined') { + sElement.textContent='선택한 답: '+select[Index].selectedAnswer; + } else { + sElement.textContent ='무응답'; // 또는 다른 기본값 설정 + } + qnaContainer.appendChild(sElement); + + const cElement=document.createElement('div'); + cElement.classList.add('commentarystyle'); + cElement.classList.add('m-5'); + cElement.textContent=qna.c; + qnaContainer.appendChild(cElement); + +} + +function goResult(){ + commentary.style.display="none"; + ranking.style.display="none"; + result.style.display="block"; } \ No newline at end of file From 047f5f3baf6fd44cae929c02c2661a8d35f401a9 Mon Sep 17 00:00:00 2001 From: gmltn9233 Date: Fri, 8 Sep 2023 02:14:33 +0900 Subject: [PATCH 17/17] append rankingpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 초본 --- src/main/resources/templates/index.html | 26 +++--------------------- src/main/resources/templates/js/start.js | 4 ++++ 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index d311328..f00a3b8 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -125,7 +125,7 @@
- +
@@ -140,28 +140,8 @@
-
-
-
-
-
2023학년도 MZ어휘력고사 문제지
-
-
-
-

-

-

-

-
-
-
- -
-
- -
-
-
한국MZ평가원
+
오답률 랭킹
+
diff --git a/src/main/resources/templates/js/start.js b/src/main/resources/templates/js/start.js index bcca4ca..3d4a0cb 100644 --- a/src/main/resources/templates/js/start.js +++ b/src/main/resources/templates/js/start.js @@ -286,4 +286,8 @@ function goResult(){ commentary.style.display="none"; ranking.style.display="none"; result.style.display="block"; +} +function goRanking(){ + result.style.display="none"; + ranking.style.display="block"; } \ No newline at end of file