diff --git a/admin/survey_erfassen.php b/admin/survey_erfassen.php index 28a5e0f..3b4ae6b 100644 --- a/admin/survey_erfassen.php +++ b/admin/survey_erfassen.php @@ -290,74 +290,7 @@ if ($action == 'fragen') { } -if ($action == 'save') { - - $umid = $_SESSION["umfrageerf_umid"]; - - if (isset($_POST['frage'])) { - $frage = $_POST['frage']; - } - if (isset($_POST['antwort'])) { - $antwort = $_POST['antwort']; - } - - if (isset($_POST['multiple'])) { - if ($_POST['multiple'] == '1') { - $multiple = '1'; - } else { - $multiple = '0'; - } - } else { - $multiple = '0'; - } - - # Gibt es die Frage schon - $result = $db->query("SELECT count(*) Anz FROM jumi_umfragen_fragen WHERE umid='$umid' and frage='$frage'"); - $row = $result->fetch_array(); - - if ($row['Anz'] == '0' and $frage != '') { - $sql1 = $db->query("INSERT INTO jumi_umfragen_fragen ( umid - , frage - , multiple - ) - VALUES - ( '$umid' - , '$frage' - , '$multiple' - ) - "); - $ufid = $db->insert_id; - $_SESSION["umfrageerf_ufid"] = $ufid; - } else { - $ufid = $_SESSION["umfrageerf_ufid"]; - $update = $db->query("UPDATE jumi_umfragen_fragen - SET frage ='$frage' - ,multiple ='$multiple' - WHERE ufid = $ufid - "); - } - $ufid = $_SESSION["umfrageerf_ufid"]; - - # Gibt es diese Antwort schon - $result2 = $db->query("SELECT count(*) Anz FROM jumi_umfragen_antworten WHERE ufid='$ufid' and antwort='$antwort'"); - $row2 = $result2->fetch_array(); - if ($row2['Anz'] == '0' and $antwort != '') { - $sql1 = $db->query("INSERT INTO jumi_umfragen_antworten ( ufid - , antwort - ) - VALUES - ( '$ufid' - , '$antwort' - ) - "); - $uaid = $db->insert_id; - $_SESSION["umfrageerf_uaid"] = $uaid; - } - echo ""; - - -} $smarty->assign('action', "$action"); $smarty->display("$template/admin/$templatename"); diff --git a/auswertung/index.php b/auswertung/index.php new file mode 100644 index 0000000..8f5c347 --- /dev/null +++ b/auswertung/index.php @@ -0,0 +1,149 @@ +query("SELECT max(umid) umid + FROM jumi_umfragen + WHERE datum_von < now() + "); + $row_umid = $query_umid->fetch_array(); + + $query_umid_detail = $db->query("SELECT headline, date_format(datum_von, '%d.%m.%Y - %H:%i') datum_von, date_format(datum_bis, '%d.%m.%Y - %H:%i') datum_bis, freitext + FROM jumi_umfragen + WHERE umid=$row_umid[umid] + "); + $row_umid_detail = $query_umid_detail->fetch_array(); + $smarty->assign('result_headline', "$row_umid_detail[headline]"); + $smarty->assign('result_datum_von', "$row_umid_detail[datum_von]"); + $smarty->assign('result_datum_bis', "$row_umid_detail[datum_bis]"); + + # Anzahl abgeschlossene Umfragen + $query_fertige = $db->query("SELECT count(*) Anz_abgeschlossen + FROM jumi_umfragen_ende + WHERE umid =$row_umid[umid] + "); + $row_fertige = $query_fertige->fetch_array(); + $smarty->assign('result_anz_fertige', "$row_fertige[Anz_abgeschlossen]"); + + # Anzahl angefangener Teilnehmer + $query_angefangen = $db->query("SELECT count(distinct concat(ip,session))-$row_fertige[Anz_abgeschlossen] Anz_angefangen + FROM jumi_umfragen_ergebnisse + WHERE ufid in (select ufid from jumi_umfragen_fragen where umid =$row_umid[umid]) + "); + $row_angefangen = $query_angefangen->fetch_array(); + $smarty->assign('result_anz_angefangen', "$row_angefangen[Anz_angefangen]"); + + + + + + $query = "SELECT ufid, frage, multiple + FROM jumi_umfragen_fragen + WHERE umid = $row_umid[umid]"; + $result = $db->query($query); + + + // Ergebnisse lesen und an den Client ausgeben + while ($row = $result->fetch_array()) { + $value2 = ''; + unset($inner1); + + # Wie viele User haben Frage 1 beantwortet + $result_anz_userfrage = $db->query("SELECT count(distinct concat(ip,session)) Anz + FROM jumi_umfragen_ergebnisse + WHERE ufid = $row[ufid] + "); + $row_anz_userfrage = $result_anz_userfrage->fetch_array(); + + # Wie viele Antworten gibt es zur Frage: Das sind 100% + $result_anz_antworten = $db->query("SELECT count(ufid) Anz + FROM jumi_umfragen_ergebnisse + WHERE ufid = $row[ufid] + "); + $row_anz_antworten = $result_anz_antworten->fetch_array(); + + + $query2 = "SELECT uaid, antwort + FROM jumi_umfragen_antworten + WHERE ufid=$row[ufid] + ORDER BY userorder ASC, uaid ASC + "; + + + $result2 = $db->query($query2) or die("Cannot execute query2"); + $ln2 = 0; + + while ($row2 = $result2->fetch_array()) { + + # Wie viele haben Antwort auf aktuelle Frage gegeben + $result_cur_antw = $db->query("SELECT count(*) Anz + FROM jumi_umfragen_ergebnisse + WHERE uaid = $row2[uaid]"); + $row_cur_antw = $result_cur_antw->fetch_array(); + + if($row_anz_antworten['Anz'] != '0'){ + $prozent = round(100/$row_anz_antworten['Anz']*$row_cur_antw['Anz'],0); + }else{ + $prozent = 0; + } + + $inner1[$ln2]['prozent'] = $prozent; + $inner1[$ln2]['uaid'] = $row2['uaid']; + $inner1[$ln2]['antwort'] = $row2['antwort']; + $value2 = $inner1; + $ln2++; + } + if($row_anz_userfrage['Anz'] != 0){ + $anz_userfrage = $row_anz_userfrage['Anz']; + }else{ + $anz_userfrage = 0; + } + $row['inner'] = $value2; + $row['anz_userfrage'] = $anz_userfrage; + $row['anz_antworten_frage'] = $row_anz_antworten['Anz']; + $table_data[] = $row; + } + $smarty->assign('table_data', $table_data); + +# echo"
"; +# print_r($table_data); +# echo""; + + + $query3 = "SELECT freitext + FROM jumi_umfragen_erg_freitext + WHERE umid = $row_umid[umid] + ORDER BY uefid desc"; + $result3 = $db->query($query3); + + + // Ergebnisse lesen und an den Client ausgeben + while ($row3 = $result3->fetch_array()) { + $table_data3[] = $row3; + } + $smarty->assign('table_data3', $table_data3); + + +} + + +$smarty->assign('action', "$action"); +$smarty->display("modern/auswertung/$templatename"); +?> diff --git a/controller/admin_erfassen.php b/controller/admin_erfassen.php index 48dbb89..c696ae7 100644 --- a/controller/admin_erfassen.php +++ b/controller/admin_erfassen.php @@ -2,36 +2,139 @@ require_once("../config.inc.php"); $function = $_POST['function']; - if($function == 'delete'){ - $tabelle = $_POST['tabelle']; - $spalte = $_POST['spalte']; - $id = $_POST['id']; - $stmt = $db->query("DELETE FROM $tabelle WHERE $spalte = $id"); - if($stmt){ - echo "success: DELETE FROM $tabelle WHERE $spalte = $id"; - }else{ - echo "error: DELETE FROM $tabelle WHERE $spalte = $id"; - } +if ($function == 'erfmultiple') { + $multiple = $_POST['multiple']; + $umid = $_SESSION["umfrageerf_umid"]; + $ufid = $_SESSION["umfrageerf_ufid"]; + if($ufid != ''){ + if (isset($multiple)) { + if ($multiple == '1') { + $multiple = '1'; + } else { + $multiple = '0'; + } + } else { + $multiple = '0'; + } + + $update = $db->query("UPDATE jumi_umfragen_fragen + SET multiple ='$multiple' + WHERE ufid = $ufid + "); + if($update){ + echo "success"; + }else{ + echo -1; + } + + }else{ + echo -1; + } +} + +if ($function == 'save') { + $frage = $_POST['frage']; + $antwort = $_POST['antwort']; + $multiple = $_POST['multiple']; + + + $umid = $_SESSION["umfrageerf_umid"]; + + if (isset($_POST['frage'])) { + $frage = $_POST['frage']; + } + if (isset($_POST['antwort'])) { + $antwort = $_POST['antwort']; } - if($function == 'deleteQuestion'){ - - $id2 = $_POST['id2']; - - $stmt1 = $db->query("DELETE FROM jumi_umfragen_antworten WHERE ufid = $id2"); - $stmt2 = $db->query("DELETE FROM jumi_umfragen_fragen WHERE ufid = $id2"); - # ggf. bereis Abstimmergebnisse löschen - - # Sonst werden keine neue Fragen erfasst -# unset($_SESSION["umfrageerf_ufid"]); - - - if($stmt1 and $stmt2){ - echo "DELETE FROM jumi_umfragen_antworten WHERE ufid = $id2 | DELETE FROM jumi_umfragen_fragen WHERE ufid = $id2"; - }else{ - echo "Nicht geklappt"; - } + if (isset($multiple)) { + if ($multiple == '1') { + $multiple = '1'; + } else { + $multiple = '0'; + } + } else { + $multiple = '0'; } + # Gibt es die Frage schon + $result = $db->query("SELECT count(*) Anz FROM jumi_umfragen_fragen WHERE umid='$umid' and frage='$frage'"); + $row = $result->fetch_array(); -?> + if ($row['Anz'] == '0' and $frage != '') { + $sql1 = $db->query("INSERT INTO jumi_umfragen_fragen ( umid + , frage + , multiple + ) + VALUES + ( '$umid' + , '$frage' + , '$multiple' + ) + "); + $ufid = $db->insert_id; + $_SESSION["umfrageerf_ufid"] = $ufid; + } else { + $ufid = $_SESSION["umfrageerf_ufid"]; + $update = $db->query("UPDATE jumi_umfragen_fragen + SET frage ='$frage' + ,multiple ='$multiple' + WHERE ufid = $ufid + "); + } + $ufid = $_SESSION["umfrageerf_ufid"]; + + # Gibt es diese Antwort schon + $result2 = $db->query("SELECT count(*) Anz FROM jumi_umfragen_antworten WHERE ufid='$ufid' and antwort='$antwort'"); + $row2 = $result2->fetch_array(); + if ($row2['Anz'] == '0' and $antwort != '') { + $sql1 = $db->query("INSERT INTO jumi_umfragen_antworten ( ufid + , antwort + ) + VALUES + ( '$ufid' + , '$antwort' + ) + "); + $uaid = $db->insert_id; + $_SESSION["umfrageerf_uaid"] = $uaid; + } + echo "success"; + #echo ""; + +} + + +if ($function == 'delete') { + $tabelle = $_POST['tabelle']; + $spalte = $_POST['spalte']; + $id = $_POST['id']; + $stmt = $db->query("DELETE FROM $tabelle WHERE $spalte = $id"); + if ($stmt) { + echo "success: DELETE FROM $tabelle WHERE $spalte = $id"; + } else { + echo "error: DELETE FROM $tabelle WHERE $spalte = $id"; + } +} + +if ($function == 'deleteQuestion') { + + $id2 = $_POST['id2']; + + $stmt1 = $db->query("DELETE FROM jumi_umfragen_antworten WHERE ufid = $id2"); + $stmt2 = $db->query("DELETE FROM jumi_umfragen_fragen WHERE ufid = $id2"); + # ggf. bereis Abstimmergebnisse löschen + + # Sonst werden keine neue Fragen erfasst + # unset($_SESSION["umfrageerf_ufid"]); + + + if ($stmt1 and $stmt2) { + echo "DELETE FROM jumi_umfragen_antworten WHERE ufid = $id2 | DELETE FROM jumi_umfragen_fragen WHERE ufid = $id2"; + } else { + echo "Nicht geklappt"; + } +} + + +?> \ No newline at end of file diff --git a/js/components/admin_erfassen.js b/js/components/admin_erfassen.js index 248e93b..58b5ae1 100644 --- a/js/components/admin_erfassen.js +++ b/js/components/admin_erfassen.js @@ -1,45 +1,114 @@ +function erf_multiple(){ + var checkBox = document.getElementById("multiple"); -function onClickDelete(id){ - - document.getElementById("antwort").value= ""; - r = confirm('Antwort löschen1?'); - if(r) { - $.ajax({ - type: 'POST', - url: '../controller/admin_erfassen.php', - data: { - 'function': 'delete', - 'tabelle': 'jumi_umfragen_antworten', - 'spalte': 'uaid', - 'id': id - }, - success: function(result) { //we got the response - alert(result); - }, - error: function(xhr, status, exception) { - console.log(xhr); - } - }); + if(checkBox.checked == true){ + var var_multiple = 1; + }else{ + var var_multiple = 0; + } + $.ajax({ + type: 'POST', + url: '../controller/admin_erfassen.php', + data: { + 'function': 'erfmultiple', + 'multiple': var_multiple + }, + success: function(result) { //we got the response +// if(result==-1){ +// alert("Bitte zunächst die Frage erfassen"); +// $(document).ajaxStop(function(){ +// window.location = "?action=fragen&erfassen=1"; +// }); +// }else{ +// $(document).ajaxStop(function(){ +// window.location = "?action=fragen&erfassen=1"; +// }); +// } + }, + error: function(xhr, status, exception) { + console.log(xhr); } + }); + } +function erfassensave(){ + var frage = document.getElementById("frage").value; + var antwort = document.getElementById("antwort").value; + var checkBox = document.getElementById("multiple"); -function onClickDeleteQuestion(id2){ - document.getElementById("frage").value = ""; - document.getElementById("antwort").value= ""; - r = confirm('Gesamte Frage löschen?'); - if(r) { - $.ajax({ - type: 'POST', - url: '../controller/admin_erfassen.php', - data: { - 'function': 'deleteQuestion', - 'id2': id2 - }, - success: function(result){ -// document.getElementById("del").innerHTML = "entfernt"; -//Text einblenden geht nicht, da ein Refresh gemacht wird. Dann sieht man den Text nicht - } - }); + if(checkBox.checked == true){ + var var_multiple = 1; + }else{ + var var_multiple = 0; + } + + $.ajax({ + type: 'POST', + url: '../controller/admin_erfassen.php', + data: { + 'function': 'save', + 'frage': frage, + 'antwort': antwort, + 'multiple': var_multiple + }, + success: function(result) { //we got the response + $(document).ajaxStop(function(){ + window.location = "?action=fragen&erfassen=1"; + }); + }, + error: function(xhr, status, exception) { + console.log(xhr); } + }); + } + +function onClickDelete(id) { + + document.getElementById("antwort").value = ""; + r = confirm('Antwort löschen?'); + if (r) { + $.ajax({ + type: 'POST', + url: '../controller/admin_erfassen.php', + data: { + 'function': 'delete', + 'tabelle': 'jumi_umfragen_antworten', + 'spalte': 'uaid', + 'id': id + }, + success: function(result) { //we got the response + $(document).ajaxStop(function(){ + window.location = "?action=fragen&erfassen=1"; + }); + }, + error: function(xhr, status, exception) { + console.log(xhr); + } + }); + } +} + +function onClickDeleteQuestion(id2) { + document.getElementById("frage").value = ""; + document.getElementById("antwort").value = ""; + r = confirm('Gesamte Frage löschen?'); + if (r) { + $.ajax({ + type: 'POST', + url: '../controller/admin_erfassen.php', + data: { + 'function': 'deleteQuestion', + 'id2': id2 + }, + success: function(result) { + // document.getElementById("del").innerHTML = "entfernt"; + //Text einblenden geht nicht, da ein Refresh gemacht wird. Dann sieht man den Text nicht + $(document).ajaxStop(function(){ + window.location = "?action=fragen&erfassen=1"; + }); + } + }); + } +} \ No newline at end of file diff --git a/templates/modern/admin/survey_erfassen.html b/templates/modern/admin/survey_erfassen.html index 4933590..2349d8f 100644 --- a/templates/modern/admin/survey_erfassen.html +++ b/templates/modern/admin/survey_erfassen.html @@ -281,6 +281,11 @@ {literal} +function keysave(ele) { + if(event.key === 'Enter') { + erfassensave(); + } +} $(document).ready(function() { @@ -368,7 +373,9 @@ - - {/if} + + +
{$result_headline}
+ +({$result_datum_von} bis {$result_datum_bis})
+Vollständige Teilnehmer | +{$result_anz_fertige} | +
---|---|
Teilweise beantwortet | +{$result_anz_angefangen} | +
{$table_data[table_data].frage}
({$table_data[table_data].anz_userfrage} Personen)
(Multiple Choice Frage)
+ {/if} + {section name=inner loop=$table_data[table_data].inner} +Bemerkungen |
+
---|
{$table_data3[table_data3].freitext} | +
tpl_vars['result_headline']->value;?> +
+ +(tpl_vars['result_datum_von']->value;?> + bis tpl_vars['result_datum_bis']->value;?> +)
+Vollständige Teilnehmer | +tpl_vars['result_anz_fertige']->value;?> + | +
---|---|
Teilweise beantwortet | +tpl_vars['result_anz_angefangen']->value;?> + | +
tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['frage'];?>
+
(tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['anz_userfrage'];?>
+ Personen)
(Multiple Choice Frage)
+ + tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['inner']) ? count($_loop) : max(0, (int) $_loop)); +$__section_inner_1_total = $__section_inner_1_loop; +$_smarty_tpl->tpl_vars['__smarty_section_inner'] = new Smarty_Variable(array()); +if ($__section_inner_1_total !== 0) { +for ($__section_inner_1_iteration = 1, $_smarty_tpl->tpl_vars['__smarty_section_inner']->value['index'] = 0; $__section_inner_1_iteration <= $__section_inner_1_total; $__section_inner_1_iteration++, $_smarty_tpl->tpl_vars['__smarty_section_inner']->value['index']++){ +?> +Bemerkungen |
+
---|
tpl_vars['table_data3']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data3']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data3']->value['index'] : null)]['freitext'];?> + | +
tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['frage'];?>
- (tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['anz_userfrage'];?>
+
(tpl_vars['table_data']->value[(isset($_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_table_data']->value['index'] : null)]['anz_userfrage'];?>
Personen)
(Multiple Choice Frage)
diff --git a/templates_c/f5d4a0b4fbdc268efcb11fce31782046bfefabac_0.file.survey_erfassen.html.php b/templates_c/f5d4a0b4fbdc268efcb11fce31782046bfefabac_0.file.survey_erfassen.html.php index 806e373..3969756 100644 --- a/templates_c/f5d4a0b4fbdc268efcb11fce31782046bfefabac_0.file.survey_erfassen.html.php +++ b/templates_c/f5d4a0b4fbdc268efcb11fce31782046bfefabac_0.file.survey_erfassen.html.php @@ -1,18 +1,18 @@ _decodeProperties($_smarty_tpl, array ( 'version' => '3.1.39', - 'unifunc' => 'content_6419aa7c4f4e92_26012688', + 'unifunc' => 'content_6419d8ac51df14_26022447', 'has_nocache_code' => false, 'file_dependency' => array ( 'f5d4a0b4fbdc268efcb11fce31782046bfefabac' => array ( 0 => 'F:\\git\\survey\\templates\\modern\\admin\\survey_erfassen.html', - 1 => 1679403631, + 1 => 1679415462, 2 => 'file', ), ), @@ -20,7 +20,7 @@ if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array ( array ( ), ),false)) { -function content_6419aa7c4f4e92_26012688 (Smarty_Internal_Template $_smarty_tpl) { +function content_6419d8ac51df14_26022447 (Smarty_Internal_Template $_smarty_tpl) { if ($_smarty_tpl->tpl_vars['action']->value == '') {?> @@ -342,6 +342,11 @@ if ($_smarty_tpl->tpl_vars['action']->value == 'fragen') {?> +function keysave(ele) { + if(event.key === 'Enter') { + erfassensave(); + } +} $(document).ready(function() { @@ -434,7 +439,9 @@ if ($_smarty_tpl->tpl_vars['action']->value == 'fragen') {?> src="../js/components/admin_erfassen.js"> > - + + - +