Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewFeedback page does not account for hooks #1914

Closed
damianhxy opened this issue Jun 2, 2023 · 2 comments · Fixed by #2003
Closed

viewFeedback page does not account for hooks #1914

damianhxy opened this issue Jun 2, 2023 · 2 comments · Fixed by #2003

Comments

@damianhxy
Copy link
Member

Steps To Reproduce
Add a parseAutoresult hook to the lab's config file that returns a score hash that differs from what would be obtained from a simple JSON.parse.

For example,

  def parseAutoresult(autoresult, _isOfficial)
    {"Problem 1": 1, "Problem 2": 2, "Problem 3": 3, "Problem 4": 4, "Problem 5": 5, "Problem 6": 6}
  end

Current behavior
viewFeedback page shows scores based on score JSON

Expected behavior
viewFeedback page shows the final scores (after any hooks)

@damianhxy
Copy link
Member Author

damianhxy commented Jun 2, 2023

This can be achieved by replacing parseScore with something like

def getScores(scores)
    score_hash = scores.map { |s|
      [s.problem.name, s.score]
    }.to_h
    if @jsonFeedback&.key?("_scores_order") == false
      @jsonFeedback["_scores_order"] = score_hash.keys
    end
    @total = 0
    score_hash.keys.each do |k|
      @total += score_hash[k].to_f
    rescue NoMethodError
      flash.now[:error] ||= ""
      flash.now[:error] += "The score for #{k} could not be parsed.<br>"
      flash.now[:html_safe] = true
    end
    score_hash["_total"] = @total
    score_hash
  end

and calling @scoreHash = getScores @submission.scores.includes(:problem)

However, there is currently a distinction between autograded scores and "manual" scores, where the sidebar displays differently for manually graded scores. If we want to maintain this distinction, we should check the grader_id and only set @scoreHash if it is not 0.

@damianhxy
Copy link
Member Author

Screenshot 2023-06-02 at 23 36 59

As an interesting side-effect of the current approach, JSON strings in manual feedback is parsed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants