CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches: Difference between revisions
No edit summary |
No edit summary |
||
Line 69: | Line 69: | ||
<strong>Issue #329<br></strong> | <strong>Issue #329<br></strong> | ||
This was a new requirement to add an option to upload topics along with the teams assigned. | This was a new requirement to add an option to upload topics along with the teams assigned. | ||
Code Changes: | |||
import_file/_sign_up_topic.html.erb (All the select tags has been changed | |||
<th> | |||
<select name="select1" id="select1" class="form-control" style="background-color:lightgrey"> | |||
<option value="topic_identifier">Topic Identifier (required)</option> | |||
<option value="topic_name">Topic Name (required)</option> | |||
<option value="max_choosers">Max Choosers (required)</option> | |||
<option value="category">Category (optional)</option> | |||
<option value="description">Description (optional)</option> | |||
<option value="link">Link (optional)</option> | |||
<option value="assigned_team">Assigned Team (optional)</option> | |||
</select> | |||
</th> | |||
<br> | |||
model/sing_up_topic.rb | |||
def self.import(row_hash, session, _id = nil) | |||
if row_hash.length < 3 | |||
raise ArgumentError, "The CSV File expects the format: Topic identifier, Topic name, Max choosers, Topic Category (optional), Topic Description (Optional), Topic Link (optional), Assigned Team Name (optional)." | |||
end | |||
topic = SignUpTopic.where(topic_name: row_hash[:topic_name], assignment_id: session[:assignment_id]).first | |||
if topic.nil? | |||
attributes = ImportTopicsHelper.define_attributes(row_hash) | |||
topic_new_id = ImportTopicsHelper.create_new_sign_up_topic(attributes, session) | |||
unless row_hash[:assigned_team].nil? | |||
team = Team.where(name: row_hash[:assigned_team]).first | |||
ImportTopicsHelper.assign_team_topic(topic_new_id, team.id) | |||
end | |||
else | |||
topic.max_choosers = row_hash[:max_choosers] | |||
topic.topic_identifier = row_hash[:topic_identifier] | |||
# topic.assignment_id = session[:assignment_id] | |||
topic.save | |||
unless row_hash[:assigned_team].nil? | |||
team = Team.where(name: row_hash[:assigned_team]).first | |||
newteam = SignedUpTeam.where(topic_id: topic.id, team_id: team.id).first | |||
if newteam.nil? | |||
ImportTopicsHelper.assign_team_topic(topic.id, team.id) | |||
else | |||
newteam.team_id = team.id | |||
newteam.save | |||
end | |||
end | |||
end | |||
end | |||
<br> | |||
An option column checkbox (Teams Assigned) has been added to the UI | An option column checkbox (Teams Assigned) has been added to the UI | ||
<br> | <br> | ||
[[File: | [[File:Issue153SS2.png]] | ||
<br> | |||
A new column Assigned Team is added where the columns are being mapped. | |||
[[File:Issue153SS3.png]] |
Revision as of 22:42, 28 October 2019
Issue #918
New code introduced is as follows.
File:app/helpers/import_topics_helper.rb
Code:
def self.define_attributes(row_hash)
attributes = {} if !row_hash[:description].nil? and !row_hash[:description].ascii_only? row_hash[:description] = self.trim_non_ascii(row_hash[:description]) puts row_hash[:description] end attributes["topic_identifier"] = row_hash[:topic_identifier].strip attributes["topic_name"] = row_hash[:topic_name].strip attributes["max_choosers"] = row_hash[:max_choosers].strip attributes end
def self.trim_non_ascii(string) string.split().each do |char| !char.ascii_only? ? string.tr!(char, ' ') : nil end string.gsub!(/\s+/, ' ') end
Issue #328
This was an issue to fix the functionality of Insert any new members into existing team. This was due to faulty handling of the option handle_dups and incorrect checking of parameters.
Code was modified to ensure minimal impact to existing testcases and functionalities.
Code:
name = handle_duplicate(team, name, id, options["handle_dups"], teamtype)
After fixing changes
Issue #329
This was a request to add an option to rename existing team if there was a conflict in the team name.
New code introduced was as follows:
In start.html.erb
<option value="rename_existing">rename the existing team and import</option>
In team.rb
# E1938: Added handling for renaming old team when conflict arises if handle_dups == "rename_existing" if teamtype.is_a?(CourseTeam.class) team.update(name: self.generate_team_name(Course.find(id).name)) elsif teamtype.is_a?(AssignmentTeam.class) team.update(name: self.generate_team_name(Assignment.find(id).name)) end return name end
The state of D before conflicting import:
After fixing changes
As you can see the new team got the name D and the old file got renamed to Team_17.
Issue #329
This was a new requirement to add an option to upload topics along with the teams assigned.
Code Changes: import_file/_sign_up_topic.html.erb (All the select tags has been changed
<select name="select1" id="select1" class="form-control" style="background-color:lightgrey"> <option value="topic_identifier">Topic Identifier (required)</option> <option value="topic_name">Topic Name (required)</option> <option value="max_choosers">Max Choosers (required)</option> <option value="category">Category (optional)</option> <option value="description">Description (optional)</option> <option value="link">Link (optional)</option> <option value="assigned_team">Assigned Team (optional)</option> </select>
model/sing_up_topic.rb
def self.import(row_hash, session, _id = nil)
if row_hash.length < 3
raise ArgumentError, "The CSV File expects the format: Topic identifier, Topic name, Max choosers, Topic Category (optional), Topic Description (Optional), Topic Link (optional), Assigned Team Name (optional)."
end
topic = SignUpTopic.where(topic_name: row_hash[:topic_name], assignment_id: session[:assignment_id]).first
if topic.nil?
attributes = ImportTopicsHelper.define_attributes(row_hash)
topic_new_id = ImportTopicsHelper.create_new_sign_up_topic(attributes, session)
unless row_hash[:assigned_team].nil?
team = Team.where(name: row_hash[:assigned_team]).first
ImportTopicsHelper.assign_team_topic(topic_new_id, team.id)
end
else
topic.max_choosers = row_hash[:max_choosers]
topic.topic_identifier = row_hash[:topic_identifier]
# topic.assignment_id = session[:assignment_id]
topic.save
unless row_hash[:assigned_team].nil?
team = Team.where(name: row_hash[:assigned_team]).first
newteam = SignedUpTeam.where(topic_id: topic.id, team_id: team.id).first
if newteam.nil?
ImportTopicsHelper.assign_team_topic(topic.id, team.id)
else
newteam.team_id = team.id
newteam.save
end
end
end
end
An option column checkbox (Teams Assigned) has been added to the UI
A new column Assigned Team is added where the columns are being mapped.