CSC/ECE 517 Spring 2017/oss E1727

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

This project was completed as part of a greater open source project called Expertiza.

Expertiza is a web application platform, similar to wikipedia, which offers teachers and students a way to organize for group assignments and porjects. By using Expertiza, students have the ability to submit and coordinate peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.

Expertiza offers several features which are useful to a classroom-style learning environment. Among those several features, this project represents a contribution to the organization of the code used for assignment signup sheets.

Background

The work for this project was completed by a group of three students from NC State. However, the project was completed according to guidelines provided by a coordinator who works with Expertiza.

Following the guidelines provided, the group worked to clean up a portion of the Expertiza project code through refactorization and reorganization. More specifically, logical code needed to be separated from portions of the project which were not responsible for containing code for the functionality of the application.

Motivation

The motivation for this project was to make the project code easier for programmers to read by compartmentalizing portions of the code to separate locations in the project according to the functionality of the code.

The scope of this project was limited to functionalities associated with the signup sheet. This meant that logical code that was embedded in "view" (a folder containing html formatting and design code) should be moved to a more appropriate location, the "helpers" folder (this folder contains compartmentalized auxiliary functions that "help" with other parts of the project).

Tasks Identified

    Documents: _add_signup_topics.html.erb, _due_dates.html.erb
  • Move javascript code to assets (folder): There was some javascript at the bottom of the file _add_signup_topics.html.erb. This was moved to a new file app/assets/javascripts/signup.js. The functions were modified to pass in the number of teams that needed to be toggled (since it is now in a separate file without access to that information). The javascript from the file _due_dates.html.erb was also moved to the new signup.js file.

This functionality can be tested by logging in as an instructor, make sure you are managing assignments, then click the "Edit" button of an assignment (the little pencil icon on the right), then choose the "Topic" tab. If you click "Hide all teams" link, all team names and team member unity ids will be hidden. Click the link again and the content will be shown. If you click individual top names, it should hide/show only one team's info.

    Documents: _suggested_topic.html.erb, intelligent_topic_selection.html.erb
  • Move logical code to helper file and assign self-explanatory method names.
    Documents: _all_actions.html.erb, _topic_names.html.erb
  • Move logical code to helper file and assign self-explanatory method names.

Testing:

  • Create a test file named sign_up_sheet_helper_spec.rb in spec/helpers
  • Write test cases for all methods in sign_up_sheet_helper.rb using factories

Classes

  • sign_up_sheet_helper.rb
  • sign_up_sheet_helper_spec.rb

Project Modifications

New Method: check_topic_due_date_value()

  def check_topic_due_date_value(assignment_due_dates, topic_id, deadline_type_id = 1, review_round = 1)
    due_date = get_topic_deadline(assignment_due_dates, topic_id, deadline_type_id, review_round)
    DateTime.parse(due_date.to_s).strftime("%Y-%m-%d %H:%M").in_time_zone
  end

New Method: get_topic_deadline()

  def get_topic_deadline(assignment_due_dates, topic_id, 
                                  deadline_type_id = 1, review_round = 1)
    topic_due_date = TopicDueDate.where(parent_id: topic_id,
                                        deadline_type_id: deadline_type_id,
                                        round: review_round).first rescue nil
    if !topic_due_date.nil?
      topic_due_date.due_at
    else
      assignment_due_dates[review_round - 1].due_at.to_s
    end
  end

New Method: get_suggested_topics()

  def get_suggested_topics(assignment_id)
    team_id = TeamsUser.team_id(assignment_id, session[:user].id)
    teams_users = TeamsUser.where(team_id: team_id)
    teams_users_array = []
    teams_users.each do |teams_user|
      teams_users_array << teams_user.user_id
    end
    @suggested_topics = SignUpTopic.where(assignment_id: 
                        assignment_id, private_to: teams_users_array)
  end

New Method: get_intelligent_topic_row()

  def get_intelligent_topic_row(topic, selected_topics, max_team_size)
    row_html = ''
    if !selected_topics.nil? && !selected_topics.empty?
      selected_topics.each do |selected_topic|
        row_html = if selected_topic.topic_id == topic.id and 
                                                 !selected_topic.is_waitlisted
                     '<tr bgcolor="yellow">'
                   elsif selected_topic.topic_id == topic.id and
                                                    selected_topic.is_waitlisted
                     '<tr bgcolor="lightgray">'
                   else
                     '<tr id="topic_' + topic.id.to_s + '">'
                   end
      end
    else
      row_html = '<tr id="topic_' + topic.id.to_s + '" style="background-color:' +
                  get_topic_bg_color(topic, max_team_size) + '">'
    end
    row_html.html_safe
  end

New Method: get_topic_bg_color()

 def get_topic_bg_color(topic, max_team_size)
    calculation = (400 * (1 - (Math.tanh(2 * [max_team_size.to_f / Bid.where(topic_id:
       topic.id).count, 1].min - 1) + 1) / 2)).to_i.to_s
    'rgb(' + calculation + ',' + calculation + ',0)'
  end

New Method: render_participant_info()

  def render_participant_info(topic, assignment, participants)
    name_html = ''
    if !participants.nil? && !participants.empty?
      chooser_present = false
      participants.each do |participant|
        next unless topic.id == participant.topic_id
        chooser_present = true
        if assignment.max_team_size > 1
          name_html += '<br/><b>' + participant.team_name_placeholder + '</b><br/>'
        end
        name_html += 'participant.user_name_placeholder'
        if participant.is_waitlisted
          name_html += '<font color="red">(waitlisted)</font>'
        end
        name_html += '<br/>'
      end
      name_html += 'No choosers.' unless chooser_present
    end
    name_html.html_safe
  end
end

New Test for Helper Classes: spec/helpers/sign_up_sheet_helper_spec.rb

Implemented positive and negative test cases for all the methods in sign_up_sheet_helper.rb

Running the Project Remotely

We have hosted our forked repo so you can review our changes here:

http://138.197.104.185:3000/

Suggested login for Instructor privileges is 'instructor6' with password 'password'. To login as a student, you can use 'student5000' with password 'password'

Testing Instructions

First task

This functionality can be tested by logging in as an instructor, make sure you are managing assignments, then click the "Edit" button of an assignment (the little pencil icon on the right), then choose the "Topic" tab. If you click "Hide all teams" link, all team names and team member unity ids will be hidden. Click the link again and the content will be shown. If you click individual top names, it should hide/show only one team's info.

Helper File Changes

There is no change in the expected behaviour.

  • get_suggested_topics: Retrieve list of topics suggested by signed in user for an assignment.
  • get_intelligent_topic_row: Render Intelligent Row in bidding based topic selection.
  • get_topic_bg_color: Render background color for row based on signed in user and status of the topic.
  • render_participant_info: Render Participant Info based on topic, assignment and participants.