- Posts: 5
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ $.post('https://www.myServer.de/myFolder/getTermin.php' , { sid: "{SID}", gid: "{GID}", qid:"{QID}" , quotid:"19152", vorgabe:"{eqVorgabe}" }, function(data) { $('#question{QID} input[type="text"]').val(data) }); }); </script>
<style type="text/css">.ls-answers, .answer-container { display: none; } </style>
<?php // Zunächst Verbindung zur Datenbank; ich benutze hier z.B. die Bibliothek "meekrodb" //Da kann man ja das gewohnte benutzen "mysqli, pdo, ..."; meekrodb ist auch nur ein wrapper für pdo. require_once 'meekrodb.class.php'; DB::$host='myHost'; DB::$user='myUser'; DB::$password='myPasswort'; DB::$dbName='myDBName'; // Die übergebenen Parameter werden in Variablen eingelesen $iSID = $_POST["sid"]; $iGID = $_POST["gid"]; $iQID = $_POST["qid"]; $iQuotID = $_POST["quotid"]; $iVorgabe = $_POST["vorgabe"]; // Dies ist etwas umständlich; ich will damit nur die Anzahl der möglichen Termine erhalten $iVorgabe=str_replace("(","",$iVorgabe); $iVorgabe=str_replace(")","",$iVorgabe); $iVorgabe=str_replace(" ","",$iVorgabe); $aVorgabe=explode(",",$iVorgabe); // Der SGQA Code der Tabellenspalte wird zusammengebaut $iFQuoteID=$iSID.'X'.$iGID.'X'.$iQuotID; //Jetzt erfolgt für jeden Termin (Code) die Abfrage nach der Anzahl und die Zusammenstellung des Ergebnisstrings $result=""; for ($i=1;$i<=count($aVorgabe);$i++) { $daten[$i] = DB::queryFirstRow("SELECT count(".$iFQuoteID.") as Zahl FROM lime_survey_".$iSID." WHERE (submitdate is not NULL) AND (".$iFQuoteID."=".$i.")"); $result.=str_pad($daten[$i]['Zahl'],3,"0",STR_PAD_LEFT); } // Rückgabe echo $result; ?>
ist es jetzt ein bisschen "von hinten durch die Brust ins Auge".You can not use this system in expression manager for answer part in LimeSurvey 3 and up.