|
16 | 16 |
|
17 | 17 | (* For new style packages see: https://mathematica.stackexchange.com/a/176489) *) |
18 | 18 | (* Declare package context *) |
19 | | -BeginPackage["evaluate`"] |
| 19 | +BeginPackage["evaluate`"]; |
20 | 20 |
|
21 | 21 | EvaluationFunction[type_, answer_, response_, params_] := Module[{result, feedback}, |
22 | 22 | Print["Running Evaluation Function"]; |
23 | 23 | result = evalQ[type, answer, response, params]; |
24 | | - Print["Results"]; |
25 | | - Print[result]; |
26 | 24 | feedback = If[result["is_correct"], |
27 | 25 | Lookup[params, "correct_response_feedback", "Correct!"], |
28 | 26 | Lookup[params, "incorrect_response_feedback", "Incorrect!"] |
29 | 27 | ]; |
| 28 | + |
30 | 29 | <| |
31 | | - "command" -> "eval", |
32 | | - "result" -> <| |
33 | | - "is_correct" -> result["is_correct"], |
34 | | - "feedback" -> feedback, |
35 | | - "error" -> result["error"] |
36 | | - |> |
| 30 | + "is_correct" -> result["is_correct"], |
| 31 | + "feedback" -> feedback, |
| 32 | + "error" -> result["error"] |
37 | 33 | |> |
38 | | -] |
| 34 | +]; |
39 | 35 |
|
40 | | -Begin["`Private`"] |
| 36 | +Begin["`Private`"]; |
41 | 37 |
|
42 | 38 | equalQNumeric[answer_, response_, params_] := Module[{tolerance}, |
43 | 39 | Print["Evaluating Equal Numeric"]; |
|
174 | 170 | equalQOther[answer, response, params] |
175 | 171 | ] |
176 | 172 | ]; |
177 | | - |
178 | | -EvaluationFunction[type_, answer_, response_, params_] := Module[{result,feedback}, |
179 | | - Print["Running Evaluation Function"]; |
180 | | - result = evalQ[type, answer, response, params]; |
181 | | - Print["Results"]; |
182 | | - Print[result]; |
183 | | - feedback = If[result["is_correct"], |
184 | | - Lookup[params, "correct_response_feedback", "Correct!"], |
185 | | - Lookup[params, "incorrect_response_feedback", "Incorrect!"] |
186 | | - ]; |
187 | | - <| |
188 | | - "command" -> "eval", |
189 | | - "result" -> <| |
190 | | - "is_correct" -> result["is_correct"], |
191 | | - "feedback" -> feedback, |
192 | | - "error" -> result["error"] |
193 | | - |> |
194 | | - |> |
195 | | -]; |
196 | | - |
197 | | -evalQuestionIO = Function[ |
198 | | - Module[{jsonData, result,requestData,answer,response,params,type}, |
199 | | - jsonData = Import[#1, "JSON"] //. List :> Association; |
200 | | - requestData = jsonData["params"]; |
201 | | - answer = requestData["answer"]; |
202 | | - response = requestData["response"]; |
203 | | - params = requestData["params"]; |
204 | | - type = params["comparisonType"]; |
205 | | - Print["Evaluating Response Against Answer"]; |
206 | | - result = EvaluationFunction[type, answer, response, params]; |
207 | | - Print["Response"]; |
208 | | - Print[result]; |
209 | | - Export[#2, result, "JSON", "Compact" -> True] |
210 | | - ] |
211 | | -]; |
212 | | -End[] |
| 173 | +End[]; |
213 | 174 | EndPackage[] |
0 commit comments