How do I create problems in Cody Coursework which require students to process data file(s)?

2 次查看(过去 30 天)
With the introduction of Cody Coursework, I'm often asked how to create problems requiring students process data files.

采纳的回答

MathWorks Community Team
编辑:MathWorks Community Team 2014-6-9
Here's how:
First, prepare the data file(s) you wish students' code to access.
Second, post the data file(s) somewhere online accessible by Cody Coursework. This must not be behind the school's firewall, it must be publicly accessible. One option is to use the public folder of a free dropbox account. If using DropBox, it will help to "copy the public link" using their web interface.
Third, design your Test Suite to load the data file into the students' current working folder before calling the students' code to test. Here's an example:
%%Prepare data files for student
in_f='http://url/datafile.csv';
out_f='./datafile.csv';
urlwrite(in_f,out_f);
% check to ensure the file loaded ok
fid=fopen(out_f);
assert(isequal(CheckFile(),1));
other tests follow
Alternatively, for more advanced students, you could replace the third step by offering students a function template with code to bring the data into the local folder in which their code will be run by Cody Coursework. For example:
function result = student_code(input)
% hint for students, keep this template code
urlwrite('http://url/datafile.csv','./datafile.csv');
addpath('.');
% students' TODO: insert your code here:
% students, please do not modify code outside these comments
end
Either way, students can now use standard MATLAB file operations to open and manipulate the data file(s) loaded into their current working folder.
Please note, to ensure system reliability, Cody Coursework resets system state each time a solution attempt is tested. This is why the file is loaded on each execution of the Test Suite.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by