====== CRM/RTR audio measuring ====== ===== Displaying the rating in the questionnaire ===== Using the chart library ChartJS, the rating can be displayed as a chart, either after the assessment (on the following page), or live during the recording. ==== Live chart ==== To display a chart during data collection, save the following HTML/JavaScript code in a section (**List of Questions** -> **Add Text** -> //Display// "HTML Code").
The placeholder ''%questionID%'' is replaced by the following PHP code with the identifier of the question. Place the following PHP code under **Compose Questionnaire** directly under the CRM question. The identifier ''CR01'' must be replaced with the identifier of the CRM question, and the identifier ''CR02'' must be replaced with the identifier of the text containing the JavaScript code. library('ChartJS'); show('CR02', [ '%questionID%' => 'CR01' ]); ==== Chart after completion ==== If the chart is to be displayed on a later page in the questionnaire, the data is retrieved from the dataset using ''value()''. To do this, create the following HTML/JavaScript code in a section in the **Questionnaire** (**Add text** -> //Display// "HTML code").
Place the following PHP code in the questionnaire (**Compose Questionnaire**) where you want the chart to appear. Replace "CR01rsp" with the variable identifier of your CRM question. If the question's identifier is AB01, the variable identifier will be "AB01rsp" by default. $data = value('CR01rsp', 'label'); $data = explode(',', $data); $values = [null]; foreach ($data as $value) { $iValue = (int)$value; if ($iValue >= 0) { $values[] = (int)$value; } else { $values[] = NULL; } } replace('%data%', json_encode($values)); replace('%labels%', json_encode(array_keys($values))); library('ChartJS'); option('nextbutton', false); Drag the text module created above to the same page in the questionnaire (**Compose Questionnaire**) under the PHP code.