Skip to content

Commit

Permalink
Merge pull request #382 from berkeley-cocosci/notification-commit
Browse files Browse the repository at this point in the history
Notification commit
  • Loading branch information
thomasmorgan authored Jul 15, 2016
2 parents d2dc652 + f878b04 commit 418a7bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 3 additions & 8 deletions wallace/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,14 +1202,12 @@ def worker_function(event_type, assignment_id, participant_id):
participant.end_time = datetime.now()
participant.status = "abandoned"
exp.assignment_abandoned(participant=participant)
session.commit()

elif event_type == 'AssignmentReturned':
if participant.status == "working":
participant.end_time = datetime.now()
participant.status = "returned"
exp.assignment_returned(participant=participant)
session.commit()

elif event_type == 'AssignmentSubmitted':
if participant.status == "working":
Expand Down Expand Up @@ -1248,30 +1246,27 @@ def worker_function(event_type, assignment_id, participant_id):

# If they fail the attention check, fail nodes and replace.
if not attended:
exp.log("Attention check failed.", key)
participant.status = "did_not_attend"
exp.attention_check_failed(participant=participant)
exp.recruiter().recruit_participants(n=1)
else:
# All good. Possibly recruit more participants.
exp.log("All checks passed.", key)
participant.status = "approved"

exp.submission_successful(participant=participant)
session.commit()

exp.recruit()

exp.log_summary()

elif event_type == "NotificationMissing":
if participant.status == "working":
participant.end_time = datetime.now()
participant.status = "missing_notification"
session.commit()

else:
exp.log("Error: unknown event_type {}".format(event_type), key)

session.commit()


def date_handler(obj):
"""Serialize dates."""
Expand Down
14 changes: 12 additions & 2 deletions wallace/heroku/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def check_db_for_missing_notifications():
p_time = (current_time - p.creation_time).total_seconds()

if p_time > (duration + 120):
print ("participant {} with status {} has been playing for too "
print ("Error: participant {} with status {} has been playing for too "
"long and no notification has arrived - "
"running emergency code".format(p.id, p.status))

Expand All @@ -87,7 +87,17 @@ def check_db_for_missing_notifications():
toaddr = config.get('HIT Configuration', 'contact_email_on_error')
whimsical = os.getenv("whimsical")

if status in ["Submitted", "Approved", "Rejected"]:
if status == "Approved":
# if its been approved, set the status accordingly
print "status set to approved"
p.status = "approved"
session.commit()
elif status == "Rejected":
print "status set to rejected"
# if its been rejected, set the status accordingly
p.status = "rejected"
session.commit()
elif status == "Submitted":
# if it has been submitted then resend a submitted notification
args = {
'Event.1.EventType': 'AssignmentSubmitted',
Expand Down

0 comments on commit 418a7bf

Please sign in to comment.