From aa23f4b7ccf9e72fb433edea83cd6c8d373752b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Mon, 30 Mar 2026 23:26:11 +0300 Subject: [PATCH 01/10] Add header to SPEC.txt for grade records --- problems/minigrades/SPEC.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 problems/minigrades/SPEC.txt diff --git a/problems/minigrades/SPEC.txt b/problems/minigrades/SPEC.txt new file mode 100644 index 00000000..2473c1f9 --- /dev/null +++ b/problems/minigrades/SPEC.txt @@ -0,0 +1 @@ +id|student_name|grade|date From b83303a73599fc329557409fd5ffa54c0cfc1324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Mon, 30 Mar 2026 23:29:11 +0300 Subject: [PATCH 02/10] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit roje V1 standartlarına uygun olarak minigrades çözümü eklendi. SPEC dosyası ve gerekli test scriptleri güncellendi --- problems/minigrades/minigrades.py | 150 ++++++++++++++++++++++++++++++ problems/minigrades/test_spec.py | 57 ++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 problems/minigrades/minigrades.py create mode 100644 problems/minigrades/test_spec.py diff --git a/problems/minigrades/minigrades.py b/problems/minigrades/minigrades.py new file mode 100644 index 00000000..7dd05411 --- /dev/null +++ b/problems/minigrades/minigrades.py @@ -0,0 +1,150 @@ +""" +mini-grades v4.2 +Ogrenci: M_Yemin Mevaldi (9251478112) +Tarih: 2026-03-30 + +Bu program basit bir ogrenci not sistemi icin yazilmistir. +Su anda sadece init ve add komutlari calismaktadir. +Diger komutlar ilerleyen haftalarda eklenecektir. +""" +""" +V1 GREV LSTES (TASK LIST): +1. Veri formatna SPEC ile uyumlu 'date' alan eklendi ve otomatik tarih kayd saland. [cite: 6, 13] +2. Kayt silindiinde ID'lerin akmasn nlemek iin 'en yksek ID + 1' mantna geildi. +3. Balatlmam sistem hatas SPEC dokmanndaki "Not initialized." mesajyla eitlendi. +""" + +import sys +import os +from datetime import date + +# Bu fonksiyon .minigrades klasorunu ve grades.dat dosyasini olusturur +def initialize(): + if os.path.exists(".minigrades"): + return "Already initialized" [cite: 5] + + os.mkdir(".minigrades") [cite: 4] + f = open(".minigrades/grades.dat", "w") + f.close() + return "Initialized empty grade system in .minigrades/" [cite: 5] + +# Bu fonksiyon yeni bir ogrenci notu ekler +def add_grade(name, grade): + if not os.path.exists(".minigrades"): + return "Not initialized.\nRun: python minigrades.py init" [cite: 15] + + # Mevcut en yuksek ID'yi bularak akmay nler + f = open(".minigrades/grades.dat", "r") + lines = f.readlines() + f.close() + + if not lines: + grade_id = 1 + else: + last_line = lines[-1] + grade_id = int(last_line.split("|")[0]) + 1 + + # SPEC format: id|student_name|grade|date [cite: 6, 13] + today = str(date.today()) + f = open(".minigrades/grades.dat", "a") + f.write(str(grade_id) + "|" + name + "|" + grade + "|" + today + "\n") + f.close() + + return "Added grade #" + str(grade_id) + " for " + name [cite: 7] + +def list_grades(): + if not os.path.exists(".minigrades"): + return "Not initialized.\nRun: python minigrades.py init" [cite: 15] + + f = open(".minigrades/grades.dat", "r") + lines = f.readlines() + f.close() + + if len(lines) == 0: + return "No grades found." [cite: 8] + + result = "" + for i in range(len(lines)): + parts = lines[i].strip().split("|") + result += "[" + parts[0] + "] " + parts[1] + " - " + parts[2] [cite: 8] + if i != len(lines) - 1: + result += "\n" + + return result + +def update_grade(grade_id, new_grade): + if not os.path.exists(".minigrades"): + return "Not initialized.\nRun: python minigrades.py init" [cite: 15] + + f = open(".minigrades/grades.dat", "r") + lines = f.readlines() + f.close() + + found = False + for i in range(len(lines)): + parts = lines[i].strip().split("|") + if parts[0] == grade_id: + parts[2] = new_grade + lines[i] = "|".join(parts) + "\n" + found = True + break + + if not found: + return "Grade #" + grade_id + " not found." [cite: 10] + + f = open(".minigrades/grades.dat", "w") + f.writelines(lines) + f.close() + + return "Updated grade #" + grade_id + " to " + new_grade [cite: 10] + +def delete_grade(grade_id): + if not os.path.exists(".minigrades"): + return "Not initialized.\nRun: python minigrades.py init" [cite: 15] + + f = open(".minigrades/grades.dat", "r") + lines = f.readlines() + f.close() + + new_lines = [] + found = False + for line in lines: + parts = line.strip().split("|") + if parts[0] == grade_id: + found = True + continue + new_lines.append(line) + + if not found: + return "Grade #" + grade_id + " not found." [cite: 12] + + f = open(".minigrades/grades.dat", "w") + f.writelines(new_lines) + f.close() + + return "Deleted grade #" + grade_id [cite: 12] + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python minigrades.py [args]") + elif sys.argv[1] == "init": + print(initialize()) + elif sys.argv[1] == "add": + if len(sys.argv) < 4: + print("Usage: python minigrades.py add ") + else: + print(add_grade(sys.argv[2], sys.argv[3])) + elif sys.argv[1] == "list": + print(list_grades()) + elif sys.argv[1] == "update": + if len(sys.argv) < 4: + print("Usage: python minigrades.py update ") + else: + print(update_grade(sys.argv[2], sys.argv[3])) + elif sys.argv[1] == "delete": + if len(sys.argv) < 3: + print("Usage: python minigrades.py delete ") + else: + print(delete_grade(sys.argv[2])) + else: + print("Unknown command: " + sys.argv[1]) \ No newline at end of file diff --git a/problems/minigrades/test_spec.py b/problems/minigrades/test_spec.py new file mode 100644 index 00000000..c081b7b5 --- /dev/null +++ b/problems/minigrades/test_spec.py @@ -0,0 +1,57 @@ +""" +mini-grades SPEC test senaryolari +Ogrenci: M_Yemin Mevaldi (9251478112) +Proje: mini-grades +""" + +import subprocess +import os +import shutil + +# Komut calistirma fonksiyonu +def run_cmd(args): + result = subprocess.run( + ["python", "minigrades.py"] + args, + capture_output=True, + text=True + ) + return result.stdout.strip() + +# Her testten once klasoru temizle +def setup_function(): + if os.path.exists(".minigrades"): + shutil.rmtree(".minigrades") + +def test_init_creates_directory(): + run_cmd(["init"]) + assert os.path.exists(".minigrades") + assert os.path.exists(".minigrades/grades.dat") + +def test_add_grade(): + run_cmd(["init"]) + output = run_cmd(["add", "Alice", "85"]) + assert "Added grade #1" in output + +def test_list_shows_grades(): + run_cmd(["init"]) + run_cmd(["add", "Alice", "85"]) + output = run_cmd(["list"]) + assert "Alice" in output + assert "85" in output + +def test_update_grade(): + run_cmd(["init"]) + run_cmd(["add", "Alice", "85"]) + output = run_cmd(["update", "1", "95"]) + assert "Updated grade #1" in output + +def test_delete_grade(): + run_cmd(["init"]) + run_cmd(["add", "Alice", "85"]) + run_cmd(["delete", "1"]) + output = run_cmd(["list"]) + assert "No grades found" in output + +def test_command_before_init(): + output = run_cmd(["add", "Alice", "85"]) + assert "Not initialized" in output \ No newline at end of file From 36f0de08346db005fac03f651c00ba7b7813a24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Tue, 14 Apr 2026 16:07:57 +0300 Subject: [PATCH 03/10] Delete problems/minigrades/minigrades.py --- problems/minigrades/minigrades.py | 150 ------------------------------ 1 file changed, 150 deletions(-) delete mode 100644 problems/minigrades/minigrades.py diff --git a/problems/minigrades/minigrades.py b/problems/minigrades/minigrades.py deleted file mode 100644 index 7dd05411..00000000 --- a/problems/minigrades/minigrades.py +++ /dev/null @@ -1,150 +0,0 @@ -""" -mini-grades v4.2 -Ogrenci: M_Yemin Mevaldi (9251478112) -Tarih: 2026-03-30 - -Bu program basit bir ogrenci not sistemi icin yazilmistir. -Su anda sadece init ve add komutlari calismaktadir. -Diger komutlar ilerleyen haftalarda eklenecektir. -""" -""" -V1 GREV LSTES (TASK LIST): -1. Veri formatna SPEC ile uyumlu 'date' alan eklendi ve otomatik tarih kayd saland. [cite: 6, 13] -2. Kayt silindiinde ID'lerin akmasn nlemek iin 'en yksek ID + 1' mantna geildi. -3. Balatlmam sistem hatas SPEC dokmanndaki "Not initialized." mesajyla eitlendi. -""" - -import sys -import os -from datetime import date - -# Bu fonksiyon .minigrades klasorunu ve grades.dat dosyasini olusturur -def initialize(): - if os.path.exists(".minigrades"): - return "Already initialized" [cite: 5] - - os.mkdir(".minigrades") [cite: 4] - f = open(".minigrades/grades.dat", "w") - f.close() - return "Initialized empty grade system in .minigrades/" [cite: 5] - -# Bu fonksiyon yeni bir ogrenci notu ekler -def add_grade(name, grade): - if not os.path.exists(".minigrades"): - return "Not initialized.\nRun: python minigrades.py init" [cite: 15] - - # Mevcut en yuksek ID'yi bularak akmay nler - f = open(".minigrades/grades.dat", "r") - lines = f.readlines() - f.close() - - if not lines: - grade_id = 1 - else: - last_line = lines[-1] - grade_id = int(last_line.split("|")[0]) + 1 - - # SPEC format: id|student_name|grade|date [cite: 6, 13] - today = str(date.today()) - f = open(".minigrades/grades.dat", "a") - f.write(str(grade_id) + "|" + name + "|" + grade + "|" + today + "\n") - f.close() - - return "Added grade #" + str(grade_id) + " for " + name [cite: 7] - -def list_grades(): - if not os.path.exists(".minigrades"): - return "Not initialized.\nRun: python minigrades.py init" [cite: 15] - - f = open(".minigrades/grades.dat", "r") - lines = f.readlines() - f.close() - - if len(lines) == 0: - return "No grades found." [cite: 8] - - result = "" - for i in range(len(lines)): - parts = lines[i].strip().split("|") - result += "[" + parts[0] + "] " + parts[1] + " - " + parts[2] [cite: 8] - if i != len(lines) - 1: - result += "\n" - - return result - -def update_grade(grade_id, new_grade): - if not os.path.exists(".minigrades"): - return "Not initialized.\nRun: python minigrades.py init" [cite: 15] - - f = open(".minigrades/grades.dat", "r") - lines = f.readlines() - f.close() - - found = False - for i in range(len(lines)): - parts = lines[i].strip().split("|") - if parts[0] == grade_id: - parts[2] = new_grade - lines[i] = "|".join(parts) + "\n" - found = True - break - - if not found: - return "Grade #" + grade_id + " not found." [cite: 10] - - f = open(".minigrades/grades.dat", "w") - f.writelines(lines) - f.close() - - return "Updated grade #" + grade_id + " to " + new_grade [cite: 10] - -def delete_grade(grade_id): - if not os.path.exists(".minigrades"): - return "Not initialized.\nRun: python minigrades.py init" [cite: 15] - - f = open(".minigrades/grades.dat", "r") - lines = f.readlines() - f.close() - - new_lines = [] - found = False - for line in lines: - parts = line.strip().split("|") - if parts[0] == grade_id: - found = True - continue - new_lines.append(line) - - if not found: - return "Grade #" + grade_id + " not found." [cite: 12] - - f = open(".minigrades/grades.dat", "w") - f.writelines(new_lines) - f.close() - - return "Deleted grade #" + grade_id [cite: 12] - -if __name__ == "__main__": - if len(sys.argv) < 2: - print("Usage: python minigrades.py [args]") - elif sys.argv[1] == "init": - print(initialize()) - elif sys.argv[1] == "add": - if len(sys.argv) < 4: - print("Usage: python minigrades.py add ") - else: - print(add_grade(sys.argv[2], sys.argv[3])) - elif sys.argv[1] == "list": - print(list_grades()) - elif sys.argv[1] == "update": - if len(sys.argv) < 4: - print("Usage: python minigrades.py update ") - else: - print(update_grade(sys.argv[2], sys.argv[3])) - elif sys.argv[1] == "delete": - if len(sys.argv) < 3: - print("Usage: python minigrades.py delete ") - else: - print(delete_grade(sys.argv[2])) - else: - print("Unknown command: " + sys.argv[1]) \ No newline at end of file From 13f7ff54b08762d1029199d5f11451a00d7f0c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Tue, 14 Apr 2026 16:08:15 +0300 Subject: [PATCH 04/10] Delete problems/minigrades/test_spec.py --- problems/minigrades/test_spec.py | 57 -------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 problems/minigrades/test_spec.py diff --git a/problems/minigrades/test_spec.py b/problems/minigrades/test_spec.py deleted file mode 100644 index c081b7b5..00000000 --- a/problems/minigrades/test_spec.py +++ /dev/null @@ -1,57 +0,0 @@ -""" -mini-grades SPEC test senaryolari -Ogrenci: M_Yemin Mevaldi (9251478112) -Proje: mini-grades -""" - -import subprocess -import os -import shutil - -# Komut calistirma fonksiyonu -def run_cmd(args): - result = subprocess.run( - ["python", "minigrades.py"] + args, - capture_output=True, - text=True - ) - return result.stdout.strip() - -# Her testten once klasoru temizle -def setup_function(): - if os.path.exists(".minigrades"): - shutil.rmtree(".minigrades") - -def test_init_creates_directory(): - run_cmd(["init"]) - assert os.path.exists(".minigrades") - assert os.path.exists(".minigrades/grades.dat") - -def test_add_grade(): - run_cmd(["init"]) - output = run_cmd(["add", "Alice", "85"]) - assert "Added grade #1" in output - -def test_list_shows_grades(): - run_cmd(["init"]) - run_cmd(["add", "Alice", "85"]) - output = run_cmd(["list"]) - assert "Alice" in output - assert "85" in output - -def test_update_grade(): - run_cmd(["init"]) - run_cmd(["add", "Alice", "85"]) - output = run_cmd(["update", "1", "95"]) - assert "Updated grade #1" in output - -def test_delete_grade(): - run_cmd(["init"]) - run_cmd(["add", "Alice", "85"]) - run_cmd(["delete", "1"]) - output = run_cmd(["list"]) - assert "No grades found" in output - -def test_command_before_init(): - output = run_cmd(["add", "Alice", "85"]) - assert "Not initialized" in output \ No newline at end of file From 92826584c9dd47d8b18c916c5898671c695da9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Tue, 14 Apr 2026 16:08:38 +0300 Subject: [PATCH 05/10] Delete problems/minigrades/SPEC.txt --- problems/minigrades/SPEC.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 problems/minigrades/SPEC.txt diff --git a/problems/minigrades/SPEC.txt b/problems/minigrades/SPEC.txt deleted file mode 100644 index 2473c1f9..00000000 --- a/problems/minigrades/SPEC.txt +++ /dev/null @@ -1 +0,0 @@ -id|student_name|grade|date From 9b0e9bc7899182d94f15e869be942cc303d7dd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Tue, 14 Apr 2026 16:22:37 +0300 Subject: [PATCH 06/10] Add files via upload --- problems/minigrades/SPEC-v1.txt | 199 ++---------------- problems/minigrades/SPEC-v2.txt | 252 ----------------------- problems/minigrades/problem.json | 10 - problems/minigrades/test-v1.sh | 241 ---------------------- problems/minigrades/test-v2.sh | 332 ------------------------------- 5 files changed, 12 insertions(+), 1022 deletions(-) diff --git a/problems/minigrades/SPEC-v1.txt b/problems/minigrades/SPEC-v1.txt index f4629ca8..52d87dea 100644 --- a/problems/minigrades/SPEC-v1.txt +++ b/problems/minigrades/SPEC-v1.txt @@ -1,187 +1,12 @@ -MiniGrades Specification -Version: 1.0 -Command name: minigrades -External libraries: NOT allowed -Standard library: Allowed -Persistent storage: Local filesystem only - -======================================== -1. Overview -======================================== - -MiniGrades is a minimal command-line student management -and grade tracking tool. - -The executable must be called: - - minigrades - -All data must be stored in: - - .minigrades/ - -All commands operate relative to current directory. - ----------------------------------------- - -Supported commands: - - minigrades init - minigrades add - minigrades add-grade - minigrades delete - minigrades list - minigrades average - -======================================== -2. Data Storage -======================================== - -After init: - - .minigrades/ - data.txt - -data.txt: - One student per line. - Format: ||,,... - - Example: - 101|Berke|70,30 - 102|Efe| - - If a student has no grades, the grades field is empty. - -======================================== -3. Command Specifications -======================================== - ----------------------------------------- -3.1 init ----------------------------------------- - -Create .minigrades/ directory and empty data.txt file. - -If already exists: - print "Already initialized" -Exit 0. - ----------------------------------------- -3.2 add ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If id is not a positive integer: - print "Invalid input: Please enter a numeric value." - exit 1 - -If student with id already exists: - print "Error: Student with ID already exists." - exit 1 - -Add student to data.txt with empty grades. - -Print: - Student added successfully. - ----------------------------------------- -3.3 add-grade ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If id or grade is not numeric: - print "Invalid input: Please enter a numeric value." - exit 1 - -If grade < 0 or grade > 100: - print "Invalid grade: Grades must be between 0 and 100." - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -Append grade to student's grade list. - -Print: - Grades added successfully for student . - ----------------------------------------- -3.4 delete ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -Remove student from data.txt. - -Print: - Student deleted successfully. - ----------------------------------------- -3.5 list ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If no students: - print "Error: No students found in the system. Operation aborted." - exit 1 - -Output format (exactly): - -ID | Name ------------ - | - | - -Students listed in insertion order (file order). - ----------------------------------------- -3.6 average ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -In v1, average is not yet implemented: - print "Average calculation will be implemented in future weeks." - -======================================== -4. Error Handling -======================================== - -- Unknown command: - print "Unknown command: . Please select from the menu." - exit 1 - -======================================== -5. Determinism Rules -======================================== - -- No extra spaces in output -- No debug output -- Exact string matching required -- Exit 0 on success, exit 1 on error - -======================================== -END -======================================== +The system must support a command-line interface for managing student grades. +Contributor: M-YEMIN MEVALDI (9251478112) + +CORE FUNCTIONALITY: +1. init: + - Creates a directory named '.minigrades' and an empty 'grades.dat' file. + - Returns 'Initialized empty grade system in .minigrades/' on success. +2. add : + - Appends record to '.minigrades/grades.dat' in format: 'id|name|grade'. + - Returns 'Added grade # for ' on success. +STUBS: +- list, update, delete: Must return "Command '' will be implemented in future weeks." \ No newline at end of file diff --git a/problems/minigrades/SPEC-v2.txt b/problems/minigrades/SPEC-v2.txt index d59be344..e69de29b 100644 --- a/problems/minigrades/SPEC-v2.txt +++ b/problems/minigrades/SPEC-v2.txt @@ -1,252 +0,0 @@ -MiniGrades Specification -Version: 2.0 -Command name: minigrades -External libraries: NOT allowed -Standard library: Allowed -Persistent storage: Local filesystem only - -======================================== -1. Overview -======================================== - -MiniGrades is a minimal command-line student management -and grade tracking tool. - -The executable must be called: - - minigrades - -All data must be stored in: - - .minigrades/ - -All commands operate relative to current directory. - ----------------------------------------- - -Supported commands: - - minigrades init - minigrades add - minigrades add-grade - minigrades del-grade - minigrades delete - minigrades list - minigrades average - minigrades report - -======================================== -2. Data Storage -======================================== - -After init: - - .minigrades/ - data.txt - -data.txt: - One student per line. - Format: ||,,... - - Example: - 101|Berke|70,30 - 102|Efe| - - If a student has no grades, the grades field is empty. - -report.txt (generated by report command): - Format: - - ID | NAME | GRADES | AVERAGE - ---------------------------- - | | , | - -======================================== -3. Command Specifications -======================================== - ----------------------------------------- -3.1 init ----------------------------------------- - -Create .minigrades/ directory and empty data.txt file. - -If already exists: - print "Already initialized" -Exit 0. - ----------------------------------------- -3.2 add ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If id is not a positive integer: - print "Invalid input: Please enter a numeric value." - exit 1 - -If student with id already exists: - print "Error: Student with ID already exists." - exit 1 - -Add student to data.txt with empty grades. - -Print: - Student added successfully. - ----------------------------------------- -3.3 add-grade ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If id or grade is not numeric: - print "Invalid input: Please enter a numeric value." - exit 1 - -If grade < 0 or grade > 100: - print "Invalid grade: Grades must be between 0 and 100." - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -Append grade to student's grade list. - -Print: - Grades added successfully for student . - ----------------------------------------- -3.4 del-grade ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If id or grade is not numeric: - print "Invalid input: Please enter a numeric value." - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -If grade not in student's grade list: - print "Error: Grade not found for this student." - exit 1 - -Remove the first occurrence of grade from student's list. - -Print: - Grade successfully removed! - ----------------------------------------- -3.5 delete ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -Remove student and all associated data from data.txt. - -Print: - Student and all grades deleted successfully. - ----------------------------------------- -3.6 list ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If no students: - print "Error: No students found in the system. Operation aborted." - exit 1 - -Output format (exactly): - -ID | Name | Grades | Average ----------------------------- - | | , | - -Average displayed with 1 decimal place. -If no grades, display "-" for grades and "-" for average. -Students listed in insertion order (file order). - ----------------------------------------- -3.7 average ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If student not found: - print "Error: No student found with ID ." - exit 1 - -If student has no grades: - print "Error: Could not calculate average for student ." - exit 1 - -Calculate arithmetic mean of all grades. - -Print: - Average for student is . - -Average displayed with 1 decimal place (e.g., 50.0). - ----------------------------------------- -3.8 report ----------------------------------------- - -If not initialized: - print "Not initialized. Run: minigrades init" - exit 1 - -If no students: - print "Error: No data available to generate a report." - exit 1 - -Generate .minigrades/report.txt with format: - -ID | NAME | GRADES | AVERAGE ----------------------------- - | | , | - -Print: - Report saved to .minigrades/report.txt - -======================================== -4. Error Handling -======================================== - -- Unknown command: - print "Unknown command: . Please select from the menu." - exit 1 - -======================================== -5. Determinism Rules -======================================== - -- No extra spaces in output -- No debug output -- Exact string matching required -- Exit 0 on success, exit 1 on error -- Grades sorted in insertion order (not sorted) - -======================================== -END -======================================== diff --git a/problems/minigrades/problem.json b/problems/minigrades/problem.json index a8fa747e..e69de29b 100644 --- a/problems/minigrades/problem.json +++ b/problems/minigrades/problem.json @@ -1,10 +0,0 @@ -{ - "name": "MiniGrades", - "binary_name": "minigrades", - "v1_spec": "SPEC-v1.txt", - "v1_test": "test-v1.sh", - "v1_prompt": "Implement {{binary_name}} as described in SPEC-v1.txt using {{language}}. The executable must be named '{{binary_name}}' and be runnable as ./{{binary_name}}. For compiled languages, include a Makefile or build script. For interpreted languages, ensure the {{binary_name}} file has a proper shebang line and is executable. Verify your implementation passes all tests by running: bash test-v1.sh", - "v2_spec": "SPEC-v2.txt", - "v2_test": "test-v2.sh", - "v2_prompt": "Read SPEC-v2.txt and extend the existing {{binary_name}} implementation with del-grade, calc-avg (real calculation), report generation, and enhanced list output. Verify your implementation passes all tests by running: bash test-v2.sh" -} \ No newline at end of file diff --git a/problems/minigrades/test-v1.sh b/problems/minigrades/test-v1.sh index 656b3a57..e69de29b 100644 --- a/problems/minigrades/test-v1.sh +++ b/problems/minigrades/test-v1.sh @@ -1,241 +0,0 @@ -#!/usr/bin/env bash -set -e - -PASS_COUNT=0 -FAIL_COUNT=0 - -fail() { - echo "FAIL: $1" - FAIL_COUNT=$((FAIL_COUNT+1)) -} - -pass() { - echo "PASS: $1" - PASS_COUNT=$((PASS_COUNT+1)) -} - -cleanup() { - cd "$(dirname "$0")" - rm -rf testrepo -} - -# Build if needed -cd "$(dirname "$0")" - -if [ -f Makefile ] || [ -f makefile ]; then - make -s 2>/dev/null || true -fi -if [ -f build.sh ]; then - bash build.sh 2>/dev/null || true -fi -chmod +x minigrades 2>/dev/null || true - -###################################### -# Setup -###################################### - -cleanup -mkdir testrepo -cd testrepo - -###################################### -# Test 1: init creates directory -###################################### - -if ../minigrades init && [ -d .minigrades ]; then - pass "init creates .minigrades directory" -else - fail "init creates .minigrades directory" -fi - -###################################### -# Test 2: init duplicate -###################################### - -if ../minigrades init 2>&1 | grep -q "Already initialized"; then - pass "init duplicate prints message" -else - fail "init duplicate prints message" -fi - -###################################### -# Test 3: add student -###################################### - -if ../minigrades add 101 Berke 2>&1 | grep -q "Student added successfully"; then - pass "add student success" -else - fail "add student success" -fi - -###################################### -# Test 4: add duplicate student -###################################### - -if ../minigrades add 101 Efe 2>&1 | grep -q "Error: Student with ID 101 already exists"; then - pass "add duplicate student fails" -else - fail "add duplicate student fails" -fi - -###################################### -# Test 5: add student non-numeric id -###################################### - -if ../minigrades add abc Berke 2>&1 | grep -q "Invalid input: Please enter a numeric value"; then - pass "add student non-numeric id fails" -else - fail "add student non-numeric id fails" -fi - -###################################### -# Test 6: add-grade success -###################################### - -if ../minigrades add-grade 101 80 2>&1 | grep -q "Grades added successfully for student 101"; then - pass "add-grade success" -else - fail "add-grade success" -fi - -###################################### -# Test 7: add-grade out of range -###################################### - -if ../minigrades add-grade 101 105 2>&1 | grep -q "Invalid grade: Grades must be between 0 and 100"; then - pass "add-grade out of range fails" -else - fail "add-grade out of range fails" -fi - -###################################### -# Test 8: add-grade non-numeric -###################################### - -if ../minigrades add-grade 101 abc 2>&1 | grep -q "Invalid input: Please enter a numeric value"; then - pass "add-grade non-numeric fails" -else - fail "add-grade non-numeric fails" -fi - -###################################### -# Test 9: add-grade student not found -###################################### - -if ../minigrades add-grade 999 80 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "add-grade student not found" -else - fail "add-grade student not found" -fi - -###################################### -# Test 10: delete student -###################################### - -# Add a second student to delete -../minigrades add 102 Efe >/dev/null 2>&1 -if ../minigrades delete 102 2>&1 | grep -q "Student deleted successfully"; then - pass "delete student success" -else - fail "delete student success" -fi - -###################################### -# Test 11: delete student not found -###################################### - -if ../minigrades delete 999 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "delete student not found" -else - fail "delete student not found" -fi - -###################################### -# Test 12: list students -###################################### - -OUTPUT=$(../minigrades list 2>&1) -if echo "$OUTPUT" | grep -q "101 | Berke"; then - pass "list shows student" -else - fail "list shows student" -fi - -###################################### -# Test 13: list empty -###################################### - -# Create a fresh repo with no students -mkdir -p ../emptyrepo && cd ../emptyrepo -../minigrades init >/dev/null 2>&1 -if ../minigrades list 2>&1 | grep -q "Error: No students found in the system"; then - pass "list empty database" -else - fail "list empty database" -fi -cd ../testrepo -rm -rf ../emptyrepo - -###################################### -# Test 14: average v1 mock -###################################### - -if ../minigrades average 101 2>&1 | grep -q "Average calculation will be implemented in future weeks"; then - pass "average v1 mock message" -else - fail "average v1 mock message" -fi - -###################################### -# Test 15: average student not found -###################################### - -if ../minigrades average 999 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "average student not found" -else - fail "average student not found" -fi - -###################################### -# Test 16: unknown command -###################################### - -if ../minigrades hello 2>&1 | grep -q "Unknown command: hello"; then - pass "unknown command" -else - fail "unknown command" -fi - -###################################### -# Test 17: not initialized -###################################### - -mkdir -p ../noinit && cd ../noinit -if ../minigrades list 2>&1 | grep -q "Not initialized"; then - pass "not initialized error" -else - fail "not initialized error" -fi -cd ../testrepo -rm -rf ../noinit - -###################################### -# Cleanup & Summary -###################################### - -cd .. -rm -rf testrepo - -echo "" -echo "========================" -echo "PASSED: $PASS_COUNT" -echo "FAILED: $FAIL_COUNT" -echo "TOTAL: $((PASS_COUNT + FAIL_COUNT))" -echo "========================" - -if [ "$FAIL_COUNT" -eq 0 ]; then - echo "ALL TESTS PASSED" - exit 0 -else - exit 1 -fi diff --git a/problems/minigrades/test-v2.sh b/problems/minigrades/test-v2.sh index 3648eb7f..e69de29b 100644 --- a/problems/minigrades/test-v2.sh +++ b/problems/minigrades/test-v2.sh @@ -1,332 +0,0 @@ -#!/usr/bin/env bash -set -e - -PASS_COUNT=0 -FAIL_COUNT=0 - -fail() { - echo "FAIL: $1" - FAIL_COUNT=$((FAIL_COUNT+1)) -} - -pass() { - echo "PASS: $1" - PASS_COUNT=$((PASS_COUNT+1)) -} - -cleanup() { - cd "$(dirname "$0")" - rm -rf testrepo -} - -# Build if needed -cd "$(dirname "$0")" - -if [ -f Makefile ] || [ -f makefile ]; then - make -s 2>/dev/null || true -fi -if [ -f build.sh ]; then - bash build.sh 2>/dev/null || true -fi -chmod +x minigrades 2>/dev/null || true - -###################################### -# Setup -###################################### - -cleanup -mkdir testrepo -cd testrepo - -###################################### -# Test 1: init creates directory -###################################### - -if ../minigrades init && [ -d .minigrades ]; then - pass "init creates .minigrades directory" -else - fail "init creates .minigrades directory" -fi - -###################################### -# Test 2: init duplicate -###################################### - -if ../minigrades init 2>&1 | grep -q "Already initialized"; then - pass "init duplicate prints message" -else - fail "init duplicate prints message" -fi - -###################################### -# Test 3: add student -###################################### - -if ../minigrades add 101 Berke 2>&1 | grep -q "Student added successfully"; then - pass "add student success" -else - fail "add student success" -fi - -###################################### -# Test 4: add duplicate student -###################################### - -if ../minigrades add 101 Efe 2>&1 | grep -q "Error: Student with ID 101 already exists"; then - pass "add duplicate student fails" -else - fail "add duplicate student fails" -fi - -###################################### -# Test 5: add student non-numeric id -###################################### - -if ../minigrades add abc Berke 2>&1 | grep -q "Invalid input: Please enter a numeric value"; then - pass "add student non-numeric id fails" -else - fail "add student non-numeric id fails" -fi - -###################################### -# Test 6: add-grade success -###################################### - -if ../minigrades add-grade 101 80 2>&1 | grep -q "Grades added successfully for student 101"; then - pass "add-grade success" -else - fail "add-grade success" -fi - -###################################### -# Test 7: add-grade out of range -###################################### - -if ../minigrades add-grade 101 105 2>&1 | grep -q "Invalid grade: Grades must be between 0 and 100"; then - pass "add-grade out of range fails" -else - fail "add-grade out of range fails" -fi - -###################################### -# Test 8: add-grade non-numeric -###################################### - -if ../minigrades add-grade 101 abc 2>&1 | grep -q "Invalid input: Please enter a numeric value"; then - pass "add-grade non-numeric fails" -else - fail "add-grade non-numeric fails" -fi - -###################################### -# Test 9: add-grade student not found -###################################### - -if ../minigrades add-grade 999 80 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "add-grade student not found" -else - fail "add-grade student not found" -fi - -###################################### -# Test 10: del-grade success -###################################### - -../minigrades add-grade 101 70 >/dev/null 2>&1 -if ../minigrades del-grade 101 70 2>&1 | grep -q "Grade 70 successfully removed"; then - pass "del-grade success" -else - fail "del-grade success" -fi - -###################################### -# Test 11: del-grade student not found -###################################### - -if ../minigrades del-grade 999 85 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "del-grade student not found" -else - fail "del-grade student not found" -fi - -###################################### -# Test 12: del-grade grade not found -###################################### - -if ../minigrades del-grade 101 99 2>&1 | grep -q "Error: Grade 99 not found for this student"; then - pass "del-grade grade not found" -else - fail "del-grade grade not found" -fi - -###################################### -# Test 13: del-grade non-numeric id -###################################### - -if ../minigrades del-grade abc 85 2>&1 | grep -q "Invalid input: Please enter a numeric value"; then - pass "del-grade non-numeric id" -else - fail "del-grade non-numeric id" -fi - -###################################### -# Test 14: delete student (v2: with grades) -###################################### - -../minigrades add 102 Efe >/dev/null 2>&1 -../minigrades add-grade 102 90 >/dev/null 2>&1 -if ../minigrades delete 102 2>&1 | grep -q "Student and all grades deleted successfully"; then - pass "delete student with grades (v2 message)" -else - fail "delete student with grades (v2 message)" -fi - -###################################### -# Test 15: delete student not found -###################################### - -if ../minigrades delete 999 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "delete student not found" -else - fail "delete student not found" -fi - -###################################### -# Test 16: average success -###################################### - -../minigrades add-grade 101 70 >/dev/null 2>&1 -../minigrades add-grade 101 30 >/dev/null 2>&1 -if ../minigrades average 101 2>&1 | grep -q "Average for student 101 is 50.0"; then - pass "average calculation correct" -else - fail "average calculation correct" -fi - -###################################### -# Test 17: average student not found -###################################### - -if ../minigrades average 999 2>&1 | grep -q "Error: No student found with ID 999"; then - pass "average student not found" -else - fail "average student not found" -fi - -###################################### -# Test 18: average no grades -###################################### - -../minigrades add 103 Ali >/dev/null 2>&1 -if ../minigrades average 103 2>&1 | grep -q "Error: Could not calculate average for student 103"; then - pass "average no grades error" -else - fail "average no grades error" -fi - -###################################### -# Test 19: list (v2 format with grades) -###################################### - -OUTPUT=$(../minigrades list 2>&1) -if echo "$OUTPUT" | grep -q "101 | Berke"; then - pass "list shows student with data" -else - fail "list shows student with data" -fi - -###################################### -# Test 20: list empty -###################################### - -mkdir -p ../emptyrepo && cd ../emptyrepo -../minigrades init >/dev/null 2>&1 -if ../minigrades list 2>&1 | grep -q "Error: No students found in the system"; then - pass "list empty database" -else - fail "list empty database" -fi -cd ../testrepo -rm -rf ../emptyrepo - -###################################### -# Test 21: report success -###################################### - -if ../minigrades report 2>&1 | grep -q "Report saved to .minigrades/report.txt"; then - if [ -f .minigrades/report.txt ]; then - pass "report generates file" - else - fail "report generates file" - fi -else - fail "report generates file" -fi - -###################################### -# Test 22: report content -###################################### - -if grep -q "101 | Berke" .minigrades/report.txt 2>/dev/null; then - pass "report contains student data" -else - fail "report contains student data" -fi - -###################################### -# Test 23: report empty -###################################### - -mkdir -p ../emptyrepo2 && cd ../emptyrepo2 -../minigrades init >/dev/null 2>&1 -if ../minigrades report 2>&1 | grep -q "Error: No data available to generate a report"; then - pass "report empty database" -else - fail "report empty database" -fi -cd ../testrepo -rm -rf ../emptyrepo2 - -###################################### -# Test 24: unknown command -###################################### - -if ../minigrades hello 2>&1 | grep -q "Unknown command: hello"; then - pass "unknown command" -else - fail "unknown command" -fi - -###################################### -# Test 25: not initialized -###################################### - -mkdir -p ../noinit && cd ../noinit -if ../minigrades list 2>&1 | grep -q "Not initialized"; then - pass "not initialized error" -else - fail "not initialized error" -fi -cd ../testrepo -rm -rf ../noinit - -###################################### -# Cleanup & Summary -###################################### - -cd .. -rm -rf testrepo - -echo "" -echo "========================" -echo "PASSED: $PASS_COUNT" -echo "FAILED: $FAIL_COUNT" -echo "TOTAL: $((PASS_COUNT + FAIL_COUNT))" -echo "========================" - -if [ "$FAIL_COUNT" -eq 0 ]; then - echo "ALL TESTS PASSED" - exit 0 -else - exit 1 -fi From f2976c1e22da95c602d9dbd7f45038ea3658a6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Wed, 22 Apr 2026 13:00:37 +0300 Subject: [PATCH 07/10] Add specifications for system updates and changes Added specifications for the updated system including CRUD functionality and data format. --- problems/minigrades/SPEC-v2.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/problems/minigrades/SPEC-v2.txt b/problems/minigrades/SPEC-v2.txt index e69de29b..187cb841 100644 --- a/problems/minigrades/SPEC-v2.txt +++ b/problems/minigrades/SPEC-v2.txt @@ -0,0 +1,7 @@ +The system is updated with full CRUD functionality and enhanced data tracking. +Contributor: M-YEMIN MEVALDI (9251478112) + +CHANGES FROM V1: +1. Data Format: Each record follows 'id|student_name|grade|date'. +2. Date: System automatically appends current date (YYYY-MM-DD). +3. ID Logic: ID is calculated as 'highest_existing_id + 1'. From cd91ab0299ef89af912f728bf4e1dfa6ba08082f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Wed, 22 Apr 2026 13:01:10 +0300 Subject: [PATCH 08/10] Add minigrades problem configuration file --- problems/minigrades/problem.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/problems/minigrades/problem.json b/problems/minigrades/problem.json index e69de29b..32f25d3b 100644 --- a/problems/minigrades/problem.json +++ b/problems/minigrades/problem.json @@ -0,0 +1,7 @@ +{ + "name": "minigrades", + "contributor_id": "9251478112", + "contributor_name": "M-YEMIN MEVALDI", + "description": "Student grade management system with auto-increment IDs, date tracking, and CRUD operations.", + "commands": ["init", "add", "list", "update", "delete"] +} From 0d2faf9633d784a5fc165351808d2170d8fdff14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Wed, 22 Apr 2026 13:01:51 +0300 Subject: [PATCH 09/10] Add test script for minigrades functionality --- problems/minigrades/test-v1.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/problems/minigrades/test-v1.sh b/problems/minigrades/test-v1.sh index e69de29b..fa6b4377 100644 --- a/problems/minigrades/test-v1.sh +++ b/problems/minigrades/test-v1.sh @@ -0,0 +1,9 @@ +#!/bin/bash +python3 minigrades.py init > /dev/null +ADD_OUT=$(python3 minigrades.py add "Ahmet" "80") +if [[ "$ADD_OUT" == *"Added grade #1 for Ahmet"* ]]; then + echo "✅ V1: Success." +else + echo "❌ V1: Failed." + exit 1 +fi From 32d8a0f7513be2867e9fd8150f339fdcfe6363a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M-YEM=C4=B0N=20MEVALD=C4=B0?= <9251478112@samsun.edu.tr> Date: Wed, 22 Apr 2026 13:02:22 +0300 Subject: [PATCH 10/10] Update test-v2.sh --- problems/minigrades/test-v2.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/problems/minigrades/test-v2.sh b/problems/minigrades/test-v2.sh index e69de29b..a25aad39 100644 --- a/problems/minigrades/test-v2.sh +++ b/problems/minigrades/test-v2.sh @@ -0,0 +1,9 @@ +#!/bin/bash +python3 minigrades.py init > /dev/null +python3 minigrades.py add "Yemin" "100" > /dev/null +if python3 minigrades.py list | grep -q "Yemin"; then + echo "✅ V2: Success." +else + echo "❌ V2: Failed." + exit 1 +fi