MATLAB Answers

locked output files students can turn in

2 views (last 30 days)
Shae Morgan
Shae Morgan on 25 Aug 2020
Commented: Shae Morgan on 26 Aug 2020
I'm wondering if I can get some input on a problem. I'm trying to save data generated in an app (made with AppDesigner) into a spreadsheet or other output file. Students will be using this program, and I'd like for there to be a way to password protect the file or something so the students can't modify their answers or adjust them prior to turning them in. I see two options, but I'm curious what other solutions may exist:
  1. use ActiveX to open excel, password protect, and save the file - but this requires whoever downloads the app to have microsoft excel. I'd like this to be more versatile as many students don't. An example I found combing MATLAB answers looks something like this:
%set password
openPassword = "password";
protectPassword = "password";
%open and set up
excel = actxGetRunningServer('Excel.Application'); % attach to open Excel instance
excel.Visible = true; % ensure Excel is visible
wb = excel.Workbooks.Add();% add a new workbook to the workbooks collection
wb.Password = openPassword;% set the password property
ws = wb.ActiveSheet(); % set ws variable to the active worksheet in wb
% write data
ws.Range("A1:A2").Value2 = {'hello','world'}
% protect the sheet, save, and close
wb.Protect(protectPassword, true, true);
2. use the sendmail function to send the data to the instructor via e-mail when the student clicks a "submit" callback function. Can you configure sendmail for an app that is distributed so that all submissions are sent to the same e-mail? How does sendmail work when packaged into an app?
Any other ideas?


Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 25 Aug 2020
What information are the students being called upon to provide as the work to be graded? A modified or new app? A script or function? Or just several arrays of numbers?
Rather than trusting the spreadsheet of expected results that you receive from the same source (the students) that provide the actual results, you could give them a test suite that they can use to validate their work and grade them using a separate test suite that you don't give them. Three of us wrote a guest blog post on Loren Shure's blog seven years ago (wow! It's been that long?) showing a way you could do this. There are some more advanced techniques you could use in place of manually manipulating the path to make each students' functions available to be tested[*] but I think this "two-tiered" testing approach will help both you and your students.
[*] As one example, define a class-related function that calls dir to list the directories containing each student's submission. Use that function to populate a ClassSetupParameter propery. Finally have a TestClassSetup method add each directory in turn to the MATLAB path using a matlab.unittest.fixture.PathFixture for that particular run of the tests.


Show 2 older comments
Rik on 26 Aug 2020
Most universities and schools also have student IDs. That should guarantee each student to have a unique seed:
This only works if you have a way to convert the IDs to an integer less then 2^32. The code above only works if there are 9 digits or fewer.
Shae Morgan
Shae Morgan on 26 Aug 2020
Another excellent suggestion. Thanks!

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!