Testing Learner Solutions
Assessment tests are for determining whether the learner got the correct answer. When you write tests, think about the types of common errors that a learner often makes, and include tests for these conditions. The following examples illustrate some of the more common conditions to consider in writing assessments. The examples include suggestions for the messages to provide to learners as output after the tests run.
Example Problems
Example problems from MathWorks® staff are provided to help you write problems and assessments. These example problems illustrate good practices for authoring problems and creating assessments to test the accuracy of leaner submissions.
Assessments
For all tests:
You can set the assessment method to Correct/Incorrect or Weighted. The assessment method determines how the points assigned to the problem are awarded.
You can indicate that a test is a pre-test.
Test types can be among these options:
Compare to ref solution (script problems only; for function problems, use the assessment function
assessVariableEqual
)Whether a function or keyword is present
Whether a function or keyword is absent
Write out the assessment using MATLAB® code
You can convert any of these options (except for MATLAB code) to MATLAB code.
See Write Assessments for Function-Based Learner Solutions and Write Assessments for Script-Based Learner Solutions for details on these types.
Correct/Incorrect Assessments
If you select the Correct/Incorrect method, the problem is treated as pass/fail. Assessments defined as Correct/Incorrect return 1 if all tests pass and 0 if any tests fail. If all assessments are correct, the maximum point possible are awarded. If any assessment tests are marked incorrect, no points are awarded.
Weighted Assessments
If you select the Weighted method, it is possible to award partial credit. You assign each assessment test a percentage of the total points possible. You can modify the percentage by changing the point value (weight) assigned to each assessment. The points awarded are determined by summing the percentages of the assessments marked correct and multiplying by the maximum points possible.
For example, consider a problem with two assessment tests. You want 1/3 of the points (33%) to be awarded for getting the first assessment correct and 2/3 (67%) for getting the second one correct. When creating the assessments, you would assign one point to the first test and two points to the second test.
The following images demonstrate what the learner sees when the assessment is weighted.
Before submitting a solution, the assessment section is empty.
After submitting a solution that passes the assessment, the assessment section turns green, the title shows "All Tests Passed (100%)" and the list below shows the test name with a green check and 100% displayed to the right:
After submitting a solution that does not pass the assessment, the entire assessment section turns red, the title shows "0 of 1 Tests Passed (0%)", and the list displays 0% and the reason the test failed, for example, “The submission must contain a variable named x.":
To indicate assessments are weighted, select
Weighted
as the Assessment
Method.
When you create multiple assessments, you assign the weight each assessment should have by assigning points. The following example shows test 1 gets 1 point for 33% and test 2 gets 2 points for 67%.
You can show the percentage to learners. The following example shows the learner view, which is the assessment name and the percentage the test is given.
Learner Feedback
Show Customized Feedback
You can provide additional customized feedback to the learner on test failure. This feedback can be written using rich text format, including formatted text, hypertext links, images, and math equations.
The following image shows a problem description that contains bullets, mathematical equations, properly formatted code, and a picture.
Show Feedback for Initial Error Only (Script-Based Problems)
In a script-based problem, an initial error may cause subsequent errors. You may want to encourage the learner to focus first on the initial error.
When you select the option Only Show Feedback for Initial Error, detailed feedback is shown for the initial error, but is hidden by default for subsequent errors. The learner can display this additional feedback by clicking Show Feedback.