<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sleaston</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sleaston"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sleaston"/>
	<updated>2026-05-12T08:05:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151978</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151978"/>
		<updated>2023-12-02T20:33:52Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 2. Student Takes Questionnaire Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|100px]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/submit_answers \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/submit_answers \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151975</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151975"/>
		<updated>2023-12-02T20:23:33Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 2. Student Takes Questionnaire Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|100px]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/submit_answers \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151819</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151819"/>
		<updated>2023-11-28T15:55:37Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 1. Login as an Instructor and Get Bearer Token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|100px]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151818</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151818"/>
		<updated>2023-11-28T15:55:21Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 1. Login as an Instructor and Get Bearer Token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|100px]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151817</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151817"/>
		<updated>2023-11-28T15:53:08Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 1. Login as an Instructor and Get Bearer Token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|left]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151816</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151816"/>
		<updated>2023-11-28T15:52:36Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 1. Login as an Instructor and Get Bearer Token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151815</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151815"/>
		<updated>2023-11-28T15:51:46Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* student_quizzes_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
module Api&lt;br /&gt;
  module V1&lt;br /&gt;
    class StudentQuizzesController &amp;lt; ApplicationController&lt;br /&gt;
      before_action :authenticate_request!&lt;br /&gt;
      before_action :check_instructor_role, except: [:submit_answers]&lt;br /&gt;
      before_action :set_student_quiz, only: [:show, :edit, :update, :destroy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes&lt;br /&gt;
      def index&lt;br /&gt;
        @quizzes = Questionnaire.all&lt;br /&gt;
        render json: @quizzes&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id&lt;br /&gt;
      def show&lt;br /&gt;
        render json: @student_quiz&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # GET /student_quizzes/:id/calculate_score&lt;br /&gt;
      def calculate_score&lt;br /&gt;
        # Find the ResponseMap by its ID.&lt;br /&gt;
        # Make sure this ID is the ID of the ResponseMap, not the Questionnaire or the Participant.&lt;br /&gt;
        response_map = ResponseMap.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
        if response_map&lt;br /&gt;
          # Return the score of the ResponseMap&lt;br /&gt;
          render json: { score: response_map.score }, status: :ok&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: 'Attempt not found or you do not have permission to view this score.' }, status: :not_found&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/assign&lt;br /&gt;
      def assign_quiz_to_student&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        questionnaire = Questionnaire.find(params[:questionnaire_id])&lt;br /&gt;
