langcog / web-cdi

7 stars 5 forks source link

CDI CAT Split Background #332

Closed JMankewitz closed 3 years ago

JMankewitz commented 3 years ago

Hello!

Previously, used the split background option for the "Computer Adaptive Test - Split background" instrument. This option does not seem to be working anymore, even with the "english_split" background is used. Specifically, it doesn't move to a backpage when "show backpage" is selected, and only the first confirmation questions are asked in the front.

We'd like to still use the full background with confirmation questions for this study, so if this is an easy fix we'd really appreciate it!

HenryMehta commented 3 years ago

@JMankewitz Fixed and loaded to both dev and production. Please test in dev to confirm before using in production

JMankewitz commented 3 years ago

I get the following error in dev testing the CAT - Split Background Info administration with the show backpage toggle and show confirmation questions toggled on.

AttributeError at /form/cat/fill/b2f0fc3329d1479e40692231f9cf6d0d99693fb2979f2f96f905035ec545a77f/

'NoneType' object has no attribute 'path'

Environment:

Request Method: GET
Request URL: http://webcdi-dev.stanford.edu/form/cat/fill/b2f0fc3329d1479e40692231f9cf6d0d99693fb2979f2f96f905035ec545a77f/

Django Version: 2.2.13
Python Version: 3.6.12
Installed Applications:
('researcher_UI',
 'modeltranslation',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cdi_forms',
 'crispy_forms',
 'django_tables2',
 'bootstrap4',
 'bootstrap3',
 'form_utils',
 'registration',
 'supplementtut',
 'django.contrib.sites',
 'axes',
 'health_check',
 'health_check.db',
 'health_check.cache',
 'health_check.storage',
 'localflavor',
 'django_countries',
 'webcdi',
 'ckeditor',
 'ckeditor_uploader')
Installed Middleware:
['django.middleware.common.BrokenLinkEmailsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'axes.middleware.AxesMiddleware',
 'webcdi.middleware.LoginRequiredMiddleware']

Traceback:

File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)

File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  97.         return handler(request, *args, **kwargs)

File "/opt/python/current/app/webcdi/cdi_forms/cat_forms/views.py" in get
  158.                 filename = os.path.realpath(PROJECT_ROOT + self.object.study.demographic.path)

Exception Type: AttributeError at /form/cat/fill/b2f0fc3329d1479e40692231f9cf6d0d99693fb2979f2f96f905035ec545a77f/
Exception Value: 'NoneType' object has no attribute 'path'

link: https://webcdi-dev.stanford.edu/form/fill/b2f0fc3329d1479e40692231f9cf6d0d99693fb2979f2f96f905035ec545a77f/

JMankewitz commented 3 years ago

Computer Adaptive Test (English CAT) looks fine with the English_Split demographics selected.

HenryMehta commented 3 years ago

@JMankewitz @vmarchman Sorry, access to CAT - Split Background should have been removed from your access list. This is an old style demographic information form which has been replaced. It needs to remain in the database tables but user access should not be there.. Similarly, instruments with titles like WS2, WG2 (ie the previous split forms) should all be removed.

I believe I removed everyone's access in production (although I've just gone through all records again and someone has added some back in) when I put them live but failed to do development.

It is now a couple of hours later and I've been doing some work on removing the Intruments which are no longer valid in order to avoid this issue in the future. My concerns are

  1. ensuring we do not lose respondent data
  2. ensuring we maintain database integrity (the way the original code was written, sometime integers are used instead of database relationships, which is a concern)

I took a copy of the production database and connected up to the copy. I took a count of all administration responses (2,093,213) - this is individual answers to individual questions. I deleted all of these 'invalid' Instruments, which automatically means associated data is also deleted. In theory there should be no participant data deleted because that has already been associated with the valid Instruments. I had the same number of administration responses. So that indicates concern 1 is ok.

I then downloaded the data for prolific_june_5. This data all looked correct which indicates concern 2 is ok.

I think we should update production to remove the invalid Instruments. I don't know if you would like to do some testing of this (I always advise you do testing) and if you do I would suggest I take a copy of production into development, carryout the changes I made above and then you compare production data downloads to dev data downloads. They should be the same