How to grade output files in MATLAB Grader?

6 views (last 30 days)
I want to be able to have students generate output files in MATLAB grader (like .txt files or .xlsx files) and be graded on whether they match the solution .txt file or .xlsx file. When running the reference function and the student function, all the variable outputs are collected as usual, but there was no file output (like the files disappeared!). For some reason, plots work fine, but being able to work with outputting and comparing files would be great and would be beneficial to the students.
  3 Comments
Anugeeth Raghavan
Anugeeth Raghavan on 14 Feb 2022
Thank you Cris,
This is the 2nd semester that we have been using MATLAB Grader as a tool to manage HW submissions and grading. Previously, we had our students code their solution locally in their MATLAB IDE, where they would submit their .m files after they were done coding it. We then graded the student files using an MATLAB app that we developed that would compare the student output to the solution output. This software also compared file output and excel output. I was hoping that MATLAB grader would be able to compare file outputs in some manner. The ways I was thinking about was visdiff for .txt files and isequal(readcell('student.xlsx'), readcell('solution.xlsx')). I figure that comparing the variables they are meant to write would be a good work around, but it would be nice to be able to compare files directly.
Cris LaPierre
Cris LaPierre on 14 Feb 2022
Edited: Cris LaPierre on 15 Feb 2022
Unfortunately, visdiff will not work in MATLAB Grader. Therefore, I think I would pursue an approach that loads their file to a variable and compares it to a reference variable.
  • For text files, I would maybe load the file using readlines
  • For xlsx files, I prefer readtable.
However, there are challenges in ensuring MATLAB Grader is doing what you think it is doing when it comes to working with files. What you need to keep in mind is that the reference solution and learner solution are writing their files to the same place. This has some implications on how you need to design the problem so that
  • the learner file doesn't replace the reference file
  • the reference file doesn't serve as the learner's file if their code doesn't create a file
  • the problem can be saved as final
There are several paths forward, but which to recommend depends on the specifics of the problem. It may be helfpul to work with your institution's customer success engineer to design your solution. If you con't know who that is, you can contact support.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!