Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 82 additions & 43 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -311,14 +311,13 @@ packages:
source: hosted
version: "0.6.17+1"
flutter_math_fork:
dependency: "direct overridden"
description:
path: "."
ref: "565f053bc0b1026d7fe6e423f5c492526df5e472"
resolved-ref: "565f053bc0b1026d7fe6e423f5c492526df5e472"
url: "https://github.com/DouglasSerena/flutter_math_fork.git"
source: git
version: "0.6.3+1"
dependency: transitive
description:
name: flutter_math_fork
sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand All @@ -339,10 +338,10 @@ packages:
dependency: transitive
description:
name: flutter_svg
sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2"
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
version: "2.0.10+1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -449,6 +448,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
line_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -493,26 +516,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.11.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -541,18 +564,10 @@ packages:
dependency: "direct main"
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
path_drawing:
dependency: transitive
description:
name: path_drawing
sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977
url: "https://pub.dev"
source: hosted
version: "1.0.1"
version: "1.9.0"
path_parsing:
dependency: transitive
description:
Expand Down Expand Up @@ -722,18 +737,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
stream_transform:
dependency: transitive
description:
Expand Down Expand Up @@ -770,10 +785,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -878,6 +893,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.7"
vector_graphics:
dependency: transitive
description:
name: vector_graphics
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
vector_graphics_codec:
dependency: transitive
description:
name: vector_graphics_codec
sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
vector_graphics_compiler:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
vector_math:
dependency: transitive
description:
Expand All @@ -894,22 +933,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.0+2"
watcher:
vm_service:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
version: "13.0.0"
watcher:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -951,5 +990,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.2.0-0 <4.0.0"
flutter: ">=3.10.0"
7 changes: 0 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ dev_dependencies:
build_runner: ^2.4.6
json_serializable: ^6.7.1

dependency_overrides:
# https://github.com/simpleclub-extended/flutter_math_fork/pull/64
flutter_math_fork:
git:
url: https://github.com/DouglasSerena/flutter_math_fork.git
ref: 565f053bc0b1026d7fe6e423f5c492526df5e472

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down
3 changes: 1 addition & 2 deletions script/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

CAP_BASE_URL: str = "https://cap.rcpet.edu.tw/exam/"
CAP_START_YEAR: int = 104
CAP_END_YEAR: int = 112

CAP_END_YEAR: int = 113

CAP_EXPLANATION_FILES: dict[int, list[ExplanationFile]] = {
112: [
Expand Down
27 changes: 18 additions & 9 deletions script/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
from concurrent.futures import ThreadPoolExecutor

import pymupdf

from config import *
from models.exam import Exam
from models.exam_subject import ExamSubject
Expand All @@ -10,8 +12,7 @@
save_parse_result,
parse_exam_answer,
parse_exam_indicator,
parse_exam_explanation,
)
parse_exam_explanation, )

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -74,12 +75,20 @@ def parse_exam_papers():
exam_subjects: list[ExamSubject] = []

answers = parse_exam_answer(get_exam_file_path(year, ExamFileType.Answer))
passing_rate = parse_exam_indicator(
get_exam_file_path(year, ExamFileType.Passing_Rate)
)
discrimination_index = parse_exam_indicator(
get_exam_file_path(year, ExamFileType.DISCRIMINATION_INDEX)
)
try:
passing_rate = parse_exam_indicator(
get_exam_file_path(year, ExamFileType.Passing_Rate)
)
except pymupdf.FileNotFoundError:
passing_rate = {subject: [None] * 70 for subject in subjects}
print(f"Passing rate not found for year {year}.")
try:
discrimination_index = parse_exam_indicator(
get_exam_file_path(year, ExamFileType.DISCRIMINATION_INDEX)
)
except pymupdf.FileNotFoundError:
discrimination_index = {subject: [None] * 70 for subject in subjects}
print(f"Discrimination index not found for year {year}.")

for subject in subjects:
explanations = parse_exam_explanation(
Expand All @@ -105,9 +114,9 @@ def parse_exam_papers():

exam = Exam(year, f"{year} 年國中教育會考", exam_subjects)
exams.append(exam)
exams.reverse()
logger.info(f"Parsed CAP exam papers for year {year}.")

exams.reverse()
save_parse_result(exams)

elapsed_time = time.time() - start_time
Expand Down
9 changes: 6 additions & 3 deletions script/tools/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os

import requests

from config import CAP_BASE_URL
from models.cap_subject import CAPSubject
from models.explanation_file import ExplanationFile
Expand All @@ -22,8 +21,9 @@ def __download_file(url: str, file_path: str, retry: int = 0):
if retry > 3:
print("Failed to download the file after 3 retries: " + url)
return

response = requests.get(url)

response = requests.get(url, allow_redirects=False)
# If allow redirects, the response status code will never be 200 because the page will be redirected to home page.
if response.status_code != 200:
return __download_file(url.replace(".pdf", "-2.pdf"), file_path, retry + 1)

Expand All @@ -49,6 +49,9 @@ def download_exam_paper(year: int, subject: CAPSubject):
url = f"{CAP_BASE_URL}{year}/{year}P_{subject.value}.pdf"
if year in special_years:
url = url.replace(".pdf", "150DPI.pdf")
if year == 113 and subject == CAPSubject.NATURE:
url = url.replace(".pdf", "%20.pdf")
# As you can see, there is a space in the file name.

__download_file(url, file_path)

Expand Down