CSC/ECE 517 Spring 2017/oss E1727: Difference between revisions
Line 36: | Line 36: | ||
==== New Method: check_topic_due_date_value() ==== | ==== 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) | <nowiki>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) | 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 | DateTime.parse(due_date.to_s).strftime("%Y-%m-%d %H:%M").in_time_zone | ||
end | end</nowiki> | ||
==== New Method: get_topic_deadline() ==== | ==== New Method: get_topic_deadline() ==== | ||
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 52: | Line 52: | ||
assignment_due_dates[review_round - 1].due_at.to_s | assignment_due_dates[review_round - 1].due_at.to_s | ||
end | end | ||
end | end</nowiki> | ||
==== New Method: get_suggested_topics() ==== | ==== New Method: get_suggested_topics() ==== | ||
def get_suggested_topics(assignment_id) | <nowiki>def get_suggested_topics(assignment_id) | ||
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) | ||
Line 64: | Line 64: | ||
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 | end</nowiki> | ||
==== New Method: get_intelligent_topic_row() ==== | ==== New Method: get_intelligent_topic_row() ==== | ||
def get_intelligent_topic_row(topic, selected_topics) | <nowiki>def get_intelligent_topic_row(topic, selected_topics) | ||
row_html = '' | row_html = '' | ||
if !selected_topics.nil? && selected_topics.size != 0 | if !selected_topics.nil? && selected_topics.size != 0 | ||
Line 85: | Line 85: | ||
end | end | ||
row_html.html_safe | row_html.html_safe | ||
end | end</nowiki> | ||
==== New Method: get_topic_bg_color() ==== | ==== New Method: get_topic_bg_color() ==== |
Revision as of 18:51, 22 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).
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
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 = 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