MATLAB Grader: What should my assessment return when it determines a student solution is correct or incorrect?
2 ビュー (過去 30 日間)
古いコメントを表示
Let's say the assignment is to create (and leave open) a figure with three subplots and one of the subplots should have the title "Oscillating Motion". I want to use an assessment of Test Type MATLAB Code to check the figure the student's code has created. I can easily check that using Matlab code similar to the following
% Get the handles of all subplots
axis_handles = findobj(gcf, 'type', 'axes');
% see if the title matches the requirement
set_required_title = false;
for axnum=1:length(axis_handles)
title_str = get(get(axis_handles(axnum),'Title'),'String');
set_required_title = set_required_title | strcmpi(title_str,'Oscillating Motion');
end
How do I return that result (the variable set_required_title) as an assessment test?
BTW, just for context of what I am talking about, in my LMS, this looks like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1659571/image.gif)
0 件のコメント
採用された回答
Dyuman Joshi
2024 年 4 月 4 日
編集済み: Dyuman Joshi
2024 年 4 月 4 日
You can use assert to check a condition (whether the title contains a particular text or not) and throw a (custom defined) error (like the one you have written - with subplot number added if you want to provide a specific error) when the condition is not satisfied.
5 件のコメント
Dyuman Joshi
2024 年 4 月 4 日
It's linked to that page, yes.
As for on example, you can check the documentation page of assert, but thpse are not in the context of use in MATLAB Grader.
I can help you write one, if you could copy and paste the code you have posted in the image.
その他の回答 (1 件)
Cris LaPierre
2024 年 4 月 4 日
編集済み: Cris LaPierre
2024 年 4 月 8 日
Please see this Answer: https://www.mathworks.com/matlabcentral/answers/548631-matlab-grader-determining-if-a-variable-is-a-function-handle#answer_451644
Your assessment must return an error if the answer is incorrect. Otherwise, it is considered correct. This is what assert, as well as the built-in assessment functions do.
2 件のコメント
Cris LaPierre
2024 年 4 月 4 日
Since you are grading a plot, I suggest also looking at this answer. It shows how to build a more robust custom assessment test so that students alway receive meaningful feedback.
参考
カテゴリ
Help Center および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!