State Sequence Table (SST) questions
The State Sequence Table Question Type
This page shows a new work-in-progress question type that we have introduced into our introductory programming course, COSC131, at the University of Canterbury. The question type aims to address the problem that many students have only a fuzzy idea of the state of a program and don't seem to be following the detailed step-by-step change of state as the program executes.
The question type uses the HTML-UI and presents an OK interface to the student, but authoring of questions is currently very cumbersome. A software-engineering student in Belgium is looking into making authoring easier.
Here is the current version (27 August 2024) prototype of the SST question type. It replaces the previous October 2023 question type. The two question types are not exactly compatible, so if you're already using the 2023 version proceed with caution. See below for instructions.
Translating old python3_state_sequence table questions to the new python3_sst version
- Open the question for editing
- Change the CodeRunner type from python3_state_sequence_table to python3_sst
- Make a note of the Template params field and then clear it.
- Clear the UI parameters field if non-empty
- Click Save-and-continue-editing
- Use the control panel to set the values of the various parameters num_vars, num_rows etc to the values from the original Template params field.
- Save the question
- Preview and check that it behaves correctly.
Introducing State Sequence Tables [Intro given to students]
When you write a program you're instructing the Python engine what to do. We can think of the Python engine as some sort of robot, and for the rest of this info panel we'll use the term "robot" and "Python engine" interchangeably.
If the robot is to behave the way you want it to, you'd better know exactly how it will interpret each of the instructions (statements) you give it in your program. So bear with us while we focus in some detail on exactly how our robot behaves when a trivial program to execute.
The concept of robot (program) state
We will describe the behaviour of the robot in terms of its state at any given time. For now we will define that state as having just three components:
- The line number in the program that the robot has just executed.
- A set of known variable names and their values.
- The output from the robot so far in its execution.
We will disregard (3) for now because the trivial program below doesn't generate output (that is, when the robot follows the instructions in the program it is executing, it doesn't print anything).
Representing the state sequence
Consider what happens as the Python Robot steps through the following program line-by-line.
wow = 20 which = wow + 5 wow = wow + which thing = 2 * wowThe state changes at each step, and we can represent the sequence of states in a state sequence table as shown below.
Note the following:
- At each given step, we can read across the row to see the state of the program. For example, at step 3:
- We are at line number 3.
- The variable
wow
has the value 45. The smooth shading indicates it was assigned that value at this step. - The variable
which
has the value 25. The striped shading indicates it was assigned that value at some earlier step. - The variable
thing
is still undefined - it doesn't actually exist yet.
- In a state sequence table, the order of the columns of variables is defined to be the order in which the variables get created as the program executes.
- You can easily see the effects of all the assignment statements by looking at all the smoothly-shaded cells.
- Although line numbers correspond one-to-one with step numbers in this program, that will not be the case in later programs, when constructs like if statements and loops jump forwards and backwards in the code.
Please make sure you understand the state sequence table representation before continuing.
From now on, we'll drop the term "robot" and follow the more conventional terminology of talking about the "state of the program as it executes". But always keep in mind that the program is just a set of instructions and the "state as it executes" is really the state of the engine/robot that is executing the program.
<END OF STUDENT INTRO PANEL>
Some sample SST questions
The following questions are a small sample from those we've asked in our COSC131 course. Keep in mind that there were lots of other questions, tutorials and info panels between these questions, which were introduced over a three week period.
Firstly, here are the xml exports of the questions (these are the ones using the new python3_sst question type):
- Example 1
- Example 2
- Example with output
- Example of a trivial function call
- Example with nested ifs
- Example with a while loop
And now the questions. You'll need to be logged in as trial, with password trial to use them. If you login using the panel within the embedded question rather than the usual login at the top right, you'll have to refresh the page after logging in.