Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
stub new experiment features for tasking during user feedback
  • Loading branch information
dtraviglia committed Jun 3, 2015
1 parent da741e0 commit 31c6de1563252c2228898de1a1faff2dac8d3ae0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 38 deletions.
@@ -30,7 +30,13 @@ def tearDownClass(cls):
def setUp(self):
# REALLY REALLY should do this soon...
# TODO find a way to call populate_db
experiment = Experiment(name='Test-exp', task_count=2, task_length=30, has_achievements=True, has_intake=True, has_followup=True, auto_tasking=True)
experiment = Experiment(name='Test-exp',
task_count=2,
task_length=30,
has_achievements=True,
has_intake=True,
has_followup=True,
auto_tasking=True)
experiment.save()

test_tasks = [
@@ -6,7 +6,7 @@

{% block container %}
<section>
<h1 align="center"><b>Login to XDATA's Online Experiment</b></h1>
<h1 align="center"><b>Login to XDATA's {{experiment_title}} Experiment</b></h1>
<form class="form-signin" id="login_form" method="post" action="{% url 'op_tasks:login' %}">
{% csrf_token %}
<h4 class="form-signin-heading">Please sign in</h4>
@@ -9,7 +9,8 @@
url(r'^task_list/$', views.task_list, name='task_list'),
url(r'^product/(?P<task_pk>[0-9]+)$', views.product, name='product'),
url(r'^register$', views.register, name='register'),
url(r'^login$', views.login_participant, name='login'),
# url(r'^login/(?P<title>\w+)$', views.login_participant, name='login'),
url(r'^login/$', views.login_participant, name='login'),
url(r'^logout/$', views.logout_participant, name='logout'),
url(r'^intro/$', views.intro, name='intro'),
url(r'^intro/(?P<process>\w+)$', views.intro, name='intro'),
@@ -58,38 +58,41 @@ def product(request, task_pk):

tasklist_length = len(userprofile.tasklistitem_set.all())

# if it's not the last task, make the next task active
if current_tasklistitem.index < (tasklist_length - 1):
next_tasklistitem = userprofile.tasklistitem_set.get(index=current_tasklistitem.index+1)

# if you got here because you just completed a task,
# then set it complete and make the exit task active
if current_tasklistitem.task_complete == False:
current_tasklistitem.task_complete = True
current_tasklistitem.task_active = False
current_tasklistitem.exit_active = True
current_tasklistitem.date_complete = timezone.now()
sessionID = '%s::%s' % (userprofile.user_hash, current_tasklistitem.pk)
try:
current_tasklistitem.activity_count = count_activities(sessionID)
except:
current_tasklistitem.activity_count = 0
userprofile.progress += 20
print 'task complete', timezone.now()

# you likely got here because you just completed an exit task
# so mark it complete and move
else:
current_tasklistitem.exit_active = False
current_tasklistitem.exit_complete = True
print 'survey complete', current_tasklistitem.index
userprofile.progress += 15
if current_tasklistitem.index < tasklist_length - 1:
next_tasklistitem.task_active = True
next_tasklistitem.save()
if userprofile.experiment.sequential_tasks == True:

# if it's not the last task, make the next task active
if current_tasklistitem.index < (tasklist_length - 1):
next_tasklistitem = userprofile.tasklistitem_set.get(index=current_tasklistitem.index+1)

# if you got here because you just completed a task,
# then set it complete and make the exit task active
if current_tasklistitem.task_complete == False:
current_tasklistitem.task_complete = True
current_tasklistitem.task_active = False
current_tasklistitem.exit_active = True
current_tasklistitem.date_complete = timezone.now()
sessionID = '%s::%s' % (userprofile.user_hash, current_tasklistitem.pk)
try:
current_tasklistitem.activity_count = count_activities(sessionID)
except:
current_tasklistitem.activity_count = 0
userprofile.progress += 20
print 'task complete', timezone.now()

# you likely got here because you just completed an exit task
# so mark it complete and move
else:
current_tasklistitem.save()

current_tasklistitem.exit_active = False
current_tasklistitem.exit_complete = True
print 'survey complete', current_tasklistitem.index
userprofile.progress += 15
if current_tasklistitem.index < tasklist_length - 1:
next_tasklistitem.task_active = True
next_tasklistitem.save()
else:
current_tasklistitem.save()


userprofile.save()
current_tasklistitem.save()
return HttpResponseRedirect("/tasking/task_list")
@@ -221,7 +224,10 @@ def login_participant(request):
else:
# No context variables to pass to the template system, hence the
# blank dictionary object...
return render_to_response('registration/login.html', {}, context)
# experiment_title = title
return render(request, 'registration/login.html')
# return render(request, 'registration/login.html', {'experiment_title': experiment_title})


# return login_view(request, authentication_form=MyAuthForm)

@@ -1,5 +1,5 @@
from django.conf.urls import patterns, include, url
from xdata.views import *
from xdata import views
from django.contrib import admin
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
@@ -10,8 +10,9 @@
url(r'^tasking/', include('op_tasks.urls', namespace="op_tasks")),
url(r'^experiment/', include('exp_portal.urls', namespace="exp_portal")),
url(r'^developer/', include('developer.urls', namespace="developer")),
url(r'^user_feedback/', views.user_feedback_home, name='user_feedback_home'),
url(r'^admin/', include(admin.site.urls)),
(r'^$', index),
url(r'^$', views.index, name='index'),
# (r'^contact/$', contact),

)
@@ -8,4 +8,7 @@
from forms import *

def index(request):
return render_to_response('index.html')
return render(request, 'index.html')

def user_feedback_home(request):
return render(request, 'user_feedback_index.html')

0 comments on commit 31c6de1

Please sign in to comment.