Skip to content

File type question#681

Merged
mchurchward merged 11 commits into
PoetOS:MOODLE_500_STABLEfrom
srobotta:file_type_question
Jan 16, 2026
Merged

File type question#681
mchurchward merged 11 commits into
PoetOS:MOODLE_500_STABLEfrom
srobotta:file_type_question

Conversation

@srobotta
Copy link
Copy Markdown
Contributor

Hi Mike,

this is the next attempt to open a pull request for the file type response. This will replace PR #599 (which I can try to close after creating this one).
The original work was done by Laurent David. He introduced this question/response type and also created PR #471. Luca Bösch added some tests. I completed the work.

There is code for backup and restore (as requested from you the last time).
I rebased it on the MOODLE_500_STABLE branch.

This PR also contains two changes unrelated to that feature but that are fixing two issues we had in the past and that are missing in the current MOODLE_500_STABLE branch.

Best regards, Stephan

@mchurchward
Copy link
Copy Markdown
Contributor

Thanks. I will review. In the meantime, can you fix the CI errors please?

lucaboesch added a commit to lucaboesch/moodle-mod_questionnaire that referenced this pull request Nov 17, 2025
lucaboesch added a commit to lucaboesch/moodle-mod_questionnaire that referenced this pull request Nov 17, 2025
lucaboesch added a commit to lucaboesch/moodle-mod_questionnaire that referenced this pull request Nov 17, 2025
@srobotta srobotta force-pushed the file_type_question branch 2 times, most recently from fbaf4cc to 1b8da9e Compare November 17, 2025 20:06
@srobotta
Copy link
Copy Markdown
Contributor Author

CI errors should be fixed by now.

@mchurchward
Copy link
Copy Markdown
Contributor

Can you do a rebase with the current MOODLE_500_STABLE branch please? There are commits here that shouldn't be.

@srobotta
Copy link
Copy Markdown
Contributor Author

It is already rebased on your MOODLE_500_STABLE branch. When I tried a fetch and rebase now, it claimed to be up to date already.

@mchurchward
Copy link
Copy Markdown
Contributor

Hmmm... Okay. Looks like this commit was missing from the 500 branch. I'll keep it.
But this commit doesn't seem to need to be there. Why is it there?

I will leave some comments in the code review as well.

Copy link
Copy Markdown
Contributor

@mchurchward mchurchward left a comment

Choose a reason for hiding this comment

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

Well I appreciate the changes made that are not part of this actual issue, it is really necessary to limit the changes to the specific issue. If there are CI issues that are not caused by your code, they should be fixed separately. Can you simplify this PR? Possibly make a new one limited to the only the code needed for this question type?

Comment thread backup/moodle2/restore_questionnaire_stepslib.php
Comment thread classes/feedback_section_form.php Outdated
Comment thread classes/output/renderer.php
Comment thread classes/question/drop.php Outdated
Comment thread db/upgrade.php Outdated
Comment thread report.php
Comment thread report.php Outdated
Comment thread tests/behat/questionnaire_activity_completion.feature
Comment thread tests/custom_completion_test.php
Comment thread view.php
Copy link
Copy Markdown
Contributor

@mchurchward mchurchward left a comment

Choose a reason for hiding this comment

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

Testing functionality.
I added a file type question. I set the questionnaire so that I could save and resume. I added a file to the file question and saved my response. When I resumed, there was no file attached. I think that needs to be saved too.

@srobotta
Copy link
Copy Markdown
Contributor Author

Thanks for looking at it, I will see that I implement the changes within the next days. I inform you as soon as I am done.

lucaboesch and others added 8 commits November 27, 2025 13:37
Fix upload when several file upload questions are used.
- Adjust siganture of methods to their parent
- Limit the files to upload to one for each question
- Use questionaire id for file draft area instead of question id in
  the questionaire.

Fix handling of file uploads
- allow upload of one file only.
- new submit does not load previously existing files.

