From 0c0ebabd3faf99d8e883f1ab5cc32014e8a3e3a9 Mon Sep 17 00:00:00 2001 From: Eric <101823195+erichung1113@users.noreply.github.com> Date: Thu, 11 May 2023 16:12:15 +0800 Subject: [PATCH 01/60] Update Account_Generator.cpp --- MyScripts/Account_Generator.cpp | 41 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/MyScripts/Account_Generator.cpp b/MyScripts/Account_Generator.cpp index 0040b25..7497116 100644 --- a/MyScripts/Account_Generator.cpp +++ b/MyScripts/Account_Generator.cpp @@ -1,11 +1,6 @@ #include using namespace std; -#define all(a) begin(a), end(a) -#define pb push_back -#define pii pair -#define F first -#define S second -#define mp make_pair +#define PASSWORD_LENTH 6 const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', @@ -17,40 +12,42 @@ const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; -string genPass() { +string Generate_Password() { string password; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < PASSWORD_LENTH; i++) { int idx = rand() % 62; - password.pb(chr[idx]); + password += chr[idx]; } return password; } -int main() { - srand(time(NULL)); - /* +/* + Output: + users: - username: "team1" password: "dssinsdnds" first_name: "TeamName" - */ +*/ + +int main() { + srand(time(0)); + ifstream TeamnameFile("teamname.txt"); ofstream PasswordFile("password.txt"); - ofstream SettingFile("context.yaml"); - - for (int i = 1; i <= 200; i++) { - string password = genPass(); - string teamname; - getline(TeamnameFile,teamname); + ofstream SettingFile("contest.user.yaml"); + string teamname; + int User_Idx = 1; + while (getline(TeamnameFile, teamname)) { + string password = Generate_Password(); PasswordFile << password << '\n'; - SettingFile << " - username: \"team" << setw(3) << setfill('0') << i << "\"\n"; + SettingFile << " - username: \"team" << setw(3) << setfill('0') << User_Idx << "\"\n"; SettingFile << " password: \"" << password << "\"\n"; SettingFile << " first_name: \"" << teamname << "\"\n"; + User_Idx++; } TeamnameFile.close(); PasswordFile.close(); SettingFile.close(); } - -// g++ gen.cpp && ./a.out && rm a.out From c278f899c10b4cdb3b067f06ae72711860c40cc1 Mon Sep 17 00:00:00 2001 From: Eric <101823195+erichung1113@users.noreply.github.com> Date: Sat, 13 May 2023 18:59:18 +0800 Subject: [PATCH 02/60] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e33606..6861507 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ sudo docker exec -t cms sudo cmsAddAdmin admin 接著打開瀏覽器並輸入以下網址就可使用啦 -參賽者介面:`localhost:8888` +參賽者介面:`[本機ip]:8888` -管理員介面:`localhost:8889` +管理員介面:`[本機ip]:8889` -計分板:`localhost:8890` +計分板:`[本機ip]:8890` 更詳細的教學請見 : [CMS Online Judge Docker安裝教學](https://hackmd.io/WKsC33XYRme4sM-Kkst_XA) From e4506341914f73a1c1f3fed56e27936d03958db9 Mon Sep 17 00:00:00 2001 From: Eric <101823195+erichung1113@users.noreply.github.com> Date: Sat, 13 May 2023 19:21:15 +0800 Subject: [PATCH 03/60] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6861507..bce51c7 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ sudo docker exec -t cms sudo cmsAddAdmin admin 接著打開瀏覽器並輸入以下網址就可使用啦 -參賽者介面:`[本機ip]:8888` +參賽者介面:`[內網ip]:8888` -管理員介面:`[本機ip]:8889` +管理員介面:`[內網ip]:8889` -計分板:`[本機ip]:8890` +計分板:`[內網ip]:8890` 更詳細的教學請見 : [CMS Online Judge Docker安裝教學](https://hackmd.io/WKsC33XYRme4sM-Kkst_XA) From fca69b6554fc931d1c7f8f5ebcfcff0599445982 Mon Sep 17 00:00:00 2001 From: Eric <101823195+erichung1113@users.noreply.github.com> Date: Sat, 13 May 2023 19:22:43 +0800 Subject: [PATCH 04/60] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bce51c7..b7abefd 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ sudo docker exec -t cms sudo cmsAddAdmin admin 接著打開瀏覽器並輸入以下網址就可使用啦 -參賽者介面:`[內網ip]:8888` +參賽者介面:`[本幾ip]:8888` -管理員介面:`[內網ip]:8889` +管理員介面:`[本幾ip]:8889` -計分板:`[內網ip]:8890` +計分板:`[本幾ip]:8890` 更詳細的教學請見 : [CMS Online Judge Docker安裝教學](https://hackmd.io/WKsC33XYRme4sM-Kkst_XA) From 8ed5def9fb9dabb1d747787c01e7bd63a5bbbfe7 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung09060@users.noreply.github.com> Date: Thu, 20 Jul 2023 01:38:27 +0800 Subject: [PATCH 05/60] Create pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Polygon/pack_to_yaml.sh diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh new file mode 100644 index 0000000..5d72d13 --- /dev/null +++ b/Polygon/pack_to_yaml.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -e + +if [[ ! -d "cmsPackage" ]]; then + mkdir "cmsPackage" +fi + +echo -n "please enter problem name or all : " +read reply + +if [[ $reply == "all" ]];then + toDoList=$(ls | sed s/pack.sh//g | sed s/cmsPackage//g) +else + toDoList=$reply +fi + +for PROBLEM_NAME in $toDoList; do + if [[ -d "cmsPackage/$PROBLEM_NAME" ]]; then + rm -rf cmsPackage/$PROBLEM_NAME + fi + + mkdir "cmsPackage/$PROBLEM_NAME" + mkdir "cmsPackage/$PROBLEM_NAME/statement" + mkdir "cmsPackage/$PROBLEM_NAME/gen" + mkdir "cmsPackage/$PROBLEM_NAME/input" + mkdir "cmsPackage/$PROBLEM_NAME/output" + + N=$(ls $PROBLEM_NAME/tests | wc -l) + N=$((N/2)) + + for ((i = 1; i <= $N; i++)); do + id=$i + + if [ $i -lt 10 ]; then + id="0$i" + fi + + cp "$PROBLEM_NAME/tests/$id" "cmsPackage/$PROBLEM_NAME/input/input$((i-1)).txt" + cp "$PROBLEM_NAME/tests/$id.a" "cmsPackage/$PROBLEM_NAME/output/output$((i-1)).txt" + done + public_tc=$(seq -s, 0 $((N-1)) ) + public_tc=${public_tc%,} + + echo -e "name: $PROBLEM_NAME +title: $PROBLEM_NAME +time_limit: 1 +memory_limit: 256 +n_input: $N +token_mode: disabled +public_testcases: $public_tc +infile: "" +outfile: "" + " > cmsPackage/$PROBLEM_NAME/task.yaml + + echo -e "# ST: 100 +$(seq 1 $N) + " > cmsPackage/$PROBLEM_NAME/gen/GEN +done From c4b81fa2b84744b6b9b9a3aa23aa89f88d8518ea Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung09060@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:16:55 +0800 Subject: [PATCH 06/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 5d72d13..0e8dc97 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -5,13 +5,9 @@ if [[ ! -d "cmsPackage" ]]; then mkdir "cmsPackage" fi -echo -n "please enter problem name or all : " -read reply - -if [[ $reply == "all" ]];then +toDoList=$@ +if [[ $# == 0 ]];then toDoList=$(ls | sed s/pack.sh//g | sed s/cmsPackage//g) -else - toDoList=$reply fi for PROBLEM_NAME in $toDoList; do @@ -48,11 +44,13 @@ memory_limit: 256 n_input: $N token_mode: disabled public_testcases: $public_tc -infile: "" -outfile: "" +infile: \"\" +outfile: \"\" " > cmsPackage/$PROBLEM_NAME/task.yaml echo -e "# ST: 100 $(seq 1 $N) " > cmsPackage/$PROBLEM_NAME/gen/GEN + + touch cmsPackage/$PROBLEM_NAME/statement/statement.pdf done From 5fc3fe856d890164b9ed9b7abb22f1e61edfa573 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung09060@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:17:12 +0800 Subject: [PATCH 07/60] Rename pack.sh to pack_testcase.sh --- Polygon/{pack.sh => pack_testcase.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Polygon/{pack.sh => pack_testcase.sh} (99%) diff --git a/Polygon/pack.sh b/Polygon/pack_testcase.sh similarity index 99% rename from Polygon/pack.sh rename to Polygon/pack_testcase.sh index 7b125f9..dc66b7c 100644 --- a/Polygon/pack.sh +++ b/Polygon/pack_testcase.sh @@ -54,4 +54,4 @@ for PROBLEM_NAME in $toDoList; do echo "Problem : $PROBLEM_NAME finished !" rm -rf "$PROBLEM_NAME/RenamedTestCase" -done \ No newline at end of file +done From 5d4b7f3ef88a406f42a4a1dddf921a32d7f7a788 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung09060@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:18:06 +0800 Subject: [PATCH 08/60] Update README.md --- Polygon/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 1625b6d..8c7c651 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -1,6 +1,6 @@ # Package test case from polygon package to cms format -1. 把這份repo載下來,並進到Polygon資料夾。或是直接建立一個資料夾並把pack.sh放進去 +1. 把這份repo載下來,並進到Polygon資料夾。或是直接建立一個資料夾並把pack_testcase.sh放進去 2. 到Polygon的Packages點擊Full並下載Linux版。 image @@ -9,7 +9,7 @@ 4. 執行以下指令後會生成一個`cmsTestCase`資料夾,為每一題測資的zip檔。 ``` -sudo chmod a+x pack.sh && ./pack.sh +sudo chmod a+x pack_testcase.sh && ./pack_testcase.sh ``` image From 3af0ba9e0c3e46cd82914be77c8e1ebfdffc1988 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Mon, 31 Jul 2023 05:16:30 +0800 Subject: [PATCH 09/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 50 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 0e8dc97..a2e5b36 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -1,25 +1,34 @@ #!/bin/bash set -e -if [[ ! -d "cmsPackage" ]]; then - mkdir "cmsPackage" +if [[ -d "Contest" ]]; then + rm -r Contest fi +mkdir "Contest" -toDoList=$@ -if [[ $# == 0 ]];then - toDoList=$(ls | sed s/pack.sh//g | sed s/cmsPackage//g) +echo -n "Enter file name or blank for all : " +read toDoList + +if [[ $toDoList == "" ]];then + toDoList=$(ls | sed s/pack_to_yaml.sh//g | sed s/Contest//g) fi +echo -e "name: \"HSPC-Final\" +description: \"國立成功大學暑期高中生程式設計邀請賽決賽\" +token_mode: disabled +timezone: \"+8\" +tasks:" > "Contest/contest.yaml" + for PROBLEM_NAME in $toDoList; do - if [[ -d "cmsPackage/$PROBLEM_NAME" ]]; then - rm -rf cmsPackage/$PROBLEM_NAME + if [[ -d "Contest/$PROBLEM_NAME" ]]; then + rm -rf Contest/$PROBLEM_NAME fi - mkdir "cmsPackage/$PROBLEM_NAME" - mkdir "cmsPackage/$PROBLEM_NAME/statement" - mkdir "cmsPackage/$PROBLEM_NAME/gen" - mkdir "cmsPackage/$PROBLEM_NAME/input" - mkdir "cmsPackage/$PROBLEM_NAME/output" + mkdir "Contest/$PROBLEM_NAME" + mkdir "Contest/$PROBLEM_NAME/statement" + mkdir "Contest/$PROBLEM_NAME/gen" + mkdir "Contest/$PROBLEM_NAME/input" + mkdir "Contest/$PROBLEM_NAME/output" N=$(ls $PROBLEM_NAME/tests | wc -l) N=$((N/2)) @@ -31,8 +40,8 @@ for PROBLEM_NAME in $toDoList; do id="0$i" fi - cp "$PROBLEM_NAME/tests/$id" "cmsPackage/$PROBLEM_NAME/input/input$((i-1)).txt" - cp "$PROBLEM_NAME/tests/$id.a" "cmsPackage/$PROBLEM_NAME/output/output$((i-1)).txt" + cp "$PROBLEM_NAME/tests/$id" "Contest/$PROBLEM_NAME/input/input$((i-1)).txt" + cp "$PROBLEM_NAME/tests/$id.a" "Contest/$PROBLEM_NAME/output/output$((i-1)).txt" done public_tc=$(seq -s, 0 $((N-1)) ) public_tc=${public_tc%,} @@ -46,11 +55,18 @@ token_mode: disabled public_testcases: $public_tc infile: \"\" outfile: \"\" - " > cmsPackage/$PROBLEM_NAME/task.yaml + " > Contest/$PROBLEM_NAME/task.yaml echo -e "# ST: 100 $(seq 1 $N) - " > cmsPackage/$PROBLEM_NAME/gen/GEN + " > Contest/$PROBLEM_NAME/gen/GEN + + echo "statement" > Contest/$PROBLEM_NAME/statement/statement.pdf + + echo " - \"$PROBLEM_NAME\"" >> "Contest/contest.yaml" - touch cmsPackage/$PROBLEM_NAME/statement/statement.pdf done +echo "users: + - username: \"test\" + password: \"test\" + first_name: \"test\"" >> "Contest/contest.yaml" From a38f90abe26e0374d310782407d475596e6453b9 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Mon, 31 Jul 2023 23:51:48 +0800 Subject: [PATCH 10/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 49 ++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index a2e5b36..a350e0a 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -6,7 +6,7 @@ if [[ -d "Contest" ]]; then fi mkdir "Contest" -echo -n "Enter file name or blank for all : " +echo -n "Enter Problem Name or blank for all : " read toDoList if [[ $toDoList == "" ]];then @@ -20,53 +20,36 @@ timezone: \"+8\" tasks:" > "Contest/contest.yaml" for PROBLEM_NAME in $toDoList; do - if [[ -d "Contest/$PROBLEM_NAME" ]]; then - rm -rf Contest/$PROBLEM_NAME - fi - mkdir "Contest/$PROBLEM_NAME" mkdir "Contest/$PROBLEM_NAME/statement" mkdir "Contest/$PROBLEM_NAME/gen" mkdir "Contest/$PROBLEM_NAME/input" mkdir "Contest/$PROBLEM_NAME/output" - N=$(ls $PROBLEM_NAME/tests | wc -l) - N=$((N/2)) + N=$(($(ls $PROBLEM_NAME/tests | wc -l)/2)) + public_tc=$(seq -s, 0 $((N-1))) + public_tc=${public_tc%,} + PROBLEM_TITTLE=$(cat $PROBLEM_NAME/problem.xml | grep -m 1 'value="[^\"]*"' -o | sed -e s/value=// -e s/\"//g) + TIME_LIMIT=$(($(cat $PROBLEM_NAME/problem.xml | grep '' | sed -e s/''// -e s/'<\/time-limit>'//)/1000)) - for ((i = 1; i <= $N; i++)); do + for ((i = 01; i <= $N; i++)); do id=$i - if [ $i -lt 10 ]; then id="0$i" fi - + cp "$PROBLEM_NAME/tests/$id" "Contest/$PROBLEM_NAME/input/input$((i-1)).txt" cp "$PROBLEM_NAME/tests/$id.a" "Contest/$PROBLEM_NAME/output/output$((i-1)).txt" done - public_tc=$(seq -s, 0 $((N-1)) ) - public_tc=${public_tc%,} - - echo -e "name: $PROBLEM_NAME -title: $PROBLEM_NAME -time_limit: 1 -memory_limit: 256 -n_input: $N -token_mode: disabled -public_testcases: $public_tc -infile: \"\" -outfile: \"\" - " > Contest/$PROBLEM_NAME/task.yaml - - echo -e "# ST: 100 -$(seq 1 $N) - " > Contest/$PROBLEM_NAME/gen/GEN - + + echo -e "name: $PROBLEM_NAME\ntitle: $PROBLEM_TITTLE\ntime_limit: $TIME_LIMIT\nmemory_limit: 256\nn_input: $N\ntoken_mode: disabled\npublic_testcases: $public_tc\ninfile: \"\"\noutfile: \"\"" > Contest/$PROBLEM_NAME/task.yaml + echo -e "# ST: 100\n$(seq 1 $N)" > Contest/$PROBLEM_NAME/gen/GEN echo "statement" > Contest/$PROBLEM_NAME/statement/statement.pdf - echo " - \"$PROBLEM_NAME\"" >> "Contest/contest.yaml" + printf "%-3s %ss (%s)\n" "$PROBLEM_NAME" "$TIME_LIMIT" "$PROBLEM_TITTLE" done -echo "users: - - username: \"test\" - password: \"test\" - first_name: \"test\"" >> "Contest/contest.yaml" + +echo -e "users:\n - username: \"test\"\n password: \"test\"\n first_name: \"test\"" >> "Contest/contest.yaml" +echo -e "## CMS Contest import command\n\`\`\`\nsudo cmsImportUser --all -L italy_yaml . && sudo cmsImportContest -i -L italy_yaml .\n\`\`\`" >> "Contest/README.md" +echo ".DS_Store" >> "Contest/.gitignore" From 6400e15d232d5751f3cb6e84137eb9b6c194f135 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Tue, 1 Aug 2023 02:02:09 +0800 Subject: [PATCH 11/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index a350e0a..8b115df 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -51,5 +51,5 @@ for PROBLEM_NAME in $toDoList; do done echo -e "users:\n - username: \"test\"\n password: \"test\"\n first_name: \"test\"" >> "Contest/contest.yaml" -echo -e "## CMS Contest import command\n\`\`\`\nsudo cmsImportUser --all -L italy_yaml . && sudo cmsImportContest -i -L italy_yaml .\n\`\`\`" >> "Contest/README.md" -echo ".DS_Store" >> "Contest/.gitignore" +echo "sudo cmsImportUser --all -L italy_yaml . && sudo cmsImportContest -i -L italy_yaml ." >> "Contest/import.sh" +echo "Finished!" From 53e9d5a6d6a2b7d1fa92b71915d033dc5b162cc6 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 01:38:04 +0800 Subject: [PATCH 12/60] Update README.md --- Polygon/README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 8c7c651..78c2cb4 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -1,17 +1,26 @@ -# Package test case from polygon package to cms format +# Convert Polygon Package To CMS Format -1. 把這份repo載下來,並進到Polygon資料夾。或是直接建立一個資料夾並把pack_testcase.sh放進去 -2. 到Polygon的Packages點擊Full並下載Linux版。 +1. Go Polygon's Packages, click Full and Download the Linux version image -3. 解壓縮所有檔案到此資料夾(可順便更改檔名) +2. Extract the archive to a new folder (Remember to change file name) image -4. 執行以下指令後會生成一個`cmsTestCase`資料夾,為每一題測資的zip檔。 +## Convert Whole Package +1. Copy pack_to_yaml.sh to that folder + +Score mode +allowed language +start time end time + +## Convert Package Only +1. Copy pack_testcase.sh to that folder +2. Run the following command, then a folder named cmsTestCase will be generated, which contains zip files for each problem. +2. 執行以下指令後會生成一個`cmsTestCase`資料夾,為每一題測資的zip檔。 ``` sudo chmod a+x pack_testcase.sh && ./pack_testcase.sh ``` image -5.到CMS Task中下方Test Case的地方點擊` Add multiple testcases`並選擇該題的zip檔上傳 +3.到CMS Task中下方Test Case的地方點擊` Add multiple testcases`並選擇該題的zip檔上傳 image From ffa77b6d9f2301a360665c8d0341f3c8511602f1 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:15:32 +0800 Subject: [PATCH 13/60] Update pack_testcase.sh --- Polygon/pack_testcase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_testcase.sh b/Polygon/pack_testcase.sh index dc66b7c..7b202f5 100644 --- a/Polygon/pack_testcase.sh +++ b/Polygon/pack_testcase.sh @@ -6,7 +6,7 @@ if [[ ! -d "cmsTestCase" ]]; then fi if [[ $# == 0 ]];then - toDoList=$(ls | sed s/pack.sh//g | sed s/cmsTestCase//g) + toDoList=$(ls | sed s/pack_testcase.sh//g | sed s/cmsTestCase//g) else toDoList=$@ fi From 8d039d7d76126dbaa9e8bbf973642450227df49f Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:15:55 +0800 Subject: [PATCH 14/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 8b115df..1089722 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -6,7 +6,7 @@ if [[ -d "Contest" ]]; then fi mkdir "Contest" -echo -n "Enter Problem Name or blank for all : " +echo -n "Enter Problem Name or blank for all to add to a Contest: " read toDoList if [[ $toDoList == "" ]];then From b50711f9595a56ee04d9a2a5c1c0307e2d189bc8 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:20:52 +0800 Subject: [PATCH 15/60] Update README.md --- Polygon/README.md | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 78c2cb4..a8e4370 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -3,24 +3,37 @@ 1. Go Polygon's Packages, click Full and Download the Linux version image -2. Extract the archive to a new folder (Remember to change file name) -image +2. Extract the archive to a new folder (Remember to change file name, you can add multiple problems in that folder) -## Convert Whole Package -1. Copy pack_to_yaml.sh to that folder +Next, there will be two conversion methods, which are Full Contest Conversion and TestCase Only Conversion. +## Full Contest Conversion +1. Copy pack_to_yaml.sh to your folder +image -Score mode -allowed language -start time end time +2. Run the following command, then a folder named Contest will be generated, which is a CMS contest package with problems you added. +``` +chmod u+x pack_to_yaml.sh && ./pack_to_yaml.sh +``` +image + +3. You can enter Contest folder and run the command to import contest to cms. +``` +chmod u+x import.sh && ./import.sh +``` +4. After importing the contest, there are a few more settings you need to do: + 1. score mode + 2. allowed language + 3. contest's start time and end time -## Convert Package Only +## TestCase Only Conversion 1. Copy pack_testcase.sh to that folder +image + 2. Run the following command, then a folder named cmsTestCase will be generated, which contains zip files for each problem. -2. 執行以下指令後會生成一個`cmsTestCase`資料夾,為每一題測資的zip檔。 ``` -sudo chmod a+x pack_testcase.sh && ./pack_testcase.sh +chmod u+x pack_testcase.sh && ./pack_testcase.sh ``` image -3.到CMS Task中下方Test Case的地方點擊` Add multiple testcases`並選擇該題的zip檔上傳 +3. Go to the `Test Case` at the bottom of CMS Task, click `Add multiple testcases` and select the zip file of the problem to upload. image From e08072a6138fbae9f3a387307c595ff48d32de23 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:26:12 +0800 Subject: [PATCH 16/60] Update README.md --- Polygon/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index a8e4370..72703f3 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -1,11 +1,11 @@ # Convert Polygon Package To CMS Format -1. Go Polygon's Packages, click Full and Download the Linux version +1. Go Polygon's Packages, click Full and Download the Linux version. image 2. Extract the archive to a new folder (Remember to change file name, you can add multiple problems in that folder) -Next, there will be two conversion methods, which are Full Contest Conversion and TestCase Only Conversion. +Next, there will be two conversion methods, which are `Full Contest Conversion` and `TestCase Only Conversion`. ## Full Contest Conversion 1. Copy pack_to_yaml.sh to your folder image @@ -16,14 +16,14 @@ chmod u+x pack_to_yaml.sh && ./pack_to_yaml.sh ``` image -3. You can enter Contest folder and run the command to import contest to cms. +3. You need to go into the Contest folder and run the command to import contest on CMS. ``` chmod u+x import.sh && ./import.sh ``` -4. After importing the contest, there are a few more settings you need to do: - 1. score mode - 2. allowed language - 3. contest's start time and end time +4. After importing the contest, you still need to change some settings: + a. score mode // + b. allowed language // + c. contest's start time and end time // ## TestCase Only Conversion 1. Copy pack_testcase.sh to that folder From a2b0b061fbbb1f294d1f94dc982377812f7c86a2 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:27:26 +0800 Subject: [PATCH 17/60] Update README.md --- Polygon/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 72703f3..fa4a954 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -20,10 +20,10 @@ chmod u+x pack_to_yaml.sh && ./pack_to_yaml.sh ``` chmod u+x import.sh && ./import.sh ``` -4. After importing the contest, you still need to change some settings: - a. score mode // - b. allowed language // - c. contest's start time and end time // +4. After importing the contest, you still need to change some settings:\ + a. score mode \ + b. allowed language \ + c. contest's start time and end time \ ## TestCase Only Conversion 1. Copy pack_testcase.sh to that folder From 9b9bb8b5da4d60eb28f033bdd51644d917f0af50 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 03:29:55 +0800 Subject: [PATCH 18/60] Update README.md --- Polygon/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index fa4a954..b9b1de7 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -23,7 +23,7 @@ chmod u+x import.sh && ./import.sh 4. After importing the contest, you still need to change some settings:\ a. score mode \ b. allowed language \ - c. contest's start time and end time \ + c. contest's start time and end time ## TestCase Only Conversion 1. Copy pack_testcase.sh to that folder @@ -35,5 +35,7 @@ chmod u+x pack_testcase.sh && ./pack_testcase.sh ``` image -3. Go to the `Test Case` at the bottom of CMS Task, click `Add multiple testcases` and select the zip file of the problem to upload. +3. Go to `Test Case` at the bottom of CMS Task, and click `Add multiple testcases` then select the zip file of the problem to upload. image + +4. Finish!🥳 From b7008133d9902e8b9b226db842970d69e0facd4c Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung1113@users.noreply.github.com> Date: Wed, 2 Aug 2023 05:02:35 +0800 Subject: [PATCH 19/60] Update README.md --- Polygon/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index b9b1de7..28561f1 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -1,6 +1,6 @@ # Convert Polygon Package To CMS Format -1. Go Polygon's Packages, click Full and Download the Linux version. +1. Go to Polygon's Packages, click Full and Download Linux version. image 2. Extract the archive to a new folder (Remember to change file name, you can add multiple problems in that folder) @@ -16,7 +16,7 @@ chmod u+x pack_to_yaml.sh && ./pack_to_yaml.sh ``` image -3. You need to go into the Contest folder and run the command to import contest on CMS. +3. Go into the Contest folder and run the command to import contest to CMS. ``` chmod u+x import.sh && ./import.sh ``` @@ -35,7 +35,8 @@ chmod u+x pack_testcase.sh && ./pack_testcase.sh ``` image -3. Go to `Test Case` at the bottom of CMS Task, and click `Add multiple testcases` then select the zip file of the problem to upload. +3. Go to `Test Case` at the bottom of Task on CMS, and click `Add multiple testcases` then select the zip file of the problem to upload. +Screenshot 2023-08-02 at 5 00 27 AM image -4. Finish!🥳 +4. Congratulations!🥳 From 7cbd723b8537b3df6b823c2e1ba81aa52ccec1db Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Sun, 29 Oct 2023 22:56:18 +0800 Subject: [PATCH 20/60] Update README.md --- Polygon/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 28561f1..8ad7aa8 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -7,10 +7,13 @@ Next, there will be two conversion methods, which are `Full Contest Conversion` and `TestCase Only Conversion`. ## Full Contest Conversion -1. Copy pack_to_yaml.sh to your folder +1. Copy pack_to_yaml.sh to your folder or use the following command +``` +curl https://raw.githubusercontent.com/erichung9060/cms/main/Polygon/pack_to_yaml.sh -o pack_to_yaml.sh +``` image -2. Run the following command, then a folder named Contest will be generated, which is a CMS contest package with problems you added. +3. Run the following command, then a folder named Contest will be generated, which is a CMS contest package with problems you added. ``` chmod u+x pack_to_yaml.sh && ./pack_to_yaml.sh ``` From 508e20fb31aeb7a20ce0555db8c3d16d45deed47 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:12:35 +0800 Subject: [PATCH 21/60] Rename pack_testcase.sh to pack_to_testcase.sh --- Polygon/{pack_testcase.sh => pack_to_testcase.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Polygon/{pack_testcase.sh => pack_to_testcase.sh} (100%) diff --git a/Polygon/pack_testcase.sh b/Polygon/pack_to_testcase.sh similarity index 100% rename from Polygon/pack_testcase.sh rename to Polygon/pack_to_testcase.sh From b79a9659f4a0d1d7e2289c4f61849980163eac3a Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:13:03 +0800 Subject: [PATCH 22/60] Update README.md --- Polygon/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 8ad7aa8..806d832 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -29,12 +29,12 @@ chmod u+x import.sh && ./import.sh c. contest's start time and end time ## TestCase Only Conversion -1. Copy pack_testcase.sh to that folder +1. Copy pack_to_testcase.sh.sh to that folder image 2. Run the following command, then a folder named cmsTestCase will be generated, which contains zip files for each problem. ``` -chmod u+x pack_testcase.sh && ./pack_testcase.sh +chmod u+x pack_to_testcase.sh.sh && ./pack_to_testcase.sh.sh ``` image From fdab9c18edc4f3fe661547c4049a316061f1cede Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:13:44 +0800 Subject: [PATCH 23/60] Update README.md --- Polygon/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon/README.md b/Polygon/README.md index 806d832..73313db 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -29,12 +29,12 @@ chmod u+x import.sh && ./import.sh c. contest's start time and end time ## TestCase Only Conversion -1. Copy pack_to_testcase.sh.sh to that folder +1. Copy pack_to_testcase.sh to that folder image 2. Run the following command, then a folder named cmsTestCase will be generated, which contains zip files for each problem. ``` -chmod u+x pack_to_testcase.sh.sh && ./pack_to_testcase.sh.sh +chmod u+x pack_to_testcase.sh && ./pack_to_testcase.sh ``` image From cb47bd16f3f059b8158b06b7b8290fa02b93b7c5 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:16:35 +0800 Subject: [PATCH 24/60] Update pack_to_testcase.sh --- Polygon/pack_to_testcase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_to_testcase.sh b/Polygon/pack_to_testcase.sh index 7b202f5..4226221 100644 --- a/Polygon/pack_to_testcase.sh +++ b/Polygon/pack_to_testcase.sh @@ -6,7 +6,7 @@ if [[ ! -d "cmsTestCase" ]]; then fi if [[ $# == 0 ]];then - toDoList=$(ls | sed s/pack_testcase.sh//g | sed s/cmsTestCase//g) + toDoList=$(ls | sed s/pack_to_testcase.sh//g | sed s/cmsTestCase//g) else toDoList=$@ fi From 010e5938e8a749d8a56ed595e543bcebba6729ec Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 4 Jan 2024 00:46:29 +0800 Subject: [PATCH 25/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 1089722..a5a7d00 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -27,8 +27,6 @@ for PROBLEM_NAME in $toDoList; do mkdir "Contest/$PROBLEM_NAME/output" N=$(($(ls $PROBLEM_NAME/tests | wc -l)/2)) - public_tc=$(seq -s, 0 $((N-1))) - public_tc=${public_tc%,} PROBLEM_TITTLE=$(cat $PROBLEM_NAME/problem.xml | grep -m 1 'value="[^\"]*"' -o | sed -e s/value=// -e s/\"//g) TIME_LIMIT=$(($(cat $PROBLEM_NAME/problem.xml | grep '' | sed -e s/''// -e s/'<\/time-limit>'//)/1000)) @@ -42,7 +40,7 @@ for PROBLEM_NAME in $toDoList; do cp "$PROBLEM_NAME/tests/$id.a" "Contest/$PROBLEM_NAME/output/output$((i-1)).txt" done - echo -e "name: $PROBLEM_NAME\ntitle: $PROBLEM_TITTLE\ntime_limit: $TIME_LIMIT\nmemory_limit: 256\nn_input: $N\ntoken_mode: disabled\npublic_testcases: $public_tc\ninfile: \"\"\noutfile: \"\"" > Contest/$PROBLEM_NAME/task.yaml + echo -e "name: $PROBLEM_NAME\ntitle: $PROBLEM_TITTLE\ntime_limit: $TIME_LIMIT\nmemory_limit: 256\nn_input: $N\ntoken_mode: disabled\npublic_testcases: all\ninfile: \"\"\noutfile: \"\"" > Contest/$PROBLEM_NAME/task.yaml echo -e "# ST: 100\n$(seq 1 $N)" > Contest/$PROBLEM_NAME/gen/GEN echo "statement" > Contest/$PROBLEM_NAME/statement/statement.pdf echo " - \"$PROBLEM_NAME\"" >> "Contest/contest.yaml" From a91206c1975023d8d60f85d2b99a6b89f815106e Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:24:10 +0800 Subject: [PATCH 26/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index a5a7d00..a6c5142 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -1,6 +1,11 @@ #!/bin/bash set -e +# configuration +Contest_Name="week0" +Contest_Description="AA競程 - TOI模擬賽 Online Judge" +#-------------- + if [[ -d "Contest" ]]; then rm -r Contest fi @@ -13,8 +18,8 @@ if [[ $toDoList == "" ]];then toDoList=$(ls | sed s/pack_to_yaml.sh//g | sed s/Contest//g) fi -echo -e "name: \"HSPC-Final\" -description: \"國立成功大學暑期高中生程式設計邀請賽決賽\" +echo -e "name: \"$Contest_Name\" +description: \"$Contest_Description\" token_mode: disabled timezone: \"+8\" tasks:" > "Contest/contest.yaml" @@ -29,6 +34,7 @@ for PROBLEM_NAME in $toDoList; do N=$(($(ls $PROBLEM_NAME/tests | wc -l)/2)) PROBLEM_TITTLE=$(cat $PROBLEM_NAME/problem.xml | grep -m 1 'value="[^\"]*"' -o | sed -e s/value=// -e s/\"//g) TIME_LIMIT=$(($(cat $PROBLEM_NAME/problem.xml | grep '' | sed -e s/''// -e s/'<\/time-limit>'//)/1000)) + MEMORY_LIMIT=$(($(cat $PROBLEM_NAME/problem.xml | grep '' | sed -e s/''// -e s/'<\/memory-limit>'//)/1024/1024)) for ((i = 01; i <= $N; i++)); do id=$i @@ -40,12 +46,12 @@ for PROBLEM_NAME in $toDoList; do cp "$PROBLEM_NAME/tests/$id.a" "Contest/$PROBLEM_NAME/output/output$((i-1)).txt" done - echo -e "name: $PROBLEM_NAME\ntitle: $PROBLEM_TITTLE\ntime_limit: $TIME_LIMIT\nmemory_limit: 256\nn_input: $N\ntoken_mode: disabled\npublic_testcases: all\ninfile: \"\"\noutfile: \"\"" > Contest/$PROBLEM_NAME/task.yaml + echo -e "name: $PROBLEM_NAME\ntitle: $PROBLEM_TITTLE\ntime_limit: $TIME_LIMIT\nmemory_limit: $MEMORY_LIMIT\nn_input: $N\ntoken_mode: disabled\npublic_testcases: all\ninfile: \"\"\noutfile: \"\"" > Contest/$PROBLEM_NAME/task.yaml echo -e "# ST: 100\n$(seq 1 $N)" > Contest/$PROBLEM_NAME/gen/GEN echo "statement" > Contest/$PROBLEM_NAME/statement/statement.pdf echo " - \"$PROBLEM_NAME\"" >> "Contest/contest.yaml" - printf "%-3s %ss (%s)\n" "$PROBLEM_NAME" "$TIME_LIMIT" "$PROBLEM_TITTLE" + printf "%s %ds %dMiB %s\n" "$PROBLEM_NAME" "$TIME_LIMIT" "$MEMORY_LIMIT" "$PROBLEM_TITTLE" done echo -e "users:\n - username: \"test\"\n password: \"test\"\n first_name: \"test\"" >> "Contest/contest.yaml" From 455eea5d4e9ec5a4070b9741b319fc317d74264c Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:24:54 +0800 Subject: [PATCH 27/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index a6c5142..1e9b448 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -2,8 +2,8 @@ set -e # configuration -Contest_Name="week0" -Contest_Description="AA競程 - TOI模擬賽 Online Judge" +Contest_Name="test_contest" +Contest_Description="contest of testing cms judge" #-------------- if [[ -d "Contest" ]]; then From bf6d060b0df97b6a86c8f319cec91c636e8fc438 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 20:50:35 +0800 Subject: [PATCH 28/60] Update README.md --- Polygon/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Polygon/README.md b/Polygon/README.md index 73313db..cae052e 100644 --- a/Polygon/README.md +++ b/Polygon/README.md @@ -30,6 +30,9 @@ chmod u+x import.sh && ./import.sh ## TestCase Only Conversion 1. Copy pack_to_testcase.sh to that folder +``` +curl https://raw.githubusercontent.com/erichung9060/cms/main/Polygon/pack_to_testcase.sh -o pack_to_testcase.sh +``` image 2. Run the following command, then a folder named cmsTestCase will be generated, which contains zip files for each problem. From bd7f5e0a20f9296edebc1fa6b10f49c33e0ef407 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 20:54:11 +0800 Subject: [PATCH 29/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 1e9b448..32e4f55 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -11,7 +11,7 @@ if [[ -d "Contest" ]]; then fi mkdir "Contest" -echo -n "Enter Problem Name or blank for all to add to a Contest: " +echo -n "Enter the name of the problem to add to a contest, or leave blank to add all." read toDoList if [[ $toDoList == "" ]];then From 97deeb2ae2904b176440e36fbd5356bac672ddec Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 20:54:49 +0800 Subject: [PATCH 30/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index 32e4f55..fc28e21 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -11,7 +11,7 @@ if [[ -d "Contest" ]]; then fi mkdir "Contest" -echo -n "Enter the name of the problem to add to a contest, or leave blank to add all." +echo -n "Enter the name of the problem to add to a contest, or leave blank to add all : " read toDoList if [[ $toDoList == "" ]];then From 7dca8682bda52a024da9c19ef0875dbb29332e75 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 20:55:00 +0800 Subject: [PATCH 31/60] Update pack_to_testcase.sh --- Polygon/pack_to_testcase.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Polygon/pack_to_testcase.sh b/Polygon/pack_to_testcase.sh index 4226221..eba0fbd 100644 --- a/Polygon/pack_to_testcase.sh +++ b/Polygon/pack_to_testcase.sh @@ -5,10 +5,11 @@ if [[ ! -d "cmsTestCase" ]]; then mkdir "cmsTestCase" fi -if [[ $# == 0 ]];then - toDoList=$(ls | sed s/pack_to_testcase.sh//g | sed s/cmsTestCase//g) -else - toDoList=$@ +echo -n "Enter the name of the problem to zip testcase, or leave blank to zip all : " +read toDoList + +if [[ $toDoList == "" ]];then + toDoList=$(ls | sed s/pack_to_yaml.sh//g | sed s/Contest//g) fi for PROBLEM_NAME in $toDoList; do From 6b63a17d8264c6e1ff84ccf4f9d2035c996bfafb Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:37:27 +0800 Subject: [PATCH 32/60] Create monitor.sh --- MyScripts/monitor.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 MyScripts/monitor.sh diff --git a/MyScripts/monitor.sh b/MyScripts/monitor.sh new file mode 100644 index 0000000..202f0c9 --- /dev/null +++ b/MyScripts/monitor.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +while true; do + if ! curl -s http://localhost:8888 > /dev/null; then + sudo cmsResourceService -a <<< 1 + fi + sleep 60 +done From ceecab076a22dff685eff1a8fdd2c04131039b5c Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:37:49 +0800 Subject: [PATCH 33/60] Rename monitor.sh to cms_process_monitor.sh --- MyScripts/{monitor.sh => cms_process_monitor.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MyScripts/{monitor.sh => cms_process_monitor.sh} (100%) diff --git a/MyScripts/monitor.sh b/MyScripts/cms_process_monitor.sh similarity index 100% rename from MyScripts/monitor.sh rename to MyScripts/cms_process_monitor.sh From 26e9cbc324a3e85b92ecd237a33b4de0d225aa18 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:45:40 +0800 Subject: [PATCH 34/60] fix to 0-based --- Polygon/pack_to_testcase.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Polygon/pack_to_testcase.sh b/Polygon/pack_to_testcase.sh index eba0fbd..eb7f1aa 100644 --- a/Polygon/pack_to_testcase.sh +++ b/Polygon/pack_to_testcase.sh @@ -32,18 +32,18 @@ for PROBLEM_NAME in $toDoList; do ALL="" for ((i = 1; i <= $N; i++)); do - zero="000" - zero=${zero:0:$((3-${#i}))} + index=$((i-1)) + index=$(printf "%03d" $index) if [ $i -lt 10 ]; then - cp "$PROBLEM_NAME/tests/0$i" "$PROBLEM_NAME/RenamedTestCase/input.$zero$i" - cp "$PROBLEM_NAME/tests/0$i.a" "$PROBLEM_NAME/RenamedTestCase/output.$zero$i" + cp "$PROBLEM_NAME/tests/0$i" "$PROBLEM_NAME/RenamedTestCase/input.$index" + cp "$PROBLEM_NAME/tests/0$i.a" "$PROBLEM_NAME/RenamedTestCase/output.$index" else - cp "$PROBLEM_NAME/tests/$i" "$PROBLEM_NAME/RenamedTestCase/input.$zero$i" - cp "$PROBLEM_NAME/tests/$i.a" "$PROBLEM_NAME/RenamedTestCase/output.$zero$i" + cp "$PROBLEM_NAME/tests/$i" "$PROBLEM_NAME/RenamedTestCase/input.$index" + cp "$PROBLEM_NAME/tests/$i.a" "$PROBLEM_NAME/RenamedTestCase/output.$index" fi - ALL+="$PROBLEM_NAME/RenamedTestCase/input.$zero$i $PROBLEM_NAME/RenamedTestCase/output.$zero$i " + ALL+="$PROBLEM_NAME/RenamedTestCase/input.$index $PROBLEM_NAME/RenamedTestCase/output.$index " done if [ -f "cmsTestCase/${PROBLEM_NAME}.zip" ]; then From 219435c4425f4c7b7d3805b7fb0f4f58080f04ad Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:37:01 +0800 Subject: [PATCH 35/60] Update pack_to_yaml.sh --- Polygon/pack_to_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon/pack_to_yaml.sh b/Polygon/pack_to_yaml.sh index fc28e21..ad9234b 100644 --- a/Polygon/pack_to_yaml.sh +++ b/Polygon/pack_to_yaml.sh @@ -15,7 +15,7 @@ echo -n "Enter the name of the problem to add to a contest, or leave blank to ad read toDoList if [[ $toDoList == "" ]];then - toDoList=$(ls | sed s/pack_to_yaml.sh//g | sed s/Contest//g) + toDoList=$(ls | sed s/pack_to_yaml.sh//g | sed s/pack_to_testcase.sh//g | sed s/Contest//g) fi echo -e "name: \"$Contest_Name\" From 43fdfdd8ac6f6e579b82e19b933194be03fd5de2 Mon Sep 17 00:00:00 2001 From: erichung1113 Date: Mon, 15 Apr 2024 21:56:38 +0800 Subject: [PATCH 36/60] adapt script for Bash --- MyScripts/Add_Problem_Id_To_File_Name.cpp | 28 --------------- .../Groups_Submissions_By_Problem_Name.sh | 28 +++++++++++++++ MyScripts/Sort_Submissions_By_Problem_ID.cpp | 34 ------------------- 3 files changed, 28 insertions(+), 62 deletions(-) delete mode 100644 MyScripts/Add_Problem_Id_To_File_Name.cpp create mode 100644 MyScripts/Groups_Submissions_By_Problem_Name.sh delete mode 100644 MyScripts/Sort_Submissions_By_Problem_ID.cpp diff --git a/MyScripts/Add_Problem_Id_To_File_Name.cpp b/MyScripts/Add_Problem_Id_To_File_Name.cpp deleted file mode 100644 index f9e65e3..0000000 --- a/MyScripts/Add_Problem_Id_To_File_Name.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -using namespace std; -#define TEAM_NUMBER 200 -#define MIN_PROBLEM_ID 'A' -#define MAX_PROBLEM_ID 'H' -int main() { - for (int i = 1; i <= TEAM_NUMBER; i++) { - string foldername1 = "team" + string(3 - to_string(i).length(), '0') + to_string(i); - for (const auto& entry1 : filesystem::directory_iterator(foldername1)) { - ifstream file(entry1.path()); - string s, line; - - for (int i = 0; i < 5; i++) { - getline(file, line); - s += line; - } - - if (s.find(".%l") == string::npos) { - cout << "fail on " << entry1.path() << '\n'; - return 1; - } - file.close(); - char p = s[s.find(".%l") - 1]; - rename(entry1.path(), string(entry1.path()) + "_p" + string(1, p)); - } - } - cout << "Successful\n"; -} diff --git a/MyScripts/Groups_Submissions_By_Problem_Name.sh b/MyScripts/Groups_Submissions_By_Problem_Name.sh new file mode 100644 index 0000000..bd3ede1 --- /dev/null +++ b/MyScripts/Groups_Submissions_By_Problem_Name.sh @@ -0,0 +1,28 @@ +#! /usr/bin/bash + +# 1. first copy all submissions from /var/local/lib/cms/submissions to ~ +# 2. run this script +# 3. you will get a folder named Problem_Submissions, which groups submissions by problem name + +rm -rf Problem_Submissions +IFS=$'\n' + +getProblemName(){ + ProblemName=$(head -n 3 $1 | tr -d '\r\n' | tr -cd '[:alnum:]-_}.%' | sed 's/\.%l.*//' | awk -F '}' '{print $NF}') + echo $ProblemName +} + +for team in $(ls submissions); do + for submission in $(ls submissions/$team); do + problem=$(getProblemName "submissions/$team/$submission") + time=$(echo "$submission" | sed 's/ /_/g') + rename="${team}_${problem}_${time}.cpp" + + if [ ! -d "$problem" ]; then + mkdir -p "Problem_Submissions/$problem" + fi + cp "submissions/$team/$submission" "Problem_Submissions/$problem/$rename" + + done + echo "$team done!" +done diff --git a/MyScripts/Sort_Submissions_By_Problem_ID.cpp b/MyScripts/Sort_Submissions_By_Problem_ID.cpp deleted file mode 100644 index 1fc7c9b..0000000 --- a/MyScripts/Sort_Submissions_By_Problem_ID.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -using namespace std; -#define TEAM_NUMBER 200 -#define MIN_PROBLEM_ID 'A' -#define MAX_PROBLEM_ID 'H' - -int main() { - for(char i=MIN_PROBLEM_ID;i<=MAX_PROBLEM_ID;i++){ - filesystem::create_directory("p"+string(1,i)); - } - for (int i = 1; i <= TEAM_NUMBER; i++) { - string TeamName = "team" + string(3 - to_string(i).length(), '0') + to_string(i); - for (const auto& entry1 : filesystem::directory_iterator(TeamName)) { - ifstream file(entry1.path()); - string s, line; - - for (int i = 0; i < 5; i++) { - getline(file, line); - s += line; - } - - if (s.find(".%l") == string::npos) { - cout << "fail on " << entry1.path() << '\n'; - return 1; - } - file.close(); - - string problem_ID = "p" + string(1, s[s.find(".%l") - 1]); - string NewName = string(entry1.path()).substr(8) + "_" + TeamName; - filesystem::copy(entry1.path(), problem_ID + "/" +NewName); - } - } - cout << "Successful\n"; -} From 1067e4731ce54056d86de1e1667b0f290e393828 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:59:27 +0800 Subject: [PATCH 37/60] Update Groups_Submissions_By_Problem_Name.sh --- MyScripts/Groups_Submissions_By_Problem_Name.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MyScripts/Groups_Submissions_By_Problem_Name.sh b/MyScripts/Groups_Submissions_By_Problem_Name.sh index bd3ede1..b5477a8 100644 --- a/MyScripts/Groups_Submissions_By_Problem_Name.sh +++ b/MyScripts/Groups_Submissions_By_Problem_Name.sh @@ -15,14 +15,17 @@ getProblemName(){ for team in $(ls submissions); do for submission in $(ls submissions/$team); do problem=$(getProblemName "submissions/$team/$submission") - time=$(echo "$submission" | sed 's/ /_/g') - rename="${team}_${problem}_${time}.cpp" + time=$(echo $submission | awk -F '.' '{print $1}') if [ ! -d "$problem" ]; then mkdir -p "Problem_Submissions/$problem" fi - cp "submissions/$team/$submission" "Problem_Submissions/$problem/$rename" - + cp "submissions/$team/$submission" "Problem_Submissions/$problem/$team" + echo -e "\n$time" >> "Problem_Submissions/$problem/$team" done echo "$team done!" done + +for problem in $(ls Problem_Submissions); do + python moss.py $problem +done From 8bdce1bf34b541dff90519131fa5bdaeb6d4ca6e Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:59:55 +0800 Subject: [PATCH 38/60] Create moss.py --- MyScripts/moss.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 MyScripts/moss.py diff --git a/MyScripts/moss.py b/MyScripts/moss.py new file mode 100644 index 0000000..a01e901 --- /dev/null +++ b/MyScripts/moss.py @@ -0,0 +1,11 @@ +import mosspy, sys + +userid = 61861013 + +m = mosspy.Moss(userid, "python") + +m.addFilesByWildcard("Problem_Submissions/" + sys.argv[1] + "/*") + +url = m.send() + +print (sys.argv[1] + " : " + url) From 028027d87dc6a37c6e074279f1721a5928638d77 Mon Sep 17 00:00:00 2001 From: erichung1113 Date: Tue, 16 Apr 2024 17:26:29 +0800 Subject: [PATCH 39/60] update moss.py --- MyScripts/moss.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MyScripts/moss.py b/MyScripts/moss.py index a01e901..a4e7be2 100644 --- a/MyScripts/moss.py +++ b/MyScripts/moss.py @@ -1,3 +1,5 @@ +#python moss.py [problem_name] + import mosspy, sys userid = 61861013 From f46d19a75d35f11992ba70f80074c876d883fac3 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:27:08 +0800 Subject: [PATCH 40/60] Rename Moss.py to delete.py --- MyScripts/{Moss.py => delete.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MyScripts/{Moss.py => delete.py} (100%) diff --git a/MyScripts/Moss.py b/MyScripts/delete.py similarity index 100% rename from MyScripts/Moss.py rename to MyScripts/delete.py From 631a226ae9e6867e5f7a344eee3977894405971d Mon Sep 17 00:00:00 2001 From: erichung1113 Date: Tue, 16 Apr 2024 17:28:35 +0800 Subject: [PATCH 41/60] update moss.py --- MyScripts/delete.py | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 MyScripts/delete.py diff --git a/MyScripts/delete.py b/MyScripts/delete.py deleted file mode 100644 index e300519..0000000 --- a/MyScripts/delete.py +++ /dev/null @@ -1,12 +0,0 @@ -import mosspy - -userid = 61861013 - -m = mosspy.Moss(userid, "python") - - -m.addFilesByWildcard("pH/*") - -url = m.send() # Submission Report URL - -print ("Report Url: " + url) From 36484222c875806c0525df515061b4741461acc9 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:29:47 +0800 Subject: [PATCH 42/60] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b7abefd..9e33606 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ sudo docker exec -t cms sudo cmsAddAdmin admin 接著打開瀏覽器並輸入以下網址就可使用啦 -參賽者介面:`[本幾ip]:8888` +參賽者介面:`localhost:8888` -管理員介面:`[本幾ip]:8889` +管理員介面:`localhost:8889` -計分板:`[本幾ip]:8890` +計分板:`localhost:8890` 更詳細的教學請見 : [CMS Online Judge Docker安裝教學](https://hackmd.io/WKsC33XYRme4sM-Kkst_XA) From b9edc69f2e0b48679b1a97d9fd7e2f05f64f4f13 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:22:18 +0800 Subject: [PATCH 43/60] Update Account_Generator.cpp --- MyScripts/Account_Generator.cpp | 42 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/MyScripts/Account_Generator.cpp b/MyScripts/Account_Generator.cpp index 7497116..ac3ad92 100644 --- a/MyScripts/Account_Generator.cpp +++ b/MyScripts/Account_Generator.cpp @@ -21,33 +21,41 @@ string Generate_Password() { return password; } -/* - Output: - - users: - - username: "team1" - password: "dssinsdnds" - first_name: "TeamName" -*/ +string Generate_Account(int idx) { + stringstream account; + account << "team" << setw(3) << setfill('0') << idx; + return account.str(); +} int main() { srand(time(0)); - + map > team; ifstream TeamnameFile("teamname.txt"); ofstream PasswordFile("password.txt"); + ofstream AccountFile("account.txt"); ofstream SettingFile("contest.user.yaml"); - string teamname; - int User_Idx = 1; + string prev_teamname, teamname, account, password; + int Team_Idx = 1; while (getline(TeamnameFile, teamname)) { - string password = Generate_Password(); - PasswordFile << password << '\n'; - SettingFile << " - username: \"team" << setw(3) << setfill('0') << User_Idx << "\"\n"; - SettingFile << " password: \"" << password << "\"\n"; - SettingFile << " first_name: \"" << teamname << "\"\n"; - User_Idx++; + if(teamname == prev_teamname) { + AccountFile << account << "\n"; + PasswordFile << password << "\n"; + }else{ + account = Generate_Account(Team_Idx); + password = Generate_Password(); + + SettingFile << " - username: \"" << account << "\"\n"; + SettingFile << " password: \"" << password << "\"\n"; + SettingFile << " first_name: \"" << teamname << "\"\n"; + AccountFile << account << "\n"; + PasswordFile << password << "\n"; + Team_Idx++; + } + prev_teamname = teamname; } TeamnameFile.close(); PasswordFile.close(); + AccountFile.close(); SettingFile.close(); } From 82b2127d20040fced223f28741d62ad2267faf1f Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:05:01 +0800 Subject: [PATCH 44/60] Create dependency.sh --- MyScripts/dependency.sh | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 MyScripts/dependency.sh diff --git a/MyScripts/dependency.sh b/MyScripts/dependency.sh new file mode 100644 index 0000000..24bc4da --- /dev/null +++ b/MyScripts/dependency.sh @@ -0,0 +1,57 @@ +import xml.etree.ElementTree as ET +import json + +file_path = "problem.xml" + +# Load the XML file +tree = ET.parse(file_path) +root = tree.getroot() + +groups = [] +group_points = {} +group_dependencies = {} +group_counts = {} +group_testcase_regex = {} + +for group in root.findall(".//group"): + group_name = group.get('name') + groups.append(group_name) + + points = group.get('points', '0') + group_points[group_name] = int(float(points)) + + dependencies = [dep.get('group') for dep in group.findall('.//dependency')] + group_dependencies[group_name] = dependencies + +for test in root.findall(".//test"): + group = test.get('group') + if group in group_counts: + group_counts[group] += 1 + else: + group_counts[group] = 1 + +for group in groups: + print(group, group_counts[group], group_points[group], group_dependencies[group]) + +#--------------------------------------------------- + +cur = 0 +for group in groups: + count = group_counts[group] + print(f"{cur:03d} {cur + count - 1:03d}") + cur += count + regex = input() + # regex = group + group_testcase_regex[group] = regex + + +score_parameters = [] +for group in groups: + testcase_regex = group_testcase_regex[group] + for dependency in group_dependencies[group]: + testcase_regex += "|" + group_testcase_regex[dependency] + + score_parameters.append((group_points[group],testcase_regex)) + +json_string = json.dumps(score_parameters) +print('\n\n' + json_string) From bacbcad4ef0a55e09a29b61c3b4b4588feffb407 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 10 May 2024 10:15:42 +0800 Subject: [PATCH 45/60] annoymous account --- MyScripts/Account_Generator.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/MyScripts/Account_Generator.cpp b/MyScripts/Account_Generator.cpp index ac3ad92..ee739c8 100644 --- a/MyScripts/Account_Generator.cpp +++ b/MyScripts/Account_Generator.cpp @@ -1,7 +1,8 @@ #include using namespace std; -#define PASSWORD_LENTH 6 +// #define ANNOYMOUS_TEAM_NUMBER 10 +#define PASSWORD_LENTH 6 const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', @@ -37,22 +38,29 @@ int main() { string prev_teamname, teamname, account, password; int Team_Idx = 1; + +#ifdef ANNOYMOUS_TEAM_NUMBER + while(Team_Idx < ANNOYMOUS_TEAM_NUMBER){ + teamname = Generate_Account(Team_Idx); +#else while (getline(TeamnameFile, teamname)) { +#endif if(teamname == prev_teamname) { AccountFile << account << "\n"; PasswordFile << password << "\n"; - }else{ - account = Generate_Account(Team_Idx); - password = Generate_Password(); - - SettingFile << " - username: \"" << account << "\"\n"; - SettingFile << " password: \"" << password << "\"\n"; - SettingFile << " first_name: \"" << teamname << "\"\n"; - AccountFile << account << "\n"; - PasswordFile << password << "\n"; - Team_Idx++; + continue; } - prev_teamname = teamname; + account = Generate_Account(Team_Idx); + password = Generate_Password(); + + SettingFile << " - username: \"" << account << "\"\n"; + SettingFile << " password: \"" << password << "\"\n"; + SettingFile << " first_name: \"" << teamname << "\"\n"; + AccountFile << account << "\n"; + PasswordFile << password << "\n"; + Team_Idx++; + + prev_teamname = teamname; } TeamnameFile.close(); PasswordFile.close(); From 513b101fe45f405f0e93759a1914679287098e43 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 10 May 2024 10:46:53 +0800 Subject: [PATCH 46/60] Update Account_Generator.cpp --- MyScripts/Account_Generator.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/MyScripts/Account_Generator.cpp b/MyScripts/Account_Generator.cpp index ee739c8..f67d936 100644 --- a/MyScripts/Account_Generator.cpp +++ b/MyScripts/Account_Generator.cpp @@ -1,6 +1,11 @@ #include using namespace std; -// #define ANNOYMOUS_TEAM_NUMBER 10 +#define AUTO_GENERATE_TEAM_NAME +#define AUTO_GENERATE_ACCOUNT + +#ifdef AUTO_GENERATE_TEAM_NAME + #define TEAM_NUMBER 10 +#endif #define PASSWORD_LENTH 6 const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', @@ -33,30 +38,42 @@ int main() { map > team; ifstream TeamnameFile("teamname.txt"); ofstream PasswordFile("password.txt"); - ofstream AccountFile("account.txt"); ofstream SettingFile("contest.user.yaml"); +#ifdef AUTO_GENERATE_ACCOUNT + ofstream AccountFile("account.txt"); +#else + ifstream AccountFile("account.txt"); +#endif string prev_teamname, teamname, account, password; int Team_Idx = 1; -#ifdef ANNOYMOUS_TEAM_NUMBER - while(Team_Idx < ANNOYMOUS_TEAM_NUMBER){ - teamname = Generate_Account(Team_Idx); +#ifdef AUTO_GENERATE_TEAM_NAME + while(Team_Idx < TEAM_NUMBER){ + teamname = Generate_Account(Team_Idx); #else while (getline(TeamnameFile, teamname)) { #endif if(teamname == prev_teamname) { +#ifdef AUTO_GENERATE_ACCOUNT AccountFile << account << "\n"; +#endif PasswordFile << password << "\n"; continue; } +#ifdef AUTO_GENERATE_ACCOUNT account = Generate_Account(Team_Idx); +#else + getline(AccountFile, account); +#endif password = Generate_Password(); SettingFile << " - username: \"" << account << "\"\n"; SettingFile << " password: \"" << password << "\"\n"; SettingFile << " first_name: \"" << teamname << "\"\n"; +#ifdef AUTO_GENERATE_ACCOUNT AccountFile << account << "\n"; +#endif PasswordFile << password << "\n"; Team_Idx++; From a6a1ae4bbca7f9f99eca6334a77877e1f2779cec Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 16 May 2024 03:01:17 +0800 Subject: [PATCH 47/60] Rename cms_process_monitor.sh to auto_launch.sh --- MyScripts/{cms_process_monitor.sh => auto_launch.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MyScripts/{cms_process_monitor.sh => auto_launch.sh} (100%) diff --git a/MyScripts/cms_process_monitor.sh b/MyScripts/auto_launch.sh similarity index 100% rename from MyScripts/cms_process_monitor.sh rename to MyScripts/auto_launch.sh From 97a9f723591bf29dbb0d366de880d908f47e9bd8 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 16 May 2024 04:11:59 +0800 Subject: [PATCH 48/60] Update auto_launch.sh --- MyScripts/auto_launch.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MyScripts/auto_launch.sh b/MyScripts/auto_launch.sh index 202f0c9..f95660e 100644 --- a/MyScripts/auto_launch.sh +++ b/MyScripts/auto_launch.sh @@ -1,8 +1,11 @@ #!/bin/bash +id="" while true; do - if ! curl -s http://localhost:8888 > /dev/null; then - sudo cmsResourceService -a <<< 1 + if ! curl -s http://localhost:8888 > /dev/null || [[ $id != $(cat /home/contest/contest_id) ]]; then + id=$(cat /home/contest/contest_id) + kill $(ps aux | grep cms | awk '{print $2}' | head -n -1) + cmsResourceService -a <<< $id & fi - sleep 60 + sleep 1 done From 622bc0c64f3a7ddcfbddd45854a786d482219b40 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 16 May 2024 04:51:54 +0800 Subject: [PATCH 49/60] Create import_user.sh --- MyScripts/import_user.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 MyScripts/import_user.sh diff --git a/MyScripts/import_user.sh b/MyScripts/import_user.sh new file mode 100644 index 0000000..21ca21b --- /dev/null +++ b/MyScripts/import_user.sh @@ -0,0 +1,5 @@ +paste id name account password | while read -r name id account password; do + echo "$name, $id, $account, $password" + cmsAddUser $name $id $account -p $password; + cmsAddParticipation -c 1 $account +done From b513d79a9c4ab7c6b991b9ee7520e4571f57dc38 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 16 May 2024 04:56:34 +0800 Subject: [PATCH 50/60] Rename auto_launch.sh to auto_relaunch.sh --- MyScripts/{auto_launch.sh => auto_relaunch.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename MyScripts/{auto_launch.sh => auto_relaunch.sh} (100%) diff --git a/MyScripts/auto_launch.sh b/MyScripts/auto_relaunch.sh similarity index 100% rename from MyScripts/auto_launch.sh rename to MyScripts/auto_relaunch.sh From 702ad20a96d4ba9790c75086f7b560d1db12e982 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 16 May 2024 12:06:12 +0800 Subject: [PATCH 51/60] Update Account_Generator.cpp --- MyScripts/Account_Generator.cpp | 87 +++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/MyScripts/Account_Generator.cpp b/MyScripts/Account_Generator.cpp index f67d936..5365148 100644 --- a/MyScripts/Account_Generator.cpp +++ b/MyScripts/Account_Generator.cpp @@ -1,27 +1,34 @@ #include using namespace std; -#define AUTO_GENERATE_TEAM_NAME + +// *Important* Check if the same team name exist for different teams. + #define AUTO_GENERATE_ACCOUNT +#define AUTO_GENERATE_TEAMNAME -#ifdef AUTO_GENERATE_TEAM_NAME - #define TEAM_NUMBER 10 +#if defined(AUTO_GENERATE_ACCOUNT) && defined(AUTO_GENERATE_TEAMNAME) + #define ACCOUNT_NUMBER 10 #endif +#define AccountPrefix "account" +#define TeamnamePrefix "team" + #define PASSWORD_LENTH 6 -const char chr[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', +const char chr[] = {'2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', + 'H', 'J', 'K', 'L', 'M', 'N', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', + 'h', 'i', 'j', 'k', 'm', 'n', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; string Generate_Password() { string password; + int sz = sizeof(chr); for (int i = 0; i < PASSWORD_LENTH; i++) { - int idx = rand() % 62; + int idx = rand() % sz; password += chr[idx]; } return password; @@ -29,14 +36,19 @@ string Generate_Password() { string Generate_Account(int idx) { stringstream account; - account << "team" << setw(3) << setfill('0') << idx; + account << AccountPrefix << setw(3) << setfill('0') << idx; return account.str(); } +string Generate_Teamname(int idx) { + stringstream teamname; + teamname << TeamnamePrefix << setw(3) << setfill('0') << idx; + return teamname.str(); +} + int main() { srand(time(0)); map > team; - ifstream TeamnameFile("teamname.txt"); ofstream PasswordFile("password.txt"); ofstream SettingFile("contest.user.yaml"); #ifdef AUTO_GENERATE_ACCOUNT @@ -44,43 +56,54 @@ int main() { #else ifstream AccountFile("account.txt"); #endif +#ifdef AUTO_GENERATE_TEAMNAME + ofstream TeamnameFile("teamname.txt"); +#else + ifstream TeamnameFile("teamname.txt"); +#endif - string prev_teamname, teamname, account, password; - int Team_Idx = 1; + string teamname, account, password; + int Account_Idx = 1; -#ifdef AUTO_GENERATE_TEAM_NAME - while(Team_Idx < TEAM_NUMBER){ - teamname = Generate_Account(Team_Idx); -#else +#if defined(AUTO_GENERATE_TEAMNAME) && defined(AUTO_GENERATE_ACCOUNT) + while(Account_Idx <= ACCOUNT_NUMBER){ + teamname = Generate_Teamname(Account_Idx); + account = Generate_Account(Account_Idx); +#elif !defined(AUTO_GENERATE_ACCOUNT) && !defined(AUTO_GENERATE_TEAMNAME) + while (getline(AccountFile, account)) { + getline(TeamnameFile, teamname); +#elif defined(AUTO_GENERATE_ACCOUNT) && !defined(AUTO_GENERATE_TEAMNAME) while (getline(TeamnameFile, teamname)) { + account = Generate_Account(Account_Idx); +#elif !defined(AUTO_GENERATE_ACCOUNT) && defined(AUTO_GENERATE_TEAMNAME) + while (getline(AccountFile, account)) { + teamname = Generate_Teamname(Account_Idx); #endif - if(teamname == prev_teamname) { -#ifdef AUTO_GENERATE_ACCOUNT - AccountFile << account << "\n"; -#endif - PasswordFile << password << "\n"; - continue; - } -#ifdef AUTO_GENERATE_ACCOUNT - account = Generate_Account(Team_Idx); -#else - getline(AccountFile, account); -#endif + password = Generate_Password(); SettingFile << " - username: \"" << account << "\"\n"; SettingFile << " password: \"" << password << "\"\n"; SettingFile << " first_name: \"" << teamname << "\"\n"; + #ifdef AUTO_GENERATE_ACCOUNT AccountFile << account << "\n"; +#endif +#ifdef AUTO_GENERATE_TEAMNAME + TeamnameFile << teamname << "\n"; #endif PasswordFile << password << "\n"; - Team_Idx++; - - prev_teamname = teamname; + + Account_Idx++; } TeamnameFile.close(); PasswordFile.close(); AccountFile.close(); SettingFile.close(); } + +/* + cms username: account + cms password: password + cms first_name: teamname +*/ From e771199c2ae19a49ba0c6ecf6245e123675b495a Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Tue, 8 Oct 2024 03:41:50 +0800 Subject: [PATCH 52/60] Create alias.sh --- MyScripts/alias.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 MyScripts/alias.sh diff --git a/MyScripts/alias.sh b/MyScripts/alias.sh new file mode 100644 index 0000000..1ca590f --- /dev/null +++ b/MyScripts/alias.sh @@ -0,0 +1,3 @@ +alias stopcms="sudo kill \$(ps aux | grep cms | awk '{print \$2}' | head -n -1) > /dev/null 2>&1" +alias startcms="sudo cmsResourceService -a" +alias restartcms="stopcms; startcms" From 3fab8a3e3bf62746775e3cfd18b51e7e2c62cb85 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 14 Nov 2024 00:23:53 +0800 Subject: [PATCH 53/60] Update auto_relaunch.sh --- MyScripts/auto_relaunch.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/MyScripts/auto_relaunch.sh b/MyScripts/auto_relaunch.sh index f95660e..74610ff 100644 --- a/MyScripts/auto_relaunch.sh +++ b/MyScripts/auto_relaunch.sh @@ -1,11 +1,7 @@ #!/bin/bash -id="" +id="4" -while true; do - if ! curl -s http://localhost:8888 > /dev/null || [[ $id != $(cat /home/contest/contest_id) ]]; then - id=$(cat /home/contest/contest_id) - kill $(ps aux | grep cms | awk '{print $2}' | head -n -1) - cmsResourceService -a <<< $id & - fi - sleep 1 -done +if ! curl -s http://localhost:8888 > /dev/null; then + kill $(ps aux | grep cms | awk '{print $2}' | head -n -1) + cmsResourceService -a <<< $id & +fi From b163a2440478a65e92fd6051e9550f3d1631ba4c Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:51:52 +0800 Subject: [PATCH 54/60] Update auto_relaunch.sh --- MyScripts/auto_relaunch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MyScripts/auto_relaunch.sh b/MyScripts/auto_relaunch.sh index 74610ff..de8bfac 100644 --- a/MyScripts/auto_relaunch.sh +++ b/MyScripts/auto_relaunch.sh @@ -1,7 +1,7 @@ #!/bin/bash -id="4" +id="1" if ! curl -s http://localhost:8888 > /dev/null; then kill $(ps aux | grep cms | awk '{print $2}' | head -n -1) - cmsResourceService -a <<< $id & + /usr/local/bin/cmsResourceService -a <<< $id & fi From d3834e89177a4516f7345233416ab526ed20056b Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:51:33 +0800 Subject: [PATCH 55/60] Update and rename dependency.sh to dependency.py --- MyScripts/{dependency.sh => dependency.py} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename MyScripts/{dependency.sh => dependency.py} (85%) diff --git a/MyScripts/dependency.sh b/MyScripts/dependency.py similarity index 85% rename from MyScripts/dependency.sh rename to MyScripts/dependency.py index 24bc4da..a302b99 100644 --- a/MyScripts/dependency.sh +++ b/MyScripts/dependency.py @@ -1,7 +1,9 @@ +# usage : python3 dependency.py pA + import xml.etree.ElementTree as ET -import json +import json, sys -file_path = "problem.xml" +file_path = sys.argv[1] + "/problem.xml" # Load the XML file tree = ET.parse(file_path) @@ -31,7 +33,7 @@ group_counts[group] = 1 for group in groups: - print(group, group_counts[group], group_points[group], group_dependencies[group]) + print(f"Group {group} : number: {group_counts[group]}, points: {group_points[group]}, dependency: {group_dependencies[group]}") #--------------------------------------------------- From 4b6dcc54e54f859b2e2acc862c39004a80205367 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:07:50 +0800 Subject: [PATCH 56/60] Update dependency.py --- MyScripts/dependency.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/MyScripts/dependency.py b/MyScripts/dependency.py index a302b99..d4d25b4 100644 --- a/MyScripts/dependency.py +++ b/MyScripts/dependency.py @@ -15,22 +15,36 @@ group_counts = {} group_testcase_regex = {} +for test in root.find(".//judging").findall(".//test"): # find test in tests + group = test.get('group') + + if group not in groups: + groups.append(group) + group_counts[group] = 0 + + group_counts[group] += 1 + + for group in root.findall(".//group"): group_name = group.get('name') - groups.append(group_name) points = group.get('points', '0') group_points[group_name] = int(float(points)) - dependencies = [dep.get('group') for dep in group.findall('.//dependency')] - group_dependencies[group_name] = dependencies + # dependencies = [dep.get('group') for dep in group.findall('.//dependency')] + dependencies = [] + for dep in group.findall('.//dependency'): + dep_name = dep.get('group') -for test in root.findall(".//test"): - group = test.get('group') - if group in group_counts: - group_counts[group] += 1 - else: - group_counts[group] = 1 + dependencies.append(dep_name) + if len(group_dependencies[dep_name]): + dependencies.extend(group_dependencies[dep_name]) + + dependencies = list(set(dependencies)) + dependencies.sort() + # dependencies = list(set(dependencies)).sort() + + group_dependencies[group_name] = dependencies for group in groups: print(f"Group {group} : number: {group_counts[group]}, points: {group_points[group]}, dependency: {group_dependencies[group]}") From 2c80f703687877d5dc23389718a6e2e134338be8 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:08:04 +0800 Subject: [PATCH 57/60] Update dependency.py --- MyScripts/dependency.py | 1 - 1 file changed, 1 deletion(-) diff --git a/MyScripts/dependency.py b/MyScripts/dependency.py index d4d25b4..1dd175e 100644 --- a/MyScripts/dependency.py +++ b/MyScripts/dependency.py @@ -42,7 +42,6 @@ dependencies = list(set(dependencies)) dependencies.sort() - # dependencies = list(set(dependencies)).sort() group_dependencies[group_name] = dependencies From d98854aa0f137a3f6ef095490e00739fcb6b2696 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG <101823195+erichung9060@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:08:47 +0800 Subject: [PATCH 58/60] Update dependency.py --- MyScripts/dependency.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/MyScripts/dependency.py b/MyScripts/dependency.py index 1dd175e..0daf0bb 100644 --- a/MyScripts/dependency.py +++ b/MyScripts/dependency.py @@ -31,7 +31,6 @@ points = group.get('points', '0') group_points[group_name] = int(float(points)) - # dependencies = [dep.get('group') for dep in group.findall('.//dependency')] dependencies = [] for dep in group.findall('.//dependency'): dep_name = dep.get('group') @@ -56,7 +55,6 @@ print(f"{cur:03d} {cur + count - 1:03d}") cur += count regex = input() - # regex = group group_testcase_regex[group] = regex From 8188978fec0e10f785f6957e0e950b7f083d50ea Mon Sep 17 00:00:00 2001 From: EHDW Date: Mon, 17 Nov 2025 21:35:39 +0800 Subject: [PATCH 59/60] =?UTF-8?q?Postgres=2018+=20=E5=B7=B2=E7=B6=93?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=94=A8=20/var/lib/postgresql/<=E7=89=88?= =?UTF-8?q?=E6=9C=AC>/main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3c79ba7..3264e5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: environment: POSTGRES_HOST_AUTH_METHOD: trust volumes: - - "/cms_docker_postgresql_data:/var/lib/postgresql/data" + - "/cms_docker_postgresql_data:/var/lib/postgresql" cms_test: container_name: cms From 8bcb9ecae8a671479ad7c8c27b90583602fa7354 Mon Sep 17 00:00:00 2001 From: RUEI TING HUNG Date: Tue, 18 Nov 2025 17:05:05 +0800 Subject: [PATCH 60/60] docs: Update CMS repository URL in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e33606..da53c94 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ sudo apt install docker-compose -y ``` **Step. 3 下載cms** ``` -git clone https://github.com/erichung1113/cms.git && cd cms +git clone https://github.com/erichung9060/cms.git && cd cms ``` **Step. 4 執行docker compose** ```