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

Reimplemented StudentQuizzesController #112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SahithiAmmana
Copy link

No description provided.

review_response_maps.each do |response_map|
reviewee_team = Team.find(response_map.reviewee_id)

next unless reviewee_team.parent_id == assignment_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to cycle through all the response maps? Couldn't we just do a find to find the response map with the right parent?

redirect_to action: :fetch_available_quizzes_for_reviewer, assignment_id: params[:assignment_id], questionnaire_id: response.response_map.reviewed_object_id, map_id: map.id
end
else
flash[:error] = 'You have already taken this quiz, below are the records for your responses.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"below is the record of your responses."

validates :seq, presence: true, numericality: true # sequence must be numeric
validates :txt, length: { minimum: 0, allow_nil: false, message: "can't be nil" } # user must define text content for a question
validates :question_type, presence: true # user must define type for a question
validates :break_before, presence: true

QUESTION_TYPES = {
'MultipleChoiceCheckbox' => :calculate_score_for_checkbox_question,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"MultipleChocieTextbox" --> "Checkbox"
"MultipleChoiceRadio" --> "MultipleChoice"

validates :seq, presence: true, numericality: true # sequence must be numeric
validates :txt, length: { minimum: 0, allow_nil: false, message: "can't be nil" } # user must define text content for a question
validates :question_type, presence: true # user must define type for a question
validates :break_before, presence: true

QUESTION_TYPES = {
'MultipleChoiceCheckbox' => :calculate_score_for_checkbox_question,
'TrueFalse' => :calculate_score_for_truefalse_question,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name is too complicated. Couldn't there just be a score method implemented in Response, that could be overridden where necessary?

-Ed

@quiz_score = @response.aggregate_questionnaire_score # Use the score calculated by Response model
end

# Fetches quizzes for a given assignment that a reviewer has not yet started.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for this method would be "unattempted_quizzes".

# Submits the quiz response and calculates the score.
def submit_quiz
map = ResponseMap.find(params[:map_id])
# Check if there is any response for this map_id. This is to prevent student from taking the same quiz twice.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are embedding a POLICY into this mechanism. Bad design! Let the instructor decide whether someone can take a quiz over, e.g., to improve their score.

flash[:error] = 'Please answer every question.'
redirect_to action: :fetch_available_quizzes_for_reviewer, assignment_id: params[:assignment_id], questionnaire_id: response.response_map.reviewed_object_id, map_id: map.id
end
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another POLICY that belongs elsewhere. Did you ever skip a question on a test? Why don't you want to let other students do that?

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

Successfully merging this pull request may close these issues.

2 participants