Change refence of file.itemid to questionnaire_response_file.id

update existing files.itemid to questionnaire_response_file.id
Improvements to satisfy code checker.

Make the file upload work with required setting, fix delete of records

Add file question type
Fix cleanup of old file responses.
Add backup/restore handling for file response type.
@srobotta srobotta force-pushed the file_type_question branch 5 times, most recently from 202e766 to c42bf28 Compare November 28, 2025 18:26
@srobotta
Copy link
Copy Markdown
Contributor Author

Hi Mike,

I just finished working on it and it works from my point of few now. Could you please have another check? Also, now in this diff I can explain all the changes. There should be no left overs from other stuff.

Thank you, Stephan

@mchurchward
Copy link
Copy Markdown
Contributor

Thanks for all your work on this. I will strive to review this soon.

Copy link
Copy Markdown
Contributor

@mchurchward mchurchward left a comment

Choose a reason for hiding this comment

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

One last change. The current MOODLE_500_STABLE uses version 2025041400.01. Can you change the version file in the PR to use 2025041400.02, and then update your upgrade.php file as well? Then I can merge.

Copy link
Copy Markdown
Contributor

@mchurchward mchurchward left a comment

Choose a reason for hiding this comment

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

I just tested the backup and restore with file type questions and I don't think its working yet. The restore didn't seem to restore the uploaded files into the results.
Test steps:

  1. Install questionnaire with file question type.
  2. Add a questionnaire with a couple of questions including file type.
  3. Respond from a couple of users, uploading different files.
  4. Backup the course with just the questionnaire and all responses.
  5. Download the backup file and keep.
  6. Uninstall questionnaire - this hopefully ensures that the uploaded files are removed.
  7. Reinstall questionnaire.
  8. Restore the saved questionnaire backup into the same course as before.
  9. Look a the restored responses. The file questions should have files. In my test, they were missing.

@srobotta
Copy link
Copy Markdown
Contributor Author

srobotta commented Jan 12, 2026

Thanks for the comment. Indeed, I see that in a fresh instance the images are not imported, or at least not visible in the responses. I'll fix that.

@srobotta
Copy link
Copy Markdown
Contributor Author

Hi Mike, the restore works now. I also updated the version as requested.

@mchurchward mchurchward merged commit 5f1d0cf into PoetOS:MOODLE_500_STABLE Jan 16, 2026
3 checks passed
@mchurchward
Copy link
Copy Markdown
Contributor

Thanks for the fixes and all of the work you have put into this. It will be a great addition.

mchurchward pushed a commit that referenced this pull request Jan 16, 2026
* Circumvent number on string error, resolves #538. (#563)

* Add file question type

Fix upload when several file upload questions are used.
- Adjust siganture of methods to their parent
- Limit the files to upload to one for each question
- Use questionaire id for file draft area instead of question id in
  the questionaire.

Fix handling of file uploads
- allow upload of one file only.
- new submit does not load previously existing files.

Change refence of file.itemid to questionnaire_response_file.id

update existing files.itemid to questionnaire_response_file.id

Improvements to satisfy code checker.

Make the file upload work with required setting, fix delete of records

* Make sid public, because its already used via #[\AllowDynamicProperties]
Fix cleanup of old file responses.
Add backup/restore handling for file response type.

* Fix restore of files in backup.
---------

Co-authored-by: Luca Bösch <luca.boesch@bfh.ch>
Co-authored-by: Laurent David <lmedavid@gmail.com>
@djarran
Copy link
Copy Markdown

djarran commented Jan 29, 2026

Hi @mchurchward, it's great to have this feature merged. Would there be any issue if we backport this to the MOODLE_404_STABLE branch? Thanks

@mchurchward
Copy link
Copy Markdown
Contributor

You can do that for yours, sure.

djarran pushed a commit to catalyst/moodle-mod_questionnaire that referenced this pull request Feb 2, 2026
* Circumvent number on string error, resolves PoetOS#538. (PoetOS#563)

