E1829 OSS project Duke Blue Fix import glitches

From Expertiza_Wiki
Jump to navigation Jump to search

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

  1. 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.
  2. 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’.
  3. Then the import_team_members function is called
  4. We get the user through his/her name
  5. If a user isn’t registered, we get a nil object and raise an ImportError
  6. Else we add the user to the team if he/she isn’t already in the team
  7. 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

  1. We included a new option in the duplicate handler field.
  2. We added a new handler in the handleDuplicates method to handle the given option as shown in the below screenshot.
  3. 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

  1. We validate the file before importing the teams. Thus, the file needs to mandatorily be uploaded in order to import team.

Issue 183

  1. 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
  2. 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
  3. 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

  1. Sql allows unicode values to be stored in the database.

Test Plan


Issue 918

  1. Login as an instructor with the following credential
Username: instructor6
Password: password
  1. Click on import topics
  2. Upload a file in the format given on the page, in place of topic description insert non-ASCII characters and upload
  3. Click on the import button.
  4. on the summary page, you should be able to see topic uploaded along with its description containing non-ASCII characters

Issue 329

  1. Login as an instructor with the following credential
Username: instructor6
Password: password
  1. 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.
  2. Upload a file containing the already existing team name.
  3. Click on import team button
  4. 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

  1. Login as an instructor with the following credential
Username: instructor6
Password: password
  1. 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.
  2. Upload a file containing the already existing team name and new team members
  3. Click on import team button
  4. On the summary page, you should be able to see the existing team with additional team members

Issue 183

  1. Login as an instructor with the following credential
Username: instructor6
Password: password
  1. Upload a file in the format given on the page without password field
  2. Click on import participant button
  3. You should be able to successfully import the participants

Issue 181

  1. Login as an instructor with the following credential
Username: instructor6
Password: password
  1. Click on import participant button without uploading a file.
  2. You should be able to see a prompt error to upload a file and then import

References

  1. Deployed link
  2. GitHub Repository
  3. GitHub Pull Request