locked output files students can turn in

Hello,
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);
wb.SaveAs(filepath);
wb.Close();
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?
Thanks!

 Accepted Answer

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.

5 Comments

Shae Morgan
Shae Morgan on 25 Aug 2020
Edited: Shae Morgan on 25 Aug 2020
I'm just looking to store some arrays of numbers / cells of text (obtained from text edit fields, and other sources), not evaluate a full function or program. More basic than that - similar to the "hello,world" in my example code above.
If the randomly generated question reads:
"Solve the equation: 2+5 = ______"
and the blank is an edit text field, I have the program store the true answer (7) and compare it with their entered value, grade it, and then e-mail the answer to me (or save it to a password protected spreadsheet). Except instead of one question, it'll be like a 30 x 8 matrix of true answers, submitted answers, and grades.
Ah, okay. I was thinking this was a programming assignment for your students but instead MATLAB is being used as something more along the lines of a worksheet generator.
Since you're randomly generating the questions, maybe instead of having them send back the correct answers for the generated problems you can include the seed value for the random number generator that was used to generate the questions.
rng shuffle
S = rng;
Then include the fields of the S struct in the file. You can use those with rng to set the random number generator to the same state the student's MATLAB session used to generate the questions and so regenerate them. If a student is willing to go to the effort of finding the correct parameter values to make their desired answers match the generated questions, I think they've earned the grade :) And if multiple students get the exact same seed, either they all shuffled the random generator at the exact same time or there was some "collaboration."
this is a good idea.
Thanks!
Most universities and schools also have student IDs. That should guarantee each student to have a unique seed:
studentID='s123456789';
seed=str2double(studentID(isstrprop(studentID,'digit')));
rng(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.
@Rik
Another excellent suggestion. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Update figure-Based Apps in Help Center and File Exchange

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!