E1829 OSS project Duke Blue Fix import glitches
This wiki page is for the description of changes made to Fix import glitches.
Introduction
Expertiza is an open source project based on Ruby on Rails framework. The Expertiza project is a software that creates reusable learning objects through peer review. It is a web application where students can submit and peer-review learning objects (articles, code, websites, etc). It is used in some courses at NC State University and by professors at several other universities. It supports team projects, and the submission of almost any document type, including URLs and wiki pages. Expertiza enables the instructor to create new and customize existing assignments. It also enables the instructor to create a list of topics the students can sign up for as part of a project. Students can form teams in Expertiza to work on various projects and assignments. Expertiza supports submission across various document types, including the URLs and wiki pages.
Problem Description
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.
Issue #329
Rename existing team when there is a conflict
->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
Merge teams when there is a conflict
->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
Validate file when importing participants
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
It seems that non-ASCII characters in the description (e.g., a curly apostrophe, and perhaps also an en-dash) caused a SQL error in inserting the description string into the database.
->While importing the participants, the user can include special characters in the project description and is successfully stored in the database:
Issue #183
Count of fields wrong in import
When importing participants (or users), it is typical not to specify a password, but rather to have the system generate it. But if you do that, Expertiza reports that each record in the file you are importing does not have enough records.
->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:
Use Case Diagram
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
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
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:
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 181
- We validate the file before importing the teams. Thus, the file needs to mandatorily be uploaded in order to import team.
Issue 183
- In the import method in user.rb file, there is a validation to check if the record length is less than 3 which is exclusive of password
- If the record length is greater than 3, it indicates that there is a password in the record and we save the password in the database
- If the length is equal to 3 then new system password is generated and saved for the user
In file app/models/user.rb
def self.import(row_hash, _row_header, session, id = nil) raise ArgumentError, "Only #{row_hash.length} column(s) is(are) found.It must contain at least username, full name, email." if row_hash.length < 3 user = User.find_by_name(row_hash[:name]) puts "inside import" if user.nil? attributes = ImportFileHelper.define_attributes(row_hash) user = ImportFileHelper.create_new_user(attributes, session) if(row_hash.length>3) user.password=row_hash[:password] user.save else password = user.reset_password end
Issue #918
- Sql allows unicode values to be stored in the database.
Test Plan
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