Skip to content

Add an addProblems API method and assign added problems in bulk. - #3289

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:api-add-problem-updates
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:api-add-problem-updates

Conversation

@drgrice1

Copy link
Copy Markdown
Member

The library browser's "Add All" button sent a separate addProblem request for each problem. So add an addProblems API method that adds multiple problems to a set in one request, and use it in the library browser instead. Note that the request timeout that was previously set to 10 seconds is now 10 seconds times the number of problems being added to account for the additional processing needed for more problems. This fixes the FIXME in htdocs/js/SetMaker/setmaker.js that I added about four years ago.

Both the addProblem and addProblems API methods now use the new internal addProblemToSet method. This method fixes the incorrect handling of the maxAttempts, att_to_open_children, and counts_parent_grade parameters that the previous addProblem method had.

Assigning a problem to all set users inserted the user problems one at a time in a loop, which is very slow for sets assigned to many users. So the assignProblemsToAllSetUsers utility method was added that assigns several problems to all set users at once using _assignMultipleProblemsToGivenUsers. The assignProblemsToAllSetUsers method is used in the previous assignProblemToAllSetUsers utility method, the API methods, and when adding blank problems in the set detail page.

When adding multiple blank problems in the set detail page, the blank problem template is now copied to the set directory once instead of being read and written for each problem, and a failure to copy it is reported to the user.

Also delete the unused add_selected method of SetMaker.pm.

@drgrice1
drgrice1 force-pushed the api-add-problem-updates branch from 0530d4c to aba3e60 Compare November 17, 2026 19:30

@pstaabp pstaabp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. I test by adding 160 problems to a set. On develop, that took about 5-6 seconds. On this, less than 1.

The library browser's "Add All" button sent a separate `addProblem`
request for each problem. So add an `addProblems` API method that adds
multiple problems to a set in one request, and use it in the library
browser instead. Note that the request timeout that was previously set
to 10 seconds is now 10 seconds times the number of problems being added
to account for the additional processing needed for more problems. This
fixes the FIXME in `htdocs/js/SetMaker/setmaker.js` that I added about
four years ago.

Both the `addProblem` and `addProblems` API methods now use the new
internal `addProblemToSet` method. This method fixes the incorrect
handling of the `maxAttempts`, `att_to_open_children`, and
`counts_parent_grade` parameters that the previous `addProblem` method
had.

Assigning a problem to all set users inserted the user problems one at a
time in a loop, which is very slow for sets assigned to many users. So
the `assignProblemsToAllSetUsers` utility method was added that assigns
several problems to all set users at once using `_assignMultipleProblemsToGivenUsers`.
The `assignProblemsToAllSetUsers` method is used in the previous
`assignProblemToAllSetUsers` utility method, the API methods, and when
adding blank problems in the set detail page.

When adding multiple blank problems in the set detail page, the blank
problem template is now copied to the set directory once instead of
being read and written for each problem, and a failure to copy it is
reported to the user.

Also delete the unused add_selected method of SetMaker.pm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drgrice1
drgrice1 force-pushed the api-add-problem-updates branch from aba3e60 to bb25873 Compare November 17, 2026 23:06
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.

2 participants