* Add file question type

Fix upload when several file upload questions are used.
- Adjust siganture of methods to their parent
- Limit the files to upload to one for each question
- Use questionaire id for file draft area instead of question id in
  the questionaire.

Fix handling of file uploads
- allow upload of one file only.
- new submit does not load previously existing files.

Change refence of file.itemid to questionnaire_response_file.id

update existing files.itemid to questionnaire_response_file.id

Improvements to satisfy code checker.

Make the file upload work with required setting, fix delete of records

* Make sid public, because its already used via #[\AllowDynamicProperties]
Fix cleanup of old file responses.
Add backup/restore handling for file response type.

* Fix restore of files in backup.
---------

Co-authored-by: Luca Bösch <luca.boesch@bfh.ch>
Co-authored-by: Laurent David <lmedavid@gmail.com>
djarran pushed a commit to catalyst/moodle-mod_questionnaire that referenced this pull request Feb 2, 2026
* Circumvent number on string error, resolves PoetOS#538. (PoetOS#563)

* Add file question type

Fix upload when several file upload questions are used.
- Adjust siganture of methods to their parent
- Limit the files to upload to one for each question
- Use questionaire id for file draft area instead of question id in
  the questionaire.

Fix handling of file uploads
- allow upload of one file only.
- new submit does not load previously existing files.

Change refence of file.itemid to questionnaire_response_file.id

update existing files.itemid to questionnaire_response_file.id

Improvements to satisfy code checker.

Make the file upload work with required setting, fix delete of records

* Make sid public, because its already used via #[\AllowDynamicProperties]
Fix cleanup of old file responses.
Add backup/restore handling for file response type.

* Fix restore of files in backup.
---------

Co-authored-by: Luca Bösch <luca.boesch@bfh.ch>
Co-authored-by: Laurent David <lmedavid@gmail.com>
golenkovm added a commit to catalyst/moodle-mod_questionnaire that referenced this pull request Feb 9, 2026
@voegii
Copy link
Copy Markdown

voegii commented Feb 11, 2026

Hi, thank you for this.

After an update, a database error appears on the questionnaire preview page. The table "questionnaire_response_file" is missing.

When updating from a version greater than 2023101500 the table "questionnaire_response_file" will not be created. See https://github.com/PoetOS/moodle-mod_questionnaire/blob/MOODLE_500_STABLE/db/upgrade.php#L1032

@mchurchward
Copy link
Copy Markdown
Contributor

Hi, thank you for this.

After an update, a database error appears on the questionnaire preview page. The table "questionnaire_response_file" is missing.

When updating from a version greater than 2023101500 the table "questionnaire_response_file" will not be created. See https://github.com/PoetOS/moodle-mod_questionnaire/blob/MOODLE_500_STABLE/db/upgrade.php#L1032

Yep. Looks like the version merge didn't get done correctly. I have created issue 707 to deal with this.

mchurchward pushed a commit that referenced this pull request Feb 19, 2026
* Circumvent number on string error, resolves #538. (#563)

* Add file question type

Fix upload when several file upload questions are used.
- Adjust siganture of methods to their parent
- Limit the files to upload to one for each question
- Use questionaire id for file draft area instead of question id in
  the questionaire.

Fix handling of file uploads
- allow upload of one file only.
- new submit does not load previously existing files.

Change refence of file.itemid to questionnaire_response_file.id

update existing files.itemid to questionnaire_response_file.id

Improvements to satisfy code checker.

Make the file upload work with required setting, fix delete of records

* Make sid public, because its already used via #[\AllowDynamicProperties]
Fix cleanup of old file responses.
Add backup/restore handling for file response type.

* Fix restore of files in backup.
---------

Co-authored-by: Luca Bösch <luca.boesch@bfh.ch>
Co-authored-by: Laurent David <lmedavid@gmail.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.

6 participants