# Can AI be used for grading code copy exercises and adjust difficulty based on these scores?

I'm a senior in a bachelor Multimedia and Creative Technology. My experience is mostly full-stack web app development.

For my bachelor's thesis, I need to do research in a subject I have no experience in. I want to build an application where students can exercise HTML and CSS. Teachers can upload simple code pieces (e.g. h1, h2, and list with elements) with difficulty levels and students can try to copy these exercises with a code editor on the web with live preview.

My question:

• Is it possible to use AI for grading these "copies", give the students scores, and, based on these scores, adjust the difficulty level so the next exercise is harder or easier?

• And if so, could you put me in the right direction?

I might be wrong, but I would suggest you approach this problem more simply rather than using neural networks or other machine learning constructs. Machine learning is concerned with making a computer learn from a lot of data. You do not need a lot of data to score how well the student's code compares to the teacher's code. You also do not need recommender systems to suggest the next question. Recommender systems suggest by infering the user's preferences, whereas in your case you can simply suggest the next question based on how well the student did on the current question and the type of current question.

I would first identify the following three subproblems:

1. Scoring and assigning a difficulty score to a teacher's code piece.
2. Scoring how similar the student's solution is to the true solution.
3. Predicting next question based on the current problem difficulty and student score for the current problem.

For the first you can develop some algorithms to do feature extraction from the html, css or whatever code piece you want to evaluate. Features can be the following: length of the code piece, number of tags, number of different tags, number of attributes and so on. Combine them in a mathematical formula to calculate a difficulty score for the code piece. I would suggest a linear combination like the following: $$Y = \sum{a_i X_i}$$ where $$X_i$$ is the $$i$$th feature. Then, normalizing all the scores of all questions to a range of $$[0, 100]$$. You can even have an upper decision boundary such that whenever a certain score is reached, the normalized difficulty score will be $$100$$.

For the second you should start by checking if the student's code compiles, i.e. there are no syntax errors. Then, you can use Levenshtein Distance to calculate how many characters the student was wrong from the original solution. The goal of a good training should be for the student to infer the exact tags and attributes, so the exact sequence of characters. Calculate the percentage of mistakes over total length of code piece and assign it to $$x$$. Use a mathematical formula of your liking to score how well the student did given $$x$$. I would suggest you consider the following formula: $$e^{-0.1x}$$. It is $$100\%$$ score for $$0$$ mistakes and $$50\%$$ score for having $$8\%$$ of mistakes. Have a look at the graph at desmos.com.

Similarly, you can construct a formula or recipe for choosing the difficulty of the next problem. It should be based on the current score and the current problem's difficulty. You can even force the student to repeat the question, or a question of similar difficulty if the score is below $$50\%$$. If the score is above $$50\%$$, you can for example increase the difficulty level of the questions by 1 point every 3 correctly solved problems. Nevertheless, there are many ways you can approach this.

Hope this helps. Good luck in your thesis.

• Sorry for this very late reply. Your answer helped a lot in deciding the flow and building this application. Thank you! Jan 24 at 13:42