Skip to content

com_courses: draw every page of a form whose PDF was re-uploaded - #1926

Merged
nkissebe merged 1 commit into
hubzero:2.4-mainfrom
denphi:fix/com-courses-form-missing-pages
Sep 16, 2026
Merged

nkissebe merged 1 commit into
hubzero:2.4-mainfrom
denphi:fix/com-courses-form-missing-pages

Conversation

@denphi

@denphi denphi commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

A re-uploaded PDF renders its page images into forms//<max version + 1>/, but saving the layout bumps the question version every time. Once the layout is saved twice after an upload, the latest version no longer has a matching directory and PdfForm::eachPage() falls back to the newest older one.

That fallback set $version_dir, so the image URLs pointed at the new PDF, but left $base at the form root. The page count therefore came from the original upload's PNGs. When the new PDF has more pages, the extra pages are never rendered, yet getQuestionAnswerMap() still requires their questions -- so students get "Please ensure you have selected an answer for each question" with no incomplete marker on screen, and a timed form only accepts the submit once the limit expires, scoring the hidden questions as unanswered. The layout editor and results view share eachPage() and lose the same pages.

$base is now taken from whichever version dir was chosen, so the page count and the image URLs always read the same directory.

The fallback also read the natsorted list by position, but natsort() keeps the scandir keys, so it could pick the wrong older directory. The list is now reindexed and walked in order.

https://nanohub.org/support/ticket/514078

A re-uploaded PDF renders its page images into forms/<id>/<max version + 1>/,
but saving the layout bumps the question version every time. Once the layout
is saved twice after an upload, the latest version no longer has a matching
directory and PdfForm::eachPage() falls back to the newest older one.

That fallback set $version_dir, so the image URLs pointed at the new PDF, but
left $base at the form root. The page count therefore came from the original
upload's PNGs. When the new PDF has more pages, the extra pages are never
rendered, yet getQuestionAnswerMap() still requires their questions -- so
students get "Please ensure you have selected an answer for each question"
with no incomplete marker on screen, and a timed form only accepts the submit
once the limit expires, scoring the hidden questions as unanswered. The layout
editor and results view share eachPage() and lose the same pages.

$base is now taken from whichever version dir was chosen, so the page count
and the image URLs always read the same directory.

The fallback also read the natsorted list by position, but natsort() keeps the
scandir keys, so it could pick the wrong older directory. The list is now
reindexed and walked in order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@denphi
denphi requested a review from nkissebe as a code owner September 14, 2026 15:23
@nkissebe
nkissebe merged commit 32334bc into hubzero:2.4-main Sep 16, 2026
1 of 2 checks passed
nkissebe pushed a commit that referenced this pull request Sep 16, 2026
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
nkissebe pushed a commit that referenced this pull request Sep 16, 2026
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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