diff --git a/Functions/Add Social Media Link .md b/Functions/Add Social Media Link .md new file mode 100644 index 0000000..b42e6c3 --- /dev/null +++ b/Functions/Add Social Media Link .md @@ -0,0 +1,21 @@ +// This code allows you to add a hyperlink to an image in a Qualtrics survey. +// My primary use case has been to create sharing buttons for social media platforms at the end of the survey. + +// ##### IMP #### +// You'll have to use a URL shortner, if Qualtrics detects a social media site, it won't allow the image to load. +// I've gotten it to work for ONLY Graphic Questions. Though they can be on the same page. If you find a way for other question types, please let me know. +// I've also not been able to get the mouse pointed to change. Qualtrics' system settings keep overriding any CSS I add. + +// BOTH attributes need to added +// "href" refers to the URL where you want the participants to go +// "target : _blank" opens the link a new window. If you don't add this, the link opens in the same window and Qualtrics doesn't allow social media sites to load. + +Qualtrics.SurveyEngine.addOnReady(function () { // Didn't work on Qualtrics.SurveyEngine.addOnload + let QuestionId = "#" + this.questionId; // Get the Question ID + jQuery(QuestionId).wrap( + jQuery("").attr({ + href: "your-url-goes-here", + target: "_blank", + }) + ); +}); diff --git a/Functions/Change Question Text.md b/Functions/Change Question Text.md new file mode 100644 index 0000000..b3bd2cf --- /dev/null +++ b/Functions/Change Question Text.md @@ -0,0 +1,26 @@ +// This script allows you to change the Question Text based on the choice made. +// There were three choices in the qurestion, and I wanted to change the text of the question, based on what they clicked. + +Qualtrics.SurveyEngine.addOnload(function() +{ + + this.questionclick = function(event,element){ + //for a single answer multiple choice question, the element type will be radio + if (element.type == 'radio') + { + var choiceNum = element.id.split('~')[2]; + if (choiceNum == 1) { + jQuery("#"+this.questionId+" .QuestionText").html("Please continue and click next when you are done."); // Changes the question text + + } else if (choiceNum == 2) { + jQuery("#"+this.questionId+" .QuestionText").html("Please click next to exit or select the other choice if you would like to"); + + } else if (choiceNum == 3) { + jQuery("#"+this.questionId+" .QuestionText").html("Looking for alternate methods...."); + }; + }; +} + + + +}); \ No newline at end of file diff --git a/Functions/Character Limit Reminder.md b/Functions/Character Limit Reminder.md new file mode 100644 index 0000000..a5b6bbd --- /dev/null +++ b/Functions/Character Limit Reminder.md @@ -0,0 +1,31 @@ +Qualtrics.SurveyEngine.addOnload(function() +{ + //Create a placeholder to display the reminder message + char_rem = document.createElement("p"); + char_rem.setAttribute("id", "char_reminder"); + char_rem.setAttribute("style", "color:LightGray;"); + this.getChoiceContainer().parentNode.appendChild(char_rem); + +}); + +Qualtrics.SurveyEngine.addOnReady(function() +{ + const qid = this.questionId; + document.querySelector("#QR\\~" + qid).oninput = function () {limited();}; + + function limited(){ + curr_len = document.querySelector("#QR\\~" + qid).value.length; + + //Set the max_len as an embedded data field equal to maximum length in validation options + max_len = "${e://Field/max_len}"; + //Nothing will be displayed if the characters are less than 10 + //If you want to always have the reminder, then delete the statement below and remove the if condition + reminder = ""; + if(curr_len>10){ + rem_len = max_len - curr_len; + reminder = rem_len + "/20 characters remaining"; + } + document.querySelector("#char_reminder").innerText = reminder; + } + +}); \ No newline at end of file diff --git a/Functions/Check sum dynamically via JS.md b/Functions/Check sum dynamically via JS.md new file mode 100644 index 0000000..a4bf4c5 --- /dev/null +++ b/Functions/Check sum dynamically via JS.md @@ -0,0 +1,62 @@ +Qualtrics.SurveyEngine.addOnload(function () { + //Diables the next button at the start + // You can delete this if you are fine with the sum as being zero + this.disableNextButton(); +}); + +Qualtrics.SurveyEngine.addOnReady(function () { + //Get the Question Id + const qid = this.questionId; + // Get the number of choices + n_choices = Qualtrics.SurveyEngine.registry[qid].getChoices(); + + const base_msg = jQuery("#"+qid+" .QuestionText").html(); + + // Detect a change in any of the choices + n_choices.forEach((item) => { + console.log("input detected"); + document.querySelector("#QR\\~" + qid + "\\~" + item).oninput = function () {chk_sum();}; + }); + + that = this; + function chk_sum() { + var max_sum = parseInt("${e://Field/max_sum}"); + var current_sum = 0; + + padding_pre = '
'; + padding_post = ''; + err_msg = "The total should be more than zero and less than " + max_sum + " to proceed"; + + //Iterate over each of choices + n_choices.forEach((item) => { + curr_val = parseInt(document.querySelector("#QR\\~" + qid + "\\~" + item).value); + // Check for empty blocks + if (isNaN(curr_val)) { + if (document.querySelector("#QR\\~" + qid + "\\~" + item).value == "") { + curr_val = 0; + } else { + + err_msg = "Please enter only valid integer numbers."; + } + } + //Check for invalid characters + if (document.querySelector("#QR\\~" + qid + "\\~" + item).value.search(/\D/) != -1){ + err_msg = "Please enter only valid integer numbers."; + curr_val = max_sum + 1; + + } + current_sum += curr_val; + }); + err_msg = base_msg + padding_pre + err_msg + padding_post; + + //Checks for zero and the value being more than zero and less than the max_sum + // If you are fine with zero then delete "current_sum >0 &&" + if (current_sum > 0 && current_sum <= max_sum) { + that.enableNextButton(); + jQuery("#"+qid+" .QuestionText").html(base_msg); + } else { + that.disableNextButton(); + jQuery("#"+qid+" .QuestionText").html(err_msg); + } + } +}); \ No newline at end of file diff --git a/Functions/Clear Text Entry Box.md b/Functions/Clear Text Entry Box.md new file mode 100644 index 0000000..282a4ff --- /dev/null +++ b/Functions/Clear Text Entry Box.md @@ -0,0 +1,17 @@ +Qualtrics.SurveyEngine.addOnReady(function(){ + + const qid = this.questionId; + n_choices = Qualtrics.SurveyEngine.registry[qid].getChoices().length; + // Set this according to where you are placing your text entry box + //This refers to the last choice, -1 to the second last choice etc.... + text_choice = n_choices; + + this.questionclick = function(event,element){ + var selected_choice = element.id.split('~')[2]; + if(selected_choice !=text_choice) + { + document.querySelector("#QR\\~" + qid + "\\~" + text_choice + "\\~TEXT").value = ""; + } + } + +}); \ No newline at end of file diff --git a/Functions/Complex Display Logic.md b/Functions/Complex Display Logic.md new file mode 100644 index 0000000..c1510e4 --- /dev/null +++ b/Functions/Complex Display Logic.md @@ -0,0 +1,34 @@ +Qualtrics.SurveyEngine.addOnload(function () { + // Hide the question as soon as the page loads + this.getQuestionContainer().hide(); + + //Variable to decide whether to show the question or not. Initially false + show_answer = false; + + //Create an embedded variable with all the valid choices using a seperator + // In this a comma "," is used + var valid_choices = "${e://Field/valid_choices}"; + valid_choices = valid_choices.split(","); + + //Get your entered choice. This is showning an embedded variable + // Which you can set based on your question type. + const entered_choice = "${e://Field/entered_choice}"; + + // Check if the entered choice is equal to any of the valid choices + valid_choices.forEach((item) => { + if (item.trim() == entered_choice) { + show_answer = true; + } + }); + + //Show the question, if the condition is met + if (show_answer == true) { + this.getQuestionContainer().show(); + } + + //Optionally you can add a condition to click the next button + // If you only have that one question on the page + if (show_answer == false) { + this.clickNextButton(); + } +}); diff --git a/Functions/Constant Sum Allow only integers.md b/Functions/Constant Sum Allow only integers.md new file mode 100644 index 0000000..2c32da5 --- /dev/null +++ b/Functions/Constant Sum Allow only integers.md @@ -0,0 +1,22 @@ +Qualtrics.SurveyEngine.addOnReady(function () { + //Get the Question Id + const qid = this.questionId; + // Get the number of choices + n_choices = Qualtrics.SurveyEngine.registry[qid].getChoices(); + + const base_msg = jQuery("#" + qid + " .QuestionText").html(); + padding_pre = '
'; + padding_post = ""; + err_msg = base_msg + padding_pre + "Please enter only valid integer numbers." + padding_post; + + // Detect a change in any of the choices + n_choices.forEach((item) => { + document.querySelector("#QR\\~" + qid + "\\~" + item).oninput = function () { + if (document.querySelector("#QR\\~" + qid + "\\~" + item).value.search(/\D/) != -1) { + jQuery("#" + qid + " .QuestionText").html(err_msg); + } else { + jQuery("#" + qid + " .QuestionText").html(base_msg); + } + }; + }); +}); diff --git a/Functions/Deselect Choices.md b/Functions/Deselect Choices.md new file mode 100644 index 0000000..e02aa49 --- /dev/null +++ b/Functions/Deselect Choices.md @@ -0,0 +1,55 @@ +// This is JS to allow participants to deselect their choices on the single answer type questions +// Courtesy mattyb513 Ref: https://www.qualtrics.com/community/discussion/1387/deselecting-a-radio-button +// Working Demo: https://iima.au1.qualtrics.com/jfe/form/SV_3mJczLmUFE9c7L7 + + +// You'll need to first create a Deselect Button. +// If you have multiple such buttons on the same page, you'll need to change their ids + + + +// This for a single question. For Matrix type, find below + +
+ Click on the button to deselect your choices. +
+ + + +// Question JS +Qualtrics.SurveyEngine.addOnReady(function () { + var qid_mchoice = this.questionId; //Get the Question Id + // Get the choices. This is needed as sometimes Qualtrics just goes crazy with choice numbers + all_choices = Qualtrics.SurveyEngine.registry[qid_mchoice].getChoices(); + + jQuery("#Deselect1").click(function () { + all_choices.forEach((item) => { + Qualtrics.SurveyEngine.registry[qid_mchoice].setChoiceValue(item,false); + }); + }); +}); + + + + +// For Matrices +// Add the button above as one of the statements +Qualtrics.SurveyEngine.addOnReady(function(){ + qid_matrix = this.questionId; + scale_points = Object.keys(Qualtrics.SurveyEngine.QuestionInfo[qid_matrix].Answers).length; + + // Get the location of the Deselect Button + choices = Qualtrics.SurveyEngine.QuestionInfo[qid_matrix].Choices; + deselect_position=[]; + Object.keys(choices).forEach((item)=>{ + if(choices[item].Text.includes("Deselect1")) deselect_position.push(item); + }); + deselect_position = parseInt(deselect_position); + + // Clear the choices + jQuery("#Deselect1").click(function () { + for(i=1;i<=scale_points;i++){ + Qualtrics.SurveyEngine.registry[qid_matrix].setChoiceValue(deselect_position,i,false); + } + }); +}); \ No newline at end of file diff --git a/Functions/Hide Next Button for a short while.md b/Functions/Hide Next Button for a short while.md new file mode 100644 index 0000000..1a2146e --- /dev/null +++ b/Functions/Hide Next Button for a short while.md @@ -0,0 +1,18 @@ +// Hides the Next Button for pre-defined amount of time and then displays it. + +Qualtrics.SurveyEngine.addOnload(function() +{ + + this.hideNextButton(); //Hide the question as soon as the page loads + +}); + +Qualtrics.SurveyEngine.addOnReady(function() +{ + + var delayTime = 6000 //This is the time of delay + var that = this; + setTimeout(function(){that.showNextButton();}, delayTime); // Function to show the next button + + +}); \ No newline at end of file diff --git a/Functions/Hide Question for a short while.md b/Functions/Hide Question for a short while.md new file mode 100644 index 0000000..9f63d46 --- /dev/null +++ b/Functions/Hide Question for a short while.md @@ -0,0 +1,17 @@ +// Hides the Question and Choices for pre-defined amount of time and then displays it. + +Qualtrics.SurveyEngine.addOnload(function() +{ + this.getQuestionContainer().hide(); // Hide the question as soon as the page loads + +}); + +Qualtrics.SurveyEngine.addOnReady(function() +{ + + var delayTime = 6000 //This is the time of delay + var that = this; + setTimeout(function(){that.getQuestionContainer().show()}, delayTime); // Function to show the question + + +}); \ No newline at end of file diff --git a/Functions/Highlight Selected Choices.md b/Functions/Highlight Selected Choices.md new file mode 100644 index 0000000..f94ff1b --- /dev/null +++ b/Functions/Highlight Selected Choices.md @@ -0,0 +1,40 @@ +Qualtrics.SurveyEngine.addOnReady(function () { + + const qid = this.questionId; + const all_choices = Qualtrics.SurveyEngine.registry[qid].getChoices(); + const base_colours = [ + "rgba(238, 50, 70, 0.3)", + "rgba(245, 150, 30, 0.3)", + "rgba(255, 203, 8, 0.3)", + "rgba(178, 210, 53, 0.3", + "rgba(0, 165, 81, 0.3)", + ]; + + // Sets the desired colours initially + all_choices.forEach((item,index) => { + document.querySelector("#" + qid + "-" + item + "-label").style.background = base_colours[index]; + document.querySelector("#" + qid + "-" + item + "-label").style.color = "#525252"; + }); + + + // Check if anyone clicks on the question + this.questionclick = function(){ + // Get the currently selected choices + var selected_choices = this.getSelectedChoices(); + + // Restore all the colours to their original state + // This is done, so that the options appear the same in case someone unselects a choice + all_choices.forEach((item,index) => { + document.querySelector("#" + qid + "-" + item + "-label").style.background = base_colours[index]; + document.querySelector("#" + qid + "-" + item + "-label").style.color = "#525252"; + }); + + // Give a different colour to the selected choices + // background is for the Box and color is for the text + // Change as desired + selected_choices.forEach((item) => { + document.querySelector("#" + qid + "-" + item + "-label").style.background = "DarkBlue"; + document.querySelector("#" + qid + "-" + item + "-label").style.color = "Yellow"; + }); + } +}); \ No newline at end of file diff --git a/Functions/Highlight unanswered questions_Request Response.md b/Functions/Highlight unanswered questions_Request Response.md new file mode 100644 index 0000000..f0a1d33 --- /dev/null +++ b/Functions/Highlight unanswered questions_Request Response.md @@ -0,0 +1,40 @@ +let my_interval; +Qualtrics.SurveyEngine.addOnReady(function(){ + let attempt = 1; + document.querySelector("#NextButton").onclick = function() { + my_interval = setInterval(() => { + err_msg = document.querySelector("#ErrorMessage"); + if (err_msg != null) { + console.log("done"); + solver(); + clearInterval(my_interval); + } + }, 10); + + }; + that = this; + var n = jQuery("#"+this.questionId+" .ChoiceRow").length; + function solver (){ + attempt++; + for(var i=0;i1){ + console.log("test"); + for(var i=0;i
+[*Link to Working Demo*](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_ba2DyuPGT8DLF6B?Q_SurveyVersionID=current) +

+*Screenshot*: + +matrix-with-header-row-at-custom-location + +

+ +*Question Javascript:* + +``` +Qualtrics.SurveyEngine.addOnload(function() +{ + base_element = document.querySelector(".SkinInner") + base_element.insertAdjacentHTML('afterbegin', '
'); + new_element = document.querySelector("#sticky_vid") + // Change the text below to add the element of your choice + new_element.innerHTML = `` + + // This is important, otherwise, the element you add will be at the back + base_element.style.zIndex = 1; + new_element.style.zIndex = 10; + +}); +``` \ No newline at end of file diff --git a/Functions/Matrix_add_header_row.md b/Functions/Matrix_add_header_row.md new file mode 100644 index 0000000..9ffbc6f --- /dev/null +++ b/Functions/Matrix_add_header_row.md @@ -0,0 +1,32 @@ +## Add Header Row to Matrix + +This function allow one to add the matrix header row at a custom location in the matrix. While Qualtrics allows repeating the header row within the table, it only does so after 5 or so rows. By using this function, one can ensure the options are visible at all times. +The script below is for adding the header as the 2th row, but multiple rows can be added with slight modification. +

+[*Link to Working Demo*](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_9Hnthujr7TA2LvD?Q_SurveyVersionID=current) +

+*Screenshot*: + +matrix-with-header-row-at-custom-location + +

+ +*Question Javascript:* +```{js} +Qualtrics.SurveyEngine.addOnReady(function() +{ + choice_table = this.getChoiceContainer(); + + //Numbering starts from 0. So the header is the 0th row, the first statement row 1 etc. + //This will create an empty row above statement 4. YOu can change it accordingly. + + new_row = choice_table.insertRow(2); + + //rows[0] refers to the header. + // So this takes the header row fills up the empty row just created. + + new_row.innerHTML = choice_table.rows[0].innerHTML; + +}); + +``` \ No newline at end of file diff --git a/Functions/Remove Powered By Qualtrics.md b/Functions/Remove Powered By Qualtrics.md new file mode 100644 index 0000000..7db8dd9 --- /dev/null +++ b/Functions/Remove Powered By Qualtrics.md @@ -0,0 +1,32 @@ +## Remove Powered by Qualtrics + +This function allow you to remove the "Powered by Qualtrics", which is usually present in the bottom right corner on computer screens and bottom centre on mobile phones. + +There are two ways to use the function. If you place it within the header (`Look and Feel --> General --> Header`), then it will across the survey. You can also use it on selected pages, by placing it the JS of any question on that page. + +

+[*Link to Working Demo*](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_50ayDWeUd6ErdeR?Q_SurveyVersionID=current) +

