<?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=Kgudipe</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=Kgudipe"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Kgudipe"/>
	<updated>2026-06-30T03:55:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2026&amp;diff=167559</id>
		<title>CSC/ECE 517 Spring 2026</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2026&amp;diff=167559"/>
		<updated>2026-03-25T18:52:35Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2026 - E2602. Reimplement student task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2026 - E2604. Finish Password Resets]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156973</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156973"/>
		<updated>2024-04-30T17:02:41Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: /* &amp;quot;Assignment of a particular Participant Method&amp;quot; Commit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
=Implementation of Participants Controller=&lt;br /&gt;
&lt;br /&gt;
The Participants Controller is designed to handle various interactions with participant data within an application, providing a range of RESTful actions. This controller facilitates operations such as listing all participants, retrieving specific participant details, and creating, updating, or deleting participant records, all through JSON responses suitable for API usage. It includes actions that are traditionally used in view-based controllers (such as new and edit) to instantiate and prepare participants for creation or editing. Additionally, the controller offers a specialized action to fetch and render a participant's assignment, enhancing its functionality by addressing specific data retrieval needs. It also implements global error handling for missing records, ensuring that all actions gracefully handle cases where participants are not found. This comprehensive approach makes the controller a central part of the participant management system in the application, equipped to handle both standard CRUD operations and specific relational data accesses in a structured and efficient manner.&lt;br /&gt;
&lt;br /&gt;
==Implemented methods==&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Create Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
   def create&lt;br /&gt;
      @participant = Participant.new(participant_params)&lt;br /&gt;
      if @participant.save&lt;br /&gt;
        render json: @participant, status: :created&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Read Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
    &lt;br /&gt;
    def index&lt;br /&gt;
      @participants = Participant.all&lt;br /&gt;
      render json: { participants: @participants }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Update Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def update&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      if @participant.update(participant_params)&lt;br /&gt;
        render json: { participant: @participant }, status: :ok&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Delete Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def destroy&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      @participant.destroy&lt;br /&gt;
      render json: { message: &amp;quot;Participant was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Participants of a particular assignment Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/b3647df49ee0a2863d9afe23b6711680650e9e25 Commit]====&lt;br /&gt;
&lt;br /&gt;
  def fetch_participants_for_assignment&lt;br /&gt;
    participants = Participant.where(assignment_id: params[:assignment_id])&lt;br /&gt;
    render json: participants, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fetch_participants_for_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Assignment of a particular Participant Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/dda3fba2d9ae2dacf1d5ad638d57e2189b17e781 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def fetch_assignment_for_participant&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        assignment = participant.assignment&lt;br /&gt;
    &lt;br /&gt;
        render json: assignment, status: :ok&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: { error: &amp;quot;Participant not found&amp;quot; }, status: :not_found&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fetch_assignment_for_participant&amp;lt;/code&amp;gt; method is designed to retrieve the assignment associated with a specific participant. It takes a participant ID from the request parameters, finds the corresponding participant record, and accesses its associated assignment. The assignment data is then rendered as a JSON object.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=Testing Plan=&lt;br /&gt;
We employ a combination of manual testing with tools like Postman, automated testing through RSpec, and API documentation and testing using Swagger. This comprehensive approach allows us to validate our API's functionality, security, and usability across various scenarios.&lt;br /&gt;
&lt;br /&gt;
==Manual testing with Postman==&lt;br /&gt;
&lt;br /&gt;
We are using Postman to test our APIs during the development process.&lt;br /&gt;
Below are few examples:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/participants: Endpoint to test the fetching of all Participants.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:GET.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.1 Postman UI displaying API testing to fetch all Participant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/participants: Endpoint to test the creation of a Participant.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:POST.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.2 Postman UI displaying API testing to create a Partcipant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PATCH api/v1/participants/4: Endpoint to test the functionality of updating Participant using its ID.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PATCH.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.3 Postman UI displaying API testing to update a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DELETE api/v1/participants/4: Endpoint to test the functionality of deleting a Participant with participant id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:DELETE.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.4 Postman UI displaying API testing to delete a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/assignments/1/participants: Endpoint to test the functionality of fetching a participant using assignment Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch a participant using assignment Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/participants/1/assignment: Endpoint to test the functionality of fetching an assignment using participant Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Participant Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch an assignment using participant Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Automated Testing with Rspec==&lt;br /&gt;
====Scenario 1: Creating a New Participant====&lt;br /&gt;
Validates the creation of a new Participant with appropriate parameters. &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 201 Created status and a JSON response with the created participant details.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;creates a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: attributes_for(:participant) }&lt;br /&gt;
        }.to change(Participant, :count).by(1)&lt;br /&gt;
        expect(response).to have_http_status(:created)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Handling Invalid Participant Creation====&lt;br /&gt;
Tests the creation process with invalid parameters to ensure robust error handling.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation&amp;lt;/b&amp;gt;: Expects a 400 Bad Request status and an error message detailing the invalid parameters.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not create a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: { user_id: nil } } &lt;br /&gt;
        }.to change(Participant, :count).by(0)&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Fetch a Participant who is not in the database====&lt;br /&gt;
Checks the behaviour when attempting to fetch a Participant not present in the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns a not found status&amp;quot; do&lt;br /&gt;
        get :show, params: { id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Fetching an Assignment of a particular Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of a particular Participant Id&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 Ok status with the assignment of the participant.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;#participant_assignment&amp;quot; do&lt;br /&gt;
    context &amp;quot;when participant exists&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns the assignment of the participant&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: participant.id }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 5: Fetching an Assignment of an invalid Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of an Invalid Participant Id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status status.&lt;br /&gt;
&lt;br /&gt;
 context &amp;quot;when participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns not found status&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 6: Updating a Participant====&lt;br /&gt;
Ensures that an existing participant can be updated with valid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 OK status and the updated participant details in the response.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;PATCH/PUT #update&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;updates the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { type: &amp;quot;NewType&amp;quot; } }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 7: Updating a Participant====&lt;br /&gt;
Checks the behavior when attempting to update a participant with invalid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 422 Unprocessable Entity status and an error message detailing the issue.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not update the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { user_id: nil } }&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==API Documentation and Testing with Swagger==&lt;br /&gt;
To provide clear, interactive API documentation, facilitating easy understanding and testing of API endpoints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Setup:&amp;lt;/b&amp;gt; Integrate Swagger with Rails application using gems like rswag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Documentation:&amp;lt;/b&amp;gt; Annotate the API code to generate Swagger documentation automatically. Ensure that each endpoint is clearly described, with information on parameters, request bodies, and response schemas.&lt;br /&gt;
Interactive Testing: Use the Swagger UI to interactively test API endpoints directly from the browser, providing an easy way for non-developers to understand and verify API functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;[[File:SWAGGER.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;i&amp;gt;Fig 5.3 Swagger UI displaying API documentation and interactive testing interface for Participants endpoints.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Relevant Links=&lt;br /&gt;
* '''Github Repository:''' https://github.com/achitti2812/expertiza_project4&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/105&lt;br /&gt;
* '''Test Video Link:''' https://youtu.be/hwGuzbqcyjQ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156972</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156972"/>
		<updated>2024-04-30T17:02:13Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: /* &amp;quot;Participants of a particular assignment Method&amp;quot; Commit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
=Implementation of Participants Controller=&lt;br /&gt;
&lt;br /&gt;
The Participants Controller is designed to handle various interactions with participant data within an application, providing a range of RESTful actions. This controller facilitates operations such as listing all participants, retrieving specific participant details, and creating, updating, or deleting participant records, all through JSON responses suitable for API usage. It includes actions that are traditionally used in view-based controllers (such as new and edit) to instantiate and prepare participants for creation or editing. Additionally, the controller offers a specialized action to fetch and render a participant's assignment, enhancing its functionality by addressing specific data retrieval needs. It also implements global error handling for missing records, ensuring that all actions gracefully handle cases where participants are not found. This comprehensive approach makes the controller a central part of the participant management system in the application, equipped to handle both standard CRUD operations and specific relational data accesses in a structured and efficient manner.&lt;br /&gt;
&lt;br /&gt;
==Implemented methods==&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Create Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
   def create&lt;br /&gt;
      @participant = Participant.new(participant_params)&lt;br /&gt;
      if @participant.save&lt;br /&gt;
        render json: @participant, status: :created&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Read Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
    &lt;br /&gt;
    def index&lt;br /&gt;
      @participants = Participant.all&lt;br /&gt;
      render json: { participants: @participants }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Update Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def update&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      if @participant.update(participant_params)&lt;br /&gt;
        render json: { participant: @participant }, status: :ok&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Delete Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def destroy&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      @participant.destroy&lt;br /&gt;
      render json: { message: &amp;quot;Participant was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Participants of a particular assignment Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/b3647df49ee0a2863d9afe23b6711680650e9e25 Commit]====&lt;br /&gt;
&lt;br /&gt;
  def fetch_participants_for_assignment&lt;br /&gt;
    participants = Participant.where(assignment_id: params[:assignment_id])&lt;br /&gt;
    render json: participants, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fetch_participants_for_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Assignment of a particular Participant Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/dda3fba2d9ae2dacf1d5ad638d57e2189b17e781 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def participant_assignment&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        assignment = participant.assignment&lt;br /&gt;
    &lt;br /&gt;
        render json: assignment, status: :ok&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: { error: &amp;quot;Participant not found&amp;quot; }, status: :not_found&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participant_assignment&amp;lt;/code&amp;gt; method is designed to retrieve the assignment associated with a specific participant. It takes a participant ID from the request parameters, finds the corresponding participant record, and accesses its associated assignment. The assignment data is then rendered as a JSON object. &lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=Testing Plan=&lt;br /&gt;
We employ a combination of manual testing with tools like Postman, automated testing through RSpec, and API documentation and testing using Swagger. This comprehensive approach allows us to validate our API's functionality, security, and usability across various scenarios.&lt;br /&gt;
&lt;br /&gt;
==Manual testing with Postman==&lt;br /&gt;
&lt;br /&gt;
We are using Postman to test our APIs during the development process.&lt;br /&gt;
Below are few examples:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/participants: Endpoint to test the fetching of all Participants.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:GET.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.1 Postman UI displaying API testing to fetch all Participant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/participants: Endpoint to test the creation of a Participant.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:POST.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.2 Postman UI displaying API testing to create a Partcipant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PATCH api/v1/participants/4: Endpoint to test the functionality of updating Participant using its ID.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PATCH.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.3 Postman UI displaying API testing to update a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DELETE api/v1/participants/4: Endpoint to test the functionality of deleting a Participant with participant id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:DELETE.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.4 Postman UI displaying API testing to delete a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/assignments/1/participants: Endpoint to test the functionality of fetching a participant using assignment Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch a participant using assignment Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/participants/1/assignment: Endpoint to test the functionality of fetching an assignment using participant Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Participant Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch an assignment using participant Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Automated Testing with Rspec==&lt;br /&gt;
====Scenario 1: Creating a New Participant====&lt;br /&gt;
Validates the creation of a new Participant with appropriate parameters. &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 201 Created status and a JSON response with the created participant details.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;creates a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: attributes_for(:participant) }&lt;br /&gt;
        }.to change(Participant, :count).by(1)&lt;br /&gt;
        expect(response).to have_http_status(:created)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Handling Invalid Participant Creation====&lt;br /&gt;
Tests the creation process with invalid parameters to ensure robust error handling.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation&amp;lt;/b&amp;gt;: Expects a 400 Bad Request status and an error message detailing the invalid parameters.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not create a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: { user_id: nil } } &lt;br /&gt;
        }.to change(Participant, :count).by(0)&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Fetch a Participant who is not in the database====&lt;br /&gt;
Checks the behaviour when attempting to fetch a Participant not present in the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns a not found status&amp;quot; do&lt;br /&gt;
        get :show, params: { id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Fetching an Assignment of a particular Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of a particular Participant Id&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 Ok status with the assignment of the participant.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;#participant_assignment&amp;quot; do&lt;br /&gt;
    context &amp;quot;when participant exists&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns the assignment of the participant&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: participant.id }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 5: Fetching an Assignment of an invalid Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of an Invalid Participant Id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status status.&lt;br /&gt;
&lt;br /&gt;
 context &amp;quot;when participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns not found status&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 6: Updating a Participant====&lt;br /&gt;
Ensures that an existing participant can be updated with valid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 OK status and the updated participant details in the response.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;PATCH/PUT #update&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;updates the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { type: &amp;quot;NewType&amp;quot; } }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 7: Updating a Participant====&lt;br /&gt;
Checks the behavior when attempting to update a participant with invalid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 422 Unprocessable Entity status and an error message detailing the issue.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not update the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { user_id: nil } }&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==API Documentation and Testing with Swagger==&lt;br /&gt;
To provide clear, interactive API documentation, facilitating easy understanding and testing of API endpoints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Setup:&amp;lt;/b&amp;gt; Integrate Swagger with Rails application using gems like rswag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Documentation:&amp;lt;/b&amp;gt; Annotate the API code to generate Swagger documentation automatically. Ensure that each endpoint is clearly described, with information on parameters, request bodies, and response schemas.&lt;br /&gt;
Interactive Testing: Use the Swagger UI to interactively test API endpoints directly from the browser, providing an easy way for non-developers to understand and verify API functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;[[File:SWAGGER.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;i&amp;gt;Fig 5.3 Swagger UI displaying API documentation and interactive testing interface for Participants endpoints.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Relevant Links=&lt;br /&gt;
* '''Github Repository:''' https://github.com/achitti2812/expertiza_project4&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/105&lt;br /&gt;
* '''Test Video Link:''' https://youtu.be/hwGuzbqcyjQ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156044</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb&amp;diff=156044"/>
		<updated>2024-04-23T17:29:00Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Created page with &amp;quot;__TOC__  ==Expertiza== [http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
=Implementation of Participants Controller=&lt;br /&gt;
&lt;br /&gt;
The Participants Controller is designed to handle various interactions with participant data within an application, providing a range of RESTful actions. This controller facilitates operations such as listing all participants, retrieving specific participant details, and creating, updating, or deleting participant records, all through JSON responses suitable for API usage. It includes actions that are traditionally used in view-based controllers (such as new and edit) to instantiate and prepare participants for creation or editing. Additionally, the controller offers a specialized action to fetch and render a participant's assignment, enhancing its functionality by addressing specific data retrieval needs. It also implements global error handling for missing records, ensuring that all actions gracefully handle cases where participants are not found. This comprehensive approach makes the controller a central part of the participant management system in the application, equipped to handle both standard CRUD operations and specific relational data accesses in a structured and efficient manner.&lt;br /&gt;
&lt;br /&gt;
==Implemented methods==&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Create Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
   def create&lt;br /&gt;
      @participant = Participant.new(participant_params)&lt;br /&gt;
      if @participant.save&lt;br /&gt;
        render json: @participant, status: :created&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Read Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
    &lt;br /&gt;
    def index&lt;br /&gt;
      @participants = Participant.all&lt;br /&gt;
      render json: { participants: @participants }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Update Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def update&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      if @participant.update(participant_params)&lt;br /&gt;
        render json: { participant: @participant }, status: :ok&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Delete Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def destroy&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      @participant.destroy&lt;br /&gt;
      render json: { message: &amp;quot;Participant was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Participants of a particular assignment Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/b3647df49ee0a2863d9afe23b6711680650e9e25 Commit]====&lt;br /&gt;
&lt;br /&gt;
  def assignment_participants&lt;br /&gt;
    participants = Participant.where(assignment_id: params[:assignment_id])&lt;br /&gt;
    render json: participants, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;assignment_participants&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Assignment of a particular Participant Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/dda3fba2d9ae2dacf1d5ad638d57e2189b17e781 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def participant_assignment&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        assignment = participant.assignment&lt;br /&gt;
    &lt;br /&gt;
        render json: assignment, status: :ok&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: { error: &amp;quot;Participant not found&amp;quot; }, status: :not_found&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participant_assignment&amp;lt;/code&amp;gt; method is designed to retrieve the assignment associated with a specific participant. It takes a participant ID from the request parameters, finds the corresponding participant record, and accesses its associated assignment. The assignment data is then rendered as a JSON object. &lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=Testing Plan=&lt;br /&gt;
We employ a combination of manual testing with tools like Postman, automated testing through RSpec, and API documentation and testing using Swagger. This comprehensive approach allows us to validate our API's functionality, security, and usability across various scenarios.&lt;br /&gt;
&lt;br /&gt;
==Manual testing with Postman==&lt;br /&gt;
&lt;br /&gt;
We are using Postman to test our APIs during the development process.&lt;br /&gt;
Below are few examples:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/participants: Endpoint to test the fetching of all Participants.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:GET.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.1 Postman UI displaying API testing to fetch all Participant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/participants: Endpoint to test the creation of a Participant.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:POST.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.2 Postman UI displaying API testing to create a Partcipant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PATCH api/v1/participants/4: Endpoint to test the functionality of updating Participant using its ID.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PATCH.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.3 Postman UI displaying API testing to update a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DELETE api/v1/participants/4: Endpoint to test the functionality of deleting a Participant with participant id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:DELETE.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.4 Postman UI displaying API testing to delete a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/assignments/1/participants: Endpoint to test the functionality of fetching a participant using assignment Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch a participant using assignment Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/participants/1/assignment: Endpoint to test the functionality of fetching an assignment using participant Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Participant Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch an assignment using participant Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Automated Testing with Rspec==&lt;br /&gt;
====Scenario 1: Creating a New Participant====&lt;br /&gt;
Validates the creation of a new Participant with appropriate parameters. &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 201 Created status and a JSON response with the created participant details.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;creates a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: attributes_for(:participant) }&lt;br /&gt;
        }.to change(Participant, :count).by(1)&lt;br /&gt;
        expect(response).to have_http_status(:created)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Handling Invalid Participant Creation====&lt;br /&gt;
Tests the creation process with invalid parameters to ensure robust error handling.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation&amp;lt;/b&amp;gt;: Expects a 400 Bad Request status and an error message detailing the invalid parameters.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not create a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: { user_id: nil } } &lt;br /&gt;
        }.to change(Participant, :count).by(0)&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Fetch a Participant who is not in the database====&lt;br /&gt;
Checks the behaviour when attempting to fetch a Participant not present in the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns a not found status&amp;quot; do&lt;br /&gt;
        get :show, params: { id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Fetching an Assignment of a particular Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of a particular Participant Id&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 Ok status with the assignment of the participant.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;#participant_assignment&amp;quot; do&lt;br /&gt;
    context &amp;quot;when participant exists&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns the assignment of the participant&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: participant.id }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 5: Fetching an Assignment of an invalid Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of an Invalid Participant Id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status status.&lt;br /&gt;
&lt;br /&gt;
 context &amp;quot;when participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns not found status&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 6: Updating a Participant====&lt;br /&gt;
Ensures that an existing participant can be updated with valid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 OK status and the updated participant details in the response.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;PATCH/PUT #update&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;updates the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { type: &amp;quot;NewType&amp;quot; } }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 7: Updating a Participant====&lt;br /&gt;
Checks the behavior when attempting to update a participant with invalid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 422 Unprocessable Entity status and an error message detailing the issue.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not update the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { user_id: nil } }&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==API Documentation and Testing with Swagger==&lt;br /&gt;
To provide clear, interactive API documentation, facilitating easy understanding and testing of API endpoints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Setup:&amp;lt;/b&amp;gt; Integrate Swagger with Rails application using gems like rswag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Documentation:&amp;lt;/b&amp;gt; Annotate the API code to generate Swagger documentation automatically. Ensure that each endpoint is clearly described, with information on parameters, request bodies, and response schemas.&lt;br /&gt;
Interactive Testing: Use the Swagger UI to interactively test API endpoints directly from the browser, providing an easy way for non-developers to understand and verify API functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;[[File:SWAGGER.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;i&amp;gt;Fig 5.3 Swagger UI displaying API documentation and interactive testing interface for Participants endpoints.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Relevant Links=&lt;br /&gt;
* '''Github Repository:''' https://github.com/achitti2812/expertiza_project4&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/105&lt;br /&gt;
* '''Test Video Link:''' https://youtu.be/hwGuzbqcyjQ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156043</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156043"/>
		<updated>2024-04-23T17:28:13Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2442 Reimplement student task controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2441 Reimplement grades/view_team (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2418. Reimplement of due date.rb (Phase 2)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=156042</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=156042"/>
		<updated>2024-04-23T17:27:44Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Undo revision 156032 by Kgudipe (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
==Plan for Implementation of Participants Controller==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Create Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====Read Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====Update Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====Delete Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====Participants of a particular assignment:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_of_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====Participants as a User:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_as_user&amp;lt;/code&amp;gt; method will focus on associating participant records with user accounts. With a user ID as input, it will join the relevant data from the participants and users tables. The resulting dataset, encapsulated in a JSON array, provides an integrated perspective on the participants' user-related attributes. This method will be particularly valuable when user-based filtering of participant data is needed.&lt;br /&gt;
&lt;br /&gt;
====Comprehensive Testing with RSwag:====&lt;br /&gt;
&lt;br /&gt;
Extensive testing using RSwag will be carried out to confirm the functionality of API endpoints and achieve full test coverage. This process entails crafting tests for every method in the controller, addressing both successful and failure scenarios, and incorporating automated tests into the Continuous Integration (CI) pipeline to maintain consistent quality and dependability.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=== Testing with RSwag: ===&lt;br /&gt;
&lt;br /&gt;
==== Integration Testing: ====&lt;br /&gt;
*RSwag will be employed to create integration tests that validate the functionality of each action within the controller.&lt;br /&gt;
*Tests for CRUD operations (Create, Read, Update, Delete) will be conducted to confirm efficient data handling and database interaction.&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Integration: ====&lt;br /&gt;
*Integration of RSwag with Swagger UI will offer an intuitive interface for users to engage with API endpoints.&lt;br /&gt;
*Swagger UI will faithfully represent the API documentation, enabling users to experiment with endpoints in an interactive manner.&lt;br /&gt;
&lt;br /&gt;
==== Parameter Validation: ====&lt;br /&gt;
*Various input values for endpoint parameters, including assignment IDs and participant IDs, will be evaluated to verify accurate processing and error management.&lt;br /&gt;
*Parameters like IDs, query strings, and request payloads will undergo validation to maintain data integrity.&lt;br /&gt;
&lt;br /&gt;
==== Error Handling: ====&lt;br /&gt;
*Tests will cover error scenarios such as validation failures, missing resources, unauthorized attempts, and server issues.&lt;br /&gt;
*Error replies will include suitable status codes, messages, and details in alignment with the API agreement.&lt;br /&gt;
&lt;br /&gt;
==== Security Testing: ====&lt;br /&gt;
*API endpoints will undergo security evaluations to identify risks like SQL injection, cross-site scripting (XSS), and exposure of sensitive information.&lt;br /&gt;
*The robustness of authentication and authorization protocols will be scrutinized to guarantee protected access to grading features.&lt;br /&gt;
&lt;br /&gt;
==== Documentation Verification: ====&lt;br /&gt;
*The API documentation produced by RSwag will be reviewed to ensure it correctly represents the endpoints, parameters, and responses that have been implemented.&lt;br /&gt;
*The documentation will be regularly updated to remain consistent with the actual functionality of the API endpoints.&lt;br /&gt;
&lt;br /&gt;
Adhering to these design principles and testing approaches, the development of the ParticipantsController will lead to a robust, easily maintainable, and extensively tested component that fulfills project specifications efficiently.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156040</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156040"/>
		<updated>2024-04-23T17:25:11Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Undo revision 156039 by Kgudipe (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2442 Reimplement student task controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2441 Reimplement grades/view_team (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2418. Reimplement of due date.rb (Phase 2)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156039</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156039"/>
		<updated>2024-04-23T17:24:35Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2442 Reimplement student task controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2441 Reimplement grades/view_team (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2418. Reimplement of due date.rb (Phase 2)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=156032</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=156032"/>
		<updated>2024-04-23T17:22:09Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
=Implementation of Participants Controller=&lt;br /&gt;
&lt;br /&gt;
The Participants Controller is designed to handle various interactions with participant data within an application, providing a range of RESTful actions. This controller facilitates operations such as listing all participants, retrieving specific participant details, and creating, updating, or deleting participant records, all through JSON responses suitable for API usage. It includes actions that are traditionally used in view-based controllers (such as new and edit) to instantiate and prepare participants for creation or editing. Additionally, the controller offers a specialized action to fetch and render a participant's assignment, enhancing its functionality by addressing specific data retrieval needs. It also implements global error handling for missing records, ensuring that all actions gracefully handle cases where participants are not found. This comprehensive approach makes the controller a central part of the participant management system in the application, equipped to handle both standard CRUD operations and specific relational data accesses in a structured and efficient manner.&lt;br /&gt;
&lt;br /&gt;
==Implemented methods==&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Create Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
   def create&lt;br /&gt;
      @participant = Participant.new(participant_params)&lt;br /&gt;
      if @participant.save&lt;br /&gt;
        render json: @participant, status: :created&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Read Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
    &lt;br /&gt;
    def index&lt;br /&gt;
      @participants = Participant.all&lt;br /&gt;
      render json: { participants: @participants }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Update Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def update&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      if @participant.update(participant_params)&lt;br /&gt;
        render json: { participant: @participant }, status: :ok&lt;br /&gt;
      else&lt;br /&gt;
        render json: @participant.errors, status: :unprocessable_entity&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Delete Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/022d12ae963d50f582fcedb5301b37c101ad0dd7 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def destroy&lt;br /&gt;
      @participant = Participant.find(params[:id])&lt;br /&gt;
      @participant.destroy&lt;br /&gt;
      render json: { message: &amp;quot;Participant was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Participants of a particular assignment Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/b3647df49ee0a2863d9afe23b6711680650e9e25 Commit]====&lt;br /&gt;
&lt;br /&gt;
  def assignment_participants&lt;br /&gt;
    participants = Participant.where(assignment_id: params[:assignment_id])&lt;br /&gt;
    render json: participants, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;assignment_participants&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;Assignment of a particular Participant Method&amp;quot; [https://github.com/expertiza/reimplementation-back-end/commit/dda3fba2d9ae2dacf1d5ad638d57e2189b17e781 Commit]====&lt;br /&gt;
&lt;br /&gt;
    def participant_assignment&lt;br /&gt;
        participant = Participant.find(params[:participant_id])&lt;br /&gt;
        assignment = participant.assignment&lt;br /&gt;
    &lt;br /&gt;
        render json: assignment, status: :ok&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: { error: &amp;quot;Participant not found&amp;quot; }, status: :not_found&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participant_assignment&amp;lt;/code&amp;gt; method is designed to retrieve the assignment associated with a specific participant. It takes a participant ID from the request parameters, finds the corresponding participant record, and accesses its associated assignment. The assignment data is then rendered as a JSON object. &lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=Testing Plan=&lt;br /&gt;
We employ a combination of manual testing with tools like Postman, automated testing through RSpec, and API documentation and testing using Swagger. This comprehensive approach allows us to validate our API's functionality, security, and usability across various scenarios.&lt;br /&gt;
&lt;br /&gt;
==Manual testing with Postman==&lt;br /&gt;
&lt;br /&gt;
We are using Postman to test our APIs during the development process.&lt;br /&gt;
Below are few examples:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/participants: Endpoint to test the fetching of all Participants.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:GET.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.1 Postman UI displaying API testing to fetch all Participant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/participants: Endpoint to test the creation of a Participant.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:POST.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.2 Postman UI displaying API testing to create a Partcipant.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PATCH api/v1/participants/4: Endpoint to test the functionality of updating Participant using its ID.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:PATCH.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.3 Postman UI displaying API testing to update a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DELETE api/v1/participants/4: Endpoint to test the functionality of deleting a Participant with participant id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:DELETE.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.4 Postman UI displaying API testing to delete a Participant using its ID.&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/assignments/1/participants: Endpoint to test the functionality of fetching a participant using assignment Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch a participant using assignment Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET api/v1/participants/1/assignment: Endpoint to test the functionality of fetching an assignment using participant Id.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Participant Id.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Fig 5.1.5 Postman UI displaying API testing to fetch an assignment using participant Id.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Automated Testing with Rspec==&lt;br /&gt;
====Scenario 1: Creating a New Participant====&lt;br /&gt;
Validates the creation of a new Participant with appropriate parameters. &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 201 Created status and a JSON response with the created participant details.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;creates a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: attributes_for(:participant) }&lt;br /&gt;
        }.to change(Participant, :count).by(1)&lt;br /&gt;
        expect(response).to have_http_status(:created)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Handling Invalid Participant Creation====&lt;br /&gt;
Tests the creation process with invalid parameters to ensure robust error handling.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation&amp;lt;/b&amp;gt;: Expects a 400 Bad Request status and an error message detailing the invalid parameters.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not create a new participant&amp;quot; do&lt;br /&gt;
        expect {&lt;br /&gt;
          post :create, params: { participant: { user_id: nil } } &lt;br /&gt;
        }.to change(Participant, :count).by(0)&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Fetch a Participant who is not in the database====&lt;br /&gt;
Checks the behaviour when attempting to fetch a Participant not present in the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns a not found status&amp;quot; do&lt;br /&gt;
        get :show, params: { id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Fetching an Assignment of a particular Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of a particular Participant Id&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 Ok status with the assignment of the participant.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;#participant_assignment&amp;quot; do&lt;br /&gt;
    context &amp;quot;when participant exists&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns the assignment of the participant&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: participant.id }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====Scenario 5: Fetching an Assignment of an invalid Participant====&lt;br /&gt;
Validates the functionality for fetching an Assignment of an Invalid Participant Id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a not found status status.&lt;br /&gt;
&lt;br /&gt;
 context &amp;quot;when participant does not exist&amp;quot; do&lt;br /&gt;
      it &amp;quot;returns not found status&amp;quot; do&lt;br /&gt;
        get :participant_assignment, params: { participant_id: -1 }&lt;br /&gt;
        expect(response).to have_http_status(:not_found)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Scenario 6: Updating a Participant====&lt;br /&gt;
Ensures that an existing participant can be updated with valid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 200 OK status and the updated participant details in the response.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;PATCH/PUT #update&amp;quot; do&lt;br /&gt;
    context &amp;quot;with valid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;updates the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { type: &amp;quot;NewType&amp;quot; } }&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scenario 7: Updating a Participant====&lt;br /&gt;
Checks the behavior when attempting to update a participant with invalid parameters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Expectation:&amp;lt;/b&amp;gt; Expects a 422 Unprocessable Entity status and an error message detailing the issue.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with invalid parameters&amp;quot; do&lt;br /&gt;
      it &amp;quot;does not update the participant&amp;quot; do&lt;br /&gt;
        patch :update, params: { id: participant.id, participant: { user_id: nil } }&lt;br /&gt;
        expect(response).to have_http_status(:unprocessable_entity)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==API Documentation and Testing with Swagger==&lt;br /&gt;
To provide clear, interactive API documentation, facilitating easy understanding and testing of API endpoints.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Setup:&amp;lt;/b&amp;gt; Integrate Swagger with Rails application using gems like rswag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Documentation:&amp;lt;/b&amp;gt; Annotate the API code to generate Swagger documentation automatically. Ensure that each endpoint is clearly described, with information on parameters, request bodies, and response schemas.&lt;br /&gt;
Interactive Testing: Use the Swagger UI to interactively test API endpoints directly from the browser, providing an easy way for non-developers to understand and verify API functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;[[File:SWAGGER.png|750px]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;i&amp;gt;Fig 5.3 Swagger UI displaying API documentation and interactive testing interface for Participants endpoints.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Relevant Links=&lt;br /&gt;
* '''Github Repository:''' https://github.com/achitti2812/expertiza_project4&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/105&lt;br /&gt;
* '''Test Video Link:''' https://youtu.be/hwGuzbqcyjQ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156031</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156031"/>
		<updated>2024-04-23T17:21:03Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Undo revision 156030 by Kgudipe (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2442 Reimplement student task controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2441 Reimplement grades/view_team (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2418. Reimplement of due date.rb (Phase 2)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156030</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=156030"/>
		<updated>2024-04-23T17:19:51Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2442 Reimplement student task controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2441 Reimplement grades/view_team (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2418. Reimplement of due date.rb (Phase 2)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SWAGGER.png&amp;diff=155793</id>
		<title>File:SWAGGER.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SWAGGER.png&amp;diff=155793"/>
		<updated>2024-04-22T17:11:40Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DELETE.png&amp;diff=155791</id>
		<title>File:DELETE.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DELETE.png&amp;diff=155791"/>
		<updated>2024-04-22T17:08:48Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Participant_Id.png&amp;diff=155788</id>
		<title>File:Participant Id.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Participant_Id.png&amp;diff=155788"/>
		<updated>2024-04-22T17:07:04Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_Id.png&amp;diff=155786</id>
		<title>File:Assignment Id.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_Id.png&amp;diff=155786"/>
		<updated>2024-04-22T17:06:22Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_model.png&amp;diff=155783</id>
		<title>File:Assignment model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_model.png&amp;diff=155783"/>
		<updated>2024-04-22T17:05:10Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe uploaded a new version of File:Assignment model.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment.png&amp;diff=155781</id>
		<title>File:Assignment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment.png&amp;diff=155781"/>
		<updated>2024-04-22T17:03:38Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe reverted File:Assignment.png to an old version&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Participant.png&amp;diff=155771</id>
		<title>File:Participant.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Participant.png&amp;diff=155771"/>
		<updated>2024-04-22T16:47:49Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe uploaded a new version of File:Participant.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment.png&amp;diff=155770</id>
		<title>File:Assignment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment.png&amp;diff=155770"/>
		<updated>2024-04-22T16:47:39Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe uploaded a new version of File:Assignment.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:PATCH.png&amp;diff=155769</id>
		<title>File:PATCH.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:PATCH.png&amp;diff=155769"/>
		<updated>2024-04-22T16:47:25Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:POST.png&amp;diff=155768</id>
		<title>File:POST.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:POST.png&amp;diff=155768"/>
		<updated>2024-04-22T16:47:06Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:GET.png&amp;diff=155767</id>
		<title>File:GET.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:GET.png&amp;diff=155767"/>
		<updated>2024-04-22T16:46:39Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155492</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155492"/>
		<updated>2024-04-09T01:50:11Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
[[File:Design_img.jpg|1000px]]&lt;br /&gt;
&lt;br /&gt;
==Plan for Implementation of Participants Controller==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Create Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====Read Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====Update Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====Delete Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====Participants of a particular assignment:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_of_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====Participants as a User:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_as_user&amp;lt;/code&amp;gt; method will focus on associating participant records with user accounts. With a user ID as input, it will join the relevant data from the participants and users tables. The resulting dataset, encapsulated in a JSON array, provides an integrated perspective on the participants' user-related attributes. This method will be particularly valuable when user-based filtering of participant data is needed.&lt;br /&gt;
&lt;br /&gt;
====Comprehensive Testing with RSwag:====&lt;br /&gt;
&lt;br /&gt;
Extensive testing using RSwag will be carried out to confirm the functionality of API endpoints and achieve full test coverage. This process entails crafting tests for every method in the controller, addressing both successful and failure scenarios, and incorporating automated tests into the Continuous Integration (CI) pipeline to maintain consistent quality and dependability.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=== Testing with RSwag: ===&lt;br /&gt;
&lt;br /&gt;
==== Integration Testing: ====&lt;br /&gt;
*RSwag will be employed to create integration tests that validate the functionality of each action within the controller.&lt;br /&gt;
*Tests for CRUD operations (Create, Read, Update, Delete) will be conducted to confirm efficient data handling and database interaction.&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Integration: ====&lt;br /&gt;
*Integration of RSwag with Swagger UI will offer an intuitive interface for users to engage with API endpoints.&lt;br /&gt;
*Swagger UI will faithfully represent the API documentation, enabling users to experiment with endpoints in an interactive manner.&lt;br /&gt;
&lt;br /&gt;
==== Parameter Validation: ====&lt;br /&gt;
*Various input values for endpoint parameters, including assignment IDs and participant IDs, will be evaluated to verify accurate processing and error management.&lt;br /&gt;
*Parameters like IDs, query strings, and request payloads will undergo validation to maintain data integrity.&lt;br /&gt;
&lt;br /&gt;
==== Error Handling: ====&lt;br /&gt;
*Tests will cover error scenarios such as validation failures, missing resources, unauthorized attempts, and server issues.&lt;br /&gt;
*Error replies will include suitable status codes, messages, and details in alignment with the API agreement.&lt;br /&gt;
&lt;br /&gt;
==== Security Testing: ====&lt;br /&gt;
*API endpoints will undergo security evaluations to identify risks like SQL injection, cross-site scripting (XSS), and exposure of sensitive information.&lt;br /&gt;
*The robustness of authentication and authorization protocols will be scrutinized to guarantee protected access to grading features.&lt;br /&gt;
&lt;br /&gt;
==== Documentation Verification: ====&lt;br /&gt;
*The API documentation produced by RSwag will be reviewed to ensure it correctly represents the endpoints, parameters, and responses that have been implemented.&lt;br /&gt;
*The documentation will be regularly updated to remain consistent with the actual functionality of the API endpoints.&lt;br /&gt;
&lt;br /&gt;
Adhering to these design principles and testing approaches, the development of the ParticipantsController will lead to a robust, easily maintainable, and extensively tested component that fulfills project specifications efficiently.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_img.jpg&amp;diff=155482</id>
		<title>File:Design img.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_img.jpg&amp;diff=155482"/>
		<updated>2024-04-09T01:45:10Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155417</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155417"/>
		<updated>2024-04-09T01:27:50Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
==Plan for Implementation of Participants Controller==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Create Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====Read Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====Update Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====Delete Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====Participants of a particular assignment:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_of_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====Participants as a User:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_as_user&amp;lt;/code&amp;gt; method will focus on associating participant records with user accounts. With a user ID as input, it will join the relevant data from the participants and users tables. The resulting dataset, encapsulated in a JSON array, provides an integrated perspective on the participants' user-related attributes. This method will be particularly valuable when user-based filtering of participant data is needed.&lt;br /&gt;
&lt;br /&gt;
====Comprehensive Testing with RSwag:====&lt;br /&gt;
&lt;br /&gt;
Extensive testing using RSwag will be carried out to confirm the functionality of API endpoints and achieve full test coverage. This process entails crafting tests for every method in the controller, addressing both successful and failure scenarios, and incorporating automated tests into the Continuous Integration (CI) pipeline to maintain consistent quality and dependability.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
=== Testing with RSwag: ===&lt;br /&gt;
&lt;br /&gt;
==== Integration Testing: ====&lt;br /&gt;
*RSwag will be employed to create integration tests that validate the functionality of each action within the controller.&lt;br /&gt;
*Tests for CRUD operations (Create, Read, Update, Delete) will be conducted to confirm efficient data handling and database interaction.&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Integration: ====&lt;br /&gt;
*Integration of RSwag with Swagger UI will offer an intuitive interface for users to engage with API endpoints.&lt;br /&gt;
*Swagger UI will faithfully represent the API documentation, enabling users to experiment with endpoints in an interactive manner.&lt;br /&gt;
&lt;br /&gt;
==== Parameter Validation: ====&lt;br /&gt;
*Various input values for endpoint parameters, including assignment IDs and participant IDs, will be evaluated to verify accurate processing and error management.&lt;br /&gt;
*Parameters like IDs, query strings, and request payloads will undergo validation to maintain data integrity.&lt;br /&gt;
&lt;br /&gt;
==== Error Handling: ====&lt;br /&gt;
*Tests will cover error scenarios such as validation failures, missing resources, unauthorized attempts, and server issues.&lt;br /&gt;
*Error replies will include suitable status codes, messages, and details in alignment with the API agreement.&lt;br /&gt;
&lt;br /&gt;
==== Security Testing: ====&lt;br /&gt;
*API endpoints will undergo security evaluations to identify risks like SQL injection, cross-site scripting (XSS), and exposure of sensitive information.&lt;br /&gt;
*The robustness of authentication and authorization protocols will be scrutinized to guarantee protected access to grading features.&lt;br /&gt;
&lt;br /&gt;
==== Documentation Verification: ====&lt;br /&gt;
*The API documentation produced by RSwag will be reviewed to ensure it correctly represents the endpoints, parameters, and responses that have been implemented.&lt;br /&gt;
*The documentation will be regularly updated to remain consistent with the actual functionality of the API endpoints.&lt;br /&gt;
&lt;br /&gt;
Adhering to these design principles and testing approaches, the development of the ParticipantsController will lead to a robust, easily maintainable, and extensively tested component that fulfills project specifications efficiently.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155416</id>
		<title>CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2445._Implement_BackEnd_for_participants.rb_(Design_Document)&amp;diff=155416"/>
		<updated>2024-04-09T01:27:15Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Created page with &amp;quot;__TOC__  ==Expertiza== [http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] stands out as an open-source initiative rooted in the Ruby on Rails framework, brought to life through the collective efforts of NC State's faculty and students. This web application supports instructors in creating tailored assignments that can either be new or build upon existing ones. Moreover, it allows for the organization of topics into a roster for student selection. Expertiza offers students the chance to team up for joint projects and assignments, promoting collaborative learning. A key feature of this platform is enabling students to peer-review their colleagues' work.&lt;br /&gt;
&lt;br /&gt;
With its capability to handle a wide variety of document types, Expertiza accepts submissions in formats ranging from URLs to wiki pages. As an open-source learning management system crafted with Ruby on Rails, it boasts a broad range of features that facilitate the submission and peer review of diverse learning materials, including articles, code, and websites. Instructors and teaching assistants can easily monitor and evaluate these submissions, making Expertiza a valuable tool for managing course assignments.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To develop the backend functionality for the participants controller of Expertiza, ensuring seamless integration with the enhanced user interface for participants. This involves setting up API endpoints for CRUD (Create, Read, Update, Delete) operations, integrating with the database, and ensuring data integrity and security. Our focus includes thorough rswag testing of the participants_controller method and demonstrating Swagger UI integration.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The reimplementation project entails:&lt;br /&gt;
#&amp;lt;b&amp;gt;CRUD Operations:&amp;lt;/b&amp;gt; Setting up CRUD (Create, Read, Update, Delete) functionalities in the controller to streamline data handling.&lt;br /&gt;
#&amp;lt;b&amp;gt;Routes:&amp;lt;/b&amp;gt; Establishing pathways for accessing actions within the participants controller.&lt;br /&gt;
#&amp;lt;b&amp;gt;Database:&amp;lt;/b&amp;gt; Maintaining a database for participant information, including their connections to &amp;quot;Assignment&amp;quot;.&lt;br /&gt;
#&amp;lt;b&amp;gt;Adherence to DRY Principle:&amp;lt;/b&amp;gt; Adhering to the Don't Repeat Yourself (DRY) principle to minimize redundancy and enhance coding efficiency.&lt;br /&gt;
#&amp;lt;b&amp;gt;Testing with RSwag:&amp;lt;/b&amp;gt; Developing detailed tests using RSwag for every controller action, ensuring their performance and compatibility with Swagger UI. This includes a video tutorial to illustrate the integration with Swagger UI and the operational efficiency of the revamped controller.&lt;br /&gt;
&lt;br /&gt;
==Plan for Implementation of Participants Controller==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Create Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; action will handle the addition of new participants. It will take participant information, conducts security validations, ensures data integrity, and inserts the new record into the database, responding with the participant's details in JSON format or an error message if the process fails.&lt;br /&gt;
&lt;br /&gt;
====Read Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt; action will accept a participant ID, retrieves the corresponding data from the database, and returns it as a JSON object. If the participant does not exist, it will send an error message.&lt;br /&gt;
&lt;br /&gt;
====Update Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; action will require a participant ID and the new data to be provided. The method will update the relevant record after security and data validation checks and returns the updated information in JSON format.&lt;br /&gt;
&lt;br /&gt;
====Delete Action:====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;delete&amp;lt;/code&amp;gt; action will remove a participant's record using their ID, ensuring that the request is authenticated and the user is authorized to perform the deletion. Upon successful deletion, it will confirm the action with a success response; otherwise, it returns an error.&lt;br /&gt;
&lt;br /&gt;
====Participants of a particular assignment:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_of_assignment&amp;lt;/code&amp;gt; method will receive an assignment ID, this method will join the pertinent records from the participants and assignments tables, retrieving a comprehensive dataset that is then converted into a JSON array. This method will be instrumental for scenarios where a holistic view of assignment participation is required.&lt;br /&gt;
&lt;br /&gt;
====Participants as a User:====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;participants_as_user&amp;lt;/code&amp;gt; method will focus on associating participant records with user accounts. With a user ID as input, it will join the relevant data from the participants and users tables. The resulting dataset, encapsulated in a JSON array, provides an integrated perspective on the participants' user-related attributes. This method will be particularly valuable when user-based filtering of participant data is needed.&lt;br /&gt;
&lt;br /&gt;
====Comprehensive Testing with RSwag:====&lt;br /&gt;
&lt;br /&gt;
Extensive testing using RSwag will be carried out to confirm the functionality of API endpoints and achieve full test coverage. This process entails crafting tests for every method in the controller, addressing both successful and failure scenarios, and incorporating automated tests into the Continuous Integration (CI) pipeline to maintain consistent quality and dependability.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
==== Single Responsibility Principle (SRP): ====&lt;br /&gt;
*Every function within the ParticipantsController will handle a distinct aspect of participant management.&lt;br /&gt;
*The functions will undergo restructuring to delineate responsibilities like fetching data, performing calculations, and presenting views.&lt;br /&gt;
*As an illustration, the view function will be dedicated to acquiring participant information.&lt;br /&gt;
&lt;br /&gt;
==== Don't Repeat Yourself (DRY) Principle: ====&lt;br /&gt;
*Redundant code within the ParticipantsController will be reduced by moving shared functionalities into auxiliary methods or modules.&lt;br /&gt;
&lt;br /&gt;
==== Encapsulation: ====&lt;br /&gt;
*The ParticipantsController will organize data and functionality into suitable methods and classes to reduce dependencies.&lt;br /&gt;
*The scope of access to instance variables and controller actions will be restricted to foster encapsulation and ensure a clear division of responsibilities.&lt;br /&gt;
&lt;br /&gt;
== Testing with RSwag: ==&lt;br /&gt;
&lt;br /&gt;
==== Integration Testing: ====&lt;br /&gt;
*RSwag will be employed to create integration tests that validate the functionality of each action within the controller.&lt;br /&gt;
*Tests for CRUD operations (Create, Read, Update, Delete) will be conducted to confirm efficient data handling and database interaction.&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Integration: ====&lt;br /&gt;
*Integration of RSwag with Swagger UI will offer an intuitive interface for users to engage with API endpoints.&lt;br /&gt;
*Swagger UI will faithfully represent the API documentation, enabling users to experiment with endpoints in an interactive manner.&lt;br /&gt;
&lt;br /&gt;
==== Parameter Validation: ====&lt;br /&gt;
*Various input values for endpoint parameters, including assignment IDs and participant IDs, will be evaluated to verify accurate processing and error management.&lt;br /&gt;
*Parameters like IDs, query strings, and request payloads will undergo validation to maintain data integrity.&lt;br /&gt;
&lt;br /&gt;
==== Error Handling: ====&lt;br /&gt;
*Tests will cover error scenarios such as validation failures, missing resources, unauthorized attempts, and server issues.&lt;br /&gt;
*Error replies will include suitable status codes, messages, and details in alignment with the API agreement.&lt;br /&gt;
&lt;br /&gt;
==== Security Testing: ====&lt;br /&gt;
*API endpoints will undergo security evaluations to identify risks like SQL injection, cross-site scripting (XSS), and exposure of sensitive information.&lt;br /&gt;
*The robustness of authentication and authorization protocols will be scrutinized to guarantee protected access to grading features.&lt;br /&gt;
&lt;br /&gt;
==== Documentation Verification: ====&lt;br /&gt;
*The API documentation produced by RSwag will be reviewed to ensure it correctly represents the endpoints, parameters, and responses that have been implemented.&lt;br /&gt;
*The documentation will be regularly updated to remain consistent with the actual functionality of the API endpoints.&lt;br /&gt;
&lt;br /&gt;
Adhering to these design principles and testing approaches, the development of the ParticipantsController will lead to a robust, easily maintainable, and extensively tested component that fulfills project specifications efficiently.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Chunduru Chetana&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Akhilsai Chittipolu &lt;br /&gt;
*Koushik Gudipelly&lt;br /&gt;
*Sri Vaishnavi Mylavarapu&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=155413</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=155413"/>
		<updated>2024-04-09T01:26:28Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=155411</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=155411"/>
		<updated>2024-04-09T01:23:21Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2401 Implementing and testing import &amp;amp; export controllers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2430 Reimplement student_task view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2410. View for Results of Bidding ]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - NTNX-1 : Extend NDB Operator to Support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2406 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2432. UI for Participants.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2402 Implement REST client, REST API, and Graphql API endpoint for repositories]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - G2400 DevOp for GitHub Miner app]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2439 Testing for view_translation_substitutor.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2443 Reimplement grades_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2434 Reimplement Frontend for the Grades view]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2435 Implement Frontend for the My Profile]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2444 Implement Frontend for the Review]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2440 Testing for questionnaire_helper, review_bids_helper]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2433 Implement UI for the Student Teams]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)]]&lt;br /&gt;
* [[CSC/ECE 517 SPring 2024 - E2445. Implement BackEnd for participants.rb (Design Document)]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153962</id>
		<title>CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153962"/>
		<updated>2024-03-24T23:24:45Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the duties_controller.rb and badges_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
duties_controller.rb&lt;br /&gt;
&lt;br /&gt;
This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is used to update the duty in the database. Finally, the delete action can be used to remove a duty from the database. Expertiza's Duties module helps with duty management.&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
The controller generates a new Badge instance by utilizing user-provided parameters via the create action. If an image file is included, it is also stored, and the badge instance's image_name attribute is updated accordingly.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza platform is a versatile and modular system designed to enable students to submit assignments and quizzes smoothly, while also facilitating collaborative learning through features such as peer review. Embraced by students, teaching assistants, and professors alike, this sophisticated system optimizes academic assessments, promoting an interactive and efficient educational environment.&lt;br /&gt;
&lt;br /&gt;
The primary aim of the student quizzes module is to provide a platform for students to generate quizzes for their peers who are working on the same assignments. This fosters a collaborative learning environment where students can collectively improve their understanding and support each other's educational progress.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Previously, the Expertiza system lacked specific functionalities related to duties and badges, which meant there were no established mechanisms within the system to manage duties or to create and manage badges. This absence was notable, as such features could significantly enhance user interaction and system management by allowing for the assignment of responsibilities and the acknowledgment of achievements within the system. To address this gap, a project has been initiated to develop and integrate these functionalities into the Expertiza system through an API framework built on Rails.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The project entails revamping and improving the Duties and Badges modules within an API framework constructed on Rails. In duties_controller.rb, actions for handling duties, such as creation, editing, updating, and deletion, in the Expertiza system are defined. Conversely, badges_controller.rb manages the creation of Badge instances, enabling users to define badge parameters and optionally attach an image file, which is then saved and linked with the badge.&lt;br /&gt;
&lt;br /&gt;
The primary focus of the project is to implement these functionalities as RESTful API endpoints, adhering strictly to JSON response standards. Comprehensive testing, covering both positive and negative scenarios, is imperative to validate the accuracy and resilience of the implemented features. Additionally, prioritizing security, error handling, and validation is crucial for maintaining data integrity and thwarting potential vulnerabilities. The reimplementation must adhere to Rails conventions and adhere to best practices, promoting maintainability and scalability while ensuring smooth integration with other modules in the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza duties and bages controller 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 each 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: Develop methods in duties_controller and badges_controller to facilitate the creation of new Duties and Badges, respectively. These methods will allow instructors and system administrators to input necessary details such as duty descriptions, badge criteria, and associated rewards.&lt;br /&gt;
&lt;br /&gt;
* Read: Implement show actions within both controllers to enable users to retrieve and view details of specific Duties and Badges. This includes viewing duty responsibilities, badge criteria, and any rewards associated with the completion of duties or earning of badges.&lt;br /&gt;
&lt;br /&gt;
* Update: Add update methods in duties_controller and badges_controller to allow for the modification of existing Duties and Badges. This functionality will enable the adjustment of details such as duty parameters and badge criteria to keep the system’s content current and relevant.&lt;br /&gt;
&lt;br /&gt;
* Delete: Create destroy actions in both controllers to support the deletion of Duties and Badges that are no longer needed or relevant. This will assist in maintaining a clean and efficient database, removing outdated or unnecessary information.&lt;br /&gt;
&lt;br /&gt;
* Index: Enhance the index actions in both duties_controller and badges_controller to list all Duties and Badges, respectively, providing users with an overview of available duties and badges. The index view will be optimized for ease of access and clarity, making it simpler for users to navigate and manage duties and badges within the system.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Duties Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
 class Api::V1::DutiesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_duty, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves all duties.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all duties from the database using the Duty.all method and renders a JSON response containing all duties.&lt;br /&gt;
  # GET /duties&lt;br /&gt;
  def index&lt;br /&gt;
    @duties = Duty.all&lt;br /&gt;
    render json: @duties&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves a specific duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a duty by its ID and renders a JSON response containing the specific duty&lt;br /&gt;
  # GET /duties/1&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @duty, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Creates a new duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Creates a new duty by instantiating a Duty object with the provided duty parameters from the request (duty_params).&lt;br /&gt;
  # POST /duties&lt;br /&gt;
  def create&lt;br /&gt;
    @duty = Duty.new(duty_params)&lt;br /&gt;
&lt;br /&gt;
    if @duty.save&lt;br /&gt;
      render json: @duty, status: :created, location: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Updates an existing duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Updates an existing duty specified by its ID using the provided duty parameters from the request (duty_params). &lt;br /&gt;
  # PATCH/PUT /duties/1&lt;br /&gt;
  def update&lt;br /&gt;
    if @duty.update(duty_params)&lt;br /&gt;
      render json: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Deletes a duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a specific duty by its ID and destroys (deletes) it. It then renders a JSON response with a success message&lt;br /&gt;
  # DELETE /duties/1&lt;br /&gt;
  def destroy&lt;br /&gt;
    @duty.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Duty was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_duty Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This technique serves as a callback to establish the @duty instance variable by locating the duty according to the :id parameter. It is applied prior to the show, update, and destroy actions to prepare the specific duty undergoing operation.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_duty&lt;br /&gt;
      @duty = Duty.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''duty_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This process filters the duty parameters received from the request, permitting only designated parameters (:name, :assignment_id, :max_members_for_duties) for creating or updating a duty. It utilizes Rails' strong parameters feature for security purposes.&lt;br /&gt;
&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def duty_params&lt;br /&gt;
      params.require(:duty).permit(:name, :assignment_id, :max_members_for_duties)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
=== Badges Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 class Api::V1::BadgesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_badge, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves all badges.&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all existing badges from the database using Badge.all and returns a JSON array containing all badge records.&lt;br /&gt;
&lt;br /&gt;
  # GET /badges&lt;br /&gt;
  # Lists all badges&lt;br /&gt;
  def index&lt;br /&gt;
    @badges = Badge.all&lt;br /&gt;
    render json: { badges: @badges }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves a specific badge.&lt;br /&gt;
&lt;br /&gt;
Description: Finds and retrieves a particular badge by its ID from the database. The method responds with a JSON object containing the details of the specific badge.&lt;br /&gt;
  # GET /badges/1&lt;br /&gt;
  # Shows a single badge&lt;br /&gt;
  def show&lt;br /&gt;
    render json: { badge: @badge }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Creates a new badge.&lt;br /&gt;
&lt;br /&gt;
Description: Instantiates a new badge using the parameters provided in the request (badge_params).&lt;br /&gt;
  # POST /badges&lt;br /&gt;
  # Creates a new badge&lt;br /&gt;
  def create&lt;br /&gt;
    @badge = Badge.new(badge_params)&lt;br /&gt;
&lt;br /&gt;
    if @badge.save&lt;br /&gt;
      render json: { badge: @badge }, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Updates an existing badge.&lt;br /&gt;
&lt;br /&gt;
Description: Modifies the attributes of an existing badge based on the parameters received in the request (badge_params).&lt;br /&gt;
  # PATCH/PUT /badges/1&lt;br /&gt;
  # Updates an existing badge&lt;br /&gt;
  def update&lt;br /&gt;
    if @badge.update(badge_params)&lt;br /&gt;
      render json: { badge: @badge }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Deletes a badge.&lt;br /&gt;
&lt;br /&gt;
Description: Locates a specific badge by its ID and removes it from the database. &lt;br /&gt;
  # DELETE /badges/1&lt;br /&gt;
  # Deletes a badge&lt;br /&gt;
  def destroy&lt;br /&gt;
    @badge.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Badge was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_badge Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Sets up a specific badge for other actions.&lt;br /&gt;
&lt;br /&gt;
Description: This callback function locates and assigns the @badge instance variable according to the :id parameter before executing the show, update, and destroy actions.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_badge&lt;br /&gt;
      @badge = Badge.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''badge_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Filters and permits badge parameters for security.&lt;br /&gt;
&lt;br /&gt;
Description: This process screens the badge parameters received via the request, permitting only certain parameters (:name, :description, :image_name, :image_file) to be utilized for creating or updating a badge.&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def badge_params&lt;br /&gt;
      params.require(:badge).permit(:name, :description, :image_name)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
'''&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. 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 User Required Setup ===&lt;br /&gt;
==== 1. Login as an User 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;admin&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;admin\&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;
&lt;br /&gt;
==== 2. User Creates Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
Be sure the ids match the database ids for the assignments.&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test duty 1&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
==== 3. User can see all available Duties ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 4. User can see a particular Duty ====&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 duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 5. User can update a Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty and assignments.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 6. User can delete a Duty ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 7. User Creates Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing creation of badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
==== 8. User can see all available Badges====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 9. User can see a particular Badge====&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 badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 10. User can update a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge_1&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 11. User can delete a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/3' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In summary, the reimplementation project for the Duties and Badges modules in Expertiza is crucial for bringing existing functionalities in line with API standards and addressing identified shortcomings from the previous implementation.&lt;br /&gt;
&lt;br /&gt;
The Duties module, managed through duties_controller.rb, is central to handling duties' creation, editing, and deletion within the system. Similarly, the Badges module, governed by badges_controller.rb, oversees badge creation and management, including handling image files.&lt;br /&gt;
&lt;br /&gt;
The main issues with the previous implementation stemmed from treating the system as a traditional Rails MVC application rather than as a Rails API. This resulted in non-compliance with API standards in request and response handling, which this reimplementation aims to fix. Furthermore, deficiencies in testing procedures underscored the need for comprehensive testing to ensure system robustness and reliability.&lt;br /&gt;
&lt;br /&gt;
The planned work involves strict adherence to API-style interactions, returning data in JSON format, and implementing thorough testing for all REST endpoints to ensure robust verification of Duties and Badge functionalities across various scenarios.&lt;br /&gt;
&lt;br /&gt;
By addressing these issues and carefully implementing planned functionalities, this reimplementation aims to improve system efficiency, robustness, and adherence to API conventions, ultimately providing a more reliable and scalable platform for managing duties and badges within Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
GitHub repository: https://github.com/kgudipe/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/91&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
'''Group members:'''&lt;br /&gt;
&lt;br /&gt;
Akhilsai Chittipolu &lt;br /&gt;
 &lt;br /&gt;
Koushik Gudipelly&lt;br /&gt;
&lt;br /&gt;
Sri Vaishnavi Mylavarapu&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Chunduru Chetana&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153913</id>
		<title>CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153913"/>
		<updated>2024-03-24T22:55:42Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Created page with &amp;quot;== Overview == Our team is tasked with creating the backend reimplementation of the duties_controller.rb and badges_controller.rb. We are to use SOLID principles and adhere to the Guidelines for Reimplementation.  duties_controller.rb  This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is us...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the duties_controller.rb and badges_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
duties_controller.rb&lt;br /&gt;
&lt;br /&gt;
This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is used to update the duty in the database. Finally, the delete action can be used to remove a duty from the database. Expertiza's Duties module helps with duty management.&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
The controller generates a new Badge instance by utilizing user-provided parameters via the create action. If an image file is included, it is also stored, and the badge instance's image_name attribute is updated accordingly.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza platform is a versatile and modular system designed to enable students to submit assignments and quizzes smoothly, while also facilitating collaborative learning through features such as peer review. Embraced by students, teaching assistants, and professors alike, this sophisticated system optimizes academic assessments, promoting an interactive and efficient educational environment.&lt;br /&gt;
&lt;br /&gt;
The primary aim of the student quizzes module is to provide a platform for students to generate quizzes for their peers who are working on the same assignments. This fosters a collaborative learning environment where students can collectively improve their understanding and support each other's educational progress.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Previously, the Expertiza system lacked specific functionalities related to duties and badges, which meant there were no established mechanisms within the system to manage duties or to create and manage badges. This absence was notable, as such features could significantly enhance user interaction and system management by allowing for the assignment of responsibilities and the acknowledgment of achievements within the system. To address this gap, a project has been initiated to develop and integrate these functionalities into the Expertiza system through an API framework built on Rails.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The project entails revamping and improving the Duties and Badges modules within an API framework constructed on Rails. In duties_controller.rb, actions for handling duties, such as creation, editing, updating, and deletion, in the Expertiza system are defined. Conversely, badges_controller.rb manages the creation of Badge instances, enabling users to define badge parameters and optionally attach an image file, which is then saved and linked with the badge.&lt;br /&gt;
&lt;br /&gt;
The primary focus of the project is to implement these functionalities as RESTful API endpoints, adhering strictly to JSON response standards. Comprehensive testing, covering both positive and negative scenarios, is imperative to validate the accuracy and resilience of the implemented features. Additionally, prioritizing security, error handling, and validation is crucial for maintaining data integrity and thwarting potential vulnerabilities. The reimplementation must adhere to Rails conventions and adhere to best practices, promoting maintainability and scalability while ensuring smooth integration with other modules in the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza duties and bages controller 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 each 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: Develop methods in duties_controller and badges_controller to facilitate the creation of new Duties and Badges, respectively. These methods will allow instructors and system administrators to input necessary details such as duty descriptions, badge criteria, and associated rewards.&lt;br /&gt;
&lt;br /&gt;
* Read: Implement show actions within both controllers to enable users to retrieve and view details of specific Duties and Badges. This includes viewing duty responsibilities, badge criteria, and any rewards associated with the completion of duties or earning of badges.&lt;br /&gt;
&lt;br /&gt;
* Update: Add update methods in duties_controller and badges_controller to allow for the modification of existing Duties and Badges. This functionality will enable the adjustment of details such as duty parameters and badge criteria to keep the system’s content current and relevant.&lt;br /&gt;
&lt;br /&gt;
* Delete: Create destroy actions in both controllers to support the deletion of Duties and Badges that are no longer needed or relevant. This will assist in maintaining a clean and efficient database, removing outdated or unnecessary information.&lt;br /&gt;
&lt;br /&gt;
* Index: Enhance the index actions in both duties_controller and badges_controller to list all Duties and Badges, respectively, providing users with an overview of available duties and badges. The index view will be optimized for ease of access and clarity, making it simpler for users to navigate and manage duties and badges within the system.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Admin shall create a test&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Duties Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
 class Api::V1::DutiesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_duty, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves all duties.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all duties from the database using the Duty.all method and renders a JSON response containing all duties.&lt;br /&gt;
  # GET /duties&lt;br /&gt;
  def index&lt;br /&gt;
    @duties = Duty.all&lt;br /&gt;
    render json: @duties&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves a specific duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a duty by its ID and renders a JSON response containing the specific duty&lt;br /&gt;
  # GET /duties/1&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @duty, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Creates a new duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Creates a new duty by instantiating a Duty object with the provided duty parameters from the request (duty_params).&lt;br /&gt;
  # POST /duties&lt;br /&gt;
  def create&lt;br /&gt;
    @duty = Duty.new(duty_params)&lt;br /&gt;
&lt;br /&gt;
    if @duty.save&lt;br /&gt;
      render json: @duty, status: :created, location: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Updates an existing duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Updates an existing duty specified by its ID using the provided duty parameters from the request (duty_params). &lt;br /&gt;
  # PATCH/PUT /duties/1&lt;br /&gt;
  def update&lt;br /&gt;
    if @duty.update(duty_params)&lt;br /&gt;
      render json: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Deletes a duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a specific duty by its ID and destroys (deletes) it. It then renders a JSON response with a success message&lt;br /&gt;
  # DELETE /duties/1&lt;br /&gt;
  def destroy&lt;br /&gt;
    @duty.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Duty was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_duty Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This technique serves as a callback to establish the @duty instance variable by locating the duty according to the :id parameter. It is applied prior to the show, update, and destroy actions to prepare the specific duty undergoing operation.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_duty&lt;br /&gt;
      @duty = Duty.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''duty_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This process filters the duty parameters received from the request, permitting only designated parameters (:name, :assignment_id, :max_members_for_duties) for creating or updating a duty. It utilizes Rails' strong parameters feature for security purposes.&lt;br /&gt;
&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def duty_params&lt;br /&gt;
      params.require(:duty).permit(:name, :assignment_id, :max_members_for_duties)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
=== Badges Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 class Api::V1::BadgesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_badge, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves all badges.&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all existing badges from the database using Badge.all and returns a JSON array containing all badge records.&lt;br /&gt;
&lt;br /&gt;
  # GET /badges&lt;br /&gt;
  # Lists all badges&lt;br /&gt;
  def index&lt;br /&gt;
    @badges = Badge.all&lt;br /&gt;
    render json: { badges: @badges }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves a specific badge.&lt;br /&gt;
&lt;br /&gt;
Description: Finds and retrieves a particular badge by its ID from the database. The method responds with a JSON object containing the details of the specific badge.&lt;br /&gt;
  # GET /badges/1&lt;br /&gt;
  # Shows a single badge&lt;br /&gt;
  def show&lt;br /&gt;
    render json: { badge: @badge }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Creates a new badge.&lt;br /&gt;
&lt;br /&gt;
Description: Instantiates a new badge using the parameters provided in the request (badge_params).&lt;br /&gt;
  # POST /badges&lt;br /&gt;
  # Creates a new badge&lt;br /&gt;
  def create&lt;br /&gt;
    @badge = Badge.new(badge_params)&lt;br /&gt;
&lt;br /&gt;
    if @badge.save&lt;br /&gt;
      render json: { badge: @badge }, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Updates an existing badge.&lt;br /&gt;
&lt;br /&gt;
Description: Modifies the attributes of an existing badge based on the parameters received in the request (badge_params).&lt;br /&gt;
  # PATCH/PUT /badges/1&lt;br /&gt;
  # Updates an existing badge&lt;br /&gt;
  def update&lt;br /&gt;
    if @badge.update(badge_params)&lt;br /&gt;
      render json: { badge: @badge }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Deletes a badge.&lt;br /&gt;
&lt;br /&gt;
Description: Locates a specific badge by its ID and removes it from the database. &lt;br /&gt;
  # DELETE /badges/1&lt;br /&gt;
  # Deletes a badge&lt;br /&gt;
  def destroy&lt;br /&gt;
    @badge.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Badge was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_badge Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Sets up a specific badge for other actions.&lt;br /&gt;
&lt;br /&gt;
Description: This callback function locates and assigns the @badge instance variable according to the :id parameter before executing the show, update, and destroy actions.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_badge&lt;br /&gt;
      @badge = Badge.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''badge_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Filters and permits badge parameters for security.&lt;br /&gt;
&lt;br /&gt;
Description: This process screens the badge parameters received via the request, permitting only certain parameters (:name, :description, :image_name, :image_file) to be utilized for creating or updating a badge.&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def badge_params&lt;br /&gt;
      params.require(:badge).permit(:name, :description, :image_name)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
'''&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. 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 User Required Setup ===&lt;br /&gt;
==== 1. Login as an User 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;admin&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;admin\&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;
&lt;br /&gt;
==== 2. User Creates Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
Be sure the ids match the database ids for the assignments.&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test duty 1&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
==== 3. User can see all available Duties ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 4. User can see a particular Duty ====&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 duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 5. User can update a Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty and assignments.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 6. User can delete a Duty ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 7. User Creates Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing creation of badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
==== 8. User can see all available Badges====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 9. User can see a particular Badge====&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 badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 10. User can update a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge_1&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 11. User can delete a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/3' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In summary, the reimplementation project for the Duties and Badges modules in Expertiza is crucial for bringing existing functionalities in line with API standards and addressing identified shortcomings from the previous implementation.&lt;br /&gt;
&lt;br /&gt;
The Duties module, managed through duties_controller.rb, is central to handling duties' creation, editing, and deletion within the system. Similarly, the Badges module, governed by badges_controller.rb, oversees badge creation and management, including handling image files.&lt;br /&gt;
&lt;br /&gt;
The main issues with the previous implementation stemmed from treating the system as a traditional Rails MVC application rather than as a Rails API. This resulted in non-compliance with API standards in request and response handling, which this reimplementation aims to fix. Furthermore, deficiencies in testing procedures underscored the need for comprehensive testing to ensure system robustness and reliability.&lt;br /&gt;
&lt;br /&gt;
The planned work involves strict adherence to API-style interactions, returning data in JSON format, and implementing thorough testing for all REST endpoints to ensure robust verification of Duties and Badge functionalities across various scenarios.&lt;br /&gt;
&lt;br /&gt;
By addressing these issues and carefully implementing planned functionalities, this reimplementation aims to improve system efficiency, robustness, and adherence to API conventions, ultimately providing a more reliable and scalable platform for managing duties and badges within Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
'''Group members:'''&lt;br /&gt;
&lt;br /&gt;
Akhilsai Chittipolu &lt;br /&gt;
 &lt;br /&gt;
Koushik Gudipelly&lt;br /&gt;
&lt;br /&gt;
Sri Vaishnavi Mylavarapu&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Chunduru Chetana&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=153909</id>
		<title>CSC/ECE 517 Spring 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=153909"/>
		<updated>2024-03-24T22:55:01Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2405 Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2407 Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2428 Replicate Roles and Institution UIs ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2429 Reimplement student_task list]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2414 Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - ‬NTNX-2‬‭ : Snapshot Functionality for provisioned databases]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2411 : Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2420. Reimplement student_quizzes_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2426. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2425. Create a Courses user interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2431. Reimplement  grades/view_team]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2404 Refactor student teams functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2403 Mentor-Meeting Management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2421. Reimplement impersonating users (within impersonate controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2413. Testing - Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2412. Testing for hamer.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2427. UI for questionnaire.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Smylava&amp;diff=153901</id>
		<title>User:Smylava</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Smylava&amp;diff=153901"/>
		<updated>2024-03-24T22:51:34Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe moved page User:Smylava to E2419. Reimplement duties controller.rb and badges controller.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[E2419. Reimplement duties controller.rb and badges controller.rb]]&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153900</id>
		<title>E2419. Reimplement duties controller.rb and badges controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153900"/>
		<updated>2024-03-24T22:51:34Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: Kgudipe moved page User:Smylava to E2419. Reimplement duties controller.rb and badges 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 duties_controller.rb and badges_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
duties_controller.rb&lt;br /&gt;
&lt;br /&gt;
This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is used to update the duty in the database. Finally, the delete action can be used to remove a duty from the database. Expertiza's Duties module helps with duty management.&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
The controller generates a new Badge instance by utilizing user-provided parameters via the create action. If an image file is included, it is also stored, and the badge instance's image_name attribute is updated accordingly.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza platform is a versatile and modular system designed to enable students to submit assignments and quizzes smoothly, while also facilitating collaborative learning through features such as peer review. Embraced by students, teaching assistants, and professors alike, this sophisticated system optimizes academic assessments, promoting an interactive and efficient educational environment.&lt;br /&gt;
&lt;br /&gt;
The primary aim of the student quizzes module is to provide a platform for students to generate quizzes for their peers who are working on the same assignments. This fosters a collaborative learning environment where students can collectively improve their understanding and support each other's educational progress.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Previously, the Expertiza system lacked specific functionalities related to duties and badges, which meant there were no established mechanisms within the system to manage duties or to create and manage badges. This absence was notable, as such features could significantly enhance user interaction and system management by allowing for the assignment of responsibilities and the acknowledgment of achievements within the system. To address this gap, a project has been initiated to develop and integrate these functionalities into the Expertiza system through an API framework built on Rails.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The project entails revamping and improving the Duties and Badges modules within an API framework constructed on Rails. In duties_controller.rb, actions for handling duties, such as creation, editing, updating, and deletion, in the Expertiza system are defined. Conversely, badges_controller.rb manages the creation of Badge instances, enabling users to define badge parameters and optionally attach an image file, which is then saved and linked with the badge.&lt;br /&gt;
&lt;br /&gt;
The primary focus of the project is to implement these functionalities as RESTful API endpoints, adhering strictly to JSON response standards. Comprehensive testing, covering both positive and negative scenarios, is imperative to validate the accuracy and resilience of the implemented features. Additionally, prioritizing security, error handling, and validation is crucial for maintaining data integrity and thwarting potential vulnerabilities. The reimplementation must adhere to Rails conventions and adhere to best practices, promoting maintainability and scalability while ensuring smooth integration with other modules in the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza duties and bages controller 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 each 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: Develop methods in duties_controller and badges_controller to facilitate the creation of new Duties and Badges, respectively. These methods will allow instructors and system administrators to input necessary details such as duty descriptions, badge criteria, and associated rewards.&lt;br /&gt;
&lt;br /&gt;
* Read: Implement show actions within both controllers to enable users to retrieve and view details of specific Duties and Badges. This includes viewing duty responsibilities, badge criteria, and any rewards associated with the completion of duties or earning of badges.&lt;br /&gt;
&lt;br /&gt;
* Update: Add update methods in duties_controller and badges_controller to allow for the modification of existing Duties and Badges. This functionality will enable the adjustment of details such as duty parameters and badge criteria to keep the system’s content current and relevant.&lt;br /&gt;
&lt;br /&gt;
* Delete: Create destroy actions in both controllers to support the deletion of Duties and Badges that are no longer needed or relevant. This will assist in maintaining a clean and efficient database, removing outdated or unnecessary information.&lt;br /&gt;
&lt;br /&gt;
* Index: Enhance the index actions in both duties_controller and badges_controller to list all Duties and Badges, respectively, providing users with an overview of available duties and badges. The index view will be optimized for ease of access and clarity, making it simpler for users to navigate and manage duties and badges within the system.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Admin shall create a test&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Duties Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
 class Api::V1::DutiesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_duty, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves all duties.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all duties from the database using the Duty.all method and renders a JSON response containing all duties.&lt;br /&gt;
  # GET /duties&lt;br /&gt;
  def index&lt;br /&gt;
    @duties = Duty.all&lt;br /&gt;
    render json: @duties&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves a specific duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a duty by its ID and renders a JSON response containing the specific duty&lt;br /&gt;
  # GET /duties/1&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @duty, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Creates a new duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Creates a new duty by instantiating a Duty object with the provided duty parameters from the request (duty_params).&lt;br /&gt;
  # POST /duties&lt;br /&gt;
  def create&lt;br /&gt;
    @duty = Duty.new(duty_params)&lt;br /&gt;
&lt;br /&gt;
    if @duty.save&lt;br /&gt;
      render json: @duty, status: :created, location: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Updates an existing duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Updates an existing duty specified by its ID using the provided duty parameters from the request (duty_params). &lt;br /&gt;
  # PATCH/PUT /duties/1&lt;br /&gt;
  def update&lt;br /&gt;
    if @duty.update(duty_params)&lt;br /&gt;
      render json: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Deletes a duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a specific duty by its ID and destroys (deletes) it. It then renders a JSON response with a success message&lt;br /&gt;
  # DELETE /duties/1&lt;br /&gt;
  def destroy&lt;br /&gt;
    @duty.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Duty was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_duty Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This technique serves as a callback to establish the @duty instance variable by locating the duty according to the :id parameter. It is applied prior to the show, update, and destroy actions to prepare the specific duty undergoing operation.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_duty&lt;br /&gt;
      @duty = Duty.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''duty_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This process filters the duty parameters received from the request, permitting only designated parameters (:name, :assignment_id, :max_members_for_duties) for creating or updating a duty. It utilizes Rails' strong parameters feature for security purposes.&lt;br /&gt;
&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def duty_params&lt;br /&gt;
      params.require(:duty).permit(:name, :assignment_id, :max_members_for_duties)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
=== Badges Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 class Api::V1::BadgesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_badge, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves all badges.&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all existing badges from the database using Badge.all and returns a JSON array containing all badge records.&lt;br /&gt;
&lt;br /&gt;
  # GET /badges&lt;br /&gt;
  # Lists all badges&lt;br /&gt;
  def index&lt;br /&gt;
    @badges = Badge.all&lt;br /&gt;
    render json: { badges: @badges }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves a specific badge.&lt;br /&gt;
&lt;br /&gt;
Description: Finds and retrieves a particular badge by its ID from the database. The method responds with a JSON object containing the details of the specific badge.&lt;br /&gt;
  # GET /badges/1&lt;br /&gt;
  # Shows a single badge&lt;br /&gt;
  def show&lt;br /&gt;
    render json: { badge: @badge }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Creates a new badge.&lt;br /&gt;
&lt;br /&gt;
Description: Instantiates a new badge using the parameters provided in the request (badge_params).&lt;br /&gt;
  # POST /badges&lt;br /&gt;
  # Creates a new badge&lt;br /&gt;
  def create&lt;br /&gt;
    @badge = Badge.new(badge_params)&lt;br /&gt;
&lt;br /&gt;
    if @badge.save&lt;br /&gt;
      render json: { badge: @badge }, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Updates an existing badge.&lt;br /&gt;
&lt;br /&gt;
Description: Modifies the attributes of an existing badge based on the parameters received in the request (badge_params).&lt;br /&gt;
  # PATCH/PUT /badges/1&lt;br /&gt;
  # Updates an existing badge&lt;br /&gt;
  def update&lt;br /&gt;
    if @badge.update(badge_params)&lt;br /&gt;
      render json: { badge: @badge }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Deletes a badge.&lt;br /&gt;
&lt;br /&gt;
Description: Locates a specific badge by its ID and removes it from the database. &lt;br /&gt;
  # DELETE /badges/1&lt;br /&gt;
  # Deletes a badge&lt;br /&gt;
  def destroy&lt;br /&gt;
    @badge.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Badge was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_badge Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Sets up a specific badge for other actions.&lt;br /&gt;
&lt;br /&gt;
Description: This callback function locates and assigns the @badge instance variable according to the :id parameter before executing the show, update, and destroy actions.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_badge&lt;br /&gt;
      @badge = Badge.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''badge_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Filters and permits badge parameters for security.&lt;br /&gt;
&lt;br /&gt;
Description: This process screens the badge parameters received via the request, permitting only certain parameters (:name, :description, :image_name, :image_file) to be utilized for creating or updating a badge.&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def badge_params&lt;br /&gt;
      params.require(:badge).permit(:name, :description, :image_name)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
'''&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. 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 User Required Setup ===&lt;br /&gt;
==== 1. Login as an User 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;admin&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;admin\&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;
&lt;br /&gt;
==== 2. User Creates Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
Be sure the ids match the database ids for the assignments.&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test duty 1&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
==== 3. User can see all available Duties ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 4. User can see a particular Duty ====&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 duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 5. User can update a Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty and assignments.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 6. User can delete a Duty ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 7. User Creates Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing creation of badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
==== 8. User can see all available Badges====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 9. User can see a particular Badge====&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 badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 10. User can update a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge_1&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 11. User can delete a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/3' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In summary, the reimplementation project for the Duties and Badges modules in Expertiza is crucial for bringing existing functionalities in line with API standards and addressing identified shortcomings from the previous implementation.&lt;br /&gt;
&lt;br /&gt;
The Duties module, managed through duties_controller.rb, is central to handling duties' creation, editing, and deletion within the system. Similarly, the Badges module, governed by badges_controller.rb, oversees badge creation and management, including handling image files.&lt;br /&gt;
&lt;br /&gt;
The main issues with the previous implementation stemmed from treating the system as a traditional Rails MVC application rather than as a Rails API. This resulted in non-compliance with API standards in request and response handling, which this reimplementation aims to fix. Furthermore, deficiencies in testing procedures underscored the need for comprehensive testing to ensure system robustness and reliability.&lt;br /&gt;
&lt;br /&gt;
The planned work involves strict adherence to API-style interactions, returning data in JSON format, and implementing thorough testing for all REST endpoints to ensure robust verification of Duties and Badge functionalities across various scenarios.&lt;br /&gt;
&lt;br /&gt;
By addressing these issues and carefully implementing planned functionalities, this reimplementation aims to improve system efficiency, robustness, and adherence to API conventions, ultimately providing a more reliable and scalable platform for managing duties and badges within Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
'''Group members:'''&lt;br /&gt;
&lt;br /&gt;
Akhilsai Chittipolu &lt;br /&gt;
 &lt;br /&gt;
Koushik Gudipelly&lt;br /&gt;
&lt;br /&gt;
Sri Vaishnavi Mylavarapu&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Chunduru Chetana&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153560</id>
		<title>E2419. Reimplement duties controller.rb and badges controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153560"/>
		<updated>2024-03-24T18:52:20Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the duties_controller.rb and badges_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
duties_controller.rb&lt;br /&gt;
&lt;br /&gt;
This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is used to update the duty in the database. Finally, the delete action can be used to remove a duty from the database. Expertiza's Duties module helps with duty management.&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
The controller generates a new Badge instance by utilizing user-provided parameters via the create action. If an image file is included, it is also stored, and the badge instance's image_name attribute is updated accordingly.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza platform is a versatile and modular system designed to enable students to submit assignments and quizzes smoothly, while also facilitating collaborative learning through features such as peer review. Embraced by students, teaching assistants, and professors alike, this sophisticated system optimizes academic assessments, promoting an interactive and efficient educational environment.&lt;br /&gt;
&lt;br /&gt;
The primary aim of the student quizzes module is to provide a platform for students to generate quizzes for their peers who are working on the same assignments. This fosters a collaborative learning environment where students can collectively improve their understanding and support each other's educational progress.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Previously, the Expertiza system lacked specific functionalities related to duties and badges, which meant there were no established mechanisms within the system to manage duties or to create and manage badges. This absence was notable, as such features could significantly enhance user interaction and system management by allowing for the assignment of responsibilities and the acknowledgment of achievements within the system. To address this gap, a project has been initiated to develop and integrate these functionalities into the Expertiza system through an API framework built on Rails.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The project entails revamping and improving the Duties and Badges modules within an API framework constructed on Rails. In duties_controller.rb, actions for handling duties, such as creation, editing, updating, and deletion, in the Expertiza system are defined. Conversely, badges_controller.rb manages the creation of Badge instances, enabling users to define badge parameters and optionally attach an image file, which is then saved and linked with the badge.&lt;br /&gt;
&lt;br /&gt;
The primary focus of the project is to implement these functionalities as RESTful API endpoints, adhering strictly to JSON response standards. Comprehensive testing, covering both positive and negative scenarios, is imperative to validate the accuracy and resilience of the implemented features. Additionally, prioritizing security, error handling, and validation is crucial for maintaining data integrity and thwarting potential vulnerabilities. The reimplementation must adhere to Rails conventions and adhere to best practices, promoting maintainability and scalability while ensuring smooth integration with other modules in the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza duties and bages controller 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 each 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: Develop methods in duties_controller and badges_controller to facilitate the creation of new Duties and Badges, respectively. These methods will allow instructors and system administrators to input necessary details such as duty descriptions, badge criteria, and associated rewards.&lt;br /&gt;
&lt;br /&gt;
* Read: Implement show actions within both controllers to enable users to retrieve and view details of specific Duties and Badges. This includes viewing duty responsibilities, badge criteria, and any rewards associated with the completion of duties or earning of badges.&lt;br /&gt;
&lt;br /&gt;
* Update: Add update methods in duties_controller and badges_controller to allow for the modification of existing Duties and Badges. This functionality will enable the adjustment of details such as duty parameters and badge criteria to keep the system’s content current and relevant.&lt;br /&gt;
&lt;br /&gt;
* Delete: Create destroy actions in both controllers to support the deletion of Duties and Badges that are no longer needed or relevant. This will assist in maintaining a clean and efficient database, removing outdated or unnecessary information.&lt;br /&gt;
&lt;br /&gt;
* Index: Enhance the index actions in both duties_controller and badges_controller to list all Duties and Badges, respectively, providing users with an overview of available duties and badges. The index view will be optimized for ease of access and clarity, making it simpler for users to navigate and manage duties and badges within the system.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Admin shall create a test&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Duties Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
 class Api::V1::DutiesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_duty, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves all duties.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all duties from the database using the Duty.all method and renders a JSON response containing all duties.&lt;br /&gt;
  # GET /duties&lt;br /&gt;
  def index&lt;br /&gt;
    @duties = Duty.all&lt;br /&gt;
    render json: @duties&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves a specific duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a duty by its ID and renders a JSON response containing the specific duty&lt;br /&gt;
  # GET /duties/1&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @duty, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Creates a new duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Creates a new duty by instantiating a Duty object with the provided duty parameters from the request (duty_params).&lt;br /&gt;
  # POST /duties&lt;br /&gt;
  def create&lt;br /&gt;
    @duty = Duty.new(duty_params)&lt;br /&gt;
&lt;br /&gt;
    if @duty.save&lt;br /&gt;
      render json: @duty, status: :created, location: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Updates an existing duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Updates an existing duty specified by its ID using the provided duty parameters from the request (duty_params). &lt;br /&gt;
  # PATCH/PUT /duties/1&lt;br /&gt;
  def update&lt;br /&gt;
    if @duty.update(duty_params)&lt;br /&gt;
      render json: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Deletes a duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a specific duty by its ID and destroys (deletes) it. It then renders a JSON response with a success message&lt;br /&gt;
  # DELETE /duties/1&lt;br /&gt;
  def destroy&lt;br /&gt;
    @duty.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Duty was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_duty Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This technique serves as a callback to establish the @duty instance variable by locating the duty according to the :id parameter. It is applied prior to the show, update, and destroy actions to prepare the specific duty undergoing operation.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_duty&lt;br /&gt;
      @duty = Duty.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''duty_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This process filters the duty parameters received from the request, permitting only designated parameters (:name, :assignment_id, :max_members_for_duties) for creating or updating a duty. It utilizes Rails' strong parameters feature for security purposes.&lt;br /&gt;
&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def duty_params&lt;br /&gt;
      params.require(:duty).permit(:name, :assignment_id, :max_members_for_duties)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
=== Badges Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 class Api::V1::BadgesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_badge, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves all badges.&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all existing badges from the database using Badge.all and returns a JSON array containing all badge records.&lt;br /&gt;
&lt;br /&gt;
  # GET /badges&lt;br /&gt;
  # Lists all badges&lt;br /&gt;
  def index&lt;br /&gt;
    @badges = Badge.all&lt;br /&gt;
    render json: { badges: @badges }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves a specific badge.&lt;br /&gt;
&lt;br /&gt;
Description: Finds and retrieves a particular badge by its ID from the database. The method responds with a JSON object containing the details of the specific badge.&lt;br /&gt;
  # GET /badges/1&lt;br /&gt;
  # Shows a single badge&lt;br /&gt;
  def show&lt;br /&gt;
    render json: { badge: @badge }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Creates a new badge.&lt;br /&gt;
&lt;br /&gt;
Description: Instantiates a new badge using the parameters provided in the request (badge_params).&lt;br /&gt;
  # POST /badges&lt;br /&gt;
  # Creates a new badge&lt;br /&gt;
  def create&lt;br /&gt;
    @badge = Badge.new(badge_params)&lt;br /&gt;
&lt;br /&gt;
    if @badge.save&lt;br /&gt;
      render json: { badge: @badge }, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Updates an existing badge.&lt;br /&gt;
&lt;br /&gt;
Description: Modifies the attributes of an existing badge based on the parameters received in the request (badge_params).&lt;br /&gt;
  # PATCH/PUT /badges/1&lt;br /&gt;
  # Updates an existing badge&lt;br /&gt;
  def update&lt;br /&gt;
    if @badge.update(badge_params)&lt;br /&gt;
      render json: { badge: @badge }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Deletes a badge.&lt;br /&gt;
&lt;br /&gt;
Description: Locates a specific badge by its ID and removes it from the database. &lt;br /&gt;
  # DELETE /badges/1&lt;br /&gt;
  # Deletes a badge&lt;br /&gt;
  def destroy&lt;br /&gt;
    @badge.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Badge was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_badge Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Sets up a specific badge for other actions.&lt;br /&gt;
&lt;br /&gt;
Description: This callback function locates and assigns the @badge instance variable according to the :id parameter before executing the show, update, and destroy actions.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_badge&lt;br /&gt;
      @badge = Badge.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''badge_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Filters and permits badge parameters for security.&lt;br /&gt;
&lt;br /&gt;
Description: This process screens the badge parameters received via the request, permitting only certain parameters (:name, :description, :image_name, :image_file) to be utilized for creating or updating a badge.&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def badge_params&lt;br /&gt;
      params.require(:badge).permit(:name, :description, :image_name)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
'''&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. 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 User Required Setup ===&lt;br /&gt;
==== 1. Login as an User 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;admin&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;admin\&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;
&lt;br /&gt;
==== 2. User Creates Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
Be sure the ids match the database ids for the assignments.&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test duty 1&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
==== 3. User can see all available Duties ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 4. User can see a particular Duty ====&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 duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 5. User can update a Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty and assignments.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 6. User can delete a Duty ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 7. User Creates Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing creation of badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
==== 8. User can see all available Badges====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 9. User can see a particular Badge====&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 badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 10. User can update a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge_1&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 11. User can delete a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/3' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In summary, the reimplementation project for the Duties and Badges modules in Expertiza is crucial for bringing existing functionalities in line with API standards and addressing identified shortcomings from the previous implementation.&lt;br /&gt;
&lt;br /&gt;
The Duties module, managed through duties_controller.rb, is central to handling duties' creation, editing, and deletion within the system. Similarly, the Badges module, governed by badges_controller.rb, oversees badge creation and management, including handling image files.&lt;br /&gt;
&lt;br /&gt;
The main issues with the previous implementation stemmed from treating the system as a traditional Rails MVC application rather than as a Rails API. This resulted in non-compliance with API standards in request and response handling, which this reimplementation aims to fix. Furthermore, deficiencies in testing procedures underscored the need for comprehensive testing to ensure system robustness and reliability.&lt;br /&gt;
&lt;br /&gt;
The planned work involves strict adherence to API-style interactions, returning data in JSON format, and implementing thorough testing for all REST endpoints to ensure robust verification of Duties and Badge functionalities across various scenarios.&lt;br /&gt;
&lt;br /&gt;
By addressing these issues and carefully implementing planned functionalities, this reimplementation aims to improve system efficiency, robustness, and adherence to API conventions, ultimately providing a more reliable and scalable platform for managing duties and badges within Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
'''Group members:'''&lt;br /&gt;
&lt;br /&gt;
Akhilsai Chittipolu &lt;br /&gt;
 &lt;br /&gt;
Koushik Gudipelly&lt;br /&gt;
&lt;br /&gt;
Sri Vaishnavi Mylavarapu&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Chunduru Chetana&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153534</id>
		<title>E2419. Reimplement duties controller.rb and badges controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E2419._Reimplement_duties_controller.rb_and_badges_controller.rb&amp;diff=153534"/>
		<updated>2024-03-24T18:07:26Z</updated>

		<summary type="html">&lt;p&gt;Kgudipe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
Our team is tasked with creating the backend reimplementation of the duties_controller.rb and badges_controller.rb.&lt;br /&gt;
We are to use SOLID principles and adhere to the Guidelines for Reimplementation.&lt;br /&gt;
&lt;br /&gt;
duties_controller.rb&lt;br /&gt;
&lt;br /&gt;
This duties_controller defines the following actions: create, update, and remove. The create action is used to save the new duty to the database. While the edit action renders the form for altering an existing duty, the update action is used to update the duty in the database. Finally, the delete action can be used to remove a duty from the database. Expertiza's Duties module helps with duty management.&lt;br /&gt;
&lt;br /&gt;
badges_controller.rb&lt;br /&gt;
&lt;br /&gt;
The controller generates a new Badge instance by utilizing user-provided parameters via the create action. If an image file is included, it is also stored, and the badge instance's image_name attribute is updated accordingly.&lt;br /&gt;
&lt;br /&gt;
== Introduction To Expertiza System == &lt;br /&gt;
The Expertiza platform is a versatile and modular system designed to enable students to submit assignments and quizzes smoothly, while also facilitating collaborative learning through features such as peer review. Embraced by students, teaching assistants, and professors alike, this sophisticated system optimizes academic assessments, promoting an interactive and efficient educational environment.&lt;br /&gt;
&lt;br /&gt;
The primary aim of the student quizzes module is to provide a platform for students to generate quizzes for their peers who are working on the same assignments. This fosters a collaborative learning environment where students can collectively improve their understanding and support each other's educational progress.&lt;br /&gt;
&lt;br /&gt;
== Issues with Previous Functionality ==&lt;br /&gt;
Previously, the Expertiza system lacked specific functionalities related to duties and badges, which meant there were no established mechanisms within the system to manage duties or to create and manage badges. This absence was notable, as such features could significantly enhance user interaction and system management by allowing for the assignment of responsibilities and the acknowledgment of achievements within the system. To address this gap, a project has been initiated to develop and integrate these functionalities into the Expertiza system through an API framework built on Rails.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
The project entails revamping and improving the Duties and Badges modules within an API framework constructed on Rails. In duties_controller.rb, actions for handling duties, such as creation, editing, updating, and deletion, in the Expertiza system are defined. Conversely, badges_controller.rb manages the creation of Badge instances, enabling users to define badge parameters and optionally attach an image file, which is then saved and linked with the badge.&lt;br /&gt;
&lt;br /&gt;
The primary focus of the project is to implement these functionalities as RESTful API endpoints, adhering strictly to JSON response standards. Comprehensive testing, covering both positive and negative scenarios, is imperative to validate the accuracy and resilience of the implemented features. Additionally, prioritizing security, error handling, and validation is crucial for maintaining data integrity and thwarting potential vulnerabilities. The reimplementation must adhere to Rails conventions and adhere to best practices, promoting maintainability and scalability while ensuring smooth integration with other modules in the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Test Driven Development (TDD) ===&lt;br /&gt;
Our approach to developing Expertiza duties and bages controller 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 each 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: Develop methods in duties_controller and badges_controller to facilitate the creation of new Duties and Badges, respectively. These methods will allow instructors and system administrators to input necessary details such as duty descriptions, badge criteria, and associated rewards.&lt;br /&gt;
&lt;br /&gt;
* Read: Implement show actions within both controllers to enable users to retrieve and view details of specific Duties and Badges. This includes viewing duty responsibilities, badge criteria, and any rewards associated with the completion of duties or earning of badges.&lt;br /&gt;
&lt;br /&gt;
* Update: Add update methods in duties_controller and badges_controller to allow for the modification of existing Duties and Badges. This functionality will enable the adjustment of details such as duty parameters and badge criteria to keep the system’s content current and relevant.&lt;br /&gt;
&lt;br /&gt;
* Delete: Create destroy actions in both controllers to support the deletion of Duties and Badges that are no longer needed or relevant. This will assist in maintaining a clean and efficient database, removing outdated or unnecessary information.&lt;br /&gt;
&lt;br /&gt;
* Index: Enhance the index actions in both duties_controller and badges_controller to list all Duties and Badges, respectively, providing users with an overview of available duties and badges. The index view will be optimized for ease of access and clarity, making it simpler for users to navigate and manage duties and badges within the system.&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
* cURL shall be used to simulate HTTP requests&lt;br /&gt;
* Only an Admin shall create a test&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Duties Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
 class Api::V1::DutiesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_duty, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves all duties.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all duties from the database using the Duty.all method and renders a JSON response containing all duties.&lt;br /&gt;
  # GET /duties&lt;br /&gt;
  def index&lt;br /&gt;
    @duties = Duty.all&lt;br /&gt;
    render json: @duties&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Retrieves a specific duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a duty by its ID and renders a JSON response containing the specific duty&lt;br /&gt;
  # GET /duties/1&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @duty, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Creates a new duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties&lt;br /&gt;
&lt;br /&gt;
Description: Creates a new duty by instantiating a Duty object with the provided duty parameters from the request (duty_params).&lt;br /&gt;
  # POST /duties&lt;br /&gt;
  def create&lt;br /&gt;
    @duty = Duty.new(duty_params)&lt;br /&gt;
&lt;br /&gt;
    if @duty.save&lt;br /&gt;
      render json: @duty, status: :created, location: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Updates an existing duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Updates an existing duty specified by its ID using the provided duty parameters from the request (duty_params). &lt;br /&gt;
  # PATCH/PUT /duties/1&lt;br /&gt;
  def update&lt;br /&gt;
    if @duty.update(duty_params)&lt;br /&gt;
      render json: @duty&lt;br /&gt;
    else&lt;br /&gt;
      render json: @duty.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
Function: Deletes a duty.&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
URL Endpoint: /duties/:id&lt;br /&gt;
&lt;br /&gt;
Description: Finds a specific duty by its ID and destroys (deletes) it. It then renders a JSON response with a success message&lt;br /&gt;
  # DELETE /duties/1&lt;br /&gt;
  def destroy&lt;br /&gt;
    @duty.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Duty was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_duty Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This technique serves as a callback to establish the @duty instance variable by locating the duty according to the :id parameter. It is applied prior to the show, update, and destroy actions to prepare the specific duty undergoing operation.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_duty&lt;br /&gt;
      @duty = Duty.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''duty_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
This process filters the duty parameters received from the request, permitting only designated parameters (:name, :assignment_id, :max_members_for_duties) for creating or updating a duty. It utilizes Rails' strong parameters feature for security purposes.&lt;br /&gt;
&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def duty_params&lt;br /&gt;
      params.require(:duty).permit(:name, :assignment_id, :max_members_for_duties)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
=== Badges Controller ===&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 class Api::V1::BadgesController &amp;lt; ApplicationController&lt;br /&gt;
  before_action :set_badge, only: %i[ show update destroy ]&lt;br /&gt;
&lt;br /&gt;
'''index Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves all badges.&lt;br /&gt;
&lt;br /&gt;
Description: Fetches all existing badges from the database using Badge.all and returns a JSON array containing all badge records.&lt;br /&gt;
&lt;br /&gt;
  # GET /badges&lt;br /&gt;
  # Lists all badges&lt;br /&gt;
  def index&lt;br /&gt;
    @badges = Badge.all&lt;br /&gt;
    render json: { badges: @badges }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''show Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: GET&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Retrieves a specific badge.&lt;br /&gt;
&lt;br /&gt;
Description: Finds and retrieves a particular badge by its ID from the database. The method responds with a JSON object containing the details of the specific badge.&lt;br /&gt;
  # GET /badges/1&lt;br /&gt;
  # Shows a single badge&lt;br /&gt;
  def show&lt;br /&gt;
    render json: { badge: @badge }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''create Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: POST&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges&lt;br /&gt;
&lt;br /&gt;
Functionality: Creates a new badge.&lt;br /&gt;
&lt;br /&gt;
Description: Instantiates a new badge using the parameters provided in the request (badge_params).&lt;br /&gt;
  # POST /badges&lt;br /&gt;
  # Creates a new badge&lt;br /&gt;
  def create&lt;br /&gt;
    @badge = Badge.new(badge_params)&lt;br /&gt;
&lt;br /&gt;
    if @badge.save&lt;br /&gt;
      render json: { badge: @badge }, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''update Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: PATCH/PUT&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Updates an existing badge.&lt;br /&gt;
&lt;br /&gt;
Description: Modifies the attributes of an existing badge based on the parameters received in the request (badge_params).&lt;br /&gt;
  # PATCH/PUT /badges/1&lt;br /&gt;
  # Updates an existing badge&lt;br /&gt;
  def update&lt;br /&gt;
    if @badge.update(badge_params)&lt;br /&gt;
      render json: { badge: @badge }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { errors: @badge.errors.full_messages }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''destroy Method:'''&lt;br /&gt;
&lt;br /&gt;
HTTP Verb: DELETE&lt;br /&gt;
&lt;br /&gt;
Endpoint: /badges/:id&lt;br /&gt;
&lt;br /&gt;
Functionality: Deletes a badge.&lt;br /&gt;
&lt;br /&gt;
Description: Locates a specific badge by its ID and removes it from the database. &lt;br /&gt;
  # DELETE /badges/1&lt;br /&gt;
  # Deletes a badge&lt;br /&gt;
  def destroy&lt;br /&gt;
    @badge.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Badge was successfully destroyed.&amp;quot; }, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''set_badge Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Sets up a specific badge for other actions.&lt;br /&gt;
&lt;br /&gt;
Description: This callback function locates and assigns the @badge instance variable according to the :id parameter before executing the show, update, and destroy actions.&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
    # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
    def set_badge&lt;br /&gt;
      @badge = Badge.find(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''badge_params Method (Private):'''&lt;br /&gt;
&lt;br /&gt;
Function: Filters and permits badge parameters for security.&lt;br /&gt;
&lt;br /&gt;
Description: This process screens the badge parameters received via the request, permitting only certain parameters (:name, :description, :image_name, :image_file) to be utilized for creating or updating a badge.&lt;br /&gt;
    # Only allow a list of trusted parameters through.&lt;br /&gt;
    def badge_params&lt;br /&gt;
      params.require(:badge).permit(:name, :description, :image_name)&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
'''&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. 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 User Required Setup ===&lt;br /&gt;
==== 1. Login as an User 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;admin&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;admin\&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;
&lt;br /&gt;
==== 2. User Creates Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
Be sure the ids match the database ids for the assignments.&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test duty 1&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 3. User can see all available Duties ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 4. User can see a particular Duty ====&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 duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 5. User can update a Duty====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty and assignments.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test&amp;quot;,&lt;br /&gt;
  &amp;quot;max_members_for_duty&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;assignment_id&amp;quot;: 1&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 6. User can delete a Duty ====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the duty.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/duties/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 7. User Creates Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'POST' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing creation of badge 3&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
==== 8. User can see all available Badges====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 9. User can see a particular Badge====&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 badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'GET' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
==== 10. User can update a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'PATCH' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/1' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg' \&lt;br /&gt;
  -H 'Content-Type: application/json' \&lt;br /&gt;
  -d '{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;test badge_1&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;testing&amp;quot;,&lt;br /&gt;
  &amp;quot;image_file&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 11. User can delete a Badge====&lt;br /&gt;
Execute the following command.  Make sure the Bearer Token matches what was obtained in step 1 when logging in as an User.&lt;br /&gt;
&lt;br /&gt;
Be sure the ids match the database ids for the badge.&lt;br /&gt;
&lt;br /&gt;
  curl -X 'DELETE' \&lt;br /&gt;
  'http://127.0.0.1:3002/api/v1/badges/3' \&lt;br /&gt;
  -H 'accept: /' \&lt;br /&gt;
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImFkbWluIiwiZnVsbF9uYW1lIjoiYWRtaW4gYWRtaW4iLCJyb2xlIjoiU3VwZXIgQWRtaW5pc3RyYXRvciIsImluc3RpdHV0aW9uX2lkIjoxLCJleHAiOjE3MTEzNDEzOTl9.GNjSZGuZnmCJVWRtwKORMgMtV6f9wiHlWzH7weLMq3z3ipTU2qw6SMoDZsSoNnRlDerknzcIaz8sccrjWdQ6CGT_IDavygi0GQzA9t8l4HZtDCObmcGRiFyFEkYoJHfxw6M2F_AQC9Csl_FgUFbQCxj-goFfVYZxs-YkXnqMl_nJFKeQRWrhkSEW-_sJm0IUw8ytmo3TuOEwbuNWwHI6EjH3acB5o4WBZxBfJPbKb3OoFEMYe-vjf6lnpLn4mIBhHrnrgNFe8AxMiqV0CuOe6Yl8MqMMyCEzf9k_1aXIpb3nqHlBATRzjrZh7vS-YDqt0bUCYNHPsSINdPqVrzhLFg'&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In summary, the reimplementation project for the Duties and Badges modules in Expertiza is crucial for bringing existing functionalities in line with API standards and addressing identified shortcomings from the previous implementation.&lt;br /&gt;
&lt;br /&gt;
The Duties module, managed through duties_controller.rb, is central to handling duties' creation, editing, and deletion within the system. Similarly, the Badges module, governed by badges_controller.rb, oversees badge creation and management, including handling image files.&lt;br /&gt;
&lt;br /&gt;
The main issues with the previous implementation stemmed from treating the system as a traditional Rails MVC application rather than as a Rails API. This resulted in non-compliance with API standards in request and response handling, which this reimplementation aims to fix. Furthermore, deficiencies in testing procedures underscored the need for comprehensive testing to ensure system robustness and reliability.&lt;br /&gt;
&lt;br /&gt;
The planned work involves strict adherence to API-style interactions, returning data in JSON format, and implementing thorough testing for all REST endpoints to ensure robust verification of Duties and Badge functionalities across various scenarios.&lt;br /&gt;
&lt;br /&gt;
By addressing these issues and carefully implementing planned functionalities, this reimplementation aims to improve system efficiency, robustness, and adherence to API conventions, ultimately providing a more reliable and scalable platform for managing duties and badges within Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
'''Group members:'''&lt;br /&gt;
&lt;br /&gt;
Akhilsai Chittipolu &lt;br /&gt;
 &lt;br /&gt;
Koushik Gudipelly&lt;br /&gt;
&lt;br /&gt;
Sri Vaishnavi Mylavarapu&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Chunduru Chetana&lt;/div&gt;</summary>
		<author><name>Kgudipe</name></author>
	</entry>
</feed>