diff --git a/db.php b/db.php index 49b83c3..edfd8ae 100644 --- a/db.php +++ b/db.php @@ -130,10 +130,50 @@ $stmt = $pdo->prepare(" 'text' => $text, 'value' => $value ]); + + if ($qid == "QID68"){ + updateResponseQ1($pdo, $value, $responseId); + } + if ($qid == "QID69"){ + updateResponseQ2($pdo, $value, $responseId); + } + if ($qid == "QID70"){ + updateResponseQ3($pdo, $value, $responseId); + } + + + + } } } +function updateResponseQ1(PDO $pdo, int $q1Value, string $responseId): bool { + $sql = "UPDATE Responses SET Q1 = :q1 WHERE id = :responseId"; + $stmt = $pdo->prepare($sql); + $stmt->bindParam(':q1', $q1Value, PDO::PARAM_INT); + $stmt->bindParam(':responseId', $responseId, PDO::PARAM_STR); + + return $stmt->execute(); +} + +function updateResponseQ2(PDO $pdo, int $q2Value, string $responseId): bool { + $sql = "UPDATE Responses SET Q2 = :q2 WHERE id = :responseId"; + $stmt = $pdo->prepare($sql); + $stmt->bindParam(':q2', $q2Value, PDO::PARAM_INT); + $stmt->bindParam(':responseId', $responseId, PDO::PARAM_STR); + + return $stmt->execute(); +} + +function updateResponseQ3(PDO $pdo, int $q3Value, string $responseId): bool { + $sql = "UPDATE Responses SET Q3 = :q3 WHERE id = :responseId"; + $stmt = $pdo->prepare($sql); + $stmt->bindParam(':q3', $q3Value, PDO::PARAM_INT); + $stmt->bindParam(':responseId', $responseId, PDO::PARAM_STR); + + return $stmt->execute(); +} ?> diff --git a/drawbar.js b/drawbar.js index e6cfd45..11a137c 100644 --- a/drawbar.js +++ b/drawbar.js @@ -28,8 +28,8 @@ SOFTWARE. function drawBar(id,data) { -console.log(id); -console.log(data); +//console.log(id); +//console.log(data); const svg = d3.select(`${id}`); const backgroundwidth = +svg.attr("width"); const backgroundradius = 10; @@ -297,7 +297,7 @@ function doBarData(id,qid, survey, Q1=0, Q2=0, Q3=0 ) { .then(response => response.text()) .then(data => { // Output result - console.log(data); + //console.log(data); const parsed = JSON.parse(data); // 2. Clean the keys and build a usable object @@ -308,9 +308,9 @@ function doBarData(id,qid, survey, Q1=0, Q2=0, Q3=0 ) { bardata[cleanKey] = entry[rawKey]; }); - console.log(bardata); + //console.log(bardata); const total = Object.values(bardata).reduce((sum, value) => sum + value, 0); - console.log(total); + //console.log(total); document.getElementById("record_no").textContent = total; if (total < 9){ return; diff --git a/drawtriangle.js b/drawtriangle.js index b0621b3..596b553 100644 --- a/drawtriangle.js +++ b/drawtriangle.js @@ -43,7 +43,7 @@ if (rag !== "") { polycolour = rag; textcolour = "black"; - console.log("rag: "+rag); + //console.log("rag: "+rag); opacity = 0.6; } diff --git a/drawtriangleinverted.js b/drawtriangleinverted.js index 75d0467..fc51186 100644 --- a/drawtriangleinverted.js +++ b/drawtriangleinverted.js @@ -43,7 +43,7 @@ if (rag !== "") { polycolour = rag; textcolour = "black"; - console.log("rag: "+rag); + //console.log("rag: "+rag); opacity = 0.6; } diff --git a/get_qid_counts.php b/get_qid_counts.php index a938e71..2075482 100644 --- a/get_qid_counts.php +++ b/get_qid_counts.php @@ -4,6 +4,7 @@ header('Content-Type: application/json'); if (php_sapi_name() === 'cli') { echo "Running from command line.\n"; $qid="QID2_7"; + $survey="SV_cwKjMqAqGxImjMG"; $q1 = 1; $q2 = 2; $q3 = 0; @@ -70,18 +71,16 @@ try { $baseSql = " SELECT a.value, - COUNT(*) AS count, - r.Q1, - r.Q2, - r.Q3 + COUNT(*) AS count FROM Answers a INNER JOIN Responses r ON a.responseId = r.id INNER JOIN Surveys s ON a.surveyId = s.id WHERE a.QID = :qid "; + //GROUP BY a.value, r.Q1, r.Q2, r.Q3 $sql = $baseSql . $qualifier . " - GROUP BY a.value, r.Q1, r.Q2, r.Q3 + GROUP BY a.value ORDER BY a.value; "; diff --git a/insertQualifiers.js b/insertQualifiers.js index 561130b..c4e0e92 100644 --- a/insertQualifiers.js +++ b/insertQualifiers.js @@ -27,7 +27,7 @@ function insertQualifiers(){ // Output result console.log(data); const parsed = JSON.parse(data); - console.log (parsed["1"]); + document.querySelector('label[for="location"]').textContent = parsed["1"][0]; // .shift(); // diff --git a/populateGraphics.js b/populateGraphics.js index 4a784e1..fe653b3 100644 --- a/populateGraphics.js +++ b/populateGraphics.js @@ -12,7 +12,7 @@ function RAGGED(average){ function getAverage(prefix) { - console.log("Prefix:", prefix); + //console.log("Prefix:", prefix); const elements = Array.from(document.querySelectorAll(`svg[id^="${prefix}"] tspan.average`)); @@ -48,7 +48,6 @@ function getSurveyData(){ let Q3=document.getElementById("gov").value; - let amber = '#ffbf00'; //doBigWhiteTriangle('svg1'); //drawtriangle('#svg1','Roles','#008845',[0.5,0.6,0.5],'red', { x: 0, y: 350 },-0.7); diff --git a/reportTemplate.html b/reportTemplate.html index 2a3b59a..a7affce 100644 --- a/reportTemplate.html +++ b/reportTemplate.html @@ -14,11 +14,30 @@
@@ -90,7 +112,7 @@You first need to enter the Survey ID, and press submit in order to get the correct groupings available to select from. The master template survey is SV_cwKjMqAqGxImjMG if you want a survey to just try out.
SV_bD838sNKZEmi6Tc is also worth experimenting with