PROJECT: NSync

Overview

NSync is a student lifestyle management and utility application built apon AddressBook - Level 4. The application uses a Command-Line interface to interact with the user. It aims to increase the efficiency of time consuming tasks that predominantly exist in a students life.

This document includes the contributions of Hu Yi Qing across the duration of the project.

Summary of contributions

  • Major Enhancement : Added the ability to download notes from IVLE automatically.

    • What it does: Allows user to download all notes of a certain module using the downloadAllNotes command or view all the available files and select which files to download with the downloadSelectNotes command.

    • Justification: This feature streamlines notes downloads by simplifying it to 1-2 lines of command input.

    • Highlights: Selenium Web-driver libraries is used to implement this feature. The libraries has several conflicts with the existing code base; which required special care to resolve.

    • Credits: Selenium WebDriver.

  • Minor Enhancement : Added the ability to view the notes download using the showNotes.

    • What it does: Displays notes downloaded.

    • Justification: User could view notes without going into directory

  • Code contributed : [Functional Code and Test Code]

  • Other Contributions :

    • Additional enhancements:

      • Implemented auto extraction of ChromeDrivers from the NSync.jar.

      • Implemented auto creation of additional file paths from NSync.jar.

    • Community:

      • Reviewed multiple pull requests: (Examples: #145, #151)

      • Reported bugs for other teams: (Examples: 1, 2)

      • Responded to bug reports: (Examples: 1, 2)

    • Tools:

      • Integrated third party library (apache.commons.io) to project

      • Integrated third party library (Selenium WebDriver) to project

Contributions to the User Guide

Displayed below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users.


Notes Commands

The download function has temporarily been disabled in accordance with NUS Information Technology Acceptable use policy for IT resources Ver4.2, Clause 4.6

You are still able to login and view available files to be downloaded. Try out downloadSelectNotes without the /file prefix!

You would need to have Google Chrome installed in the default location, run Windows 8 or above and be connected to the internet to use the download commands.
You would be unable to see your inputted command after inputting it, this is a security feature to prevent your login credentials from being compromised.

Downloading all notes from a selected module from IVLE : downloadAllNotes

Downloads the your notes from IVLE, and stores them in the folder "Notes"
Format: downloadAllNotes downloadAllNotes [user/IVLE USERNAME] [pass/IVLE PASSWORD] [mod/ENROLLED MODULE]

downloadExample

Example DownloadAllNotes command usage.

  • Automatically accesses the your IVLE account using Google Chrome, and downloads all notes and resources of the specified module.

You do not have to Enter the full module code or worry about the capitalization. Example: if you are enrolled in CS2113 and CS2101 entering mod/cs21 will select cs2101
  • You may notice a new window of Google Chrome opening up. Do not interact with it or you might interfere with the download.

chromeOpen
  • NSync might be unresponsive during the download, it is so to prevent you from accidentally introducing file corruption.

  • If your download is successful, the result window of NSync will display the exact path to your newly downloaded notes.

Examples and what you might expect :

Download Successful :

downloadAllSuccessful

Module not found :

downloadModNotFound

Password or username Incorrect :

downloadPasswordOrUsernameWrong

Display all notes from a selected module from IVLE : downloadSelectNotes without prefix "file/"

Displays all the available notes of a selected
Format: downloadSelectNotes [user/IVLE USERNAME] [pass/IVLE PASSWORD] [mod/ENROLLED MODULE]

Currently the files are not sorted in any order. In a future version we will make its sorted by file type
downloadSelectFileExample

Example DownloadSelectFile without file/ prefix usage

  • All available notes from the selected module would be sourced and displayed

  • if a file is not shown, it could be either a private folder or a submission folder, consult your lecturer for more information

Examples and what you might expect :

File Fetch Successful :

downloadSelectFileSuccess1
downloadSelectFileSuccess2
the number on the left of the file represents the file ID, it is static. Example: "0:LP41_More_UML_Inheritence.pptx" 0 is the file index.

Downloading selective notes from a selected module from IVLE : downloadSelectNotes with prefix "file/"

Download a selective number of notes from IVLE, and stores them in the folder "notes".

Format: downloadSelectNotes [user/IVLE USERNAME] [pass/IVLE PASSWORD] [mod/ENROLLED MODULE] [file/0,1,2…​n]

Use downloadSelectFile without the file\ prefix to obtain the file indexes.
downloadSelectExample

Example DownloadSelectFile with file/ prefix usage

  • The files would be downloaded one by one from IVLE to your "notes" folder.

  • if you entered a mix of invalid and valid file IDs, NSync will only only download the correct files, up till it encounters a invalid ID.

    Example: file/0,1,2,90000000,3
    if 0,1,2,3 are valid file IDs, only file 0,1,2 will be downloaded.

Examples and what you might expect :

Download Successful :

downloadSelectSuccess

File not found :

downloadSelectFileNotFound

Show all downloaded notes: showNotes

Displays all the downloaded notes in the UI
Format: showNotes

the files are displayed in the order that it is in your directory
  • It recursively searches your notes folder and displays all the files available

Examples of usage:

showNotes1
showNotes2
showNotes3

Contributions to the Developer Guide

Displayed below are sections I contributed to the Developer Guide. They showcase my ability to write documentation targeting Developers, as well as construct UML diagrams.


Download Commands

Both downloadSelectNotes and downloadAllNotes extends on the downloadAbstract class which itself extends from the command class. The implementation is similar up till the downloading segment. The download commands uses Selenium Chromedrivers to initiate downloads from the internet.

The following class diagram shows the relationship of downloadAllNotes,downloadSelectNotes as well as downloadAbstract.

DownloadClassDiagram
The download function has temporarily been disabled in accordance with NUS Information Technology Acceptable use policy for IT resources Ver4.2, Clause 4.6

However, if desired, the function can be manually enabled by changing the state of isDownloadDisabled in DownloadAbstract.java.

DownloadAllNotes command

The following Sequence diagram shows how downloadAllNotes is handled.

downloadAllNotesSequence

Format: downloadAllNotes downloadAllNotes [user/IVLE USERNAME] [pass/IVLE PASSWORD] [mod/ENROLLED MODULE]

Current Implementation

Step 1: Extract files from Jar. Since Selenium ChromeDriver requires it to be present in the directory as an executable inorder to be ran, it would need to be extracted from NSync.jar before carrying on. Additionally, a Notes folder would be created to store the notes downloaded.

Step 2: Set the webdriver.chrome.driver system variable to the location of the ChromeDriver executable. This step is necessary.

Step 3: Set the download path and other settings for ChromeDriver.

Headless mode for ChromeDriver has been disabled due to security reasons, an alternative is to start ChromeDriver in an unviewable location on the screen to prevent disrupting the users interactions.

Step 4: Login into IVLE , and check if successful. If not, a CommandExeption will be thrown to alert the user that either IVLE USERNAME or IVLE PASSWORD is incorrect.

Step 5: If user is logged in, check if the ENROLLED MODULE exists. If not, a CommandException will be thrown to alert the user that the ENROLLED MODULE specified does not exist.

Step 6: Navigate to the IVLE download page, select all files and download as .zip file.

While Downloading, the program would introduce "busy waiting" to prevent the ChromeDriver from terminating before the download is complete.

Step 7: Unzip the files and store it in a folder created based on the name of ENROLLED MODULE inside the Notes folder created at Step 1.

DownloadSelectNotes Command

The following Sequence diagram shows how downloadAllNotes is handled.

downloadSelectNotesSequence

Format: downloadSelectNotes [user/IVLE USERNAME] [pass/IVLE PASSWORD] [mod/ENROLLED MODULE] [file/FILE INDEXES: 1,2,3…​n]

The existance of the file/ prefix is optional, and the existance of this prefix will affect the execution

Current Implementation

Step 1-5: is exactly the same as DownloadAllNotes command.

Step 6a: If user has NOT entered a file/ prefix, the program will fetch all available file names and store it in a formatted string; A static FILE INDEX will be appended to the front of the file name. The formatted string is returned as a CommandResult.

Step 6b: If user has entered a file/ prefix. The program will download files according to the FILE INDEXES supplied. It is stored in the Notes folder created at Step 1.

If an incorrect file index has been supplied, download will stop after encountering an invalid index. Example: file/1,2,9000,3 if 1,2,3 are valid file indexes, only file 1,2 will be downloaded.
Design Considerations
Aspect 1: Which Driver is used

Implementation 1 (Current Implementation)

Currently downloadNotes uses ChromeDriver to initiate its downloads. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more.

The user would be required to have Google Chrome installed inorder to use this function

Pros: Google Chrome is one of the most widely used browsers in the world. Thus statistically speaking, most NUS users would already have Google Chrome installed.

Cons: Google Chrome is extremely ram intensive, and the function would fail to cater to users who do not use Google Chrome.

Implementation 2(HTML unitdriver)

HTML UnitDriver is the most light weight, natively headless and the fastest implementation of WebDriver.

Pros: Its extremely fast, does not require prior installation of any other applications to function.

Cons: It uses a javaScript engine called Rhino. This engine is incompatible with IVLE's usage of javaScript. Making it unable to navigate past Step 5.

Aspect 2: How notes are downloaded
  • Implementation 1 (Current Implementation)**

As mentioned previously, currently downloadNotes uses ChromeDriver to initiate its downloads.

Pros: The current implementation navigates through the IVLE Web page to download the files "Pseudo" manually. Thus we could be easily morph this implementation to suit other platforms and websites. Its also easy to update.

example: NTU web portal

Cons: It requires user to have Google Chrome installed.

Implementation 2 (IVLE API)

An alternative implementation is to use the existing IVLE API to instantiate the downloads.

Pros: Its supported by NUS, and thus should be more reliable than the IVLE platform.

Cons: The existing IVLE API is outdated, many parts are not functional as of 10-11-2018. Furthermore, IVLE is migrating to luminous as of 2019, thus if implemented with IVLE API, it would require a ground up rebuild to keep the function operational.

ShowNotes Command

ShowNotes recursively searches the Notes folder created by DownloadNotes Command.

Current Implementation

A static String is used to store all the information notesResult.

The files are differentiated by 2 catagories: Directories and Others. If currentFile is a directory, a recursive call will be made and the directory name appended with N tabs would be added to notesResult , else, just the file name and N tabs would be apprended and added to ` notesResult`.

N refers to the number of recursive calls made up till the point of arriving at currentFile.

Design Considerations

The Current implementation is the most efficient way to list out all the files in a directory. An Iterative method could have been used. However due to the fact that the relative "depth" of a directory is unknown. It would be rather counter-intuitive to search iteratively.