Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #122 (prolific branch) #123

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v1.2.5 (2023-04-09)

Authors: Sam Zorowitz ([#123](https://github.com/nivlab/nivturk/pull/123))

- Remove deprecated `request.user_agent` calls.
- Return entire `request.user_agent` string.
- Expand list of screened devices (e.g., mobile, tablets, game consoles).

## v1.2.4 (2023-02-28)

Authors: Yongjing Ren, Sam Zorowitz ([#120](https://github.com/nivlab/nivturk/pull/120))
Expand Down
12 changes: 5 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from app import consent, alert, experiment, complete, error
from .io import write_metadata
from .utils import gen_code
__version__ = '1.2.4'
__version__ = '1.2.5'

## Define root directory.
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -68,9 +68,7 @@ def index():
hitId = request.args.get('STUDY_ID'), # Prolific metadata
subId = gen_code(24), # NivTurk metadata
address = request.remote_addr, # NivTurk metadata
browser = request.user_agent.browser, # User metadata
platform = request.user_agent.platform, # User metadata
version = request.user_agent.version, # User metadata
user_agent = request.user_agent.string, # User metadata
code_success = cfg['PROLIFIC'].get('CODE_SUCCESS', gen_code(8).upper()),
code_reject = cfg['PROLIFIC'].get('CODE_REJECT', gen_code(8).upper()),
)
Expand All @@ -81,8 +79,8 @@ def index():
## Redirect participant to error (missing workerId).
return redirect(url_for('error.error', errornum=1000))

## Case 2: mobile / tablet user.
elif info['platform'] in ['android','iphone','ipad','wii']:
## Case 2: mobile / tablet / game console user.
elif any([device in info['user_agent'].lower() for device in ['mobile','android','iphone','ipad','kindle','nintendo','playstation','xbox']]):

## Redirect participant to error (platform error).
return redirect(url_for('error.error', errornum=1001))
Expand Down Expand Up @@ -150,7 +148,7 @@ def index():

## Update metadata.
for k, v in info.items(): session[k] = v
write_metadata(session, ['workerId','hitId','assignmentId','subId','address','browser','platform','version'], 'w')
write_metadata(session, ['workerId','hitId','assignmentId','subId','address','user_agent'], 'w')

## Redirect participant to consent form.
return redirect(url_for('consent.consent'))