Skip to content

Commit

Permalink
Refactor: Refactor URL matching and references to Experiment to use B…
Browse files Browse the repository at this point in the history
…lock (#1181)

* refactor: Update block_admin.js to use "block" instead of "experiment" in URL matching

* refactor: Refer to Block instead of Experiment
  • Loading branch information
drikusroor authored Jul 9, 2024
1 parent 09310e6 commit aaa29b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions backend/experiment/static/block_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
document.addEventListener("DOMContentLoaded", (event) => {

// Get experiment id from URL
match = window.location.href.match(/\/experiment\/experiment\/(.+)\/change/)
match = window.location.href.match(/\/experiment\/block\/(.+)\/change/)
experiment_id = match && match[1]

let buttonAddDefaultQuestions = document.createElement("input")
Expand All @@ -23,20 +23,20 @@ document.addEventListener("DOMContentLoaded", (event) => {
function toggleButton(e) {

// Check if we are on a Change Experiment (not Add Experiment) and if selection for Experiment rules has not changed
if ( experiment_id && (selectRules[selectRules.selectedIndex] === selectRules.querySelector("option[selected]")) ) {
if (experiment_id && (selectRules[selectRules.selectedIndex] === selectRules.querySelector("option[selected]"))) {
buttonAddDefaultQuestions.disabled = false
message.innerText = ""
} else {
buttonAddDefaultQuestions.disabled = true
message.innerText = "Save Experiment first"
message.innerText = "Save Block first"
}
}

async function addDefaultQuestions() {

const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;
let response = await fetch(`/experiment/add_default_question_series/${experiment_id}/`,
{method:"POST", mode: 'same-origin',headers: {'X-CSRFToken': csrftoken}})
{ method: "POST", mode: 'same-origin', headers: { 'X-CSRFToken': csrftoken } })

if (response.ok) {
location.reload()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<thead>
<tr>
<th>Session *</th>
<th>Experiment *</th>
<th>Block *</th>
<th>Participant *</th>
<th>Started</th>
<th>Finished</th>
Expand All @@ -17,7 +17,7 @@
</thead>

<tbody>
<!-- List and hide all sessions in this collection with a unique id per experiment -->
<!-- List and hide all sessions in this collection with a unique id per block -->
{% for session in sessions %}
<tr class="session-row hide experiment-{{ session.block.id }} participant-session-{{ session.participant.id }}">

Expand Down Expand Up @@ -85,7 +85,7 @@ <h2>Result : <a href="{% url 'admin:session_session_change' session.id %}" targe
<h3>
Session: <a href="{% url 'admin:session_session_change' session.id %}" target="_blank">{{ session.id }}</a><br>
Participant: <a href="{% url 'admin:participant_participant_change' session.participant.id %}" target="_blank">{{ session.participant.participant_id_url }}</a><br>
Experiment: <a href="{% url 'admin:experiment_block_change' session.block.id %}" target="_blank">{{ session.block.name }}</a>
Block: <a href="{% url 'admin:experiment_block_change' session.block.id %}" target="_blank">{{ session.block.name }}</a>
</h3>

<pre>
Expand Down

0 comments on commit aaa29b9

Please sign in to comment.