Day 5 Week 2 on JFLAP

This morning I found that there was a bug with yesterday’s work. In conversionExercise, if the problem was switched to another and then switched back, grade function would not work properly. This is because I did not use graph.clear() to clear the graph, and the reason for that is this function did not work. Today I realize that it is not this function does not work per se, instead this function deletes the html DOM element along with the graph, so the fix was easy: add the DOM element back using JavaScript after the graph is cleared. After this bug fix I spent the rest of the morning adding the grading feature to this conversion exercise. Now, the student gets one point for each state correct, loses 0.25 for each incorrect step. Their scores are shown continuously, meaning that after each operation they receive a feedback. Total possible score is the total states in the DFA converted, but the score itself is not shown to avoid hints. For score displaying, I disabled jsavscore provided by JSAV and used my own because I do not like to guess what functions do. I like to be in control.

Then I implemented this wonderful DFA exercise generator, which takes input of expressions and test cases and spits out a json file that can be used by the conversion exercise I implemented yesterday. This tool is supposed to help instructors create their own exercises. A screenshot is shown below. Instructors are able to add problems, add test cases, and when they finish click get JSON button. A download link will appear for them to download the json file.

exercise generatorediting exercise

download jsondownload JSON file

I am embarrassed to say that I spent most of the time implementing adding problem and adding test case functions. There are just too many details: name attribute for radio buttons have to be different so they don’t mess up with each other. I also have to update the indices for problems and test cases etc. I am so happy it is working.

It’s been a week since I started coding now. General impression of JavaScript: this keyword sucks! Avoid using this at all costs. Not only does it cause huge errors depending on the context, but it also confuses future developers on the project. I spent so much time reading other people’s code for a long time trying to figure out what this represents, because often times it is coming from another file, not to mention sometimes it is passed more than once. Naming and commenting are also so important that it can greatly influence the project. If a project is meant to be a coorperative effort, variables and comments have to be satisfying.

Leave a Reply

Your email address will not be published. Required fields are marked *