<?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=Asavla</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=Asavla"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Asavla"/>
	<updated>2026-05-22T19:42:31Z</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_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=156935</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=156935"/>
		<updated>2024-04-27T15:20:39Z</updated>

		<summary type="html">&lt;p&gt;Asavla: /* Current v/s New Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current vs. New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 # Controller method to create a new bookmark&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      # Normalize URL if necessary for consistency&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
      # Attempt to save the bookmark&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
&lt;br /&gt;
      # Return JSON response with the created bookmark&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      # Return JSON response with error message if save fails&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  # Controller method to update an existing bookmark&lt;br /&gt;
  def update&lt;br /&gt;
    # Normalize URL if necessary for consistency&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    # Attempt to update the bookmark&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      # Return JSON response with updated bookmark if successful&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      # Return JSON response with error messages if update fails&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
====destroy====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
* Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  # Controller method to delete a bookmark&lt;br /&gt;
  def destroy&lt;br /&gt;
    # Find the bookmark to delete&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Attempt to delete the bookmark&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    # Return JSON response indicating successful deletion&lt;br /&gt;
    render json: { message: 'Bookmark successfully deleted' }, status: :ok&lt;br /&gt;
   rescue ActiveRecord::RecordNotFound&lt;br /&gt;
     # Return JSON response with error message if bookmark not found&lt;br /&gt;
     render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design Principles Used and Implemented==&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle (SRP)===&lt;br /&gt;
Each function and class within the controller adheres to the SRP, focusing on a single aspect of bookmark management to promote maintainability and clarity. For example, the `create`, `update`, `destroy`, and `list` actions in the BookmarksController are responsible for specific CRUD operations, ensuring that each method has a clear and distinct purpose.&lt;br /&gt;
&lt;br /&gt;
===Don't Repeat Yourself (DRY)===&lt;br /&gt;
Redundancy is reduced by encapsulating shared functionalities into auxiliary methods or modules, promoting code efficiency and consistency. For instance, URL normalization logic is encapsulated into a reusable method to ensure consistency across the application, reducing duplication of code and promoting maintainability.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
Data and functionality are organized into suitable methods and classes to reduce dependencies and promote modularization and maintainability. For example, the `before_action :set_bookmark` method centralizes bookmark fetching for relevant actions, encapsulating this logic and reducing duplication within the controller.&lt;br /&gt;
&lt;br /&gt;
===Error Handling===&lt;br /&gt;
Robust error handling mechanisms are implemented to handle exceptions gracefully and provide informative error messages, enhancing user experience and troubleshooting capabilities. For example, structured error handling ensures that users receive clear error messages when CRUD operations fail, helping them understand and address any issues effectively.&lt;br /&gt;
&lt;br /&gt;
These design principles and coding patterns are instrumental in developing a robust, scalable, and maintainable bookmarks controller for the Expertiza project, ensuring high quality and reliability of the software.&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
Begin by sending a POST request to `/login` using the '''user_name''' and `password` fields to obtain an authentication token.&lt;br /&gt;
&lt;br /&gt;
[[Image:Login-postman.png | 800px | Login with provided credentials]]&lt;br /&gt;
&lt;br /&gt;
In Postman, navigate to the 'Authorization' tab for your request and select 'Bearer Token'. Paste the copied token into the 'Token' field.&lt;br /&gt;
&lt;br /&gt;
[[Image:Postman Auth section.png | 800px | Paste token in Authorization section]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== CRUD Operations ===&lt;br /&gt;
&lt;br /&gt;
==== Create Bookmark ====&lt;br /&gt;
&lt;br /&gt;
Send a POST request to the `/bookmarks` endpoint with the required parameters (`url`, `title`, `description`, `user_id`, `topic_id`).&lt;br /&gt;
&lt;br /&gt;
[[Image:Create Bookmark.png | 800px | Create a bookmark]]&lt;br /&gt;
&lt;br /&gt;
==== Read Bookmarks ====&lt;br /&gt;
&lt;br /&gt;
You can retrieve a list of bookmarks associated with a particular topic ID by sending a GET request to the `/bookmarks/list/:topic_id` endpoint.&lt;br /&gt;
&lt;br /&gt;
[[Image:List Bookmarks.png| 800px | List bookmarks]]&lt;br /&gt;
&lt;br /&gt;
==== Update Bookmark ====&lt;br /&gt;
Send a PUT request to the `/bookmarks/:id` endpoint with the bookmark ID to update. Include the updated parameters (`url`, `title`, `description`).&lt;br /&gt;
&lt;br /&gt;
[[Image:Updated bookmark.png | 800px | Update a bookmark]]&lt;br /&gt;
&lt;br /&gt;
==== Delete Bookmark ====&lt;br /&gt;
Send a DELETE request to the `/bookmarks/:id` endpoint with the bookmark ID to delete.&lt;br /&gt;
&lt;br /&gt;
[[Image:Delete bookmark.png | 800px | Delete a bookmark]]&lt;br /&gt;
&lt;br /&gt;
=== Save Rating for a Bookmark ===&lt;br /&gt;
To save a rating for a bookmark, send a POST request to the `/bookmarks/:id/rate` endpoint with the bookmark ID and the rating value.&lt;br /&gt;
&lt;br /&gt;
[[Image:Save bookmark rating.png | 800px | Save bookmark rating]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155601</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155601"/>
		<updated>2024-04-09T05:07:15Z</updated>

		<summary type="html">&lt;p&gt;Asavla: added design principles&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current v/s New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 # Controller method to create a new bookmark&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      # Normalize URL if necessary for consistency&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
      # Attempt to save the bookmark&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
&lt;br /&gt;
      # Return JSON response with the created bookmark&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      # Return JSON response with error message if save fails&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  # Controller method to update an existing bookmark&lt;br /&gt;
  def update&lt;br /&gt;
    # Normalize URL if necessary for consistency&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    # Attempt to update the bookmark&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      # Return JSON response with updated bookmark if successful&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      # Return JSON response with error messages if update fails&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
* Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  # Controller method to delete a bookmark&lt;br /&gt;
  def destroy&lt;br /&gt;
    # Find the bookmark to delete&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Attempt to delete the bookmark&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    # Return JSON response indicating successful deletion&lt;br /&gt;
    render json: { message: 'Bookmark successfully deleted' }, status: :ok&lt;br /&gt;
   rescue ActiveRecord::RecordNotFound&lt;br /&gt;
     # Return JSON response with error message if bookmark not found&lt;br /&gt;
     render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Design Principles Used and Implemented==&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle (SRP)===&lt;br /&gt;
Each function and class within the controller adheres to the SRP, focusing on a single aspect of bookmark management to promote maintainability and clarity. For example, the `create`, `update`, `destroy`, and `list` actions in the BookmarksController are responsible for specific CRUD operations, ensuring that each method has a clear and distinct purpose.&lt;br /&gt;
&lt;br /&gt;
===Don't Repeat Yourself (DRY)===&lt;br /&gt;
Redundancy is reduced by encapsulating shared functionalities into auxiliary methods or modules, promoting code efficiency and consistency. For instance, URL normalization logic is encapsulated into a reusable method to ensure consistency across the application, reducing duplication of code and promoting maintainability.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
Data and functionality are organized into suitable methods and classes to reduce dependencies and promote modularization and maintainability. For example, the `before_action :set_bookmark` method centralizes bookmark fetching for relevant actions, encapsulating this logic and reducing duplication within the controller.&lt;br /&gt;
&lt;br /&gt;
===Error Handling===&lt;br /&gt;
Robust error handling mechanisms are implemented to handle exceptions gracefully and provide informative error messages, enhancing user experience and troubleshooting capabilities. For example, structured error handling ensures that users receive clear error messages when CRUD operations fail, helping them understand and address any issues effectively.&lt;br /&gt;
&lt;br /&gt;
These design principles and coding patterns are instrumental in developing a robust, scalable, and maintainable bookmarks controller for the Expertiza project, ensuring high quality and reliability of the software.&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
Begin by sending a POST request to `/login` using the '''user_name''' and `password` fields to obtain an authentication token.&lt;br /&gt;
&lt;br /&gt;
[[Image:Login-postman.png | 800px | Login with provided credentials]]&lt;br /&gt;
&lt;br /&gt;
In Postman, navigate to the 'Authorization' tab for your request and select 'Bearer Token'. Paste the copied token into the 'Token' field.&lt;br /&gt;
&lt;br /&gt;
[[Image:Postman Auth section.png | 800px | Paste token in Authorization section]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== CRUD Operations ===&lt;br /&gt;
&lt;br /&gt;
==== Create Bookmark ====&lt;br /&gt;
&lt;br /&gt;
Send a POST request to the `/bookmarks` endpoint with the required parameters (`url`, `title`, `description`, `user_id`, `topic_id`).&lt;br /&gt;
&lt;br /&gt;
[[Image:Create Bookmark.png | 800px | Create a bookmark]]&lt;br /&gt;
&lt;br /&gt;
==== Read Bookmarks ====&lt;br /&gt;
&lt;br /&gt;
You can retrieve a list of bookmarks associated with a particular topic ID by sending a GET request to the `/bookmarks/list/:topic_id` endpoint.&lt;br /&gt;
&lt;br /&gt;
[[Image:List Bookmarks.png| 800px | List bookmarks]]&lt;br /&gt;
&lt;br /&gt;
==== Update Bookmark ====&lt;br /&gt;
Send a PUT request to the `/bookmarks/:id` endpoint with the bookmark ID to update. Include the updated parameters (`url`, `title`, `description`).&lt;br /&gt;
&lt;br /&gt;
[[Image:Updated bookmark.png | 800px | Update a bookmark]]&lt;br /&gt;
&lt;br /&gt;
==== Delete Bookmark ====&lt;br /&gt;
Send a DELETE request to the `/bookmarks/:id` endpoint with the bookmark ID to delete.&lt;br /&gt;
&lt;br /&gt;
[[Image:Delete bookmark.png | 800px | Delete a bookmark]]&lt;br /&gt;
&lt;br /&gt;
=== Save Rating for a Bookmark ===&lt;br /&gt;
To save a rating for a bookmark, send a POST request to the `/bookmarks/:id/rate` endpoint with the bookmark ID and the rating value.&lt;br /&gt;
&lt;br /&gt;
[[Image:Save bookmark rating.png | 800px | Save bookmark rating]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155600</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155600"/>
		<updated>2024-04-09T04:32:55Z</updated>

		<summary type="html">&lt;p&gt;Asavla: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current v/s New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 # Controller method to create a new bookmark&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      # Normalize URL if necessary for consistency&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
      # Attempt to save the bookmark&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
&lt;br /&gt;
      # Return JSON response with the created bookmark&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      # Return JSON response with error message if save fails&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  # Controller method to update an existing bookmark&lt;br /&gt;
  def update&lt;br /&gt;
    # Normalize URL if necessary for consistency&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    # Attempt to update the bookmark&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      # Return JSON response with updated bookmark if successful&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      # Return JSON response with error messages if update fails&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
* Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  # Controller method to delete a bookmark&lt;br /&gt;
  def destroy&lt;br /&gt;
    # Find the bookmark to delete&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Attempt to delete the bookmark&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    # Return JSON response indicating successful deletion&lt;br /&gt;
    render json: { message: 'Bookmark successfully deleted' }, status: :ok&lt;br /&gt;
   rescue ActiveRecord::RecordNotFound&lt;br /&gt;
     # Return JSON response with error message if bookmark not found&lt;br /&gt;
     render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
Postman was used to manually test the additional method in impersonate_controller.rb, as well as the actions and routes of the corresponding controllers. Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
* Login with provided credentials and copy the token&lt;br /&gt;
[[Image:Login-postman.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Copy token to Authorization section of postman and paste as Bearer token&lt;br /&gt;
[[Image:Postman Auth section.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
* Create a bookmark &lt;br /&gt;
[[Image:Create Bookmark.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* You cannot read a particular bookmark as it not a feature, you can only list the bookmarks of a topic id&lt;br /&gt;
[[Image:List Bookmarks.png| 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Update Bookmark&lt;br /&gt;
[[Image:Updated bookmark.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
* Delete Bookmark. If you get 204, that means bookmark got deleted&lt;br /&gt;
[[Image:Delete bookmark.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Save rating for a bookmark&lt;br /&gt;
[[Image:Save bookmark rating.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
Github Pull Request - https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/akshat22/reimplementation-back-end/tree/dev&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155021</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155021"/>
		<updated>2024-04-08T18:31:45Z</updated>

		<summary type="html">&lt;p&gt;Asavla: resized images&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current v/s New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 # Controller method to create a new bookmark&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      # Normalize URL if necessary for consistency&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
      # Attempt to save the bookmark&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
&lt;br /&gt;
      # Return JSON response with the created bookmark&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      # Return JSON response with error message if save fails&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  # Controller method to update an existing bookmark&lt;br /&gt;
  def update&lt;br /&gt;
    # Normalize URL if necessary for consistency&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    # Attempt to update the bookmark&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      # Return JSON response with updated bookmark if successful&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      # Return JSON response with error messages if update fails&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
* Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  # Controller method to delete a bookmark&lt;br /&gt;
  def destroy&lt;br /&gt;
    # Find the bookmark to delete&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Attempt to delete the bookmark&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    # Return JSON response indicating successful deletion&lt;br /&gt;
    render json: { message: 'Bookmark successfully deleted' }, status: :ok&lt;br /&gt;
   rescue ActiveRecord::RecordNotFound&lt;br /&gt;
     # Return JSON response with error message if bookmark not found&lt;br /&gt;
     render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
Postman was used to manually test the additional method in impersonate_controller.rb, as well as the actions and routes of the corresponding controllers. Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
* Login with provided credentials and copy the token&lt;br /&gt;
[[Image:Login-postman.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Copy token to Authorization section of postman and paste as Bearer token&lt;br /&gt;
[[Image:Postman Auth section.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
* Create a bookmark &lt;br /&gt;
[[Image:Create Bookmark.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* You cannot read a particular bookmark as it not a feature, you can only list the bookmarks of a topic id&lt;br /&gt;
[[Image:List Bookmarks.png| 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Update Bookmark&lt;br /&gt;
[[Image:Updated bookmark.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
* Delete Bookmark. If you get 204, that means bookmark got deleted&lt;br /&gt;
[[Image:Delete bookmark.png | 1200px]]&lt;br /&gt;
&lt;br /&gt;
* Save rating for a bookmark&lt;br /&gt;
[[Image:Save bookmark rating.png | 800px]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155020</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155020"/>
		<updated>2024-04-08T18:28:54Z</updated>

		<summary type="html">&lt;p&gt;Asavla: added comments&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current v/s New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 # Controller method to create a new bookmark&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      # Normalize URL if necessary for consistency&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
      # Attempt to save the bookmark&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
&lt;br /&gt;
      # Return JSON response with the created bookmark&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      # Return JSON response with error message if save fails&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  # Controller method to update an existing bookmark&lt;br /&gt;
  def update&lt;br /&gt;
    # Normalize URL if necessary for consistency&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
&lt;br /&gt;
    # Attempt to update the bookmark&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      # Return JSON response with updated bookmark if successful&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      # Return JSON response with error messages if update fails&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
* Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  # Controller method to delete a bookmark&lt;br /&gt;
  def destroy&lt;br /&gt;
    # Find the bookmark to delete&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Attempt to delete the bookmark&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    # Return JSON response indicating successful deletion&lt;br /&gt;
    render json: { message: 'Bookmark successfully deleted' }, status: :ok&lt;br /&gt;
   rescue ActiveRecord::RecordNotFound&lt;br /&gt;
     # Return JSON response with error message if bookmark not found&lt;br /&gt;
     render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
Postman was used to manually test the additional method in impersonate_controller.rb, as well as the actions and routes of the corresponding controllers. Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
* Login with provided credentials and copy the token&lt;br /&gt;
[[Image:Login-postman.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Copy token to Authorization section of postman and paste as Bearer token&lt;br /&gt;
[[Image:Postman Auth section.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Create a bookmark &lt;br /&gt;
[[Image:Create Bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* You cannot read a particular bookmark as it not a feature, you can only list the bookmarks of a topic id&lt;br /&gt;
[[Image:List Bookmarks.png| 500px]]&lt;br /&gt;
&lt;br /&gt;
* Update Bookmark&lt;br /&gt;
[[Image:Updated bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Delete Bookmark. If you get 204, that means bookmark got deleted&lt;br /&gt;
[[Image:Delete bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Save rating for a bookmark&lt;br /&gt;
[[Image:Save bookmark rating.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155012</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=155012"/>
		<updated>2024-04-08T18:12:44Z</updated>

		<summary type="html">&lt;p&gt;Asavla: merged old and new implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current v/s New Implementation===&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current implementation and the new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
*Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing on Postman==&lt;br /&gt;
&lt;br /&gt;
Postman was used to manually test the additional method in impersonate_controller.rb, as well as the actions and routes of the corresponding controllers. Before testing any of these methods with Postman, submit a request to /login using the user_name and password fields, which will send an authentication token. This token must be added to Postman's 'Authorization' tab as a 'Bearer token' before any further requests can be made. &lt;br /&gt;
&lt;br /&gt;
* Login with provided credentials and copy the token&lt;br /&gt;
[[Image:Login-postman.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Copy token to Authorization section of postman and paste as Bearer token&lt;br /&gt;
[[Image:Postman Auth section.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Create a bookmark &lt;br /&gt;
[[Image:Create Bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* You cannot read a particular bookmark as it not a feature, you can only list the bookmarks of a topic id&lt;br /&gt;
[[Image:List Bookmarks.png| 500px]]&lt;br /&gt;
&lt;br /&gt;
* Update Bookmark&lt;br /&gt;
[[Image:Updated bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Delete Bookmark. If you get 204, that means bookmark got deleted&lt;br /&gt;
[[Image:Delete bookmark.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
* Save rating for a bookmark&lt;br /&gt;
[[Image:Save bookmark rating.png | 500px]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153623</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153623"/>
		<updated>2024-03-24T20:07:36Z</updated>

		<summary type="html">&lt;p&gt;Asavla: changed link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the bookmarks crud queries is as follows:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
===New Implementation===&lt;br /&gt;
&lt;br /&gt;
The new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
*Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/76&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153620</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153620"/>
		<updated>2024-03-24T20:06:44Z</updated>

		<summary type="html">&lt;p&gt;Asavla: added info for new implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the bookmarks crud queries is as follows:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
===New Implementation===&lt;br /&gt;
&lt;br /&gt;
The new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
* Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
* Utilizes structured error handling for better response communication.&lt;br /&gt;
* Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====update====&lt;br /&gt;
* Incorporates URL normalization for consistency in bookmark data.&lt;br /&gt;
* Returns JSON response with updated bookmark information for improved client-side interactions.&lt;br /&gt;
* Provides detailed error messages in case of update failure for better troubleshooting.&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
====destroy====&lt;br /&gt;
* Utilizes structured error handling to provide informative error responses.&lt;br /&gt;
* Implements proper exception handling to gracefully manage record deletion errors.&lt;br /&gt;
*Provides clear feedback to users upon successful deletion of a bookmark.&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/86&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153611</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153611"/>
		<updated>2024-03-24T19:51:06Z</updated>

		<summary type="html">&lt;p&gt;Asavla: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the bookmarks crud queries is as follows:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
===New Implementation===&lt;br /&gt;
&lt;br /&gt;
The new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
====create====&lt;br /&gt;
- Handles URL normalization to ensure consistency in bookmark data.&lt;br /&gt;
- Utilizes structured error handling for better response communication.&lt;br /&gt;
- Implements before_action `:set_bookmark` to centralize bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/86&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153281</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153281"/>
		<updated>2024-03-24T01:02:57Z</updated>

		<summary type="html">&lt;p&gt;Asavla: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the bookmarks crud queries is as follows:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
===New Implementation===&lt;br /&gt;
&lt;br /&gt;
The new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
Repository: https://github.com/akshat22/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
Pull Request: https://github.com/expertiza/reimplementation-back-end/pull/86&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Contributors'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153262</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153262"/>
		<updated>2024-03-24T00:43:52Z</updated>

		<summary type="html">&lt;p&gt;Asavla: added code snippets for new implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
====Current Implementation====&lt;br /&gt;
&lt;br /&gt;
The current implementation of the bookmarks crud queries is as follows:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{http://}, '') if params[:url].start_with?('http://')&lt;br /&gt;
    params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://')&lt;br /&gt;
    begin&lt;br /&gt;
      Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id])&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request)&lt;br /&gt;
      flash[:success] = 'Your bookmark has been successfully created!'&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request)&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:topic_id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description])&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully updated!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request)&lt;br /&gt;
    flash[:success] = 'Your bookmark has been successfully deleted!'&lt;br /&gt;
    redirect_to action: 'list', id: @bookmark.topic_id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The problems with the current implementation, which is resolved in the new implementation, is:&lt;br /&gt;
&lt;br /&gt;
1. The new implementation is designed for API use with JSON responses, improving the interaction with API clients by clearly communicating error states and messages.&lt;br /&gt;
&lt;br /&gt;
2. The new controller utilizes structured error handling.&lt;br /&gt;
&lt;br /&gt;
3. Introduction of before_action :set_bookmark in the new controller eliminates redundancy and enhances code reusability by centralizing bookmark fetching for relevant actions.&lt;br /&gt;
&lt;br /&gt;
====New Implementation====&lt;br /&gt;
&lt;br /&gt;
The new implementation for the CRUD operations is shown below. The new functions return a JSON object instead of rendering an HTML page.&lt;br /&gt;
&lt;br /&gt;
 def create&lt;br /&gt;
    begin&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{http://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
      create_bookmark_params[:url] = create_bookmark_params[:url].gsub!(%r{https://}, '') if create_bookmark_params[:url].present? &amp;amp;&amp;amp; create_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
      @bookmark = Bookmark.new(create_bookmark_params)&lt;br /&gt;
      @bookmark.user_id = @current_user.id&lt;br /&gt;
      @bookmark.save!&lt;br /&gt;
      render json: @bookmark, status: :created and return&lt;br /&gt;
    rescue ActiveRecord::RecordInvalid&lt;br /&gt;
      render json: $ERROR_INFO.to_s, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{http://}, '') if update_bookmark_params[:url].start_with?('http://')&lt;br /&gt;
    update_bookmark_params[:url] = update_bookmark_params[:url].gsub!(%r{https://}, '') if update_bookmark_params[:url].start_with?('https://')&lt;br /&gt;
    if @bookmark.update(update_bookmark_params)&lt;br /&gt;
      render json: @bookmark, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @bookmark.errors.full_messages, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def destroy&lt;br /&gt;
    @bookmark = Bookmark.find(params[:id])&lt;br /&gt;
    @bookmark.destroy&lt;br /&gt;
    rescue ActiveRecord::RecordNotFound&lt;br /&gt;
        render json: $ERROR_INFO.to_s, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Students'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153213</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153213"/>
		<updated>2024-03-23T23:41:44Z</updated>

		<summary type="html">&lt;p&gt;Asavla: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project based on reimplementing the bookmarks controller. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
&lt;br /&gt;
The Expertiza application requires the reimplementation of its backend functionality for the BookmarksController. Currently, the system relies on traditional Rails architecture, but the project aims to transition to a more streamlined approach using Rails API. This transition is essential for scalability and flexibility, allowing for separate frontend and backend applications.&lt;br /&gt;
&lt;br /&gt;
The BookmarksController serves as the backbone for bookmark management and user interactions within the Expertiza platform. It facilitates actions such as listing bookmarks associated with specific topics, creating new bookmarks, editing existing ones, and deleting bookmarks. Furthermore, it incorporates authorization rules to ensure users possess appropriate roles and permissions for each action.&lt;br /&gt;
&lt;br /&gt;
The reimplemented BookmarksController will adhere to the Rails API structure, residing in the controller/api/v1 directory. It will maintain the existing functionality, including methods for retrieving bookmark ratings, calculating average scores for specific and total ratings, and managing strong parameters through private methods.&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
====Current Implementation====&lt;br /&gt;
&lt;br /&gt;
====New Implementation====&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
&lt;br /&gt;
===Team===&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Mohammed Ali Qureshi &amp;lt;mquresh@ncsu.edu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Students'''&lt;br /&gt;
&lt;br /&gt;
Akshat Nitin Savla &amp;lt;asavla@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Mitanshu Reshamwala &amp;lt;mresham@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Tanay Gandhi &amp;lt;tgandhi@ncsu.edu&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153207</id>
		<title>CSC/ECE 517 Spring 2024 - E2424. Reimplement the Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller&amp;diff=153207"/>
		<updated>2024-03-23T23:28:43Z</updated>

		<summary type="html">&lt;p&gt;Asavla: Created page with &amp;quot;==E2424. Reimplement the Bookmarks Controller==  This page provides a description of the Expertiza based OSS project.    __TOC__   ===About Expertiza===  [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2424. Reimplement the Bookmarks Controller==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
===New Implementation===&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
&lt;br /&gt;
===References===&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=153194</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=153194"/>
		<updated>2024-03-23T23:21:25Z</updated>

		<summary type="html">&lt;p&gt;Asavla: Added E2424 page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=153191</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=153191"/>
		<updated>2024-03-23T23:18:52Z</updated>

		<summary type="html">&lt;p&gt;Asavla: Undo revision 153189 by Asavla (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 - 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;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024&amp;diff=153189</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=153189"/>
		<updated>2024-03-23T23:17:42Z</updated>

		<summary type="html">&lt;p&gt;Asavla: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2024 - E2407. Refactor review_mapping_controller.rb]]&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 - E2414. Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2416.  Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2024 - E2417. Reimplement submitted content controller.rb]]&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 - 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 - ‬NTNX-2‬‭. Snapshot Functionality for provisioned databases]]&lt;/div&gt;</summary>
		<author><name>Asavla</name></author>
	</entry>
</feed>