&lt;br /&gt;
        # Check if the quiz is already assigned&lt;br /&gt;
        existing_map = ResponseMap.find_by(&lt;br /&gt;
          reviewee_id: participant.user_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if existing_map&lt;br /&gt;
          render json: { error: &amp;quot;This student is already assigned to the quiz.&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        student_id = participant.user_id&lt;br /&gt;
&lt;br /&gt;
        instructor_id = Assignment.find(questionnaire.assignment_id).instructor_id&lt;br /&gt;
&lt;br /&gt;
        response_map = ResponseMap.new(&lt;br /&gt;
          reviewee_id: student_id,&lt;br /&gt;
          reviewer_id: instructor_id,&lt;br /&gt;
          reviewed_object_id: questionnaire.id&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
        if response_map.save&lt;br /&gt;
          # Handle success&lt;br /&gt;
        else&lt;br /&gt;
          render json: { error: response_map.errors.full_messages.to_sentence }, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/create_questionnaire&lt;br /&gt;
      def create_questionnaire&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          questionnaire = Questionnaire.create!(questionnaire_params.except(:questions_attributes))&lt;br /&gt;
&lt;br /&gt;
          questionnaire_params[:questions_attributes].each do |question_attributes|&lt;br /&gt;
            question = questionnaire.questions.create!(question_attributes.except(:answers_attributes))&lt;br /&gt;
&lt;br /&gt;
            question_attributes[:answers_attributes].each do |answer_attributes|&lt;br /&gt;
              question.answers.create!(answer_attributes)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # POST /student_quizzes/submit_answers&lt;br /&gt;
      # Method to submit answers for a quiz&lt;br /&gt;
      def submit_answers&lt;br /&gt;
        ActiveRecord::Base.transaction do&lt;br /&gt;
          # Find the existing ResponseMap for this user and questionnaire&lt;br /&gt;
          response_map = ResponseMap.find_by(&lt;br /&gt;
            reviewee_id: current_user.id,&lt;br /&gt;
            reviewed_object_id: params[:questionnaire_id]&lt;br /&gt;
          )&lt;br /&gt;
&lt;br /&gt;
          # If no ResponseMap exists for the current user, do not proceed&lt;br /&gt;
          unless response_map&lt;br /&gt;
            render json: { error: &amp;quot;You are not assigned to take this quiz.&amp;quot; }, status: :forbidden&lt;br /&gt;
            return&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Calculate the total score based on correct answers&lt;br /&gt;
          total_score = params[:answers].sum do |answer|&lt;br /&gt;
            question = Question.find(answer[:question_id])&lt;br /&gt;
            submitted_answer = answer[:answer_value]&lt;br /&gt;
&lt;br /&gt;
            # Find or initialize the response for the question&lt;br /&gt;
            response = Response.find_or_initialize_by(&lt;br /&gt;
              response_map_id: response_map.id,&lt;br /&gt;
              question_id: question.id&lt;br /&gt;
            )&lt;br /&gt;
            response.submitted_answer = submitted_answer&lt;br /&gt;
            response.save!&lt;br /&gt;
&lt;br /&gt;
            # Increment score if the answer is correct&lt;br /&gt;
            question.correct_answer == submitted_answer ? question.score_value : 0&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          # Update the score of the ResponseMap&lt;br /&gt;
          response_map.update!(score: total_score)&lt;br /&gt;
&lt;br /&gt;
          render json: { total_score: total_score }, status: :ok&lt;br /&gt;
        end&lt;br /&gt;
      rescue ActiveRecord::RecordInvalid =&amp;gt; e&lt;br /&gt;
        render json: { error: e.message }, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # PATCH/PUT /student_quizzes/:id&lt;br /&gt;
      def update&lt;br /&gt;
        if @student_quiz.update(questionnaire_params)&lt;br /&gt;
          render json: @student_quiz&lt;br /&gt;
        else&lt;br /&gt;
          render json: @student_quiz.errors, status: :unprocessable_entity&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # DELETE /student_quizzes/:id&lt;br /&gt;
      def destroy&lt;br /&gt;
        @student_quiz.destroy&lt;br /&gt;
        head :no_content&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      private&lt;br /&gt;
&lt;br /&gt;
      def set_student_quiz&lt;br /&gt;
        @student_quiz = Questionnaire.find(params[:id])&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      def questionnaire_params&lt;br /&gt;
        params.require(:questionnaire).permit(&lt;br /&gt;
          :name, :instructor_id, :min_question_score, :max_question_score, :assignment_id,&lt;br /&gt;
          questions_attributes: [:id, :txt, :question_type, :break_before, :correct_answer, :score_value,&lt;br /&gt;
                                 answers_attributes: [:id, :answer_text, :correct]&lt;br /&gt;
          ]&lt;br /&gt;
        )&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      # New method to permit parameters for submitting answers&lt;br /&gt;
      def response_map_params&lt;br /&gt;
        params.require(:response_map).permit(:student_id, :questionnaire_id)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      # Check for instructor&lt;br /&gt;
      def check_instructor_role&lt;br /&gt;
        unless current_user.role_id == 3&lt;br /&gt;
          render json: { error: 'Only instructors are allowed to perform this action' }, status: :forbidden&lt;br /&gt;
          return&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151814</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151814"/>
		<updated>2023-11-28T15:39:50Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Database Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
  mysql -u dev -pexpertiza&lt;br /&gt;
  use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
  INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
  rails console&lt;br /&gt;
  BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following but it will not match:&lt;br /&gt;
  '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
  INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
  rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151813</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151813"/>
		<updated>2023-11-28T15:38:40Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Student Can Update a Specific Quiz Answer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
  curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
       }&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151812</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151812"/>
		<updated>2023-11-28T15:38:00Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Student Can Get a Specific Quiz Attempt Score */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
  curl -X GET \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer yJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151811</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151811"/>
		<updated>2023-11-28T15:37:39Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Instructor Can Delete a Specific Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X DELETE \&lt;br /&gt;
  http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151810</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151810"/>
		<updated>2023-11-28T15:37:25Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Instructor Can Show Details of A Specific Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151809</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151809"/>
		<updated>2023-11-28T15:37:11Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Instructor Can Show All Quizzes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
  curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151808</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151808"/>
		<updated>2023-11-28T15:36:48Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 2. Student Takes Questionnaire Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
  -d' &lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
    &amp;quot;answers&amp;quot;: [&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
      { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151807</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151807"/>
		<updated>2023-11-28T15:35:51Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 1. Login as an Student and Get Bearer Token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
  curl -X POST http://localhost:3002/login \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151806</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151806"/>
		<updated>2023-11-28T15:35:34Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 5. Instructor Assigns Participant to Questionnaire */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
    &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
curl -X POST http://localhost:3002/login \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151805</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151805"/>
		<updated>2023-11-28T15:35:08Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 5. Instructor Makes a Sample Questionnaire */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
  -d '&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  '&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
curl -X POST http://localhost:3002/login \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151804</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151804"/>
		<updated>2023-11-28T15:34:15Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* 4. Instructor Adds a Student to the Assignment as a Participant */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;participant&amp;quot;: {&lt;br /&gt;
      &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
      &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
curl -X POST http://localhost:3002/login \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151803</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151803"/>
		<updated>2023-11-28T15:33:27Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* cURL Instructor Required Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png|thumbnail|right]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;course&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
  curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
  -H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
  -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
  -d '{&lt;br /&gt;
    &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
      &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
      &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
      &amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
      &amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
  }'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;participant&amp;quot;: {&lt;br /&gt;
    &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
curl -X POST http://localhost:3002/login \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151802</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151802"/>
		<updated>2023-11-28T15:21:29Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;course&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
	&amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
	&amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
    &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
    &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
	&amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
	&amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;participant&amp;quot;: {&lt;br /&gt;
    &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
=== cURL Student Takes Questionnaire Quiz ===&lt;br /&gt;
==== 1. Login as an Student and Get Bearer Token ====&lt;br /&gt;
curl -X POST http://localhost:3002/login \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-d '{&amp;quot;user_name&amp;quot;: &amp;quot;student&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as a Student.&lt;br /&gt;
&lt;br /&gt;
==== 2. Student Takes Questionnaire Quiz ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as a student.&lt;br /&gt;
Be sure the ids match the database ids for the questionnaire and the questions.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Madrid&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
Submitting this POST will return a scored value in the JSON response.  For example, the score_value for each answer is 1, but only one of the answers is correct (Madrid is incorrect).&lt;br /&gt;
The JSON response will return a value of 1.&lt;br /&gt;
&lt;br /&gt;
If we were to submit:&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/ \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6NCwibmFtZSI6InN0dWRlbnQyIiwiZnVsbF9uYW1lIjoidHdvLCBzdHVkZW50Iiwicm9sZSI6Ikluc3RydWN0b3IiLCJpbnN0aXR1dGlvbl9pZCI6MSwiZXhwIjoxNzAwODYxMTQ5fQ.sILbToiWD_RxYts_LoIBV3x9nVsziZXE8yvlntEF8YBEyn3cIos87cdQAPYQeR5to0aNpnfTKZP7SEIQJVkFS8ucfjwqHHGRn_mMAwhsW9_muebEY-vVGlXLYlTbHJKcMcpjBeqDk620fcCfNFsOUsSaAw6Z_GA7KtxQtQU10C_XilfTSbzw-MNv7R_h2FmNs8qLqddsrDaGKsRJl_hG85incsRGoFOxT_qWGW68fjqVKkyypXesoXP_7eM8mCjsEwDUY_NBuy5oijy7S1KKvPnaYu9tWbhEh8mZF-AC3_yd9dFKWkHv-UxP-i_i1phyKVIhFbjzX-wMXg_SwtoQPw&amp;quot; \&lt;br /&gt;
-d' &lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: 7,&lt;br /&gt;
  &amp;quot;answers&amp;quot;: [&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 15, &amp;quot;answer_value&amp;quot;: &amp;quot;Paris&amp;quot; },&lt;br /&gt;
    { &amp;quot;question_id&amp;quot;: 16, &amp;quot;answer_value&amp;quot;: &amp;quot;Jupiter&amp;quot; }&lt;br /&gt;
 &lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
&lt;br /&gt;
The JSON response will return a value of 2 since both values are correct.&lt;br /&gt;
&lt;br /&gt;
=== Other Tests to Perform ===&lt;br /&gt;
You will need to login and obtain the appropriate Bearer token for the following sections.&lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show All Quizzes ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA3OTM1MDZ9.xugyF5xcmTxFAzzQzLuBhK8lKyX1yVdbZEEYZUwBLssYgI7XNI68fCO5gQM7IClh1Y4TNDAZd6-GdunCh6uVkatEPB-PZF8XuQqX_-MfYIJYZCmEaTSCYdpK-OhGRf_pDOCCMI9rGDzy59-AEBI4--fDvW-e5-oeDekS1D7nz5lter5u2UMNb_tUAOSNPkOSm6ZeSFm9uoyLkaZsxzz4jNl8PMPWrh2wNLmVAX5fb9PWMo8Ua8OPiDDohFO6eouSq-WCydciYYuhjTjWvC3eVaNQfQqf6qD8UN2ClK8yZMSwPR14CNZeAr5zcz6z725Jpiim77v2bKK2RmC9n4N1_Q&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Show Details of A Specific Quiz ====&lt;br /&gt;
curl -X GET http://localhost:3002/api/v1/student_quizzes/1 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; &lt;br /&gt;
&lt;br /&gt;
==== Instructor Can Delete a Specific Quiz ====&lt;br /&gt;
But it must not have any questions.&lt;br /&gt;
&lt;br /&gt;
curl -X DELETE \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Get a Specific Quiz Attempt Score ====&lt;br /&gt;
(The id here (which is showing 14) is the id from the response_map linking to the students attempt) &lt;br /&gt;
&lt;br /&gt;
curl -X GET \&lt;br /&gt;
http://localhost:3002/api/v1/student_quizzes/14/calculate_score \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; -H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==== Student Can Update a Specific Quiz Answer ====&lt;br /&gt;
Also, make sure you pass the id of the question and the id of the answer you want to update. &lt;br /&gt;
&lt;br /&gt;
curl -X PUT http://localhost:3002/api/v1/student_quizzes/7 \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;id&amp;quot;: 15,&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of England?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          {&lt;br /&gt;
            &amp;quot;id&amp;quot;: 35,&lt;br /&gt;
            &amp;quot;answer_text&amp;quot;: &amp;quot;London&amp;quot;,&lt;br /&gt;
            &amp;quot;correct&amp;quot;: true&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151801</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151801"/>
		<updated>2023-11-28T15:08:13Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* cURL Instructor Required Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
[[File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png]]&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;br /&gt;
&lt;br /&gt;
==== 2. Instructor Creates Course ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the institution.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/courses \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;course&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Introduction to Ruby&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
	&amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
	&amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/course_files&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Instructor Creates An Assignment ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/assignments \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA2NjU5Mjh9.rr358F0ELeN0ypOu9YnFrZMhEKOiFJm_zZv7kerjgDyJf683uex9zc2ZOfIpUNjIkq6p81lgB8H0t6o22FtnCIroqxjpThx8pyg6bXd6mX6c5NCpXNl8avde2amguMXwgA64csBy0XjkFCXupVlx89YQ7VUtkF69IOUza4r3CfZjgn3cvP2Ync9JSZAPq3EGmMa3_bUEQQ4-B3B9Y9nsPV84tUK6g3d7VLZx-I1-r0g8HcDJzcWcfkDd2BdwcaMild8f0xH-MXZOL0C2-ZnCzglDX8LN3FvetKP05zEJd5El6rxtjvr7-Ozy9qrRvzHWAnryjR9jEF951I4kUKb0jQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;assignment&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Test&amp;quot;,&lt;br /&gt;
    &amp;quot;directory_path&amp;quot;: &amp;quot;/path/to/assignment_files&amp;quot;,&lt;br /&gt;
    &amp;quot;course_id&amp;quot;: 1,  &lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,  &lt;br /&gt;
	&amp;quot;require_quiz&amp;quot;: 1,  &lt;br /&gt;
	&amp;quot;num_quiz_questions&amp;quot;: 5&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 4. Instructor Adds a Student to the Assignment as a Participant ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the user and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/participants \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MywibmFtZSI6InN0dWRlbnQiLCJmdWxsX25hbWUiOiJvbmUsIHN0dWRlbnQiLCJyb2xlIjoiU3R1ZGVudCIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4NTI5NTV9.bSztjjVs28E90E0cuMNPQj6cBqcE6XIGPKILrFzgz5gtXgb5HoW9RtUza6oITpiDN_vEhSQvSvjfOgpnekaeEcimR3Ov1537fC7i-RsN6ExjjwO25E8v50I1ZkvYOYAnj_19LyYLs48tdap2bntR3Gfw0DpUG5lt4H-yyC94eVEOsIxi59KmRJPYzO53lFHTyjfIjlqp7DapWGc9gQ2H1D9QGrHB2hLdk0Yl46PAYDZPYN76N5FRVyslcCNwjbHXcFu88hOnphDxo26W6_2zrsyNaQrVtgk0NyxaSHQ0pZfQPHke7g94HMw5EzDH3lccB5hx1YStkdxYFxCYo_BapQ&amp;quot; \&lt;br /&gt;
-d '{&lt;br /&gt;
  &amp;quot;participant&amp;quot;: {&lt;br /&gt;
    &amp;quot;user_id&amp;quot;: 4,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 2&lt;br /&gt;
  }&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 5. Instructor Makes a Sample Questionnaire====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the instructor and the assignment.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/create_questionnaire \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;questionnaire&amp;quot;: {&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;General Knowledge Quiz&amp;quot;,&lt;br /&gt;
    &amp;quot;instructor_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;min_question_score&amp;quot;: 0,&lt;br /&gt;
    &amp;quot;max_question_score&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;assignment_id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;questions_attributes&amp;quot;: [&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the capital of France?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Paris&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Paris&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Madrid&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Berlin&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Rome&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      {&lt;br /&gt;
        &amp;quot;txt&amp;quot;: &amp;quot;What is the largest planet in our solar system?&amp;quot;,&lt;br /&gt;
        &amp;quot;question_type&amp;quot;: &amp;quot;multiple_choice&amp;quot;,&lt;br /&gt;
        &amp;quot;break_before&amp;quot;: true,&lt;br /&gt;
        &amp;quot;correct_answer&amp;quot;: &amp;quot;Jupiter&amp;quot;,&lt;br /&gt;
        &amp;quot;score_value&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;answers_attributes&amp;quot;: [&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Earth&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Jupiter&amp;quot;, &amp;quot;correct&amp;quot;: true },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Mars&amp;quot;, &amp;quot;correct&amp;quot;: false },&lt;br /&gt;
          { &amp;quot;answer_text&amp;quot;: &amp;quot;Saturn&amp;quot;, &amp;quot;correct&amp;quot;: false }&lt;br /&gt;
        ]&lt;br /&gt;
      }&lt;br /&gt;
      // Add more questions as needed&lt;br /&gt;
    ]&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
'&lt;br /&gt;
==== 5. Instructor Assigns Participant to Questionnaire ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an instructor.&lt;br /&gt;
Be sure the ids match the database ids for the participant and the questionnaire.&lt;br /&gt;
&lt;br /&gt;
curl -X POST http://localhost:3002/api/v1/student_quizzes/assign \&lt;br /&gt;
-H &amp;quot;Content-Type: application/json&amp;quot; \&lt;br /&gt;
-H &amp;quot;Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MiwibmFtZSI6Imluc3RydWN0b3IiLCJmdWxsX25hbWUiOiJOZXcsIEluc3RydWN0b3IiLCJyb2xlIjoiSW5zdHJ1Y3RvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MDA4MDQxMTl9.oiaRp3AgE_9Fg_gtHO7-bK75zRw1RdU30bSzDojvB0VFNG_KgdxHPnCRRCHsKkupytpPKEU1w-u5-3UfiJtp2BQ7fWEgt3FKgBR0i2SdQKkG6_Qe99PHJEkVThcne6vqxsPN75voxh1cf2PADKUz3AG0lMzSB2NnIFdIDP98EPncIUVBpLKaZXukYjN6YDgKOer42YQgJpwlXnS9lUr85wvWKo0ouPdR0VHXwrxafTD5e_qyYUYTV3r5P8Bvh5za0Bds-HwHckFpAu0yB0kgS5a9ioFPSxHTCVzm_zCWLr9TDEbwlvJgmp4uaj2E_CkDS3hBFAiPHoEqtAuKuoVXqA&amp;quot; \&lt;br /&gt;
-d '&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;participant_id&amp;quot;: &amp;quot;3&amp;quot;,&lt;br /&gt;
  &amp;quot;questionnaire_id&amp;quot;: &amp;quot;8&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
'&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png&amp;diff=151800</id>
		<title>File:CSC517Fall2023 E2376 Convert cURL RubyMine .png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC517Fall2023_E2376_Convert_cURL_RubyMine_.png&amp;diff=151800"/>
		<updated>2023-11-28T14:59:12Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151799</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151799"/>
		<updated>2023-11-28T14:56:22Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Database Setup and Using HTTP Requests cURL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;br /&gt;
&lt;br /&gt;
==== 5. Start the Server ====&lt;br /&gt;
At this point we can start the server to issue cURL commands once the server is running.&lt;br /&gt;
Start rails server on port 3002&lt;br /&gt;
* rails s -p 3002&lt;br /&gt;
&lt;br /&gt;
=== cURL Instructor Required Setup ===&lt;br /&gt;
==== 1. Login as an Instructor and Get Bearer Token ====&lt;br /&gt;
Get bearer token first (for instructor):&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d '{&amp;quot;user_name&amp;quot;: &amp;quot;instructor&amp;quot;, &amp;quot;password&amp;quot;: &amp;quot;password123&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
Note:  You can use curl commands from the Windows command prompt, but you cannot use single quotes.  For example the above JSON command must be written for Windows:&lt;br /&gt;
* curl -X POST http://localhost:3002/login -H &amp;quot;Content-Type: application/json&amp;quot; -d “{\&amp;quot;user_name\&amp;quot;: \&amp;quot;instructor\&amp;quot;, \&amp;quot;password\&amp;quot;: \&amp;quot;password123\&amp;quot;}”&lt;br /&gt;
&lt;br /&gt;
Also, RubyMine has an option to construct HTTP requests from cURL commands.&lt;br /&gt;
Tools-&amp;gt;HTTP Client-&amp;gt;Convert cURL to HTTP Request&lt;br /&gt;
&lt;br /&gt;
Issuing the HTTP requests will return a Bearer Token that must be included while accessing other pages as an Instructor&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151798</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151798"/>
		<updated>2023-11-28T14:49:24Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== student_quizzes_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
=== Database Setup and Using HTTP Requests cURL ===&lt;br /&gt;
==== 1. Create an Institution ====&lt;br /&gt;
Open shell on the mysql server and run:&lt;br /&gt;
* mysql -u dev -pexpertiza&lt;br /&gt;
* use reimplementation_development;&lt;br /&gt;
&lt;br /&gt;
Then run the followinginsert command:&lt;br /&gt;
* INSERT INTO institutions (name, created_at, updated_at) VALUES ('North Carolina State University', NOW(), NOW());&lt;br /&gt;
&lt;br /&gt;
==== 2. Obtain an Encrypted Password ====&lt;br /&gt;
Open a new terminal in the container reimplementation-back-end-app and run the following commands&lt;br /&gt;
* rails console&lt;br /&gt;
* BCrypt::Password.create('password123')&lt;br /&gt;
&lt;br /&gt;
You should obtain a string like the following:&lt;br /&gt;
'$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG'&lt;br /&gt;
&lt;br /&gt;
This will be placed as the password in the next step.&lt;br /&gt;
&lt;br /&gt;
==== 3. Create an Admin User ====&lt;br /&gt;
Now, in the mysql terminal run the following (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('admin', 'admin2@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 1, NOW(), NOW(), 'admin admin', 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Instructor User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('instructor', 'instructor@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 3, NOW(), NOW(), 'instructor instructor’, 1);&lt;br /&gt;
&lt;br /&gt;
==== 4. Create an Student User ====&lt;br /&gt;
Repeat step 2 for an Instructor.  You will receive a different key generation even though the password is the same. (replacing the ‘$2a…’ with the one generated in step 2)&lt;br /&gt;
* INSERT INTO users (name, email, password_digest, role_id, created_at, updated_at, full_name, institution_id) VALUES ('student', 'student@example.com', '$2a$12$TWct/jRMKbb1Pm1NtxKmPuAkk8IOIHnJyBaU4eiMQ5MjV41Se0AXG', 5, NOW(), NOW(), 'student student', 1);&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151797</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151797"/>
		<updated>2023-11-28T14:38:33Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Instructor shall create a test&lt;br /&gt;
* Only a Participating Student shall take the quiz&lt;br /&gt;
* The JSON response of a Student taking a quiz shall be the score&lt;br /&gt;
* The Student shall be able to look at score of previous responses&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151656</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151656"/>
		<updated>2023-11-16T03:08:25Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  &lt;br /&gt;
&lt;br /&gt;
A student can author a Questionnaire composed of many Questions.  &lt;br /&gt;
&lt;br /&gt;
The student_quizzes_controller shall assign a Questionnaire to a reviewing student that is not the author.  The reviewing student shall take the quiz by answering the Questions in the chosen Questionnaire.  The reviewing student will submit their answers and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151653</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151653"/>
		<updated>2023-11-16T03:05:21Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.  A student can submit a Questionnaire composed of many Questions.  The student_quizzes_controller shall assign a Questionnaire to a test-taking student that is not the author.  The test-taking student shall take the quiz and receive a score upon finishing.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151650</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151650"/>
		<updated>2023-11-16T03:00:15Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Issues with Previous Functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcome. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151648</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151648"/>
		<updated>2023-11-16T02:56:55Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza system, a modular and multifunctional platform, empowers students to seamlessly submit assignments and quizzes while facilitating collaborative learning through features like peer review. Widely embraced by students, assistants, and professors, this advanced system streamlines academic assessments, fostering an efficient and interactive educational experience. &lt;br /&gt;
&lt;br /&gt;
The main goal of student quizzes module is to give an environment for students to create quizzes for other students with same assignments, giving them a chance to learn in a collaborative setting where they can collectively enhance their understanding and support each other's learning journey.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Student quizzes are currently a discontinued function from Expertiza. This module orginally interacted with many other components such as questions and questionnaires. The complex structure along with faulty coding practices has resulted in a vulnerable and error prone system. With reimplementing student quizzes we believe many of those problems can be overcame. &lt;br /&gt;
&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The student_quizzes_controller is responsible for creating, scoring, and recording responses to quizzes of reviewers.  Reviewers are students of other teams with the same assignment.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza student quizzes will adhere to a test-driven design methodology. This means that we will be utilizing the test skeletons provided to us and tests for each component of the student quizzes module before implementing the corresponding functionalities. By following this rigorous testing approach, we ensure a reliable and thoroughly validated system, enhancing the overall quality and robustness of the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Create: This operation involves the creation of new student quizzes, allowing instructors to input question numbers, set parameters, and establish quiz details. Currently, student_quizzes_controller does not have a direct create method.&lt;br /&gt;
&lt;br /&gt;
* Read: Enables users to retrieve and view existing student quizzes, accessing details such as questions, answers, and associated information for review or analysis. Currently, student_quizzes_controller does not have a direct read method.&lt;br /&gt;
&lt;br /&gt;
* Update: This operation allows users to modify or update student quizzes. It includes functionalities such as adjusting quiz parameters to keep content current and relevant. Currently, student_quizzes_controller does not have a direct update method.&lt;br /&gt;
&lt;br /&gt;
* Delete: Involves the removal of unwanted or outdated student quizzes, giving instructors the ability to manage and maintain the database of quizzes efficiently. Currently, student_quizzes_controller does not have a direct delete method.&lt;br /&gt;
&lt;br /&gt;
* Index: Index function is part of a controller action responsible for displaying information related to an assignment participant, their associated assignment, and quiz mappings for review. The code does currently have an index function, but the function will be optimized and made clearer for ease of understanding.&lt;br /&gt;
&lt;br /&gt;
* Calculate score: Calculate score function calculates the score of the participant by comparing the answers given by the users with the actual correct answers. This method will be optimized and edited to increase robustness.  This will be a private method.&lt;br /&gt;
&lt;br /&gt;
* Other functions: Currently Student quizzes have many functions, while some of them are useful and beneficial, some of them can be edited, moved or reimplemented to follow SOLID and DRY principles.  Other methods added to the controller outside of CRUD methods will be private methods.&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151307</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151307"/>
		<updated>2023-11-14T17:42:26Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
=== Issues with Previous Functionality ===&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
&lt;br /&gt;
=== Controller ===&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
&lt;br /&gt;
==== Read ====&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions performed ==&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151306</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151306"/>
		<updated>2023-11-14T17:40:47Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
=== Issues with Previous Functionality ===&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
* Test Driven Development (TDD) was not followed and tests created after the code.  The code being in a unknown state led to tests that passed possibly buggy code.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions performed ==&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151303</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151303"/>
		<updated>2023-11-14T17:38:05Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the student quizzes controller found in student_quizzes_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
=== Issues with Previous Functionality ===&lt;br /&gt;
Previous implementations of student quizzes were difficult to understand due to:&lt;br /&gt;
* The controller not following CRUD methodology&lt;br /&gt;
* The controller using vague names for variables.&lt;br /&gt;
* Difficulty in setting up a sample quiz and testing&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions performed ==&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151295</id>
		<title>CSC/ECE 517 Fall 2023 - E2376. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2376._Reimplement_student_quizzes_controller.rb&amp;diff=151295"/>
		<updated>2023-11-14T17:30:13Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: Created page with &amp;quot;== Problem Statement==  === Issues with previous functionality ===   == Solution ==   == Design ==  === Achieved Design Goals ===   === UML Diagram ===    === Class Diagram ==...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement==&lt;br /&gt;
&lt;br /&gt;
=== Issues with previous functionality ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Achieved Design Goals ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Diagram ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions performed ==&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151294</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151294"/>
		<updated>2023-11-14T17:28:40Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2352. Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2376. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2383. Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2350. Add GitLab support for using GraphQL to query user metrics 1]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2352. Add GitLab support for using GraphQL to query repository information]]&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150652</id>
		<title>CSC/ECE 517 Fall 2023 - E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150652"/>
		<updated>2023-10-30T22:49:16Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Modifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are quizzes students create after the submission of their assignment on Expertiza application. Student quizzes can consist of multiple answered checkbox questions, classic multiple choice questions and true false questions. The number of questions that can should be on the quiz is predetermined by the instructor when the assignment is created.&lt;br /&gt;
&lt;br /&gt;
Unfortunately due to a decision that is made during Spring Semester 2023, quiz function is eliminated from Expertiza, the web portal was not functional. Nevertheless the existing code was refactored according to the previous comments and tests has been completed with Rspec.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;When the project was pulled from the main repository, test plans were not previously present for student_quizzes_controller.rb. &lt;br /&gt;
Within the scope of TDD research, we have opted to have the test skeletons by Mustafa Olmez, which has given us a very good idea on the tests that should be integrated for our unit. 29 of the test skeletons were integrated into the our work allowing us to test the controller profoundly. The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory already existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
The following modifications have been made on app/controllers/student_quizzes_controller.rb&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** &amp;quot;valid&amp;quot; boolean is turned to valid_flag in order to emphasize it is a flag for checking validity of the answer&lt;br /&gt;
** questionnaire has been refactored into quiz emphasize it's usage in the program.&lt;br /&gt;
** ques_type is refactored into question_type for extra clarity&lt;br /&gt;
** new_score is refactored into each_answer_score to clarify its specific usage&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** response has been refactored to participant_response&lt;br /&gt;
** questions has been refactored to quiz_questions&lt;br /&gt;
** Additional comment for the usage of reponse is added, clarifying the previous comment asking about its usage.&lt;br /&gt;
* Explanatory comments have been added to self.take_quiz since previous feedback stated its usage was unclear.&lt;br /&gt;
* Grammatically incorrect comments have been corrected throughout the document.&lt;br /&gt;
&lt;br /&gt;
Some of the requested comments from the project description were outdated and/or already updated. Please check our Github page for further comments.&lt;br /&gt;
https://github.com/SteveEaston/expertiza&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
For our project we have managed to correct or respond all of the addressed concerns given to us in our project description. Furthermore by using the test skeletons given to us we have managed to test conduct thorough unit testing for our controller. &lt;br /&gt;
&lt;br /&gt;
The following pull request was found among in the main repository of Expertiza, which shows the quiz functionality was discontinued and removed from expertiza.&lt;br /&gt;
&lt;br /&gt;
https://github.com/expertiza/expertiza/pull/2340&lt;br /&gt;
&lt;br /&gt;
Due to the function being discontinued we have not been able to observe the functionality directly on Expertiza itself, nevertheless using the wide range of test skeletons provided to us we have managed to ensure the module would be up and running when and if the integration issues were to be resolved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150650</id>
		<title>CSC/ECE 517 Fall 2023 - E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150650"/>
		<updated>2023-10-30T22:47:54Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Modifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are quizzes students create after the submission of their assignment on Expertiza application. Student quizzes can consist of multiple answered checkbox questions, classic multiple choice questions and true false questions. The number of questions that can should be on the quiz is predetermined by the instructor when the assignment is created.&lt;br /&gt;
&lt;br /&gt;
Unfortunately due to a decision that is made during Spring Semester 2023, quiz function is eliminated from Expertiza, the web portal was not functional. Nevertheless the existing code was refactored according to the previous comments and tests has been completed with Rspec.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;When the project was pulled from the main repository, test plans were not previously present for student_quizzes_controller.rb. &lt;br /&gt;
Within the scope of TDD research, we have opted to have the test skeletons by Mustafa Olmez, which has given us a very good idea on the tests that should be integrated for our unit. 29 of the test skeletons were integrated into the our work allowing us to test the controller profoundly. The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory already existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
The following modifications have been made on app/controllers/student_quizzes_controller.rb&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** &amp;quot;valid&amp;quot; boolean is turned to valid_flag in order to emphasize it is a flag for checking validity of the answer&lt;br /&gt;
** questionnaire has been refactored into quiz emphasize it's usage in the program.&lt;br /&gt;
** ques_type is refactored into question_type for extra clarity&lt;br /&gt;
** new_score is refactored into each_answer_score to clarify its specific usage&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** response has been refactored to participant_response&lt;br /&gt;
** questions has been refactored to quiz_questions&lt;br /&gt;
** Additional comment for the usage of reponse is added, clarifying the previous comment asking about its usage.&lt;br /&gt;
* Explanatory comments have been added to self.take_quiz since previous feedback stated its usage was unclear.&lt;br /&gt;
* Grammatically incorrect comments have been corrected throughout the document.&lt;br /&gt;
&lt;br /&gt;
Some of the requested comments from the project description were outdated and/or already updated. Please check our Github page for further comments.&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
For our project we have managed to correct or respond all of the addressed concerns given to us in our project description. Furthermore by using the test skeletons given to us we have managed to test conduct thorough unit testing for our controller. &lt;br /&gt;
&lt;br /&gt;
The following pull request was found among in the main repository of Expertiza, which shows the quiz functionality was discontinued and removed from expertiza.&lt;br /&gt;
&lt;br /&gt;
https://github.com/expertiza/expertiza/pull/2340&lt;br /&gt;
&lt;br /&gt;
Due to the function being discontinued we have not been able to observe the functionality directly on Expertiza itself, nevertheless using the wide range of test skeletons provided to us we have managed to ensure the module would be up and running when and if the integration issues were to be resolved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150649</id>
		<title>CSC/ECE 517 Fall 2023 - E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2358._Refactor_student_quizzes_controller.rb&amp;diff=150649"/>
		<updated>2023-10-30T22:46:55Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are quizzes students create after the submission of their assignment on Expertiza application. Student quizzes can consist of multiple answered checkbox questions, classic multiple choice questions and true false questions. The number of questions that can should be on the quiz is predetermined by the instructor when the assignment is created.&lt;br /&gt;
&lt;br /&gt;
Unfortunately due to a decision that is made during Spring Semester 2023, quiz function is eliminated from Expertiza, the web portal was not functional. Nevertheless the existing code was refactored according to the previous comments and tests has been completed with Rspec.&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;When the project was pulled from the main repository, test plans were not previously present for student_quizzes_controller.rb. &lt;br /&gt;
Within the scope of TDD research, we have opted to have the test skeletons by Mustafa Olmez, which has given us a very good idea on the tests that should be integrated for our unit. 29 of the test skeletons were integrated into the our work allowing us to test the controller profoundly. The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory already existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
The following modifications have been made on app/controllers/student_quizzes_controller.rb&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** &amp;quot;valid&amp;quot; boolean is turned to valid_flag in order to emphasize it is a flag for checking validity of the answer&lt;br /&gt;
** questionnaire has been refactored into quiz emphasize it's usage in the program.&lt;br /&gt;
** ques_type is refactored into question_type for extra clarify&lt;br /&gt;
** new_score is refactored into each_answer_score to clarify its specific usage&lt;br /&gt;
* Following comments have been added to calculate_score:&lt;br /&gt;
** response has been refactored to participant_response&lt;br /&gt;
** questions has been refactored to quiz_questions&lt;br /&gt;
** Additional comment for the usage of reponse is added, clarifying the previous comment asking about its usage.&lt;br /&gt;
* Explanatory comments have been added to self.take_quiz since previous feedback stated its usage was unclear.&lt;br /&gt;
* Grammatically incorrect comments have been corrected throughout the document.&lt;br /&gt;
&lt;br /&gt;
Some of the requested comments from the project description were outdated and/or already updated. Please check our Github page for further comments. &lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
For our project we have managed to correct or respond all of the addressed concerns given to us in our project description. Furthermore by using the test skeletons given to us we have managed to test conduct thorough unit testing for our controller. &lt;br /&gt;
&lt;br /&gt;
The following pull request was found among in the main repository of Expertiza, which shows the quiz functionality was discontinued and removed from expertiza.&lt;br /&gt;
&lt;br /&gt;
https://github.com/expertiza/expertiza/pull/2340&lt;br /&gt;
&lt;br /&gt;
Due to the function being discontinued we have not been able to observe the functionality directly on Expertiza itself, nevertheless using the wide range of test skeletons provided to us we have managed to ensure the module would be up and running when and if the integration issues were to be resolved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150430</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150430"/>
		<updated>2023-10-29T15:11:30Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
What do we make of this capture?&lt;br /&gt;
[[File:ECE517_Fall_2023_E2558_Remove_Quiz_Functionality_Expertiza.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150429</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150429"/>
		<updated>2023-10-29T15:11:10Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
What do we make of this capture?&lt;br /&gt;
[[ECE517_Fall_2023_E2558_Remove_Quiz_Functionality_Expertiza.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ECE517_Fall_2023_E2558_Remove_Quiz_Functionality_Expertiza.jpg&amp;diff=150428</id>
		<title>File:ECE517 Fall 2023 E2558 Remove Quiz Functionality Expertiza.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ECE517_Fall_2023_E2558_Remove_Quiz_Functionality_Expertiza.jpg&amp;diff=150428"/>
		<updated>2023-10-29T15:09:30Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150427</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150427"/>
		<updated>2023-10-29T15:05:59Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150426</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150426"/>
		<updated>2023-10-29T15:05:38Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&amp;lt;nowiki&amp;gt;We found that a factory existed for student quizzes.  Much of the work previously found in the quiz_factory was incorporated into the RSpec controller tests. &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150425</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150425"/>
		<updated>2023-10-29T15:00:13Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: &amp;lt;/nowiki&amp;gt; &amp;lt;br&amp;gt;https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150424</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150424"/>
		<updated>2023-10-29T14:59:30Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.  The complete file can be found here: https://github.com/expertiza/expertiza/pull/2656/files#diff-06772dc7cd41f4d09fb403ddcc22137ade6308cb87ec53d82bf7664300c4eef7&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150423</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150423"/>
		<updated>2023-10-29T14:55:58Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications==&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150422</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150422"/>
		<updated>2023-10-29T14:55:11Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Test plans did not exist for student_quizzes_controller.rb when we started the project.  A test skeleton was created by Mustafa Olmez and integrated into the our work.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150421</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150421"/>
		<updated>2023-10-28T20:24:59Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;Student Quizzes are...&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;There were not any tests for this controller.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150420</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150420"/>
		<updated>2023-10-28T20:23:57Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;The User model is a crucial component of the Expertiza application, managing user data and authentication/authorization. It has 9 class methods, 23 instance methods, and is linked with other models for personalized user experience. The user controller is smaller but could benefit from refactoring and improved comments.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;There were not any tests for this controller.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150419</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150419"/>
		<updated>2023-10-28T20:23:21Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;The User model is a crucial component of the Expertiza application, managing user data and authentication/authorization. It has 9 class methods, 23 instance methods, and is linked with other models for personalized user experience. The user controller is smaller but could benefit from refactoring and improved comments.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;There were not any tests for this controller.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request https://github.com/expertiza/expertiza/pull/2656&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150418</id>
		<title>E2358. Refactor student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2358._Refactor_student_quizzes_controller.rb&amp;diff=150418"/>
		<updated>2023-10-28T20:22:41Z</updated>

		<summary type="html">&lt;p&gt;Sleaston: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;The User model is a crucial component of the Expertiza application, managing user data and authentication/authorization. It has 9 class methods, 23 instance methods, and is linked with other models for personalized user experience. The user controller is smaller but could benefit from refactoring and improved comments.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
==New Files==&lt;br /&gt;
#spec/controllers/student_quizzes_controller_spec.rb&lt;br /&gt;
==File Changes==&lt;br /&gt;
#app/controllers/student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan==&lt;br /&gt;
&amp;lt;nowiki&amp;gt;There were not any tests for this controller.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Rain Bayraktar &amp;lt;ybbayrak@ncsu.edu&amp;gt;&lt;br /&gt;
Steve Easton &amp;lt;sleaston@ncsu.edu&amp;gt;&lt;br /&gt;
Scott Hardin &amp;lt;shardin2@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Changes for this project are under Expertiza Pull Request [https://github.com/expertiza/expertiza/pull/2656|2656]&lt;/div&gt;</summary>
		<author><name>Sleaston</name></author>
	</entry>
</feed>