I teach the Python part of UCL’s first year module MATH0011 Mathematical Methods 2, a four week long introduction to Python for total beginners, taken by 200-250 maths and joint schools students. We cover the basics of Python data types, loops and conditionals, objects and classes, and finish off with a quick look at mathematical applications of the NumPy and Matplotlib modules.

I taught this module once before covid and followed the method of the lecturer before me closely: two hours of lectures per week, two hours of in-person computer classes per week supervised by graduate teaching assistants. The students would complete weekly exercises which the grad students checked for correctness in the computer classes, and do a short structured group project at the end of the course.

In the academic years 2019-20 and 2020-21 no in-person teaching was possible on this module, and in 2019-20 enormous over-recruitment due to the change in the way A-levels were awarded meant that the module had about 500 students, twice its usual size. This post is about how I adapted MATH0011 in those years, which was based on the use of an online collaborative environment called CoCalc.

CoCalc

Many modules across the university were previously taught using in-person computer labs. During the pandemic restrictions these had somehow to be done online. After some discussion of the options, the university IT department bought a large number of licenses for CoCalc, a cloud-based environment which allows people to use various software tools collaboratively. It has some specialised features for teaching including the ability to distribute and collect assignments with deadlines and an autograder, a clone of of nbgrader.

CoCalc allows anyone to make an account for free to try out their service. Once you have an account you can create a project, which consists of a collection of files of various types in a directory structure. You can invite collaborators to your project who have mostly the same privileges that you do, and you can add students who can interact with and edit copies of files that you assign them but can’t see or edit your master copies. You can distribute handouts to your students in the form of files you want them to work with, and assignments which they have to complete by a certain date and which you can then collect and mark either manually or, if you create the assignment using CoCalc’s nbgrader clone, automatically.

How the module worked

Aside from video lectures, the module involved the following activities:

  • students would work through weekly notebooks, Jupyter notebooks allowing them to read, modify, and write Python code.
  • students would complete weekly assessed exercises for credit
  • weekly computer classes in which TAs helped with any difficulties
  • a final short structured group project based on one of several notebooks on different mathematical topics

Weekly notebooks

The idea of the “weekly notebooks” was to have an activity students could use to learn the course content interactively, which was complementary or parallel to the lectures. I made these as Jupyter notebooks, since those allow a mix of nicely-formatted text (including LaTeX-style math rendered with MathJax) and “code cells” in which students can edit, write, and execute Python.

Before I taught MATH0011 for the first time, I went to the Programming in the Undergraduate Mathematics Curriculum conference (you can read my notes at the link) hoping for some good ideas. Vincent Knight’s talk, on his Computing for Mathematicians course course, was especially helpful. He talked about PRIMM, (now a dead link, this may be the same post) a “structured approach to teaching programming.” PRIMM suggests building teaching materials that let students move through a number of stages:

  • Predict: what will this code do? (maybe in pairs or groups)
  • Run: check some provided code against a prediction
  • Investigate: trace through the code, modify, comment, answer questions.
  • Modify: start simple and build through a series of exercises
  • Make: make their own programme from scratch

I found this a really useful framework to use while producing the notebooks.

Computer classes in CoCalc

Running fully online interactive classes was the biggest difficulty we had when all teaching was required to be online. The way we did it was through the chat function associated to every CoCalc file. Students were assigned a class time during which my TAs would be logged in. When a student uses the chat function in one of their notebook files, me and the TAs get a notification through the CoCalc website and can respond. TAs can both see and edit the student’s work which made it possible for them to give useful interactive help. While it’s no substitute for face-to-face interactions, where a TA can spot someone who needs help even if they’re not ready to ask for it, MATH0011 has a very large number of non-native English speakers (over 50%) some of whom are more comfortable with written than with spoken English.

We split the students into classes of about 60. The easiest way to do this in CoCalc was to have multiple .course files in a single MATH0011 CoCalc project. I could put the class time in the “description” for each class, and keeping everyone in the same project made distributing files much easier.

Assessed exercises

As I mentioned above, CoCalc has its own nbgrader clone for automatic assessment. To use it you create a special kind of notebook with a problem statement, a place for students to write code to solve the problem, and a set of tests to determine what mark the solution will get. You can assign these to students, set a deadline, and then collect their solutions, run nbgrader to get the marks, and return those to the students.

Unfortunately it doesn’t work that well. The first problem is simply that their nbgrader clone is unreliable: very often, if a student solution is not given full marks, the mark will change on re-running nbgrader. I had to manually re-run nbgrader on every single attempt that didn’t have full marks before I could have any confidence the marking had worked.

While that could be fixed in principle, the whole nbgrader model of setting work which is collected after a particular deadline has drawbacks. Beginner programmers need quick feedback on their mistakes, but nbgrader isn’t able to provide this - it just gives a final mark once the grader is run, so feedback is neither timely nor detailed.

The chat function mentioned in the last section was also helpful in mitigating some of the problems with nbgrader. I asked the TAs to go through the list of marks for students in their class, view the solutions of those who didn’t get full marks, and offer some help via chat. It would have been good if we could have provided a way for students to interact with each other as well as with the TAs (e.g. something like a class Discord, but I didn’t manage to arrange that when we were teaching fully online - the doubling of student numbers due to the change in A-level marking (to about 500 students) meant it was hard enough to keep my head above water without adding another platform to deal with. It’s not as simple as just making a Discord and adding all the students - GDPR rules mean you need a contractual arrangement with any service that will host student personal data - but something like this would have been a definite benefit.

The lack of instant, helpful feedback for programming exercises is the thing I’d most like to improve on this module. It seems impossible to do this using the nbgrader clone built into CoCalc - my preference would be something like CodeRunner, a moodle plugin. It would be even better if this could somehow get embedded into CoCalc so that the students didn’t have to change platform to do their exercises…

Group projects

CoCalc’s licensing model is that you pay for a license key that you can apply to any number of projects and which covers a fixed maximum number of simultaneous users. Paying for a key means that your project will have access to much greater computing resources - without a paid key everything will still work but be very slow.

That means that while CoCalc is in principle a great way for a small group of students to collaborate on a group project, you need to create a CoCalc project for each group (or preferably have the students do it) and then apply a license key to that project. If there are a lot of groups this can take a lot of time - it has to be done by the course leader since the key shouldn’t be shared with those you don’t trust.

The projects were short, structured, and on a topic in mathematics that can be explored easily using Python. I made a Jupyter notebook for each one, containing a series of exercises. Topics included iterated prisoners’ dilemma, the Gibbs phenomenon, writing classes representing well-formed formulas, breaking the Vigenère cipher, gradient descent, support vector machines, random walks, Chebyshev bias, bifurcation diagrams for iterative sequences, and the game SET.

The reasons we have projects are to show the students how far they have come, to allow them to do something (hopefully) interesting and mathematical instead of their rather routine weekly exercises, and to demonstrate just how easy it is to do quite advanced things with only a little Python. The reason they are very structured is that I’m not able to have project supervisors for each project. The reasons they are group projects are that I have to mark them all myself, so one per student is an unreasonable number, and so that students can collaborate, which mitigates the lack of supervision.

Writing the projects was by far the most enjoyable part of the course for me, and from the student feedback I know many of them found the projects a good experience. Pedagogically, though, I think they’re one of the weakest parts of the module: the structure (four exercises, only slightly open-ended) makes them just too straightforward. To some extent this is inevitable because of the teaching constraints discussed before, but I hope to do better this time by having a final genuinely open-ended section worth say half of the project mark, with some kind of constraint to stop students producing excessive amounts of work.