📚 Year 11 WJEC Computer Science: Case Study Practical Exercises | Year 11 WJEC 计算机:案例分析实战演练
In the WJEC GCSE Computer Science specification, the ability to analyse and solve real‑world problems through systematic case study work is essential. This article provides a complete walk‑through of a sample case study – developing a 'Student Grade Management System' – from initial analysis to final evaluation. You will practise the key skills tested in the Unit 2 on‑screen exam as well as the non‑exam assessment.
在 WJEC 的 GCSE 计算机科学课程中,通过系统化的案例研究来解决现实问题的能力至关重要。本文将以一个完整的示例案例——“学生成绩管理系统”——带你从初步分析直到最终评估走一遍。你将练习单元 2 上机考试和课程作业所考查的关键技能。
1. Problem Definition and Scope | 问题定义与范围
Before writing any code, you must clearly define what the system is meant to do. For this case study, a school requires a program to store and process the exam results of its Year 11 students. The system should allow a teacher to add grades for individual subjects, calculate average marks, and display the highest‑scoring student in a given subject.
在编写任何代码之前,你必须清楚地定义系统要做什么。本案例中,一所学校需要一个程序来存储和处理 Year 11 学生的考试成绩。系统应允许教师添加单科成绩、计算平均分,并显示某科目的最高分学生。
The inputs are student names, subject names, and the numeric marks they achieved. The outputs will be the class average for each subject and the name of the top student, along with their mark. The process stops when the teacher enters 'quit'. This initial scope avoids feature creep and keeps the project manageable.
输入是学生姓名、科目名称以及他们取得的分数。输出则是每科的全班平均分以及最高分学生的姓名与分数。当教师输入'quit'时,程序终止。此初始范围可避免功能蔓延,使项目易于管理。
2. Stakeholder Requirements and Success Criteria | 利益相关者需求与成功标准
The primary stakeholder is the classroom teacher who will use the software daily. Through a brief interview, we discover that the program must be simple to operate, must not lose data during a session, and must present results clearly. No login or permanent storage is required at this stage, but the algorithm must handle up to 200 students per cohort.
主要利益相关者是每日使用该软件的任课教师。通过简短访谈我们了解到,程序必须操作简单、会话期间数据不得丢失,且结果呈现要清晰。现阶段无需登录或永久存储,但算法必须能处理每个年级最多 200 名学生。
From these requirements we derive measurable success criteria: the system shall accept student data continuously until a 'quit' command; it shall compute the correct mean for any valid numerical input; it shall identify the highest mark with its owner's name; and it shall output results within 1 second on a typical school computer. These criteria will later be used to test the solution.
根据这些需求,我们得出可量化的成功标准:系统应持续接收学生数据,直到输入'quit'命令;对任何有效的数值输入,应能计算出正确的平均值;应能识别最高分及其拥有者姓名;在典型的学校计算机上,结果应在 1 秒内输出。这些标准随后将用于测试解决方案。
3. Inputs, Outputs and Processing | 输入、输出与处理过程
) and one integer variable (mark). For each subject, the program accumulates the total of marks and counts how many students were entered. The algorithm then computes the average using total ÷ count.
我们用一张简单表格来记录数据流。输入包含两个字符串变量(student_name、subject)和一个整数变量(mark)。对每个科目,程序累加分数总和并统计输入了多少名学生。然后算法通过总和 ÷ 人数计算平均分。
Additionally, the system keeps a record of the current highest mark for each subject. Whenever a new mark exceeds this stored value, the highest mark and the associated student name are updated. Outputs are the subject average (formatted to one decimal place) and the top student's details.
此外,系统会为每个科目记录当前最高分。每当新分数超过该存储值时,最高分和对应的学生姓名便会更新。输出是科目平均分(格式化为一位小数)以及最高分学生的详细信息。
Average = Σ marks ÷ n | Highest = max(marks)
hart would show a loop: input student data → update totals and checks for higher mark → if 'quit' then calculate and display results, otherwise repeat.
处理流程图将展示一个循环:输入学生数据 → 更新总和并检查是否有更高分 → 若输入'quit'则计算并显示结果,否则重复。
4. Data Structures and Storage | 数据结构与存储
In a text‑based implementation, we can use parallel lists or dictionaries. A dictionary is ideal: each key is a subject name (e.g. 'Maths'), and the value is another list containing the running total, the student count, and a sub‑list for the top student [name, mark].
在基于文本的实现中,我们可以使用并列列表或字典。字典非常理想:每个键是科目名称(例如 'Maths'),值则是另一个列表,包含累积总分、学生人数,以及一个子列表记录最佳学生 [姓名, 分数]。
| Subject (key) | Value structure |
| 'Maths' | [total_marks, count, ['Alice', 92]] |
| 'Physics' | [265, 3, ['John', 88]] |
If the teacher enters a subject not yet in the dictionary, a new entry is created with the initial mark as both the total and the top mark. This data structure allows fast lookup and updating without scanning large files. It also aligns with the WJEC emphasis on using appropriate data structures to improve efficiency.
如果教师输入了一个字典中尚不存在的科目,则会创建一个新条目,将初始分数同时作为总分和最高分。这种数据结构支持快速查找和更新,无需扫描大型文件。它也符合 WJEC 关于使用合适数据结构来提高效率的要求。
5. Algorithm Design and Pseudocode | 算法设计与伪代码
We design a main algorithm in structured English. The pseudocode below follows the WJEC pseudocode conventions, using WHILE, IF, and CASE structures where appropriate.
我们用结构化英语设计主算法。下面的伪代码遵循 WJEC 的伪代码约定,在适当处使用 WHILE、IF 和 CASE 结构。
subjects ← empty dictionary
REPEAT
OUTPUT "Enter student name (or 'quit'):"
INPUT name
IF name = 'quit' THEN EXIT REPEAT
OUTPUT "Enter subject:"
INPUT subj
OUTPUT "Enter mark:"
INPUT mark
IF mark < 0 OR mark > 100 THEN
OUTPUT "Invalid mark, try again."
ELSE
IF subj not in subjects THEN
subjects[subj] ← [mark, 1, [name, mark]]
ELSE
current ← subjects[subj]
current[0] ← current[0] + mark
current[1] ← current[1] + 1
IF mark > current[2][1] THEN
current[2] ← [name, mark]
END IF
subjects[subj] ← current
END IF
END IF
UNTIL FALSE
FOR each key in subjects DO
avg ← subjects[key][0] / subjects[key][1]
OUTPUT key, "average:", avg rounded to 1 decimal
OUTPUT "Top student:", subjects[key][2][0], "with", subjects[key][2][1]
END FOR
This algorithm runs in O(n) time where n is the number of data entries, making it highly efficient for the expected cohort size. There are no nested loops that depend on the number of subjects or students, so performance will not degrade with larger datasets.
该算法的时间复杂度为 O(n),其中 n 为数据条目数,对于预期年级规模而言非常高效。不存在依赖于科目数或学生数的嵌套循环,因此即使数据集较大,性能也不会下降。
6. Programming Implementation Techniques | 编程实现技巧
When implementing in Python, a high‑level language permitted by WJEC, you would use a dictionary where each value is a list containing three elements as described. Use a while True loop with a break when 'quit' is entered. Input validation is crucial: the mark must be cast to an integer and checked for the range 0–100.
在用 WJEC 允许的高级语言 Python 实现时,你将使用字典,其中每个值是一个包含上述三元素的列表。使用 while True 循环,并在输入 'quit' 时跳出。输入验证至关重要:必须将分数转换为整数并检查其在 0–100 范围内。
To round averages to one decimal place, you can use round(avg, 1) or format(avg, '.1f'). It is good practice to comment the code, explaining the purpose of the dictionary structure and the update logic. Remember that WJEC on‑screen exams may ask you to trace or modify such code, so your implementation must be clear and logical.
若要将平均值保留一位小数,可以使用 round(avg, 1) 或 format(avg, '.1f')。为代码添加注释、解释字典结构的用途和更新逻辑是一种良好实践。请记住,WJEC 的上机考试可能会要求你追踪或修改这些代码,因此你的实现必须清晰且合乎逻辑。
7. Test Plan and Trace Table | 测试计划与追踪表
Before running the program, create a test plan using sample data. We can design normal, boundary, and erroneous tests. For normal data, enter two students for 'Maths' with marks 56 and 78; expect average 67.0 and top student 'Student2'. For boundary data, test a mark of 0 and 100.
在运行程序前,使用样本数据制定测试计划。我们可以设计正常、边界和异常测试。对于正常数据,输入两名“数学”学生,分数分别为 56 和 78;预期平均分为 67.0,最高分学生为“Student2”。对于边界数据,测试分数 0 和 100。
Erroneous tests include entering non‑numeric characters or negative numbers; the program should display an error message and ask for the input again. A trace table can be used to follow the variables during a test run. Below is a partial trace for the first two inputs of the normal test.
异常测试包括输入非数字字符或负数;程序应显示错误消息并重新要求输入。追踪表可用于在测试运行期间跟踪变量。以下是正常测试前两次输入的部分追踪信息。
| Step | name | subj | mark | subjects['Maths'] | Output |
| 1 | Alice | Maths | 56 | [56, 1, ['Alice', 56]] | – |
| 2 | Bob | Maths | 78 | [134, 2, ['Bob', 78]] | – |
h 78. Trace tables are an explicit requirement in WJEC Unit 2 questions, so practice them thoroughly.
最后一步之后,平均分为 134 ÷ 2 = 67.0,最高分学生 Bob 78 分。追踪表是 WJEC 单元 2 题目中的明确要求,因此要认真练习。
8. Robustness and Error Handling | 健壮性与错误处理
A robust system does not crash on unexpected input. We must ensure the program handles: non‑integer marks, marks outside 0–100, and subjects with no valid entries. If the teacher types 'quit' before entering any subject data, the final FOR loop would have an empty dictionary; our algorithm handles this gracefully by simply doing nothing.
健壮的系统不会因意外输入而崩溃。我们必须确保程序能处理:非整数分数、超出 0–100 的分数,以及没有任何有效条目的科目。如果教师在输入任何科目数据之前键入 'quit',最终的 FOR 循环将处理一个空字典;我们的算法通过直接跳过操作来优雅地处理这种情况。
Using Python's try‑except block when converting the input to int will catch ValueError. Additionally, we could add a check to prevent duplicate entries for the same student in the same subject, though that may be outside the current scope. Error messages should be specific: e.g., 'Mark must be a whole number between 0 and 100'.
在 Python 中,将输入转换为 int 时使用 try‑except 块将捕获 ValueError。此外,我们可以添加检查来防止同一学生在同一科目中重复输入,尽管这可能超出当前范围。错误消息应尽可能具体,例如“分数必须是 0 到 100 之间的整数”。
9. Legal, Ethical and Environmental Considerations | 法律、伦理与环境考量
Any system handling student grades must respect data protection laws. Even this simple program could be storing personal data (name + grades), so it would be subject to the UK General Data Protection Regulation (GDPR) and the Data Protection Act 2018. Personal data should be processed lawfully and kept secure, even if only temporarily in memory.
任何处理学生成绩的系统都必须遵守数据保护法律。即便是这个简单的程序,也可能存储个人数据(姓名 + 成绩),因此它要受英国《通用数据保护条例》(GDPR)和《2018 年数据保护法》的约束。即使在内存中暂时保存,个人数据也必须合法处理并保持安全。
Ethically, the program must not allow manipulation of results without an audit trail. While not implemented here, a real system would include user authentication and logging. Environmentally, the solution has minimal footprint, but if it were part of a larger client‑server system, we would consider energy‑efficient code and cloud deployment.
伦理上,程序不得在无审计追踪的情况下允许篡改结果。虽然此处未实现,但真实的系统将包含用户认证和日志记录。环境方面,该解决方案占用资源极少,但如果它是更大的客户端‑服务器系统的一部分,我们将考虑节能代码和云部署。
10. Evaluation and Future Improvements | 评估与未来改进
Against the original success criteria, the solution performs correctly and swiftly. It can handle all valid inputs, computes accurate averages, and identifies the top performer. However, the program could be enhanced in several ways: adding file I/O to save data between sessions, allowing subject deletion, or even generating individual student reports.
对照最初的成功标准,解决方案运行正确且速度快。它能处理所有有效输入,计算准确的平均值,并识别最高分。然而,该程序也可以通过多种方式增强:增加文件读写功能以在会话之间保存数据,允许删除科目,甚至生成学生个人报告。
A graphical user interface (GUI) using tkinter would make the program more accessible for non‑technical staff. From an algorithmic perspective, we might sort the data to display a ranking, but that would increase complexity. Evaluation is a key part of WJEC assessments; you must always reflect on your solution's limitations and propose realistic refinements.
使用 tkinter 创建图形用户界面 (GUI) 将使非技术员工更容易使用。从算法角度看,我们可能对数据进行排序以显示排名,但这会增加复杂度。评估是 WJEC 评估的关键部分;你必须始终反思解决方案的局限性,并提出切实可行的改进建议。
11. Exam Tips for the On‑Screen Assessment | 上机考试应试技巧
In the WJEC Unit 2 exam, you will face similar case studies where you must design, code, test, and evaluate. Manage your time by reading the pre‑release material carefully. When writing code in the exam environment, start with a simple structure and iteratively add features. Always save your work frequently.
在 WJEC 单元 2 考试中,你会遇到类似的案例研究,需要设计、编写代码、测试和评估。合理分配时间,仔细阅读预习材料。在考试环境中编写代码时,从简单结构开始,逐步添加功能。务必经常保存你的工作。
If you are asked to write pseudocode, follow the standard conventions shown in textbooks. Use comments to explain your logic, as these can earn marks. Finally, remember that the evaluation questions often carry significant weight – always link your evaluation back to the success criteria and the user's needs.
如果要求你编写伪代码,请遵循教科书中展示的标准约定。使用注释解释你的逻辑,因为这些可以得分。最后请记住,评估题目通常占分很重——务必将你的评估与成功标准和用户需求联系起来。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图