Create / Save snapshots of programming questions on edit#8022
Create / Save snapshots of programming questions on edit#8022adi-herwana-nus wants to merge 4 commits intomasterfrom
Conversation
| class Course::Assessment::Question::VoiceResponse < ApplicationRecord | ||
| acts_as :question, class_name: 'Course::Assessment::Question' | ||
|
|
||
| def is_saving_snapshots? |
There was a problem hiding this comment.
Naming/PredicateName: Rename is_saving_snapshots? to saving_snapshots?.
| OR course_assessment_answer_programming_auto_gradings.question_snapshot_id = #{@programming_question.id}) | ||
| SQL | ||
| ) | ||
|
|
There was a problem hiding this comment.
[Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
| AND (course_assessment_answer_programming_auto_gradings.question_snapshot_id IS NULL | ||
| OR course_assessment_answer_programming_auto_gradings.question_snapshot_id = #{@programming_question.id}) | ||
| SQL | ||
| ) |
There was a problem hiding this comment.
[Correctable] Layout/ClosingParenthesisIndentation: Align ) with (.
| snapshot.skip_process_package = true | ||
| snapshot.save! | ||
|
|
||
| update_result = ActiveRecord::Base.connection.execute(<<-SQL.squish |
There was a problem hiding this comment.
Lint/UselessAssignment: Useless assignment to variable - update_result. Did you mean update_timestamp?
|
|
||
| def update | ||
| result = @programming_question.class.transaction do | ||
| old_update_timestamp = @programming_question.snapshot_of_state_at |
There was a problem hiding this comment.
Lint/UselessAssignment: Useless assignment to variable - old_update_timestamp. Did you mean update_timestamp?
| end | ||
|
|
||
| def destroy_snapshots | ||
| self.snapshots.where.not(id: self).destroy_all |
There was a problem hiding this comment.
[Correctable] Style/RedundantSelf: Redundant self detected.
| !skip_process_package? | ||
| end | ||
|
|
||
| def is_saving_snapshots? |
There was a problem hiding this comment.
Naming/PredicateName: Rename is_saving_snapshots? to saving_snapshots?.
| self.categories = duplicator.duplicate(other.categories) | ||
| end | ||
|
|
||
| def is_saving_snapshots? |
There was a problem hiding this comment.
Naming/PredicateName: Rename is_saving_snapshots? to saving_snapshots?.
| acts_as :question, class_name: 'Course::Assessment::Question' | ||
| has_one_attachment | ||
|
|
||
| def is_saving_snapshots? |
There was a problem hiding this comment.
Naming/PredicateName: Rename is_saving_snapshots? to saving_snapshots?.
|
|
||
| accepts_nested_attributes_for :groups, allow_destroy: true | ||
|
|
||
| def is_saving_snapshots? |
There was a problem hiding this comment.
Naming/PredicateName: Rename is_saving_snapshots? to saving_snapshots?.
| end | ||
| end | ||
| def get_first_test_failures_by_type(test_cases_by_type, test_results_by_type) | ||
| test_cases_by_type.entries.map do |test_case_type, test_cases| |
There was a problem hiding this comment.
[Correctable] Style/HashTransformValues: Prefer transform_values over map {...}.to_h.
| # subclasses. | ||
| # | ||
| # @param [Course::Assessment::Answer] answer The answer to be evaluated. | ||
| # @param [Course::Assessment::Answer::AutoGrading] auto_grading The auto grading object that will store the results. |
There was a problem hiding this comment.
[Correctable] Layout/CommentIndentation: Incorrect indentation detected (column 4 instead of 2).
| # and makes sure answer is in the correct state. | ||
| # | ||
| # @param [Course::Assessment::Answer] answer The answer to be graded. | ||
| # @param [Course::Assessment::Answer::AutoGrading] auto_grading The auto grading object that will store the results. |
There was a problem hiding this comment.
[Correctable] Layout/CommentIndentation: Incorrect indentation detected (column 4 instead of 2).
| # our original question by comparing the updated_at timestamps. | ||
| programming_auto_grading.question_snapshot_id = | ||
| Course::Assessment::Question::Programming. | ||
| where(current_id: question.id, snapshot_index: question.snapshot_index).first&.id || question.id |
There was a problem hiding this comment.
[Correctable] Layout/MultilineMethodCallIndentation: Align where with Course::Assessment::Question::Programming. on line 14.
|
|
||
| # If the question was updated during the evaluation, we can still find | ||
| # our original question by comparing the updated_at timestamps. | ||
| programming_auto_grading.question_snapshot_id = |
There was a problem hiding this comment.
[Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
| # For now, we have to manually query the latest_answer_ids first. | ||
| latest_answer_ids = @question.answers. | ||
| unscope(:order). | ||
| select('DISTINCT ON (submission_id) id'). |
There was a problem hiding this comment.
[Correctable] Layout/MultilineMethodCallIndentation: Align select with @question.answers. on line 16.
| # In Rails 8, it will be possible to override the batch ordering using :cursor. | ||
| # For now, we have to manually query the latest_answer_ids first. | ||
| latest_answer_ids = @question.answers. | ||
| unscope(:order). |
There was a problem hiding this comment.
[Correctable] Layout/MultilineMethodCallIndentation: Align unscope with @question.answers. on line 16.
| end | ||
| end | ||
|
|
||
| json.(auto_grading, :stdout, :stderr) if show_stdout_and_stderr |
There was a problem hiding this comment.
[Correctable] Style/LambdaCall: Prefer the use of lambda.call(...) over lambda.(...).
| end | ||
| elsif first_failures_by_type['private_test'] | ||
| explanations << format_ckeditor_rich_text(get_hint( | ||
| first_failures_by_type['private_test'], |
There was a problem hiding this comment.
[Correctable] Layout/FirstArgumentIndentation: Indent the first argument one step more than get_hint(.
| end | ||
| if first_failures_by_type['public_test'] | ||
| explanations << format_ckeditor_rich_text(get_hint( | ||
| first_failures_by_type['public_test'], |
There was a problem hiding this comment.
[Correctable] Layout/FirstArgumentIndentation: Indent the first argument one step more than get_hint(.
No description provided.