Comments (2)
Actually, it comes from how the grader works:
- a toplevel is initialized
prepare.ml
thenprelude.ml
are loaded into it- the student code is loaded into it as the module "Code"
solution.ml
is loaded into the module "Solution"test.ml
is loaded
As such, solution.ml
will execute its side-effects after the graded code, and sets the reference to the correct value.
One naive solution would be to load solution.ml
first. While this would work for constant values, it will not work if the reference contains a value that is computed : in that case, you would expect the grader to check the reference result against the solution's result, which would have been overwritten.
For now, the simplest solution I can think of is:
- If an exercise asks to modify a reference that is declared in
prepare
orprelude
, use a second reference to store the result, which will be used specifically bytest.ml
(you still need to store into the original reference, otherwise the grader will reject the exercise). - Load
solution.ml
before the student's code.
i.e.
solution.ml
let forty_two_copy = ref 0
let () =
forty_two := 42;
forty_two_copy := 42
test.ml
Section ([Text "Ref: "; Code "forty_two"] ,
test_ref [%ty: int] forty_two (!Solution.forty_two_copy)) (* /!\ use introspection *)
However, I'm not sure loading solution first is ideal: if you grade with the CLI, you can access the solution from the student code, via Solution.<ident>
(it does not work online since it first typechecks the code). One possible solution would be to also typecheck offline.
I'm actually not sure how test_ref
can be usable without such hideous tricks.
from learn-ocaml.
It seems test_ref
wasn't intended to test student answers.
In the mooc, I found a couple of uses count application of certain functions during user code execution:
- initialise the reference in
prepare.ml
(neverprelude.ml
, I agree with @OCamlPro-Couderc wrote, I can't find a reasonable use for it in that case) - (Re-)define the function you want to count uses of to increase the reference on each call
- Because of what @OCamlPro-Couderc wrote above about loading both the student code and the solution, in
test.ml
, you need to check the value of the reference after substracting the calls made fromsolution.ml
- Don't forget to add, in
test.ml
, an AST check that a clever student didn't redefine the function to not increase your reference
from learn-ocaml.
Related Issues (20)
- Feature: Add feedback button in student UI ?
- Question: Why https://ocaml.org/p/learn-ocaml/latest says `Documentation status is unknown`? HOT 2
- Feature: View synced (not graded) version of students' code HOT 3
- Feature: Add a selector to hide tokens from partition-view pages HOT 1
- Feature: Ensure `learn-ocaml build serve` immediately handles requests at second run HOT 1
- Task: Integrate feedback from https://github.com/ocsigen/js_of_ocaml/issues/1436
- Feature: Add ability to assign different exercises to each student automatically
- Feature: Add multiple choice questions to the description page
- Bug: the Closed/Open state should appear for Assigned exercises HOT 1
- Feature: Add automated comment in PRs when `static-builds.yml` succeeded
- Feature: rewrite URLs so that `%3D` chars are rendered as `=` HOT 3
- Feature: compatibility with reverse proxy headers (X-Real-IP and/or X-Forwarded-For)
- Bug: learn-ocaml master builds with many warnings HOT 2
- Bug: we always get "0 codes were not graded"
- Minor bug: `docker/build-and-push` does not include labels
- Question: open several issues in teaching-feedback as "FAQ"?
- Task: Reduce the CI/CD redundancy
- Bug: file `translations/fr.po.header` is missing HOT 1
- Bug: potential dead CSS code in `learnocaml_student_view.css`
- Bug: the Closed/Open state is buggy/confusing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learn-ocaml.