Repository navigation
CSVUploadView Component
The CSVUploadView component is responsible for adding new professors/TAs to the course. This component can only be viewed by professors and TAs since they're the only users who can add instructors to the course.
The following diagram outlines the steps of entering TAs/Professors using the CSV Upload functionality.
Select a Format (Enter Professor/TA email(s) OR Upload CSV File)
| |
next| next|
V V
Enter Emails Upload CSV File
| |
| |
--------------------------
|
next|
V
View and Confirm
|
finish
-
onReturn: A function that returns to the Manage Role Page. This function is used when the user clicks on finish or when they click on the cancel button when they're on the first step. -
course: This is the course that the TAs/Professors will be added to -
getAddedUsersList: This function takes a list of added users and displays them in a banner in the people view (parent component) -
getMissingUsers: This function takes a list of pending users and displays them in a banner in the people view (parent component)
-
pageIndex: keeps track of the page/step that the user is on in the process of adding new TAs/Professors. -
uploadType: keeps track of whether the user selected the manual addition or CSV upload option to add new professors/TAs. -
selectedFile: keeps track of the current CSV file that is selected. -
CSVErrorMessage: stores the specific error message that arises from the CSV upload process (if any) -
EnterErrorMessage: stores the specific error message that arises from the manual addition upload process (if any) -
TAEmailList: stores the list of new TAs that were parsed from the CSV/manual addition. -
professorEmailList: stores the list of new professors that were parsed from the CSV/manual addition. -
newUsers: stores a list of pending users (users that were added but don't exist in the Firestore database).
None
processCSV
Parameters: None
Runtime: O(n) (where n is the number of rows in the CSV)
Returns: None
This function is responsible for parsing the selected CSV. It checks to see if the header of the CSV contains more than two rows. If it does it sets an appropriate error message and returns. Then it checks to see if the emails are valid emails. If they are not, it sets an appropriate error message and returns. If any specific row has more than two columns, an error message will be set and the function will return. Then, a TA and professor list will be created by filtering the list of new users for all the rows where the second column is equal to either 'Professor' or 'TA'. If the length of the ta and professor lists are not equal to the list of all new users, this means that not all entered users have valid roles and therefore an error message should be shown. Finally, we update the professor and TA emails state value.
handleUpdateUsers
Parameters: event, key
Runtime: O(1)
Returns: None
This function is responsible for adding new users (using the manual input option). It retrieves the new user's email and role from the HTML event and it appends the new user to the list of new users and it updates the state.
processListOfUsers
Parameters: None
Runtime: O(1)
Returns: None
This function post processes the list of new users created during manual input. It does certain checks such as: Is the email field empty? Is the email a valid email? Is the role field equal to either 'TA' or 'Professor'. If any of these checks fail, an appropriate error message will be set. Otherwise the TAEmailList and professorEmailList states will be updated.
addNewCell
Parameters: None
Runtime: O(1)
Returns: None
This function will be called when the add button in the new user table is clicked on. It will add a new empty user to the list of new users. This will cause the table to expand its size to include a new empty row. Once that row is filled in, the user info will be updated and it will no longer appear as a new empty user in the new user list.
fileInput
Parameters: event
Runtime: O(1)
Returns: None
This function is responsible for detecting the HTML event indicating that a new file is added. Then it updates the selectedFile state with the new CSV file that was just added.
isValidEmail
Parameters: email
Runtime: O(1)
Returns: true/false
This function matches the given email against a valid email regular expression. If the check passes, that means the email is a valid email and the function will return true. If the check doesn't pass that means that the email is not a valid email and the function will return false.
previous
Parameters: None
Runtime: O(1)
Returns: None
This function is called when the user clicks the back button during the process of adding new TAs/Professors. It updates the page index by subtracting 1.
next
Parameters: None
Runtime: O(1)
Returns: None
This function is called when the user clicks the next button during the process of adding new TAs/Professors. It updates the page index by adding 1.
canClickNext
Parameters: None
Runtime: O(1)
Returns: true/false
This function determines whether the user can click the next button. It checks if the required information has been entered for the page. If so, the user is allowed to proceed with the process (the function returns true to indicate this). Otherwise, the user is not allowed to proceed with the process (the function returns false to indicate this).
addTAandProfessors
Parameters: None
Runtime: O(1)
Returns: None
This function adds the new professors/TAs by calling a firebase function: importProfessorsOrTAsFromCSV. Then it calls the function getProfOrTAEmailList
getProfOrTAEmailList
Parameters: None
Runtime: O(1)
Returns: None
This function calls the props functions getAddedUsersList and getMissingUsers which are responsible for displaying the banners of added TAs/professors and pending users.