Skip to content

Commit

Permalink
feat: Add option for 'all-in-one consent' to File Uploader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-AP committed Mar 13, 2024
1 parent 8de1aa9 commit e0b78c7
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 38 deletions.
18 changes: 18 additions & 0 deletions ddm/migrations/0047_fileuploader_combined_consent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2024-03-13 15:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ddm', '0046_donationblueprint_expected_fields_regex_matching'),
]

operations = [
migrations.AddField(
model_name='fileuploader',
name='combined_consent',
field=models.BooleanField(default=False, help_text='If enabled, participants will be asked to consent to submit all uploaded data at once. Otherwise, participant will be asked to consent to the submission of the data separately for each blueprint.', verbose_name='All-in-one consent'),
),
]
11 changes: 11 additions & 0 deletions ddm/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def get_donation_info(self):
'n_success': donations.filter(status='success').count(),
'n_pending': donations.filter(status='pending').count(),
'n_failed': donations.filter(status='failed').count(),
'n_consent': donations.filter(status='success', consent=True).count(),
'n_no_consent': donations.filter(status='success', consent=False).count(),
'n_no_data_extracted': donations.filter(status='nothing extracted').count()
}
return donation_info
Expand Down Expand Up @@ -372,6 +374,14 @@ class UploadTypes(models.TextChoices):
verbose_name='Upload type',
)

combined_consent = models.BooleanField(
default=False,
verbose_name='All-in-one consent',
help_text='If enabled, participants will be asked to consent to submit '
'all uploaded data at once. Otherwise, participant will be asked to '
'consent to the submission of the data separately for each blueprint.'
)

def __str__(self):
return self.name

Expand All @@ -385,6 +395,7 @@ def get_configs(self, participant_data=None):
configs = {
'upload_type': self.upload_type,
'name': self.name,
'combined_consent': self.combined_consent,
'blueprints': [bp.get_config() for bp in blueprints],
'instructions': [{
'index': i.index,
Expand Down
2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/css/vue_uploader.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/js/vue_uploader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/js/vue_uploader.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ddm/templates/ddm/public/data_donation.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
data-action-url='{{ request.build_absolute_uri }}'
data-exception-url='{% if request.is_secure %}https://{% else %}http://{% endif %}{{ request.get_host }}{% url "ddm-exceptions-api" project_id %}'
data-language='{{ LANGUAGE_CODE|slice:"0:2"}}'
data-pooled='{% if request.project_is_pooled %}true{% else %}false{% endif %}' <!-- Hook for ddm-pooled -->
>
<uapp></uapp>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ddm/views/admin/data_donations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FileUploaderCreate(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, Crea
""" View to create a new file uploader. """
model = FileUploader
template_name = 'ddm/admin/data_donation/file_uploader/create.html'
fields = ['name', 'upload_type']
fields = ['name', 'upload_type', 'combined_consent']
success_message = 'File Uploader was created successfully.'

def form_valid(self, form):
Expand All @@ -65,7 +65,7 @@ class FileUploaderEdit(SuccessMessageMixin, DdmAuthMixin, BlueprintMixin, Update
""" View to edit the details of an existing file uploader. """
model = FileUploader
template_name = 'ddm/admin/data_donation/file_uploader/edit.html'
fields = ['name', 'upload_type', 'index']
fields = ['name', 'upload_type', 'combined_consent', 'index']
success_message = 'Blueprint Uploader "%(name)s" was successfully updated.'

def get_context_data(self, **kwargs):
Expand Down
20 changes: 13 additions & 7 deletions docs/modules/ROOT/pages/for_researchers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,26 @@ The data donation step can incorporate multiple File Uploaders.

===== Configure File Uploader

Name:: Name of the File Uploader. Will be publicly visible to participants in the header of the file uplaoder.
Name:: Name of the File Uploader. Will be publicly visible to participants in the header of the File Uplaoder.

Upload Type:: Either "single file" or "zip file".

Index:: The position of the file uploader on the data donation page.
Only relevant if multiple file uploaders are displayed – file uploaders with a
Only relevant if multiple File Uploaders are displayed – File Uploaders with a
lower index will be displayed closer to the top of the page.

All-in-one consent:: If enabled, participants will be asked to consent to submit
all uploaded data at once. Otherwise, participant will be asked to consent to
the submission of the data separately for each blueprint.

Associated Donation Blueprints:: The donation blueprints that apply to the
expected file(s) collected with the file uploader.
expected file(s) collected with the File Uploader.


===== Configure Instructions

Donation Instructions consist of one or multiple instruction pages.
Instruction pages are displayed as a slide show at the top of file uploader.
Instruction pages are displayed as a slide show at the top of File Uploader.
For each instruction page, the following can be configured:

Text:: The instruction text displayed to the participants.
Expand Down Expand Up @@ -470,9 +474,11 @@ The participant related data contains the following information:
"briefing_consent": "1" # or "0" if participant did not consent to take part in the study
},
"donation_info": {
"n_success": 1, # number of successful donations by this participant
"n_pending": 1, # number of pending (i.e., not attempted) donations by this participant
"n_failed": 0, # number of attempted but failed donations by this participant
"n_success": 1, # number of successfully uploaded blueprints by this participant (regardless of consent).
"n_pending": 1, # number of pending (i.e., not attempted) blueprint uploads.
"n_failed": 0, # number of blueprints where an upload was attempted but failed.
"n_consent": 1, # number of successful uploads to which donation consent was given.
"n_no_consent": 0, # number of successful uploads to which no donation consent was given.
"n_no_data_extracted": 0 # number of donations by this participant where all entries were filtered out
}
}
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/UploaderApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:blueprints="uploadConfig.blueprints"
:instructions="uploadConfig.instructions"
:exception-url="this.exceptionUrl"
:pooled="this.pooled"
:combined-consent="uploadConfig.combined_consent"
@changedData="updatePostData"
></FileUploader>

Expand Down Expand Up @@ -72,8 +72,7 @@ export default {
uploadConfig: String,
actionUrl: String,
exceptionUrl: String,
language: String,
pooled: Boolean
language: String
},
data() {
this.$i18n.locale = this.language;
Expand Down
Loading

0 comments on commit e0b78c7

Please sign in to comment.