Computer ScienceComputing10th, 11th, 12thYear 11, Year 12, Year 13

How to use AI to teach computer science: a malware lesson for AP CS Principles

A high school computer science teacher's malware unit for AP Computer Science Principles: the Flint activity his students use, a simulation you can run from a student's seat, and every setting behind it.

Matthew Davis

Matthew Davis | Computer Science Teacher at The Episcopal Academy

Title card reading 'How an AP CS teacher teaches malware with AI', next to a drawing of a school network with some laptops infected.

"Flint has been invaluable for introducing new concepts and assessing student understanding. My high flyers love how they can deep-dive into course content with an AI expert. Other students who need more attention can get a one-on-one tutor."

Matthew DavisMatthew Davis, Computer science teacher at The Episcopal Academy

This lesson comes from a high school AP Computer Science Principles class. The teacher wrote the course and uses Flint to tutor students one-on-one through each unit.

TL;DR

  • In this AP CSP malware unit, each student gets one type of malware to research. They study it one-on-one with Sparky, Flint's AI tutor, which plays a cybersecurity expert and covers five topics in a fixed order.
  • When a student is stuck on something that's easier to see than to read about, Sparky can build an interactive simulation in the chat. The example below is for a student who thought worms spread the way viruses do.
  • The activity's settings are further down, and you can copy them into your own activity.

Run the simulation a student would get

Try it ยท Example session

Sparky built this simulation for one student, in the middle of the lesson

The student was assigned worms and thought a worm only spreads when someone opens a file. You're in their seat now: answer Sparky's question or press Run, then try the challenges. Then rewind to see how it got built.

InteractiveMalware outbreak
Front officeLibraryComputer labSchool networkinfectedcleanhas the patchopens unexpected files
One laptop in the front office is infected

Infected laptops by hour

hour 0- - all 30hour 24
  • Front office1/8
  • Library0/10
  • Computer lab0/12
Sparky
Here's a school network: 30 laptops in three rooms. One laptop in the front office just got a worm. 30% of the laptops have the latest security patch, and nobody opens any files. Before I run it: how far does the worm get in 24 hours?

Rewind: how it got here

Sparky wrote a brief, and Flint built the simulation from it

Sparky doesn't write the simulation's code. It writes a brief from the conversation: the concept, the misconception to test, every control and the challenges. A separate AI model builds a working simulation from that brief and puts it in the student's chat.

Interactive brief

Malware outbreak on a school network

Concept
How worms, viruses and trojans spread. A worm copies itself across a network to computers missing a security patch. A virus runs only when someone opens an infected file. A trojan doesn't spread on its own; each infection is a separate download.
Why this student
They believe a worm needs someone to open a file, the way a virus does. Ask for a prediction first, then run the worm with nobody opening anything.
Controls
Malware type: worm, virus or trojan. Laptops with the security patch, 0% to 100%, starting at 30%. People who open unexpected files, 0% to 50%, starting at 0%. A firewall between rooms, starting off.
Show
30 laptops in three rooms on one network, which laptops are patched, whose users open unexpected files, how each type of malware reaches its next laptop, and a chart of infected laptops over 24 hours.
Challenges
Keep the worm in the front office. Hold the worm to 3 laptops with the firewall off. Find malware that still spreads when every laptop is patched and the firewall is on.
Grade level
AP Computer Science Principles, grades 10 to 12
  • Read the conversation: the student thinks a worm needs someone to open a file
  • Checked the teacher's guidelines: one topic at a time, don't give everything away at once
  • Wrote the brief above
  • Built the simulation and ran it as a worm, a virus and a trojan
  • Sent it to the student's chat

The student, the network and the conversation are examples we wrote for this page. The activity Sparky works inside, including the greeting in the rewind, is the real one from the class. Interactive simulations are an Experimental feature in Flint, and they show an Experimental label in the student's chat. Sparky decides when a student needs one, and teachers can build one themselves (step 3 below).

How the activity is built

The activity is called Malware Analysis Learning Session. These are its settings.

1. Give Sparky one role

Sparky's role sets the voice for the whole chat. The role here is Cybersecurity Expert, so Sparky talks like a practitioner explaining a threat. The response style is Balanced, the middle option between Concise and Thorough.

2. Write the guidelines in the order you teach

AP Computer Science Principles

๐Ÿฆ  Malware Analysis Learning Session

Activity settings

Sparky's role

Specify Sparky's role in the activity.

Cybersecurity Expert

Response style

Control the level of detail in Sparky's responses.

Guidelines for Sparky

Provide instructions for Sparky to follow.

Act as a knowledgeable but approachable cybersecurity expert. Follow these guidelines:

  1. Be concise and avoid technical jargon unless explaining key terms.
  2. Cover topics one at a time in this order: definition, spreading mechanisms, impacts, real-world examples, and prevention.
  3. Pause after each topic to encourage questions and check understanding.
  4. If students aren't asking questions, prompt them with specific questions about the topic.
  5. Keep responses brief and conversational.
  6. Don't give away all information at once - let students think and engage.
  7. Use real-world examples sparingly and appropriately.
  8. Focus on practical understanding rather than technical details.

Sparky's greeting message

Write Sparky's first message to start the activity.

Hi! I'm your cybersecurity expert, and I'm here to help you learn about malware. Which specific type of malware have you been assigned to study? Once you let me know, we'll explore what it is, how it works, and why it's important to understand it. ๐Ÿ”’

Greeting suggestions

Provide suggestions for students to respond to Sparky's greeting message.

  • ๐Ÿฆ  I was assigned to study [...] malware
  • ๐Ÿค” Could you help me understand [...] malware?
  • ๐Ÿ“ My topic is [...], what can you tell me about it?
  • ๐Ÿ’ญ I need to learn about [...], where should we start?

Guideline 2 gives every student the same five topics, whichever malware they were assigned, so a class report on ransomware and one on spyware cover the same ground. Guideline 6 is why Sparky asked the student a question before building the simulation, instead of explaining worms outright. The greeting asks for the student's assigned malware first, and the greeting suggestions give students a sentence to start from, with a blank for their topic.

3. Add a simulation, if you want one

The guidelines above don't mention simulations, and Sparky can build one without being asked. To make one more likely, add a line like this to Guidelines for Sparky. We wrote this line for the example above; it isn't in the original activity.

Example guideline

When a student is unsure how their malware spreads, build them a live simulation they can run, and ask them to predict what will happen before they run it.

To build a simulation yourself, open a chat with Sparky, click Generate content in the message box, choose Live simulation, and describe the concept. Sparky builds a simulation with controls students can change and run.

4. Assign it to each section and read the chats

Put a copy of the activity in each section you teach. Teachers can read every student's chat in an activity, including any simulation Sparky built and what the student said about it, so it's clear who still thinks a worm needs someone to click.

Other computer science activities to build the same way

Exam review that doesn't leak the exam. Attach your unit test to an activity and tell Sparky to help students study for it without using the test's questions. Sparky then writes new practice questions on the same topics, such as encryption, data analysis and privacy for an AP CSP data unit.

Debates on real cyberattacks. In a cybersecurity course, give Sparky a role in a real case, such as a press officer answering questions about the Stuxnet worm, and have students question it or argue both sides.

Project help in Java. For an AP CSA project where students design and code their own game, set Sparky up as a coding coach. It helps students plan and write the code, and the design stays theirs.

These match the quote at the top. Students who are ahead use them to go deeper into a topic, and students who need more help get a tutor that works through it with them one step at a time.

Start the activity for free

A copy of this activity, with the role, guidelines, greeting and greeting suggestions from step 2, is in Flint's public library. Open it to try the activity, or duplicate it into a free Flint account and assign it to a class. For more computer science activities, see Flint for computer science.

Learning feels different when it fits you.