E1829 OSS project Duke Blue Fix import glitches: Difference between revisions
Line 5: | Line 5: | ||
== | == The problems and their results after resolving them== | ||
* '''Issue #329''': When importing teams there are different options to handle conflicting team names. We added an option rename EXISTING team when a conflict exists. | * '''Issue #329''': When importing teams there are different options to handle conflicting team names. We added an option rename EXISTING team when a conflict exists. |
Revision as of 18:20, 8 November 2018
This wiki page is for the description of changes made to Fix import glitches.
Background
The import feature is the most helpful feature for instructors to set up assignments. The instructors usually have a list of students, teams, etc. from their learning management system. Being able to import these into expertiza saves a lot of time when setting up an assignment.
The problems and their results after resolving them
- Issue #329: When importing teams there are different options to handle conflicting team names. We added an option rename EXISTING team when a conflict exists.
- Issue #328: When importing teams, and a conflict exists there is an option to merge the two teams by inserting the new members into an existing team.
- Issue #181: If one attempts to import users or participants, and does not specify the file to import from, a NoMethodError error occurs. the error has been handled by validating the file before importing the teams, thus the file needs to mandatorily be uploaded in order to import team.
- Issue #918: Import of topics chokes on special characters
While importing the participants, the user can include special characters in the project description and is successfully stored in the database:
- insert image here ***
- Issue #183: Count of fields wrong in import
When the user tries to upload the file to import participants, password record should be made optional and let the user upload without password record:
- insert image here***
Implementation
Issue #328
- We search the database to see if there is an existing team with the same name. In such a case we save the old team in the ‘team’ variable and set the team_exists flag to true.
- We then cal the handle_dups method which handles the case if value chosen by the user is ‘insert into existing team’, inside the code this value is represented as ‘insert’.
- Then the import_team_members function is called
- We get the user through his/her name
- If a user isn’t registered, we get a nil object and raise an ImportError
- Else we add the user to the team if he/she isn’t already in the team
- The add_member function only works till the team isn’t filled to its maximum capacity
Issue 329
- We included a new option in the duplicate handler field.
- We added a new handler in the handleDuplicates method to handle the given option as shown in the below screenshot.
- We leveraged the existing generateTeam() method and sent the existing team id to this method and replaced the existing team’s team name as follows:
Issue 181
- We validate the file before importing the teams. Thus,the file needs to mandatorily be uploaded in order to import team.
Code Snippet
Issue #329 In file app/models/team.rb
if handle_dups == "rename_existing" # rename: rename existing team if teamtype.is_a?(CourseTeam) team.update(name:self.generate_team_name(Course.find(id).name)) # update the old team name elsif teamtype.is_a?(AssignmentTeam) team.update(name:self.generate_team_name(Assignment.find(id).name)) # update the old team name end #team.update(name:self.generate_team_name(Assignment.find(id).name)) return name # send the new team name end
Issue #328 In file app/models/team.rb
if handle_dups=="insert" team.import_team_members(row_hash) return nil def import_team_members(starting_index = 0, row_hash) starting_index index = 0 row_hash[:teammembers].each do |teammember| next if index < starting_index # not sure this will work, hash is not ordered like array user = User.find_by(name: teammember.to_s) if user.nil? raise ImportError, "The user '#{teammember.to_s}' was not found. <a href='/users/new'>Create</a> this user?" else add_member(user) if TeamsUser.find_by(team_id: id, user_id: user.id).nil? end index += 1 end end
Test Plan
To check the issue resolved, please follow the steps Issue 918
- Login as an instructor with the following credential
Username: instructor6 Password: password
- Click on import topics
- Upload a file in the format given on the page, in place of topic description insert non-ASCII characters and upload
- Click on the import button.
- on the summary page, you should be able to see topic uploaded along with its description containing non-ASCII characters
Issue 329
- Login as an instructor with the following credential
Username: instructor6 Password: password
- on import team form page, in the field "If a duplicate team name is found in the rooster" select the rename the new team and import option.
- Upload a file containing the already existing team name.
- Click on import team button
- On the summary page, you should be able to see the existing team with a new name assigned and the new team with the name uploaded.
Issue 328
- Login as an instructor with the following credential
Username: instructor6 Password: password
- On the import team form page, in the field "If a duplicate team name is found in the rooster" select the insert any new team members into the existing team option.
- Upload a file containing the already existing team name and new team members
- Click on import team button
- On the summary page, you should be able to see the existing team with additional team members
Issue 183
- Login as an instructor with the following credential
Username: instructor6 Password: password
- Upload a file in the format given on the page without password field
- Click on import participant button
- You should be able to successfully import the participants
Issue 181
- Login as an instructor with the following credential
Username: instructor6 Password: password
- Click on import participant button without uploading a file.
- You should be able to see a prompt error to upload a file and then import