+ +*Screenshot*: +removed_powered_by_qualtrics + +

+ +*Javascript Code*: + +If you use it in the header, then you need place it within the `script` tags as shown below. +If you use in a question, you need to remove them. + +``` + +``` \ No newline at end of file diff --git a/Functions/Set Embedded on Page.md b/Functions/Set Embedded on Page.md new file mode 100644 index 0000000..d415b9c --- /dev/null +++ b/Functions/Set Embedded on Page.md @@ -0,0 +1,27 @@ +// This script is a demo of adding/modifying Embedded Data variables based on events on the page. + +// The script shown below allows you to add/modify Embedded Data variables as soon as the choices are submitted. + +// This allows more flexibility than the "Set Embedded Data" option in the "Survey Flow" section, as that works at block level, while this one works at Page level. + +// By modifying it a bit and adding it to the addOnReady() or addOnLoad() section, you can even recorded choices that were selected and then unselected. + +Qualtrics.SurveyEngine.addOnPageSubmit(function (type) { // To record the selection when the page is submitted + if (type == "next") { + var selChoice = this.getSelectedChoices(); // Get the selected choices + var choiceRef = ""; + var choiceText = ""; + for (let i = 0; i < selChoice.length; i++) { //Loop over all the choices selected in the question + choiceRef = "#" + this.questionId + "-" + selChoice[i] + "-label > span"; // Create a reference for the choices + choiceText = document.querySelector(choiceRef).innerHTML; //Get the value (The actual text displayed)of the choices from the webpage + + // Set Embedded Data + + if (choiceText.includes("Share")) { + Qualtrics.SurveyEngine.setEmbeddedData("Share", "TRUE"); + } else + Qualtrics.SurveyEngine.setEmbeddedData("Share", "FALSE"); + + } + } +}); diff --git a/Functions/Sort Choices Based on Value For Carry Forward Texts.md b/Functions/Sort Choices Based on Value For Carry Forward Texts.md new file mode 100644 index 0000000..1c765df --- /dev/null +++ b/Functions/Sort Choices Based on Value For Carry Forward Texts.md @@ -0,0 +1,28 @@ +Qualtrics.SurveyEngine.addOnPageSubmit(function() +{ + const qid = this.questionId; + available_choices = Qualtrics.SurveyEngine.QuestionInfo[qid].Choices; + + tot_choices = [] + for(keys in available_choices){ + tot_choices.push(keys);} + + choice_set ={}; + i=1; + tot_choices.forEach(item =>{ + option_score = document.getElementsByName("QR~"+qid+"~"+item)[0].value; + option_name = document.getElementById("header~"+qid+"~"+i).innerText.trim(); + choice_set[option_name] = option_score; + i++; + }); + + const sorted_choices = Object.fromEntries( + Object.entries(choice_set).sort(([,a],[,b]) => b-a) + ); + + i = 1; + for(keys in sorted_choices){ + Qualtrics.SurveyEngine.setEmbeddedData("top_"+i, keys); + i++; + } +}); \ No newline at end of file diff --git a/Functions/Sort Choices Based on Value.md b/Functions/Sort Choices Based on Value.md new file mode 100644 index 0000000..44e6563 --- /dev/null +++ b/Functions/Sort Choices Based on Value.md @@ -0,0 +1,21 @@ +Qualtrics.SurveyEngine.addOnPageSubmit(function() +{ + const qid = this.questionId; + const tot_choices = Qualtrics.SurveyEngine.registry[qid].getChoices().length; + + choice_set ={}; + for(i = 1; i<=tot_choices;i++){ + option_score = document.getElementsByName("QR~"+qid+"~"+i)[0].value; + option_name = document.getElementById("header~"+qid+"~"+i).innerText.trim(); + choice_set[option_name] = option_score; + } + const sorted_choices = Object.fromEntries( + Object.entries(choice_set).sort(([,a],[,b]) => b-a) + ); + + i = 1; + for(keys in sorted_choices){ + Qualtrics.SurveyEngine.setEmbeddedData("top_"+i, keys); + i++; + } +}); diff --git a/Functions/Timer Across Block.md b/Functions/Timer Across Block.md new file mode 100644 index 0000000..772edd2 --- /dev/null +++ b/Functions/Timer Across Block.md @@ -0,0 +1,34 @@ +Qualtrics.SurveyEngine.addOnload(function () { + var time_calc; +}); + +Qualtrics.SurveyEngine.addOnReady(function () { + + //Get the remaning time + var rem_time = "${e://Field/remaining_time}"; + rem_time = parseInt(rem_time); + that = this; + time_calc = setInterval(function () { + rem_time = rem_time - 1; + + // Update the remaining time every second + Qualtrics.SurveyEngine.setEmbeddedData("remaining_time", rem_time); + + if (rem_time <= 0) { + clearInterval(time_calc); + // This line will create and alert that time is up. Delete it or you may change its text as you please. + alert("times up"); + + // This will skip the other questions and go the end of the block + // Ensure that you have display logic set up accordingly + Qualtrics.SurveyEngine.setEmbeddedData("time_over", "TRUE"); + // Auto advance + that.clickNextButton(); + } + }, 1000); +}); + +Qualtrics.SurveyEngine.addOnUnload(function() +{ + clearInterval(time_calc); +}); diff --git a/Functions/custom message request response.md b/Functions/custom message request response.md new file mode 100644 index 0000000..3d15568 --- /dev/null +++ b/Functions/custom message request response.md @@ -0,0 +1,23 @@ +Qualtrics.SurveyEngine.addOnReady(function(){ + const qid = this.questionId; + tot_choices = Qualtrics.SurveyEngine.registry[qid].getChoices().length; + var sel_choices = 0; + + that = this; + this.questionclick = function(){ + sel_choices = that.getSelectedChoices().length; + } + + document.querySelector("#NextButton").onmousedown = function() {check_answers();}; + + + function check_answers(){ + if (sel_choices == tot_choices){that.clickNextButton();} + else{ + //Selecting Okay will result in continuing + if (confirm("Custom message here") == true) { + that.clickNextButton(); + } + } +} +}); \ No newline at end of file diff --git a/Functions/log values as typed.md b/Functions/log values as typed.md new file mode 100644 index 0000000..1470750 --- /dev/null +++ b/Functions/log values as typed.md @@ -0,0 +1,14 @@ +// Log values as they are typed + + +document.getElementById("submit").onclick = function() {userInput()}; +arr = []; +function userInput() +{ + var input = document.getElementById("userInput").value; + arr.push(input); + //seEmbeddedData doesn't need QuestionData + //The name of the Embedded Data variable needs to be passed as a string + //In you case, it was trying to parse the value of url_list, which was undefined + Qualtrics.SurveyEngine.setEmbeddedData("url_list", arr); +} \ No newline at end of file diff --git a/JavaScript Files/Add header row to a matrix table.js b/JavaScript Files/Add header row to a matrix table.js deleted file mode 100644 index c6b5135..0000000 --- a/JavaScript Files/Add header row to a matrix table.js +++ /dev/null @@ -1,12 +0,0 @@ -Qualtrics.SurveyEngine.addOnReady(function() -{ - choice_table = this.getChoiceContainer(); - //Numbering starts from 0. So the header is the 0th row, the first statement row 1 etc. - //This will create an empty row above statement 4. YOu can change it accordingly. - new_row = choice_table.insertRow(4); - - //rows[0] refersto the header. - // So this takes the header row fills up the empty row just created. - new_row.innerHTML = choice_table.rows[0].innerHTML; - -}); \ No newline at end of file diff --git a/JavaScript Files/Make Video Sticky on Page.js b/JavaScript Files/Make Video Sticky on Page.js new file mode 100644 index 0000000..1efee1e --- /dev/null +++ b/JavaScript Files/Make Video Sticky on Page.js @@ -0,0 +1,12 @@ + +Qualtrics.SurveyEngine.addOnload(function() +{ + base_element = document.querySelector(".SkinInner") + base_element.insertAdjacentHTML('afterbegin', '
'); + new_element = document.querySelector("#sticky_vid") + new_element.innerHTML = `` + + base_element.style.zIndex = 1; + new_element.style.zIndex = 10; + +}); diff --git a/JavaScript Files/Matrix_add_header_row.js b/JavaScript Files/Matrix_add_header_row.js new file mode 100644 index 0000000..9ffbc6f --- /dev/null +++ b/JavaScript Files/Matrix_add_header_row.js @@ -0,0 +1,32 @@ +## Add Header Row to Matrix + +This function allow one to add the matrix header row at a custom location in the matrix. While Qualtrics allows repeating the header row within the table, it only does so after 5 or so rows. By using this function, one can ensure the options are visible at all times. +The script below is for adding the header as the 2th row, but multiple rows can be added with slight modification. +

+[*Link to Working Demo*](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_9Hnthujr7TA2LvD?Q_SurveyVersionID=current) +

+*Screenshot*: + +matrix-with-header-row-at-custom-location + +

+ +*Question Javascript:* +```{js} +Qualtrics.SurveyEngine.addOnReady(function() +{ + choice_table = this.getChoiceContainer(); + + //Numbering starts from 0. So the header is the 0th row, the first statement row 1 etc. + //This will create an empty row above statement 4. YOu can change it accordingly. + + new_row = choice_table.insertRow(2); + + //rows[0] refers to the header. + // So this takes the header row fills up the empty row just created. + + new_row.innerHTML = choice_table.rows[0].innerHTML; + +}); + +``` \ No newline at end of file diff --git a/JavaScript Files/Remove Powered By Qualtrics.js b/JavaScript Files/Remove Powered By Qualtrics.js index 91adab2..7db8dd9 100644 --- a/JavaScript Files/Remove Powered By Qualtrics.js +++ b/JavaScript Files/Remove Powered By Qualtrics.js @@ -1,7 +1,24 @@ -// Remove the "Powered By Qualtrics" thingy. -// It is available at multiple places, but since their script runs at addOnLoad, it fails. -// This runs at addOnReady and hence works. +## Remove Powered by Qualtrics +This function allow you to remove the "Powered by Qualtrics", which is usually present in the bottom right corner on computer screens and bottom centre on mobile phones. + +There are two ways to use the function. If you place it within the header (`Look and Feel --> General --> Header`), then it will across the survey. You can also use it on selected pages, by placing it the JS of any question on that page. + +

+[*Link to Working Demo*](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_50ayDWeUd6ErdeR?Q_SurveyVersionID=current) +

+ +*Screenshot*: +removed_powered_by_qualtrics + +

+ +*Javascript Code*: + +If you use it in the header, then you need place it within the `script` tags as shown below. +If you use in a question, you need to remove them. + +``` \ No newline at end of file + +``` \ No newline at end of file diff --git a/screenshots/matrix_add_header_row.png b/screenshots/matrix_add_header_row.png new file mode 100644 index 0000000..2f40695 Binary files /dev/null and b/screenshots/matrix_add_header_row.png differ diff --git a/screenshots/removed_powered_by_qualtrics.png b/screenshots/removed_powered_by_qualtrics.png new file mode 100644 index 0000000..f76e993 Binary files /dev/null and b/screenshots/removed_powered_by_qualtrics.png differ diff --git a/screenshots/sticky_video.png b/screenshots/sticky_video.png new file mode 100644 index 0000000..42dd82b Binary files /dev/null and b/screenshots/sticky_video.png differ