What would be the way to make this work then? I guess i dont follow your second approach.
I created a brand new survey with just one question in it. Still getting the same null id issue. Also TomG I added a piece of code in the look and feel section as you had mentioned (i tried in both places onready and onload)Unfortunately i still get qid as null.Qualtrics.SurveyEngine.addOnload(function(){ var qid = this.questionId; console.log(qid);});Qualtrics.SurveyEngine.addOnReady(function(){ var qid = this.questionId; console.log(qid);});
I put a console.log(qid) after this line var qid=this.questionIdIt outputs the value when i first enter the question.However its null, if user clicks the next button, sees the grading page and then comes back to the question page by clicking the back button. Not sure why the questionId is null when the back button is pressed.
If i comment the line below (and the corresponding brace) //if(document.getElementById(qid).className == "Grading"){i can see the text now if the user navigates back and forth. So is that line necessary?Thanks!
I tried the above code , but cannot make it to work the second time the user goes back and then clicks next. I copied the exact code you have. I created a brand new simple question with 3 possible choices. Set score to 1 for the first choice. Add javascript to that question with the code above. I have attached images that hopefully helps in troubleshooting. Second time i do see an error in the console log. As far as the other approach, can you elaborate where should the javascript be placed.If i add a code on the addOnLoad page, its not being called when the grading page loads.
Ahmed. I probably missed copying that line of code in the editor. Whats the best way for this function to get triggered if user goes back and then clicks the next button ?Here is the actual code Qualtrics.SurveyEngine.addOnReady(function () { document.querySelector("#NextButton").addEventListener("click", grading_text); qid = this.questionId; function grading_text(){ var gt = setInterval(function (){ if(document.getElementById(qid).className == "Grading"){ document.querySelector(".GradingQuestionText.BorderColor").innerText += "Additional Text" clearInterval(gt); } },100) }});Also, i tried the following as well. The next does gets called, but the new text does not appear the second time. Qualtrics.SurveyEngine.addOnPageSubmit(function(type){if(type == "next") { alert("here"); //document.querySelector("#NextButton").addEventListener("click", grading_text); qid = this.questionId; var addltext= "hello this i
The following code works first time when clicking the next button.After answering the question, user presses the next button. This triggers the listener to append the feedback text and this text is appended to the existing question text. Now after seeing this new feedback on the scoring page, if the user presses the back button, and then chooses a different answer and then clicks the next button, then the feedback text is not being added. Qualtrics.SurveyEngine.addOnReady(function(){ document.querySelector("#NextButton").addEventListener("click", grading_text); qid = this.questionId; var feedbackText = "My feedback Text"; var gt = setInterval(function (){ if(document.getElementById(qid).className == "Grading"){ document.querySelector(".GradingQuestionText.BorderColor").innerText += feedbackText; clearInterval(gt); } },100) }});
To user: ahmedA This is exactly what i was looking for. How to add the text to class .GradingQuestionText.BorderColor (upon inspection, thats the new class that gets added on the feedback page.) I just didnt know which event to call so that i can modify/append the existing text. I will try this and get back to you. To User: Tom. I agree that the picture would help clarifying the question. I will see if i can add an image that explains my question in a much better way.
Wanted to bump this up for any ideas? Thanks!
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.