Commit 22437ea1 authored by Timo Heikkilä's avatar Timo Heikkilä
Browse files

added private experiment functionality

parent 5316f67e
......@@ -358,6 +358,14 @@ def begin_with_id():
exp_id = request.args.get('exp_id', None)
form = StartWithIdForm()
experiment_info = experiment.query.filter_by(idexperiment=exp_id).first()
instruction_paragraphs = str(experiment_info.short_instruction)
instruction_paragraphs = instruction_paragraphs.split('<br>')
consent_paragraphs = str(experiment_info.consent_text)
consent_paragraphs = consent_paragraphs.split('<br>')
if form.validate_on_submit():
......@@ -384,7 +392,7 @@ def begin_with_id():
#save the participant ID in session list for now, this is deleted after the session has been started in participant_session-view
session['begin_with_id'] = form.participant_id.data
return render_template('consent.html', exp_id=exp_id, experiment_info=experiment_info)
return render_template('consent.html', exp_id=exp_id, experiment_info=experiment_info, instruction_paragraphs=instruction_paragraphs, consent_paragraphs=consent_paragraphs)
return render_template('begin_with_id.html', exp_id=exp_id, form=form)
......@@ -1133,7 +1141,7 @@ def add_bg_question():
exp_id = request.args.get('exp_id', None)
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1188,7 +1196,7 @@ def add_questions():
exp_id = request.args.get('exp_id', None)
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1246,7 +1254,7 @@ def remove_bg_question():
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1284,7 +1292,7 @@ def remove_question():
exp_id = request.args.get('exp_id', None)
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1309,7 +1317,7 @@ def remove_experiment():
exp_id = request.args.get('exp_id', None)
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1464,7 +1472,7 @@ def remove_page():
exp_id = request.args.get('exp_id', None)
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......@@ -1551,6 +1559,24 @@ def hide_experiment():
return redirect(url_for('view_experiment', exp_id=exp_id))
@app.route('/private_experiment')
@login_required
def private_experiment():
exp_id = request.args.get('exp_id', None)
private_experiment = experiment.query.filter_by(idexperiment = exp_id).first()
private_experiment.status = 'Private'
flash("Changed status to Private")
db.session.commit()
return redirect(url_for('view_experiment', exp_id=exp_id))
@app.route('/enable_randomization')
@login_required
def enable_randomization():
......@@ -1759,7 +1785,7 @@ def add_stimuli():
exp_status = experiment.query.filter_by(idexperiment=exp_id).first()
if exp_status.status == 'Public':
if exp_status.status != 'Hidden':
flash("Experiment is public. Cannot modify structure.")
......
......@@ -112,6 +112,116 @@
<br>
<br>
{% endif %}
{% if (exp.status == 'Private') and (current_user.is_authenticated) and session['language'] == exp.language %}
<br>
<h3>Private experiment:</h3>
<ul class="list-group mb-4">
<li class="list-group-item list-group-item-info"><span class="font-weight-bold">Name:</span> {{ exp.name }} </li>
<li class="list-group-item"><span class="font-weight-bold">Instruction:</span>
{% autoescape false %}
{{ exp.short_instruction }}</li>
{% endautoescape %}
{% if current_user.is_authenticated %}
<li class="list-group-item"><span class="font-weight-bold">ID number:</span> {{ exp.idexperiment }} </li>
<li class="list-group-item"><span class="font-weight-bold">Language:</span> {{ exp.language }}</li>
<li class="list-group-item"><span class="font-weight-bold">Status:</span> {{ exp.status }}</li>
{% endif %}
{% if exp.use_forced_id == 'On'%}
<li class="list-group-item"><span class="font-weight-bold">Participation ID is required for this task.</li>
{% endif %}
<li class="list-group-item">
<a class="btn btn-outline-primary" href="{{ url_for('consent', exp_id=exp.idexperiment) }}" role="button">Begin task</a>
<a class="btn btn-outline-primary" href="{{ url_for('continue_task', exp_id=exp.idexperiment) }}" role="button">Continue task</a>
{% if current_user.is_authenticated %}
<a class="btn btn-outline-info" href="{{ url_for('admin_dryrun', exp_id=exp.idexperiment) }}" role="button">AdminRun</a>
<a class="btn btn-outline-info" href="{{ url_for('experiment_statistics', exp_id=exp.idexperiment) }}" role="button">Statistics</a>
<a class="btn btn-outline-info" href="{{ url_for('view_experiment', exp_id=exp.idexperiment) }}" role="button">View / Edit</a>
{% endif %}
</li>
</ul>
{% endif %}
{% if (exp.status == 'Private') and (current_user.is_authenticated) and session['language'] == "All" %}
<br>
<h3>Private experiment:</h3>
<ul class="list-group mb-4">
<li class="list-group-item list-group-item-info"><span class="font-weight-bold">Name:</span> {{ exp.name }} </li>
<li class="list-group-item"><span class="font-weight-bold">Instruction:</span>
{% autoescape false %}
{{ exp.short_instruction }}</li>
{% endautoescape %}
{% if current_user.is_authenticated %}
<li class="list-group-item"><span class="font-weight-bold">ID number:</span> {{ exp.idexperiment }} </li>
<li class="list-group-item"><span class="font-weight-bold">Language:</span> {{ exp.language }}</li>
<li class="list-group-item"><span class="font-weight-bold">Status:</span> {{ exp.status }}</li>
{% endif %}
{% if exp.use_forced_id == 'On'%}
<li class="list-group-item"><span class="font-weight-bold">Participation ID is required for this task.</li>
{% endif %}
<li class="list-group-item">
<a class="btn btn-outline-primary" href="{{ url_for('consent', exp_id=exp.idexperiment) }}" role="button">Begin task</a>
<a class="btn btn-outline-primary" href="{{ url_for('continue_task', exp_id=exp.idexperiment) }}" role="button">Continue task</a>
{% if current_user.is_authenticated %}
<a class="btn btn-outline-info" href="{{ url_for('admin_dryrun', exp_id=exp.idexperiment) }}" role="button">AdminRun</a>
<a class="btn btn-outline-info" href="{{ url_for('experiment_statistics', exp_id=exp.idexperiment) }}" role="button">Statistics</a>
<a class="btn btn-outline-info" href="{{ url_for('view_experiment', exp_id=exp.idexperiment) }}" role="button">View / Edit</a>
{% endif %}
</li>
</ul>
{% endif %}
{% if (exp.status == 'Hidden') and (current_user.is_authenticated) and session['language'] == exp.language %}
......
......@@ -45,10 +45,12 @@
<td>{{ exp.status }}</td>
<td>
{% if exp.status == 'Hidden' %}
<a class="btn btn-primary btn-block btn-sm btn-info" href="{{ url_for('publish_experiment', exp_id=exp.idexperiment) }}" role="button">Publish</a></td>
<a class="btn btn-primary btn-block btn-sm btn-info" href="{{ url_for('publish_experiment', exp_id=exp.idexperiment) }}" role="button">Publish (visible)</a>
<a class="btn btn-primary btn-block btn-sm btn-info" href="{{ url_for('private_experiment', exp_id=exp.idexperiment) }}" role="button">Publish (private)</a>
</td>
{% endif %}
{% if exp.status == 'Public' %}
<a class="btn btn-primary btn-block btn-sm btn-info" href="{{ url_for('hide_experiment', exp_id=exp.idexperiment) }}" role="button">Hide experiment</a></td>
{% if exp.status != 'Hidden' %}
<a class="btn btn-primary btn-block btn-sm btn-info" href="{{ url_for('hide_experiment', exp_id=exp.idexperiment) }}" role="button">Unpublish</a></td>
{% endif %}
</tr>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment