rootCircle / docFiller

Automated Google Docs Filling Web Extension written in JS
GNU General Public License v3.0
10 stars 14 forks source link

Enhancements to FieldsExtractorEngine for Improved Option Extraction #11

Closed Gyan172004 closed 1 year ago

Gyan172004 commented 1 year ago

Summary:

This pull request introduces enhancements to the FieldsExtractorEngine to improve the extraction of options for different field types. The code has been refactored and detailed comments have been added to explain the logic and extraction process more effectively.

Changes Made:

Added detailed comments for each option extraction method to improve code readability and understanding.
Refactored conditional statements to handle different field types (e.g., MultiCorrect, Dropdown, Multiple Choice, Linear Scale, Checkbox Grid) and extract options accordingly.

getOptions_MULTI_CORRECT:

Created the getOptions_MULTI_CORRECT method to extract options for both MultiCorrect and MultiCorrect With Other question types.
Options are extracted by selecting spans with dir="auto" within the question element.
The extracted options are stored in an array.

getOptions_MULTIPLE_CHOICE:

Created the getOptions_MULTIPLE_CHOICE method to extract options for both Multiple Choice and Multiple Choice With Other question types.
Options are extracted by selecting spans with dir="auto" within the question element.
The extracted options are stored in an array.

getOptions_LINEAR_SCALE:

Written the code for getOptions_LINEAR_SCALE method to handle the extraction of options for Linear Scale questions.
Extracts the lower and upper bounds from span elements with role="presentation" within the question element.
Extracts the options from div elements with dir="auto" within the question element.
Combines the bounds and options into a single array to represent the complete linear scale.

getOptions_GRID:

Written the code for getOptions_GRID method to extract options for Checkbox Grid and Multiple Choice Grid question types.
The required elements are extracted by traversing the DOM tree and using brute force since no helpful attributes were found.
Returns an object containing two arrays: rowsArray for row contents and columnsArray for column contents.

Description:

These changes aim to enhance the existing functionality of FieldsExtractorEngine, making it more versatile and accurate in extracting options for different types of questions. The detailed comments will help developers understand the logic and implementation of each method better.

Please review and merge the pull request after examining the changes. Let me know if any further improvements are needed.

rootCircle commented 1 year ago

Congratulations on your second PR to this project! :partying_face: I personally like the well documented changes you had put through, in this pull request.

I am currently not considering filler.js changes as that deemed unnecessary to this code, and for else I will test and review the extractor's code very soon and get back on it soon

You have done a really great job! KUDOS

rootCircle commented 1 year ago

I did some initial testing!

Here are some of my suggestions

  1. In multiple Choice with Other, the other option should be segregated from the code. You can use this case independently for MULTIPLE_CHOICE_WITH_OTHER than MULTIPLE_CHOICE and put keys as options and other receptively or any other appropriate name you like. [Same with CheckBox ]
  2. In Linear Scale, I will recommend separating lower and upper bound from the other options.
Gyan172004 commented 1 year ago

Thank you for your valuable feedback! Segregating the "Other" option in multiple-choice and checkbox sections will improve the user experience significantly. Separating lower and upper bounds in the Linear Scale will enhance usability. I'll work on these suggestions promptly.

Your contributions are highly valued, and I'm eager to collaborate further to create a more robust solution. I'll keep you updated on the progress. Thank you for your support!

Gyan172004 commented 1 year ago

I've implemented your suggestions, segregating the "Other" option in Multiple Choice with Other and Multiple Correct with Other and separating lower and upper bounds in Linear Scale.

It made the code more robust and will enhance the user experience.

Please take a moment to review the updates, and if you have any further suggestions or thoughts, I am eager to hear them. :)

rootCircle commented 1 year ago

I have tested new changes @Gyan172004 and your PR looks very promising, I am merging it for now.

I had reviewed your code, and found brute-forced function in getOptions_GRID() method but that's acceptable for now! We might change that later!

rootCircle commented 1 year ago

Congrats!! :smile: