# Evaluating Student Code

**URL:** <https://discourse.processing.org/t/evaluating-student-code/21570>\
**Category:** Teaching\
**Created:** [June 4, 2020, 9:02pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570 "2020-06-04T21:02:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfe1223](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pfe1223](https://discourse.processing.org/u/pfe1223)\
**Post date:** [June 4, 2020, 9:02pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/1 "2020-06-04T21:02:48Z")

</div>

Does anybody know of any grading scripts for Processing code? Perhaps something like an AST could be used to evaluate student code.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [June 5, 2020, 8:34pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/2 "2020-06-05T20:34:22Z")

</div>

Hi,

What parameter(s) do you want to evaluate? Is it time complexity, text output, graphic output or features, object oriented structure, flexibility ?

---

<div class="post-metadata">

**Author:** ![pfe1223](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pfe1223](https://discourse.processing.org/u/pfe1223)\
**Post date:** [June 5, 2020, 11:09pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/3 "2020-06-05T23:09:40Z")

</div>

Graphic output, but I realize that this might be hard, especially with animations that interact with the mouse. I have started working on a test suite that parses the student code. Instructors add the code they expect to see in each function. The test passes if the code is there. This, however, is not the best solution. So I am curious if anybody in the community has tried to tackle this problem.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 5, 2020, 11:11pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/4 "2020-06-05T23:11:17Z")

</div>

Hi @pfe1223,

I haven’t looked at it yet, but Prince Steven Annor developed a Processing 3 auto-grade module called “AutoGrad” for SuaCode. However, I believe that it is not AST based, and that each test class is custom-designed in relation to the specific assignment module.

> **[Interview with 2019 Fellow Prince Steven Annor](https://medium.com/processing-foundation/interview-with-2019-fellow-prince-steven-annor-ffb310e60401)**
>
> Prince Steven Annor’s fellowship taught 700 students in Africa to learn to code on their smartphones.

> **[PrinceSAnnor/autograd](https://github.com/PrinceSAnnor/autograd)**
>
> Automatic grading system for SuaCode. Contribute to PrinceSAnnor/autograd development by creating an account on GitHub.

You might also be interested in this:

Rather than AST-based syntax evaluation, I have in the past used visual e2e testing in which each learner is assigned a target such as an output image (assignment generation) and then is able to self-grade whether or not they have accurate produced that target. See prior discussion here:

- [https://forum.processing.org/two/discussion/20354/testing-processing-code-program](https://forum.processing.org/two/discussion/20354/testing-processing-code-program)

…as an aside, e2e visual testing is also used for regression testing on the Processing.R mode: [https://github.com/processing-r/Processing.R/blob/master/hack/generate-e2e-test.py](https://github.com/processing-r/Processing.R/blob/master/hack/generate-e2e-test.py)

---

<div class="post-metadata">

**Author:** ![pfe1223](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pfe1223](https://discourse.processing.org/u/pfe1223)\
**Post date:** [June 5, 2020, 11:16pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/5 "2020-06-05T23:16:42Z")

</div>

@jeremydouglass Thanks so much, this looks promising.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 5, 2020, 11:24pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/6 "2020-06-05T23:24:17Z")

</div>

Regarding animation and visual testing:

For random processes, give students a template with a required randomSeed() set. The PRNG used is from Java, so it is cross-platform deterministic.

For deterministic animations, you can reduce them to the static image comparison case by giving students a template that saves a frame on a given frameCount – e.g. `if(frameCount==300) saveFrame()`.

For animations with mouse interaction and a deterministic state (e.g. the image output is always the same if the mouse is at x,y) then you can again reduce them to the static image comparison case by giving students a template that saves a frame on `if(mouseX==x && mouseY==y) saveFrame()`. They have to hunt-the-pixel a bit to generate their image(s), but it shouldn’t be too bad. A slightly fancier template would have the x,y input defined from mouseX/mouseY, but on e.g. keyReleased() it overrides this with a set x,y and then fires saveFrame() – so, make your interactive sketch, but press space to save.

For non-deterministic interactive output, visual comparison isn’t usually a good fit – there are workarounds, but they are specific to certain cases or involve complex workarounds (e.g. check deterministic pixel areas only, or check for certain elements or certain properties of the output image such as histograph, or draw a deterministic version of the contents to a second buffer etc).

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 5, 2020, 11:27pm UTC](https://discourse.processing.org/t/evaluating-student-code/21570/7 "2020-06-05T23:27:27Z")

</div>

> [@pfe1223](#):
>
> I have started working on a test suite that parses the student code.

Is this suite something that you are able to share / interested in sharing? I’m not currently using something like this, but I’m interested and might be able to contribute in the future.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 6, 2020, 4:50am UTC](https://discourse.processing.org/t/evaluating-student-code/21570/8 "2020-06-06T04:50:27Z")

</div>

One further note: I found this fascinating master’s thesis project:

- ZITA - A Self Learning Tutoring Assistant [http://essay.utwente.nl/77910/1/Blok\_MA\_EEMCS.pdf](http://essay.utwente.nl/77910/1/Blok_MA_EEMCS.pdf)

Which also mentions a Processing static analysis tool:

> In addition to PMD, a tool part of a research presented at CSEDU 2018 [8]  
> is a static analysis tool that was used for research on Processing code. This tool  
> currently has no real name, so it will henceforth be referred to as ‘CSEDU’.
