CSC/ECE 517 Spring 2022 - E2228: Refactor JavaScript

From Expertiza_Wiki
Revision as of 21:58, 4 April 2022 by Yhsiang (talk | contribs)
Jump to navigation Jump to search

E2228. Refactor JavaScript

This page provides a description of the refactoring done on assignment view, a part of the Open Source project - Expertiza, at North Carolina State University.



About Expertiza

Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments, enforce deadlines etc. It also allows the instructor to create list of topics from which students can bid for their project requirements. Students can form teams in Expertiza to work on various projects and assignments. Students can also review other student's or team's work and provide useful information on the scope of improvement of their project. Expertiza supports submission across various document types, including the URLs and wiki pages.

Problem Statement

Expertiza’s primary language for managing views is JavaScript. However, these scripts are not well structured and present a large scope of improvement in terms of code quality and optimization.


What needs to be done

  • Student view
    • Extracting non-ruby js functions into a separate file.
    • We then have to come up with a solution where we can get rid of the ruby part in the JavaScript and extract those functions out of the html file too.
    • We also need to optimize the code so that it follows DRY principles.
    • Very few code comments are present. Each method should have at least 30 words of code comment, explaining what the method does.
    • Introduce Single Responsibility Principle - A method/function should only have one purpose to fulfill and increase code reusability.
    • Many functions are useless and do not serve any purpose. You also need to identify and fix them.

Design

Files Requiring Modification

  • app/views/assignments/edit/_due_dates.html.erb

It appears this partial renders the general tab of the create new assignments page. We need to add a checkbox for pair programming in this file.

  • app/views/assignments/edit/_rubrics.html.erb

This file renders the list of all the submissions for a given assignment. We need to add a new column - pair-programming which will indicate if the team has pair-programmed for this assignment or not.

  • app/views/assignments/_general.html.erb

This file renders the team information of a given assignment for a particular member. We need to add a table for pair-programming and a button to request for pair-programming.

  • app/views/assignments/edit.html.erb

We will use this helper file to add the pair-programming feature.


Design Patterns aren't applicable to our project since all it involves is to make columns sortable and some isolated issues.


Test Plan

For our project, which is mostly concerned with making changes to assignment views, we are planning to do the majority of testing through manual UI testing. As of now, we don't anticipate having to make many/any changes to files that are not views. If any changes are made to controllers, models, etc to accomplish our tasks, we will adjust or add SPEC tests to make sure our code is covered.

UI Testing

Automated Testing

Team Information

Leo Hsiang
Jacob Anderson