📚 Case Study in Action: Building a Digital Quiz | 案例分析实战演练:打造数字问答游戏
In this case study, you will follow the journey of a young programmer, Emma, as she creates a digital quiz about animals for her school project. The task is to design, build, test and evaluate a program using Scratch. You will discover how to break down a problem, plan a solution with flowcharts and pseudocode, and bring it to life with code.
在这个案例分析中,你将跟随小学生艾玛的脚步,看她如何为学校项目创建一个关于动物的数字问答游戏。任务是用 Scratch 设计、构建、测试和评估一个程序。你会发现如何分解问题、用流程图和伪代码规划方案,并通过代码将其实现。
1. Introducing the Problem Scenario | 介绍问题场景
Emma’s Computing Science teacher asked the class to create an interactive quiz that asks five questions about animals. The program should welcome the user, ask each question, check the answer, keep score, and display the final result. The quiz must also handle incorrect spelling gracefully by accepting two possible correct answers for each question.
艾玛的计算机科学老师要求全班创建一个互动问答游戏,询问五个关于动物的问题。程序要欢迎用户、逐题提问、检查答案、记录得分并显示最终结果。考虑到拼写错误,每道题必须接受两个可能的正确答案。
The scenario is realistic: many apps and websites use similar logic to test users’ knowledge. Emma needs to think like a software developer, starting from a vague idea and turning it into a working program.
这个场景很现实:很多应用和网站都用类似的逻辑测试用户知识。艾玛需要像软件开发人员一样思考,从一个模糊的想法开始,把它变成可运行的程序。
2. Understanding the Problem | 理解问题
Before writing any code, Emma read the brief several times and wrote down what the program must do. She identified the inputs (the user’s answers), the processes (checking, scoring, showing messages) and the outputs (feedback and final score).
在写任何代码之前,艾玛把任务要求读了好几遍,并写下程序必须做什么。她确定了输入(用户的回答)、处理(检查、计分、显示信息)和输出(反馈和最终得分)。
She also noted the key success criteria: the quiz must have exactly five questions, a welcome screen, a scoring system, and must accept ‘cheetah’ or ‘leopard’ for the fastest land animal, for example. This list of requirements helps avoid missing important features later.
她还记下了关键成功标准:测验必须有恰好五道题、一个欢迎界面、计分系统,并且比如对于最快的陆地动物,必须接受 ‘cheetah’ 或 ‘leopard’。这份需求列表能帮助避免日后遗漏重要特性。
3. User Stories and Requirements | 用户故事与需求
Emma used simple user stories to describe what the user wants: “As a player, I want to see my score at the end so I know how well I did.” Another story was “As a player, I want clear instructions so I don’t get confused.”
艾玛用简单的用户故事来描述用户需求:”作为玩家,我希望在结尾看到得分,这样我就知道自己答得怎么样。” 另一个故事是”作为玩家,我想要清晰的指引,这样我才不会弄糊涂。”
From these stories, she built a requirements list: 1) display a welcome message, 2) ask each question and wait for an answer, 3) compare the answer with two acceptable correct answers, 4) increase score for a correct answer, 5) show a ‘correct’ or ‘wrong’ message for every question, 6) display the total score at the end, and 7) say goodbye.
根据这些故事,她列出了一份需求清单:1) 显示欢迎消息,2) 逐一提问并等待回答,3) 将回答与两个可接受的正确答案比较,4) 答对则增加得分,5) 每道题显示”正确”或”错误”消息,6) 最后显示总分,7) 告别。
4. Planning with a Flowchart | 用流程图进行规划
To visualise the logic, Emma drew a flowchart. The chart starts with an oval ‘Start’. A rectangle says ‘Set score to 0’. Then she used a loop for each question: a diamond asks ‘Is answer equal to option A or option B?’ If true, the flow goes to ‘Add 1 to score, say Correct’ otherwise to ‘Say Wrong’. After five questions, the flow reaches ‘Display score’ and finally ‘End’.
为了可视化逻辑,艾玛画了流程图。图表以椭圆形”开始”为起点。一个矩形说”设得分为0″。然后她对每道题使用循环:菱形问”回答是否等于选项A或选项B?”如果为真,流程走向”得分加1,说正确”,否则走向”说错误”。五道题后,流程到达”显示得分”,最后”结束”。
Flowcharts use standard symbols: ovals for Start/End, rectangles for processes, diamonds for decisions. This helps Emma spot a missing step, such as resetting the score before the quiz.
流程图使用标准符号:椭圆代表开始/结束,矩形代表处理,菱形代表决策。这帮助艾玛发现遗漏的步骤,比如在测验开始前重置得分。
5. Designing the Algorithm in Pseudocode | 用伪代码设计算法
Emma wrote pseudocode, a human-readable set of steps that looks like simple English. It is not real code but helps structure the program.
艾玛编写了伪代码,那是一套可读性强的步骤,看起来像简明的英语。它不是真正的代码,但有助于构建程序。
Her pseudocode began:
她的伪代码开头如下:
score ← 0
say ‘Welcome to the Animal Quiz!’
ask question1
if answer = ‘cheetah’ or answer = ‘leopard’ then
score ← score + 1
say ‘Correct!’
else
say ‘Wrong! The answer is cheetah.’
end if
This pattern repeats for all five questions, then the final line says ‘Your score is ‘ + score. Notice the use of the arrow (←) to show assignment.
这一模式对所有五道题重复,然后最后一行说 ‘你的得分是’ + score。注意用箭头(←)表示赋值。
6. Implementing the Quiz in Scratch | 在 Scratch 中实现问答游戏
Emma opened Scratch and created a new project. She chose a backdrop and a sprite (a friendly cat). The code blocks were built under the sprite. She used the ‘when green flag clicked’ event to start.
艾玛打开 Scratch,创建了一个新项目。她选了背景和角色(一只友好的猫)。代码块建在角色下。她用”当绿旗被点击”事件来开始。
First, she initialised a variable called Score and set it to 0. She made the cat say ‘Welcome! Press space to start.’ Then she used a ‘ask ___ and wait’ block for each question. The answer was stored in the built-in answer variable. For checking, she used an ‘if … then … else’ block with an ‘or’ operator: if answer = cheetah or answer = leopard then.
首先,她初始化了一个名为 Score 的变量并设为0。她让小猫说”欢迎!按空格键开始。”然后她对每道题使用”询问 ___ 并等待”积木。回答被存储在内置的 answer 变量中。检查时,她用了”如果…那么…否则”积木搭配”或”操作符:如果 answer = cheetah 或 answer = leopard 那么。
Inside the ‘if’ branch, she increased Score by 1 and made the sprite say ‘Correct!’. In the ‘else’ branch, she made it say ‘Wrong! The correct answer is cheetah.’ After all five questions, a final ‘say’ block displayed the score.
在”如果”分支内,她将 Score 增加1,并让角色说”正确!”。在”否则”分支内,她让它说”错误!正确答案是猎豹。”所有五道题结束后,一个最终的”说”积木显示了得分。
7. Testing the Quiz with a Plan | 用测试计划测试问答
Testing is crucial. Emma created a test table to check different types of input she expected users to try.
测试至关重要。艾玛创建了一个测试表来检查用户可能尝试的不同输入类型。
| Test Case | Input | Expected Outcome | Actual Outcome |
|---|---|---|---|
| Correct answer (option 1) | cheetah | Score +1, ‘Correct!’ | As expected |
| Correct answer (option 2) | leopard | Score +1, ‘Correct!’ | As expected |
| Wrong answer | tiger | Score unchanged, ‘Wrong!’ | As expected |
| Uppercase input | CHEETAH | Must be marked wrong (case sensitive) | Wrong – improvement needed |
| Empty input | (press enter without typing) | Must be marked wrong, no crash | As expected |
Emma discovered that the quiz did not accept ‘CHEETAH’ because Scratch is case sensitive. She decided to improve the program.
艾玛发现问答不接受”CHEETAH”,因为 Scratch 对大小写敏感。她决定改进程序。
8. Debugging and Fixing Issues | 调试与修复问题
The case sensitivity bug was fixed by converting the answer to lower case before checking. In Scratch, she added a block to set answer to lower case of answer. Now ‘CHEETAH’ became ‘cheetah’ and the condition worked.
大小写敏感的缺陷通过在检查前将回答转为小写来修复。在 Scratch 中,她添加了一个积木将 answer 设为 answer 转换为小写。现在”CHEETAH”变成了”cheetah”,判断条件就生效了。
Another bug appeared: the score did not reset when the green flag was clicked again mid-quiz. Emma fixed this by always setting Score to 0 at the very start of the script.
另一个缺陷出现了:如果在问答过程中再次点击绿旗,得分不会重置。艾玛通过始终在脚本最开始将 Score 设为0来解决了这个问题。
She also added a short pause between questions so the player had time to read the feedback. This improved the user experience.
她还在各题之间添加了短暂的暂停,让玩家有时间阅读反馈。这改善了用户体验。
9. Evaluating the Project Against the Requirements | 对照需求评估项目
After fixing bugs, Emma went back to her original requirements list and ticked each one. The program met all seven requirements, but she noticed a new idea: what if the quiz included pictures of the animals? This was beyond the original brief, but it showed how evaluation leads to enhancements.
修复缺陷后,艾玛回到原始需求清单,逐一打勾。程序满足了全部七项需求,但她注意到一个新想法:如果测验包含动物图片会怎样?这超出了最初的任务说明,但显示出了评估如何带来改进。
She also asked two classmates to play the quiz and give feedback. One said the text was too fast, so Emma increased the display time for each message. The other liked the scoring and wanted a high score tracker. Emma recorded these as future improvements.
她还请两位同学玩问答并给出反馈。一位说文字过快,于是艾玛延长了每条消息的显示时间。另一位喜欢计分功能,并希望有最高分追踪器。艾玛把这些记录为未来的改进项。
10. Key Learning Points and Conclusion | 关键学习点与总结
Through this case study, Emma learned that programming is not just about writing code. It involves analysing the problem, planning with diagrams and pseudocode, building step by step, testing thoroughly, and fixing mistakes.
通过这个案例分析,艾玛认识到编程不仅仅是写代码。它涉及分析问题、用图表和伪代码规划、逐步构建、彻底测试以及修正错误。
She also discovered that real-world programs are refined through feedback and evaluation. The computing concepts used included: variables (Score), selection (if-else), iteration (repeated question patterns), Boolean logic (or), and debugging. These form the foundation of all programming languages.
她还发现真实世界的程序通过反馈和评估不断完善。用到的计算概念包括:变量(Score)、选择(if-else)、迭代(重复的问题模式)、布尔逻辑(or)和调试。这些是所有编程语言的基础。
Now you can try creating your own quiz on a topic you love, using the same process Emma followed. Happy coding!
现在你可以尝试用艾玛使用的方法,针对你喜欢的主题创建一个你自己的问答游戏。祝你编码愉快!
Published by TutorHao | Computing Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导