This problem was raised in issue904. The design of Markus’s current remark request feature is, when a grader is remarking a submission, he/she should be able to see the old mark of each rubric category as well as the total before giving new marks(as shown below).
But old marks do not appear!
As it turns out, old marks will show up after the grader marks a category and refresh the page. When I first saw this issue and try to reproduce it on our demo server and my own local server everything works fine. I also learned that the server is running ruby 1.8.7 so I decided to setup RVM+ruby1.93 at home to test it which wasted me quite a few hours with no success due to svn binding.
Meanwhile, it was found out that this issue only happens when one is using PostgreSql. Lesson learned: although including configuration details in an issue might be tedious, those details sometimes helps. However I do like the fact that Markus project has no strict rules on how to “compose” an issue so one can decide what info is useful and what is not.
After yet a few hours of struggling with setting up RVM ruby 1.8.7 + PostgreSQL, I finally got Postgresql working by giving up RVM. I still believe RVM is great but somehow it doesn’t work for me.
In results_controller.rb, somewhere around line35 we have:
@old_result = @submission.result
But debugger shows that @submission.result is not giving us the old result. As pointed out by Joey(ioev), this is because in submission.rb, the definition of the Submission class states:
has_one :result, :dependent => :destroy
belongs_to :remark_result, :class_name => “Result”
The “has_one” relation means that the Results table has foreign keys that points to rows in Submission table. See the below example(from Rails tutorial):
But Submission also belongs_to remark_result which is also a row in the Results table. Below is an example of belongs_to relation(also from rails tutorial):
So we can have two rows in the Results table that points to the same submission. @submission.remark_result should give us the desired result because it’s one-to-one, but @submission.result can return the wrong result because database will just find any result in the Results table that has a matching submission id and return that.
Joey also noticed the time-stamps of the result entries and how they affect which result will be returned by the database. In results_controller.rb, update_remark_request is the method that creates the remark_result(a new result in the Results table). By swapping the order of the following two line:
I am able to ensure that the old result row will have an older time-stamp and will be return by @submission.result. Testings show that this removes the problem with Postgresql without introducing problem back to Mysql or Sqlite. Obviously this is not a good solution at all and I will work on a better solution based on Joey’s comments.