Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load OPL set definitions from files instead of searching the OPL directory. #1653

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Apr 7, 2022

This is done in the getDefList method of lib/WeBWorK/ContentGenerator/Instructor.pm. The only time that method is called is when the homework sets editor is loaded. Note that the course's templates directory is still searched, but the Library and Contrib subdirectories are pruned and so not look into.

A new script bin/generate-OPL-set-def-lists.pl is created that generates the needed data files by searching the OPL directory. Note that this script is executed by bin/OPL-update. For now, this script is executed in docker-entrypoint.sh when the docker container is started. However, these files should be added to the OPL release built by webwork2/bin/OPL_releases/release.sh, and dealt with in the same way as the other files in webwork2/htdocs/DATA. Of course, that whole process needs to be updated and removed from the personal fork it is currently in. The release there is now more than two years old.

The defaults.config option $option{useOPLdefFiles} still is checked to determine if OPL set defintion files will be loaded and listed, but note that the $options{setDefSearchDepth} is ignored for this. The new defaults.config option $option{useContribDefFiles} determines if set definition files from the Contrib directory will be loaded and listed. This also ignores depth. So the search depth option only applies to local directories for the course.

@drgrice1 drgrice1 requested review from pstaabp and taniwallach April 7, 2022 17:22
@drgrice1 drgrice1 force-pushed the load-opl-set-defs-from-file branch from 30e04f8 to af33320 Compare April 7, 2022 17:23
Copy link
Member

@taniwallach taniwallach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me, and should speed up the loading of the set editor.

I'm not sure the location where the file is being saved should be in htdocs as no remote use of the files are apparently being planned. The data is just loaded by code in lib/WeBWorK/ContentGenerator/Instructor.pm.

depth_then_iname_sort(\@contrib_set_defs);

# Write the lists to the files in htdocs/DATA.
if ($ce->{options}{useOPLdefFiles}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think the creation of the JSON files should depend on these variables.
Some courses could override the default set in defaults.config so the files should always be available on the server.

@drgrice1
Copy link
Member Author

drgrice1 commented Apr 8, 2022

The file is saved in webwork2/htdocs/DATA the same as the other library JSON files because that is convenient and keeps it all together. It makes it easier to deal with in the docker-entrypoint.sh file. I don't see any real reason to move it elsewhere even if it doesn't need to be there.

Yeah, I thought of the issue of a course overriding the default. I will remove that check.

@drgrice1 drgrice1 force-pushed the load-opl-set-defs-from-file branch 4 times, most recently from 6c5d956 to 2eb32f5 Compare April 8, 2022 18:34
Copy link
Member

@drdrew42 drdrew42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!

@drgrice1 drgrice1 force-pushed the load-opl-set-defs-from-file branch from 2eb32f5 to 688c630 Compare April 8, 2022 21:40
drgrice1 added 3 commits April 8, 2022 16:55
…ctory.

This is done in the getDefList method of lib/WeBWorK/ContentGenerator/Instructor.pm.  The only time that method is called is when the homework sets editor is loaded.  Note that the course's templates directory is still searched, but the Library and Contrib subdirectories are pruned and so not look into.

A new script `bin/generate-OPL-set-def-lists.pl` is created that generates the needed data files by searching the OPL directory.  Note that this script is executed by `bin/OPL-update`.  For now, this script is executed in docker-entrypoint.sh when the docker container is started.  However, these files should be added to the OPL release built by webwork2/bin/OPL_releases/release.sh, and dealt with in the same way as the other files in webwork2/htdocs/DATA.  Of course, that whole process needs to be updated and removed from the personal fork it is currently in.  The release there is now more than two years old.

The defaults.config option $option{useOPLdefFiles} still is checked to determine if OPL set defintion files will be loaded and listed, but note that the $options{setDefSearchDepth} is ignored for this.  The new defaults.config option $option{useContribDefFiles} determines if set definition files from the Contrib directory will be loaded and listed.  This also ignores depth.  So the search depth option only applies to local directories for the course.
loads the set definitions for the "Set Definition Files" part, and
remove the method it was using that was not as full featured.
@drgrice1 drgrice1 force-pushed the load-opl-set-defs-from-file branch from 688c630 to 1ecdb0d Compare April 8, 2022 21:55
Copy link
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sped up the loading of the HW sets editor for me by an order of magnitude.!!! Yeah.

@pstaabp pstaabp merged commit 801c826 into openwebwork:develop Apr 8, 2022
@drgrice1 drgrice1 deleted the load-opl-set-defs-from-file branch April 8, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants