"How can i understand the code structure?"
At the risk of sounding facetious, you read the code, and you think.
Are you sure you would not be better off with the solution I suggested. Even though it is not exactly what you want, you can do it now, without writing any code at all. If you are in a rush, that is going to be a much quicker and more reliable solution. You can then develop a solution that is exactly what your teachers what some time when you are not in a rush and panicing. Just a thought.
Given the type of questions you are asking, which are pretty basic thigns about Moodle development, I am not sure how much help I can give you quickly.
If you are looking for a quick and dirty hack, add two extra column to the quiz_attempts table (e.g. teachercomment and teachercommentformat). Documenation about Moodle forms library is here: http://docs.moodle.org/dev/lib/formslib.php