COMP3311 26T1 Assignment 2
unswsh — Engineering Student & Timetabling Shell
Database Systems

[Assignment Spec]  [SQL Schema]  [Examples]

Aims

This assignment gives you practice in

The goal is to construct unswsh, an interactive shell for a cleaned subset of the mymyunsw database containing Faculty of Engineering students and courses.

Summary

Submission: Upload ass2.py to the course site or, on CSE:
cse$ give cs3311 ass2 ass2.py
Required Files: ass2.py (single Python file)
Deadline: Tuesday 21st April 2026, 8:59pm
Marks: 15% toward your total mark for this course. Marked out of 15 total possible marks.
Late Penalty: 0.2 percent off the achieved mark for each hour late, up to 5 days
any submission after 5 days scores 0 marks (UNSW late-penalty policy)

Shell behaviour & general errors

How to do this assignment

Background

The supplied database is a slimmed version of mymyunsw containing Engineering students, programs, courses and timetabled classes. Your shell will drive enrolment and planning workflows, always producing deterministic output.

Setting Up

Create a working directory and obtain the starter files:

cse$ mkdir ~/cs3311/ass2
cse$ cd ~/cs3311/ass2
cse$ cp /home/cs3311/web/26T1/assignments/ass2/ass2.py ass2.py
cse$ ln -s /home/cs3311/web/26T1/assignments/ass2/mymyunsw.dump mymyunsw.dump

Then initialise the database:

cse$ dropdb mymyunsw
cse$ createdb mymyunsw
cse$ psql mymyunsw -f mymyunsw.dump   -- loads schema + data
cse$ psql mymyunsw                    -- explore the database

If you are working on your own machine, you can download the starter files from: ass2.py, mymyunsw.dump, run_tests.py, output.json.

Environment

Provided files

Marks Breakdown

QuestionMarksSummary
Q12REPL + configure term
Q23Pretty-print student profile (as-of term)
Q33Enrol subjects + show available class options
Q44Build a conflict-free weekly plan (backtracking)
Q53Admin: create next-term offering + auto-schedule LEC/TUT

Your Tasks

Complete each task by extending ass2.py. All commands read from standard input; outputs must match the required format exactly.

Q1 (2 marks)

Implement configure mode and term selection.

Example:

echo -e '/c\nterm 5024\nshow' | python3 ass2.py
> /c
> term 5024
> show
Term { unswid: 5024, year: 2002, term: S1, starting: 2002-03-04, ending: 2002-06-14 }

Hints:

Q2 (3 marks)

Add student <ZID> to pretty-print a student's profile for the configured term.

Example:

echo -e '/c\nterm 5024\nstudent 2281773' | python3 ass2.py
> /c
> term 5024
> student 2281773
Student {
  zid: z2281773
  id:  1013041
  name: Solailakshmi Wright
  email: z2281773@student.unsw.edu.au
  stype: local
  program: Unknown
  faculty: Unknown
}
echo -e '/c\nterm 5054\nstudent 2281773' | python3 ass2.py
> /c
> term 5054
> student 2281773
Student {
  zid: z2281773
  id:  1013041
  name: Solailakshmi Wright
  email: z2281773@student.unsw.edu.au
  stype: local
  program: 1010 Chemical Engineering
  faculty: Faculty of Engineering
}

Q3 (3 marks)

Add enrol <ZID> <SUBJ1> [SUBJ2] [SUBJ3] to create course_enrolments in the configured term and then print all class options.

Example:

echo -e '/c\nterm 5024\nenrol 2281773 COMP1001' | python3 ass2.py
> /c
> term 5024
> enrol 2281773 COMP1001
Timetable {
  Tue 09-11 COMP1001 LAB EE EE-LG7
  Wed 15-16 COMP1001 LEC EE EE-LG1
  ...
}

Hints:

Q4 (4 marks)

Add plan <ZID> <SUBJ1> [SUBJ2] [SUBJ3] to search for a clash-free weekly plan without writing to the database.

Example:

echo -e '/c\nterm 5024\nplan 2281773 COMP1091 ELEC1011' | python3 ass2.py
> /c
> term 5024
> plan 2281773 COMP1091 ELEC1011
Plan {
  COMP1091 LEC Tue 12-13 OMB OMB-112
  COMP1091 TUT Thu 12-13 MAT MAT-929
  ELEC1011 LEC Wed 14-15 CLB CLB-6
  ELEC1011 TUT Tue 16-17 MECH ME-503
}

Hints:

Q5 (3 marks)

Add admin mode (admin on|off) and offer <SUBJECT_CODE> <EXPECTED> <NLEC> to create a next-term offering and auto-schedule classes.

Example:

echo -e '/c\nterm 5024\nadmin on\noffer COMP1091 30 1' | python3 ass2.py
> /c
> term 5024
> admin on
> offer COMP1091 30 1
Offering created: COMP1091 in term 5025 (course_id=74126)
  LEC Mon 09-11 K17 K17-B01
  TUT Mon 09-10 ASB CHEM-611
  TUT Mon 09-10 ASB CHEM-614

Hints:

Submission and Testing

We will test your submission by loading mymyunsw, installing your ass2.py, and running automated scripts. Ensure your program is deterministic and uses parameterised queries.

You can test on the CSE server using the autotest command:

cse$ 3311 autotest ass2

You can also test locally with the provided scripts:

cse$ python3 tests/run_tests.py
cse$ python3 tests/run_tests.py --only=q3

If you pass all tests, your outputs match the golden samples in tests/output.json.

Good luck, and code safely!