Commit 753e0ffe authored by Joachim Schunk's avatar Joachim Schunk
Browse files

use new migration mechanics in checker&test

parent 8fc24a2d
Pipeline #106281 passed with stages
in 2 minutes and 25 seconds
......@@ -8,25 +8,20 @@
[clojure.tools.logging :as log]
[clojure.tools.reader.edn :as edn]
[leukipp.components.exercise-types.check :as e-check]
[leukipp.components.exercise-types.multistep-calculation.migrate-answer
:refer
[answer-scheme-version migrate-answer]]
[leukipp.components.exercise-types.multistep-calculation.migration :refer [migrate-answer migrate-backend]]
[leukipp.components.helper
:refer
[double-division math-abs
migrate-if-necessary]])]
[double-division math-abs]])]
:cljs
[(:require
[clojure.set :refer [union]]
[clojure.string :as clj-str :refer [join split trim]]
[clojure.tools.reader.edn :as edn]
[leukipp.components.exercise-types.check :as e-check]
[leukipp.components.exercise-types.multistep-calculation.migrate-answer
:refer
[answer-scheme-version migrate-answer]]
[leukipp.components.exercise-types.multistep-calculation.migration :refer [migrate-answer migrate-backend]]
[leukipp.components.helper
:refer
[double-division math-abs migrate-if-necessary]])]))
[double-division math-abs]])]))
(def prefix-mapping {"Y" 24
"Z" 21
......@@ -534,7 +529,7 @@
:points-max (points-from-res-map :points-max res-map)
:res-map res-map}))
(defmethod e-check/check-answer :multistep-calculation [exercise answer callback]
(let [migrated-answer (migrate-if-necessary answer :answer-scheme "multistep-calculation"
answer-scheme-version migrate-answer)]
(multistep-calculation-check exercise migrated-answer callback)))
(defmethod e-check/check-answer :multistep-calculation [prepared-backend answer callback]
(let [migrated-backend (migrate-backend prepared-backend)
migrated-answer (migrate-answer answer migrated-backend)]
(multistep-calculation-check migrated-backend migrated-answer callback)))
(ns leukipp.components.exercise-types.multistep-calculation.checker-test
(:require
[leukipp.components.exercise-types.check :as e-check]
[leukipp.components.exercise-types.prepare :as e-prepare]
#?(:cljs
[cljs.test :refer-macros [deftest testing is]]
:clj
......@@ -120,8 +121,7 @@
:migration-status :current,
:mscs2021-10-16T07-18-06-G__316
{:number {:significand "1.0000", :order-of-magnitude "0"}}},
:exercise-scheme
{:type "multistep-calculation", :version "2019-11-22"},
:_schemas {:exercise-multistep-calculation "20220124-01-initial-version"},
:variables []})
(def example-answer-1 {:steps [{:id "mscas2021-11-03T14-36-09-G__978"
......@@ -142,7 +142,7 @@
:number {:significand "1" :order-of-magnitude "0"}
:units [{:prefix "" :unit "s" :expo "1"}]
:vars [{:var-type :step :var-id :mscas2021-11-03T14-36-20-G__1000}]}]
:answer-scheme {:type "multistep-calculation" :version "2020-05-20"}})
:_schemas {:exercise-multistep-calculation-answer "20220124-01-initial-version"}})
(def example-result-1 {:points 16,
:points-max 16,
......@@ -176,7 +176,7 @@
:number {:significand "2" :order-of-magnitude "0"}
:units [{:prefix "" :unit "s" :expo "1"}]
:vars [{:var-type :step :var-id :mscas2021-11-03T14-36-20-G__1000}]}]
:answer-scheme {:type "multistep-calculation" :version "2020-05-20"}})
:_schemas {:exercise-multistep-calculation-answer "20220124-01-initial-version"}})
(def example-result-2 {:points 14,
:points-max 16,
......@@ -192,23 +192,25 @@
:match-signatures
#{[:msca2019-10-10T08-46-23-G__89 :mscai2019-10-10T08-48-19-G__113]}}}})
(def prepared-example-exercise-1 (e-prepare/prepare-backend example-exercise-1))
(deftest multistep-calculation-check-1
(testing "checker - multistep-calculation-check-1"
(let [result (e-check/check-answer example-exercise-1
(let [result (e-check/check-answer prepared-example-exercise-1
(:steps example-answer-1)
#(identity nil))]
(is (= example-result-1 result)))))
(deftest multistep-calculation-check-2
(testing "checker - multistep-calculation-check-2"
(let [result (e-check/check-answer example-exercise-1
(let [result (e-check/check-answer prepared-example-exercise-1
example-answer-1
#(identity nil))]
(is (= example-result-1 result)))))
(deftest multistep-calculation-check-3
(testing "checker - multistep-calculation-check-3"
(let [result (e-check/check-answer example-exercise-1
(let [result (e-check/check-answer prepared-example-exercise-1
example-answer-2
#(identity nil))]
(is (= example-result-2 result)))))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment