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

From Expertiza_Wiki
Jump to navigation Jump to search
 
(21 intermediate revisions by 3 users not shown)
Line 19: Line 19:
     '''Documents:''' _add_signup_topics.html.erb, _due_dates.html.erb
     '''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.
* 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.  
This functionality can be tested by logging in as an instructor, making 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
     '''Documents:''' _suggested_topic.html.erb, intelligent_topic_selection.html.erb
Line 38: Line 38:


==== New Method: check_topic_due_date_value() ====
==== New Method: check_topic_due_date_value() ====
   <nowiki> def check_topic_due_date_value(assignment_due_dates, topic_id, deadline_type_id = 1, review_round = 1)
   <nowiki> def check_topic_due_date_value(assignment_due_dates, topic_id,  
      due_date = get_topic_deadline(assignment_due_dates, topic_id, deadline_type_id, review_round)
                                          deadline_type_id = 1, review_round = 1)
      DateTime.parse(due_date.to_s).strftime("%Y-%m-%d %H:%M").in_time_zone
    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</nowiki>
   end</nowiki>


==== New Method: get_topic_deadline() ====
==== New Method: get_topic_deadline() ====
   <nowiki> def get_topic_deadline(assignment_due_dates, topic_id, deadline_type_id = 1, review_round = 1)
   <nowiki> 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,
     topic_due_date = TopicDueDate.where(parent_id: topic_id,
                                         deadline_type_id: deadline_type_id,
                                         deadline_type_id: deadline_type_id,
Line 59: Line 62:
     team_id = TeamsUser.team_id(assignment_id, session[:user].id)
     team_id = TeamsUser.team_id(assignment_id, session[:user].id)
     teams_users = TeamsUser.where(team_id: team_id)
     teams_users = TeamsUser.where(team_id: team_id)
     teams_users_array = Array.new
     teams_users_array = []
     teams_users.each do |teams_user|
     teams_users.each do |teams_user|
       teams_users_array << teams_user.user_id
       teams_users_array << teams_user.user_id
     end
     end
     @suggested_topics = SignUpTopic.where(assignment_id: assignment_id, private_to: teams_users_array)
     @suggested_topics = SignUpTopic.where(assignment_id:  
                        assignment_id, private_to: teams_users_array)
   end</nowiki>
   end</nowiki>


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


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


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


===Changes to the View===
==== 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:


==== Impact Analysis ====
http://138.197.104.185:3000/
*


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


==Running the Project Locally==
===Testing Instructions===
Those who contributed to the project could run the project locally by going to a terminal window, navigating to the project folder and running the single command:
====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.


  rails server
====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.


If the project was to be run again after changes to project code have been made, the commands to run from the terminal window would be as follows:


  bundle install
==Test Plan==
  rails s
===Unit Tests===
Unit tests were required per the project assignment for helper methods which previously had no associated unit tests. These tests verified that each discrete method returned the proper values.  The tests were written using RSpec/FactoryGirl and are listed above.  A summary of the test cases is shown below.


==Testing using Selenium IDE==
{| class="wikitable"
 
! colspan="4" | Unit Test Summary
===Testing Instructions===
|-
! Method
! Parameters
! Purpose
! Tested Scenarios
|-
| check_topic_due_date_value
| assignment_due_dates, topic_id, deadline_type, review _round
| Check the due date for topic submission given the topic id and assignment due dates.
| a) All nulls, b) Legitimate value for assignment and topic ids
|-
| get_suggested_topics
| assignment_id
| Retrieve topics suggested by the signed in user for an assignment
| a) Signed In user is null b) Legitimate value for assignment and signed in user.
|-
| get_intelligent_topic_row
| topic_id, selected_topic_ids, max_team_size
| Render the row for a topic in intelligent topic selection(bidding) given the topics selected by the students and the maximum permitted team size for the assignment.
| a) Topic Selected by signed in student. b) Topic Selected by signed in student is waitlisted. c) Topic not selected by signed in student. d) Student has not selected any topics.
|-
| render_participant_info
| topic, assignment, participants
| Render Info for participants of a topic for an assignment.
| a) No Participants have been selected. b) Wrong Participants were selected. c) All legitimate values.
|-
|}


==Future Work==
====To Run the Unit Tests====
* Navigate to the expertiza home folder
* Run `rspec spec/helpers/sign_up_sheet_helper_spec.rb`

Latest revision as of 15:19, 5 April 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, making 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.


Test Plan

Unit Tests

Unit tests were required per the project assignment for helper methods which previously had no associated unit tests. These tests verified that each discrete method returned the proper values. The tests were written using RSpec/FactoryGirl and are listed above. A summary of the test cases is shown below.

Unit Test Summary
Method Parameters Purpose Tested Scenarios
check_topic_due_date_value assignment_due_dates, topic_id, deadline_type, review _round Check the due date for topic submission given the topic id and assignment due dates. a) All nulls, b) Legitimate value for assignment and topic ids
get_suggested_topics assignment_id Retrieve topics suggested by the signed in user for an assignment a) Signed In user is null b) Legitimate value for assignment and signed in user.
get_intelligent_topic_row topic_id, selected_topic_ids, max_team_size Render the row for a topic in intelligent topic selection(bidding) given the topics selected by the students and the maximum permitted team size for the assignment. a) Topic Selected by signed in student. b) Topic Selected by signed in student is waitlisted. c) Topic not selected by signed in student. d) Student has not selected any topics.
render_participant_info topic, assignment, participants Render Info for participants of a topic for an assignment. a) No Participants have been selected. b) Wrong Participants were selected. c) All legitimate values.

To Run the Unit Tests

  • Navigate to the expertiza home folder
  • Run `rspec spec/helpers/sign_up_sheet_helper_spec.rb`