Technical Articles and Newsletters

Automating Grading of Assignments in a MATLAB Programming Course

By Duarte Guerreiro Tomé Antunes, Technische Universiteit Eindhoven


When I began teaching最佳控制和动态编程with MATLAB®在Technische Universiteit Eindhoven(Tu/e),我预计课程的规模约为40。令我惊讶的是,有150名学生入学。最初我很高兴,但是我很快意识到该课程的受欢迎程度带来了一个重大问题:我只有两名助教。那个学期,一位助手几乎花了他所有的时间分级。他花了三天的时间测试学生的MATLAB代码并记录单个任务的成绩。

The next time I taught the course, we used Cody Coursework™ to grade the assignments automatically. This approach significantly improved learning outcomes. It enabled the teaching assistants to spend more time working directly with students, motivated the students by providing immediate feedback on their work, and showed me what concepts students were learning well and where they needed help.

Teaching Optimal Control and Dynamic Programming with MATLAB

Some instructors teach optimal control and dynamic programming with a heavy emphasis on mathematics—specifically on the Pontryagin’s maximum principle. Others bypass the math and proceed directly to applications. I try to find a balance, but I mostly favor the latter approach because TU/e is a technical university and our students typically prefer practical applications over abstract theory.

MATLAB enabled me to strike a balance between theory and practice. Students learn concepts in the lectures and then implement and test in MATLAB. For example, they learn how to apply the Pontryagin’s maximum principle by solving a two-point boundary value problem using numerical methods in MATLAB. Many of the other functions that the students need are built into MATLAB; when they want to use a linear quadratic regulator (LQR) or Kalman filter, for example, they can simply invoke it from their script instead of having to implement it themselves. Dynamic programming and decision-making problems, such as generating an optimal strategy for selling an asset, are easily coded in MATLAB.

Although my students come from a wide range of backgrounds, most entered the class already familiar with MATLAB. The few transfer students who did not know MATLAB learned it easily as the course progressed; their lack of previous experience was never a hindrance.

通过Cody课程自动对分配分配

引入科迪课程类品系ghtforward. I provided the students with some tips on how to submit their solutions; no lengthy training sessions were required.

For each of the three course assignments, students program MATLAB functions to solve specific problems. When the students think that the functions they have written are correct, they submit them to Cody Coursework for grading. Cody Coursework automatically grades the assignments using test suites that my teaching assistants and I created, and then provides immediate feedback on the correctness of the solution. Students are free to resubmit solutions until they are satisfied with their grade.

The first assignment, on discrete optimization, proved relatively easy. The second, on approximate dynamic programming, was more challenging because there was no optimal solution. This meant students had to try a number of suboptimal strategies, including model predictive control, rollout, and certainty equivalent control. On this assignment, the students came to appreciate the value of instant grading. If they submitted an incorrect solution, they could return to their code to look for ways to improve it without waiting to consult me or the teaching assistants.

For the final assignment, the students were asked to tune the matrices of an LQR controller to satisfy a specific set of constraints. Once again, they used Cody Coursework to check their solutions immediately and continue refining them until they met the requirements. The teaching assistants and I relied on Cody Coursework to grade the assignments and provide a summary of the results, which we used to monitor progress (Figure 1).

Figure 1. Summary of results in Cody Coursework for problems in the second assignment.

Figure 1. Summary of results in Cody Coursework for problems in the second assignment.

Unexpected Benefits of Automated Grading

My primary objective in using Cody Coursework was to minimize the time teaching assistants spent grading assignments. I discovered that Cody Coursework has other benefits.

The instant feedback on assignments proved to be a significant motivator. Seeing one’s classmates successfully complete an assignment shows that it can be done, and inspires students who are struggling to persevere. At the other end of the spectrum, students who grasped the material more easily compete with each other to be the first to find a correct solution.

我和我的教学助理监视了Cody课程中的结果,以跟踪解决方案的正确和错误的解决方案,并在提交解决方案时以及以代码行测量的提交的大小(图2)。金宝搏官方网站我们使用这些信息来确定学生发现困难的概念,以便我们以后可以在演讲中审查这些概念。

Figure 2. Cody Coursework solution map showing correct and incorrect submitted student solutions, as well as their size and order of arrival.

Figure 2. Cody Coursework solution map showing correct and incorrect submitted student solutions, as well as their size and order of arrival.

We designed the tests used by Cody Coursework to check progressively more sophisticated aspects of the students’ work. For example, on problems that incorporated a cost function, we created one test without a terminal cost and one with a terminal cost. Student solutions that took terminal cost into account would pass both tests, while those that didn’t would pass only the first. We also used both visible tests (in which the correct output to a test shown) and hidden tests (in which the test only reveals whether the code was correct or incorrect).This level of granularity provided a fairer way to assign grades and helped us better understand how well the students were absorbing the material.

Expanding the Use of Cody Coursework

For future versions of the course, I am considering using Cody Coursework to automate exam grading. I am also open to making the course more interactive. For example, if students are not grasping a particular concept, I may add an extra, previously unplanned assignment. Without automated grading, adding another assignment on the fly like this would not be feasible because of the time demands it would place on the teaching assistants.

Meanwhile, I am advocating for expanded use of Cody Coursework at TU/e. As some of my colleagues have already discovered, for any course that uses MATLAB, Cody Coursework is a highly effective tool that saves time and work and fully engages students in the course assignments.

Note: Cody Coursework became MATLAB Grader in July 2018.

学生反馈

Student feedback on Cody Coursework was overwhelmingly positive. Here is a sample of the responses we received:

“The fact that you can get immediate feedback (or confirmation) on a quite complicated piece of code is really neat, and without it, debugging your own code would really be a mess. It also motivated me to get 100% score on all the MATLAB assignments.” Joost P.

“Cody Coursework is a great platform. It gives me more confidence about my solution rather than waiting for the instructor evaluation.” Manoj P.

我在科迪课程方面的经验非常积极。绿色复选框是获得高级的额外动力。”Koen B.

“The most useful feature of Cody Coursework was the ability to check our solutions against various test cases, which helped in debugging our code and formulating it in a much more generalized manner.” Amrith V

“I like that you receive feedback immediately, which makes it much easier to find problems in your code…I learned a lot from the MATLAB assignments in a relative short period.” Ruud S.

About the Author

Duarte Guerreiro Tomé Antunes is an assistant professor at Technische Universiteit Eindhoven. He received the Licenciatura in electrical and computer engineering from the Instituto Superior Técnico (IST), Lisbon. He holds a Ph.D. from the IST Institute for Systems and Robotics. His research interests include networked control systems, stochastic control, multirate and sampled-data systems, optimization, and dynamic programming.

Published 2016 - 93065v00

View Articles for Related Capabilities