👋 WELCOME to HypeXAPI
How are we doing it?

Dynamic data

12min
this tutorial sends 4 independant xapi statements using 2 syntax structures, by using a string variable if you know hype and know your way around javascript, you have seen a few ways of how to dynamically update data for the statements by now but for the other people like me, i need to show you a few methods of how to dynamically update data variables are stored in hypecustomdata i try to identify the variables that i will use upfront and declare default values for the variables in the hypexapi() document something like this //set dynamic data hypedocument customdata myresponsevariable = ''; hypedocument customdata raw = 0; hypedocument customdata scaled = 0; hypedocument customdata success = false; hypedocument customdata videoname = 'rocket'; hypedocument customdata kcheck1 = "quiz 1"; once they are declared here, you can adjust them in the gui to add a string variable somewhere in your dictionary, add it in place like this 	 'myresult1' { 		 	 "response" '${myresponsevariable}', //string variable placeholder 	 }, to create placeholders for the boolean and number variables 	 'myresult2' { 	 "score" { 	 "raw" function() {return hypedocument customdata raw},//number variable 	 "scaled" function() {return hypedocument customdata scaled},//number variable 	 }, 	 	 	 "completion" true,	 	 "success" function() {return hypedocument customdata success}, //boolean variable 	 }, 		 		 }); set these variables in the gui when you have loaded the hypexapi export script, you have the ability to set/change the variable values from the actions panel changing the values of a string, boolean or a number variable happens the exact same way for example run expression the run expression choice in the actions hypexapi export script is a special one especially for a non coder like me if you have declared a value for a variable in hypedocument customdata , you can do things with run expression for example, you can change a number variable with some maths here we take the variable 'raw' that was set in hypecustomdata and we are adding 5 to its number value now we take the same vaiable and subtracted the number value 2 from it now we multiplied the same 'raw' variable and multiplied it by 2 you can also run some basic javascript in run expression as well something else to consider when using run expression , is to pass basic hype specific javascript like this into it myresponsevariable = document getelementbyid('mytext') value here we take the innerhtml value of 'mytext' and pass it into the variable myresponsevariable the rest is up to you have fun with the dynamic data options with the hype export script run expression tutorial with timer iso time conversion function var seconds = hypedocument customdata slidetimer; 	 if (seconds > 60) { if (seconds > 3600) { 	 const hours = math floor(seconds / 3600); 	 const minutes = math floor((seconds % 3600) / 60); 	 seconds = (seconds % 3600) % 60; 	 	 hypedocument customdata slideduration = `pt${hours}h${minutes}m${seconds}s`; 	 } else { 	 const minutes = math floor(seconds / 60); 	 seconds %= 60; 	 	 hypedocument customdata slideduration = `pt${minutes}m${seconds}s`; } } else { 	 hypedocument customdata slideduration = `pt${seconds}s`; } expanding on the result object the following tutorial shows how to use and update boolean and number variables, using the result object as a use case