CSC/ECE 517 Fall 2020 - E2068. Refactor quiz questionnaires controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 21: Line 21:
===Solution===
===Solution===
Fields for minimum_question_score and maximum_question_score have been added to the form for creating each new quiz, and subsequently passed to the controller.  The value is set per quiz, not per question.  The values are not restricted.
Fields for minimum_question_score and maximum_question_score have been added to the form for creating each new quiz, and subsequently passed to the controller.  The value is set per quiz, not per question.  The values are not restricted.
The image below shows the addition of the min_/max_question_score fields to the quiz questionnaire form.
[[File:Quiz_form2.png]]
The image below shows the values from the form used in the controller.
[[File:Quiz_controller.png]]


==Error Message on Line 78==
==Error Message on Line 78==

Revision as of 22:18, 11 October 2020

Introduction

This project contributes to Expertiza, an open-source project using Ruby on Rails. Expertiza is a platform for student learning that encourages active and cooperative learning while discouraging plagiarism.

Background

quiz_questionnaires_controller.rb is used in Expertiza to handle all functionality related to quizzes. A quiz is a type of questionnaire that allows reviewees to interact with their reviewers and making sure they read the submissions before reviewing. The student creating a quiz is supposed to ask questions related to their work, which, ideally, a reviewer should be able to answer. (If a reviewer cannot answer the questions about the reviewed work, then we might doubt the quality of that reviewer’s review.) This controller needs some changes as detailed below.

Issues

  1. Change the way min_question_score and max_question_score are set for @questionnaire on lines 39-40, as well as on lines 53-54.
    • These statements set the min and max scores to 0 and 1, respectively, regardless of what the user enters, which is not intended.
    • Change it so that the values are set according to what the user enters from the UI.
  2. Change the error message on line 78:
  3. Consider lines 259-265, different methods are called with the same parameters (question, choice_key, q_choices) to create different types of questions, depending on q_type.
  4. Make appropriate changes to tests so that they pass after the above changes.

Implementation

Min and Max Question Score

Current Implementation

Quizzes are created with a default minimum_ and maximum_question_score, which is the minimum or maximum score that can be obtained. The values are automatically set by the controller as 0 and 1, respectively. The final score of a quiz is calculated by multiplying the weight of the question by the score and summing the value of each question.

Problem(s)

Currently, minimum and maximum values cannot be set in a custom way per quiz.

Solution

Fields for minimum_question_score and maximum_question_score have been added to the form for creating each new quiz, and subsequently passed to the controller. The value is set per quiz, not per question. The values are not restricted.

Error Message on Line 78

Current Implementation

The original error message stated "Your quiz has been taken by some other students, you cannot edit it anymore."

Problem(s)

This error message is vague and can be easily misunderstood.

Solution

The error message now states "Your quiz has been taken by one or more students; you cannot edit it anymore."

Creating Questions

Current Implementation

When creating a quiz, there are currently three different methods for each of the three different question types: true-false, radio, and multiple choice.

Problem(s)

Radio and multiple choice implement very similar, almost duplicated, functionality in both methods.

Solution

Radio and multiple choice questions have been combined into a single method so as to remove the duplicated functionality. True-false questions will remain separate, because the functionality is significantly different. Future adjustments would require too many changes in the code and tests.

Files Involved

app/controllers/quiz_questionnaires_controller.rb
app/views/questionnaires/_quiz_questionnaire.html.erb
app/views/questionnaires/view.html.erb
spec/controllers/quiz_questionnaires_controller_spec.rb

Code Modifications

<insert git commit images>


Testing our Solutions

Running Tests

rspec spec/controllers/quiz_questionnaires_controller.rb

Testing Server

http://152.7.98.81:8080

Creating New Assignment

  1. Click on "Manage."
  2. Click on "Assignment."
  3. Click on "New Assignment."
  4. Check "has quiz" under the "General" tab.
  5. Set number of quiz questions in "General" tab. Note that this will not show up until after you save.
  6. Set Due Date to any date after the current date under the "Due Dates" tab.
  7. set instructor6 as a participant under the "Other Stuff" tab.

Creating New Quiz

  1. Go to the "Assignments" tab.
  2. Find the assignment you created using the steps above.
  3. Go to "Your Work."
  4. Click on "Create New Quiz."
  5. Fill out the form and click "Save." This page should show all of the settings of your quiz, including correct answers, weight, and minimum and maximum question score.


Team Information

Colleen "Bria" Engen (ceengen)
Justin Kirschner (jkirsch)
Darby Madewell (demadewe)
Mentor: Sanket Pai (sgpai)

References