CSC/ECE 517 Spring 2017/oss E1727: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 119: Line 119:
* '''get_topic_bg_color''': Render background color for row based on signed in user and status of the topic.
* '''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.
* '''render_participant_info''': Render Participant Info based on topic, assignment and participants.
==Future Work==

Revision as of 01:03, 23 March 2017

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: 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 = Array.new
    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)
    row_html = ''
    if !selected_topics.nil? && selected_topics.size != 0
      for selected_topic in @selected_topics
        if selected_topic.topic_id == topic.id and !selected_topic.is_waitlisted
          row_html = '<tr bgcolor="yellow">'
        elsif selected_topic.topic_id == topic.id and selected_topic.is_waitlisted
          row_html = '<tr bgcolor="lightgray">'
        else
          row_html = '<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) + '">'
    end
    row_html.html_safe
  end

New Method: get_topic_bg_color()

  def get_topic_bg_color(topic)
    'rgb(' + (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 + ',' + (400*(Math.tanh(2*[@max_team_size.to_f/Bid.where(topic_id:topic.id).
        count,1].min-1)+1)/2).to_i.to_s + ',0)'
  end

New Method: render_participant_info()

  def render_participant_info(topic, assignment, participants)
    name_html = ''
    if !participants.nil? && participants.size > 0
      chooser_present = false
      for participant in @participants
        if 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
      end
      unless chooser_present
        name_html += 'No choosers.'
      end
    end
    name_html.html_safe
  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.