2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Can define centre and project information in administrative menu

Able to edit questionnaires RS text and name
Can disable/enable questionnaires for viewing in admin interface
RS text entered via new CKEditor including ability to insert tokens/template replace text
Added setting table and associated getter/setter functions (currently only used for centre information but could add more)
This commit is contained in:
azammitdcarf
2011-01-18 03:32:21 +00:00
parent ca02adf4c2
commit e5615b708a
628 changed files with 117476 additions and 21 deletions

73
admin/centreinfo.php Normal file
View File

@@ -0,0 +1,73 @@
<?
/**
* Set information about this centre for diplay to operators
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011
* @package queXS
* @subpackage admin
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
*/
/**
* Configuration file
*/
include("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* CKEditor
*/
include("../include/ckeditor/ckeditor.php");
global $db;
$CKEditor = new CKEditor();
if (isset($_POST['information']))
{
set_setting("information",$_POST['information']);
}
xhtml_head(T_("Set centre information"),true,false,array("../js/window.js"));
?>
<form action="" method="post"><p>
<label for="information"><? echo T_("Set centre information: "); ?></label><? echo $CKEditor->editor("information",get_setting("information")); ?>
<input type="submit" name="update" value="<? echo T_("Update centre information"); ?>"/></p>
</form>
<?
xhtml_foot();
?>

View File

@@ -132,6 +132,7 @@ if (isset($_POST['submit']))
$sql = "SELECT questionnaire_id,description
FROM questionnaire
WHERE enabled = 1
ORDER by questionnaire_id ASC";
$questionnaires = $db->GetAll($sql);

View File

@@ -50,6 +50,7 @@ print "<div id='menu'><ul class='navmenu'>";
print "<li><h3>" . T_("Questionnaire creation and management") . "</h3>";
print "<ul><li><a href=\"?page=new.php\">" . T_("Create a new questionnaire") . "</a></li>";
print "<li><a href=\"?page=questionnairelist.php\">" . T_("Questionnaire management") . "</a></li>";
print "<li><a href=\"?page=" . LIME_URL . "admin/admin.php\">" . T_("Administer questionnaires with Limesurvey") . "</a></li>";
print "<li><a href=\"?page=import.php\">" . T_("Import a sample file (in CSV form)") . "</a></li>";
print "<li><a href=\"?page=assignsample.php\">" . T_("Assign samples to questionnaires") . "</a></li>";
@@ -85,7 +86,8 @@ print "<li><a href=\"?page=shiftreport.php\">" . T_("Shift reports") . "</a></li
print "<li><h3>" . T_("System settings") . "</h3>";
print "<ul><li><a href=\"?page=timezonetemplate.php\">" . T_("Set default timezone list") . "</a></li>";
print "<li><a href=\"?page=shifttemplate.php\">" . T_("Set default shift times") . "</a></li>";
print "<li><a href=\"?page=callrestrict.php\">" . T_("Set call restriction times") . "</a></li></ul></li>";
print "<li><a href=\"?page=callrestrict.php\">" . T_("Set call restriction times") . "</a></li>";
print "<li><a href=\"?page=centreinfo.php\">" . T_("Set centre information") . "</a></li></ul></li>";
if (VOIP_ENABLED)
{

View File

@@ -49,6 +49,11 @@ include ("../functions/functions.xhtml.php");
*/
include("../functions/functions.input.php");
/**
* CKEditor
*/
include("../include/ckeditor/ckeditor.php");
global $db;
xhtml_head(T_("New: Create new questionnaire"),true,false,array("../js/new.js"));
@@ -70,11 +75,12 @@ if (isset($_POST['import_file']))
if ($_POST['selectrs'] != "none") $rs = 1;
$name = $db->qstr($_POST['description'],get_magic_quotes_gpc());
$rs_intro = $db->qstr($_POST['rs_intro'],get_magic_quotes_gpc());
$rs_project_intro = $db->qstr($_POST['rs_project_intro'],get_magic_quotes_gpc());
$rs_project_end = $db->qstr($_POST['rs_project_end'],get_magic_quotes_gpc());
$rs_callback = $db->qstr($_POST['rs_callback'],get_magic_quotes_gpc());
$rs_answeringmachine = $db->qstr($_POST['rs_answeringmachine'],get_magic_quotes_gpc());
$rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],get_magic_quotes_gpc()));
$rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],get_magic_quotes_gpc()));
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],get_magic_quotes_gpc()));
$rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],get_magic_quotes_gpc()));
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],get_magic_quotes_gpc()));
$info = $db->qstr(html_entity_decode($_POST['info'],get_magic_quotes_gpc()));
if ($_POST['select'] == "new")
{
@@ -99,8 +105,8 @@ if (isset($_POST['import_file']))
$lime_rs_sid = bigintval($_POST['selectrs']);
}
$sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid)
VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid)";
$sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info)
VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info)";
$rs = $db->Execute($sql);
@@ -156,21 +162,43 @@ if (!empty($surveys))
print "<option onclick=\"hide(this, 'rstext');\" value=\"{$s['sid']}\">" . T_("Existing questionnaire:") . " {$s['title']}</option>";
}
}
$CKEditor = new CKEditor();
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
"/",
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array('BidiLtr', 'BidiRtl'),
array('Link','Unlink','Anchor'),
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
"/",
array('Styles','Format','Font','FontSize'),
array('TextColor','BGColor'),
array('About')),
"extraPlugins" => "tokens");
?></select></p>
<p><? echo T_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" checked="checked"/></p>
<p><? echo T_("Restrict work to shifts?"); ?> <input name="rws" type="checkbox" checked="checked"/></p>
<p><? echo T_("Questionnaire for testing only?"); ?> <input name="testing" type="checkbox"/></p>
<div id='rstext' style='display:none;'>
<p><? echo T_("Respondent selection introduction:"); ?> <textarea cols="40" rows="4" name="rs_intro"></textarea></p>
<p><? echo T_("Respondent selection project introduction:"); ?> <textarea cols="40" rows="4" name="rs_project_intro"></textarea></p>
<p><? echo T_("Respondent selection callback (already started questionnaire):"); ?> <textarea cols="40" rows="4" name="rs_callback"></textarea></p>
<p><? echo T_("Message to leave on an answering machine:"); ?> <textarea cols="40" rows="4" name="rs_answeringmachine"></textarea></p>
<p><? echo T_("Respondent selection introduction:"); echo $CKEditor->editor("rs_intro","",$ckeditorConfig);?></p>
<p><? echo T_("Respondent selection project introduction:"); echo $CKEditor->editor("rs_project_intro","",$ckeditorConfig);?></p>
<p><? echo T_("Respondent selection callback (already started questionnaire):"); echo $CKEditor->editor("rs_callback","",$ckeditorConfig);?> </p>
<p><? echo T_("Message to leave on an answering machine:"); echo $CKEditor->editor("rs_answeringmachine","",$ckeditorConfig);?> </p>
</div>
<p><? echo T_("Project end text (thank you screen):"); ?> <textarea cols="40" rows="4" name="rs_project_end"></textarea></p>
<p><? echo T_("Project end text (thank you screen):");echo $CKEditor->editor("rs_project_end","",$ckeditorConfig); ?></p>
<p><? echo T_("Project information for interviewers/operators:");echo $CKEditor->editor("info","",$ckeditorConfig);?></p>
<p><input type="submit" name="import_file" value="<? echo T_("Create Questionnaire"); ?>"/></p>
</form>
<?
xhtml_foot();
?>

View File

@@ -132,6 +132,7 @@ if (isset($_POST['submit']))
$sql = "SELECT questionnaire_id,description
FROM questionnaire
WHERE enabled = 1
ORDER by questionnaire_id ASC";
$questionnaires = $db->GetAll($sql);

207
admin/questionnairelist.php Normal file
View File

@@ -0,0 +1,207 @@
<?
/**
* Manage questionnaires by editing them or disabling/enabling them
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011
* @package queXS
* @subpackage admin
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
/**
* CKEditor
*/
include("../include/ckeditor/ckeditor.php");
global $db;
if (isset($_GET['disable']))
{
$questionnaire_id = intval($_GET['disable']);
$sql = "UPDATE questionnaire
SET enabled = 0
WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
}
if (isset($_GET['enable']))
{
$questionnaire_id = intval($_GET['enable']);
$sql = "UPDATE questionnaire
SET enabled = 1
WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
}
if (isset($_POST['update']) && isset($_GET['modify']))
{
$questionnaire_id = intval($_GET['modify']);
$ras =0;
$rws = 0;
$rs = 0;
if (isset($_POST['ras'])) $ras = 1;
if (isset($_POST['rws'])) $rws = 1;
$name = $db->qstr(html_entity_decode($_POST['description']));
if (isset($_POST['rs_intro']))
{
$rs = 1;
$rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro']));
$rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro']));
$rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback']));
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine']));
}
$info = $db->qstr(html_entity_decode($_POST['info']));
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],true));
$sql = "UPDATE questionnaire
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws'
WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
if ($rs)
{
$sql = "UPDATE questionnaire
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine
WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
}
}
xhtml_head(T_("Questionnaire list"),true,array("../css/table.css"));
if (isset($_GET['modify']))
{
$questionnaire_id = intval($_GET['modify']);
$CKEditor = new CKEditor();
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
"/",
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array('BidiLtr', 'BidiRtl'),
array('Link','Unlink','Anchor'),
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
"/",
array('Styles','Format','Font','FontSize'),
array('TextColor','BGColor'),
array('About')),
"extraPlugins" => "tokens");
$sql = "SELECT *
FROM questionnaire
WHERE questionnaire_id = $questionnaire_id";
$rs = $db->GetRow($sql);
$testing = $rws = $ras = "checked=\"checked\"";
if ($rs['restrict_appointments_shifts'] != 1) $ras = "";
if ($rs['restrict_work_shifts'] != 1) $rws = "";
if ($rs['testing'] != 1) $testing = "";
echo "<h1>" . $rs['description'] . "</h1>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit questionnaire in Limesurvey") . "</a></p>";
?>
<form action="?modify=<? echo $questionnaire_id; ?>" method="post">
<p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<? echo $rs['description']; ?>"/></p>
<p><? echo T_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" <? echo $ras; ?>/></p>
<p><? echo T_("Restrict work to shifts?"); ?> <input name="rws" type="checkbox" <? echo $rws; ?>/></p>
<p><? echo T_("Questionnaire for testing only?"); ?> <input name="testing" type="checkbox" disabled="true" <? echo $testing; ?>/></p>
<? if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) { ?>
<p><? echo T_("Respondent selection introduction:"); echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);?></p>
<p><? echo T_("Respondent selection project introduction:"); echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);?></p>
<p><? echo T_("Respondent selection callback (already started questionnaire):"); echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);?> </p>
<p><? echo T_("Message to leave on an answering machine:"); echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);?> </p>
<? } else if (!empty($rs['lime_rs_sid'])) { echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_rs_sid']}'>" . T_("Edit respondent selection instrument in Limesurvey") . "</a></p>"; } ?>
<p><? echo T_("Project end text (thank you screen):");echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); ?></p>
<p><? echo T_("Project information for interviewers/operators:");echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig); ?></p>
<p><input type="submit" name="update" value="<? echo T_("Update Questionnaire"); ?>"/></p>
</form>
<?
}
else
{
$columns = array("description","enabledisable","modify");
$titles = array(T_("Questionnaire"),T_("Enable/Disable"),("Modify"));
$sql = "SELECT
description,
CASE WHEN enabled = 0 THEN
CONCAT('<a href=\'?enable=',questionnaire_id,'\'>" . T_("Enable") . "</a>')
ELSE
CONCAT('<a href=\'?disable=',questionnaire_id,'\'>" . T_("Disable") . "</a>')
END
as enabledisable,
CONCAT('<a href=\'?modify=',questionnaire_id,'\'>" . T_("Modify"). "</a>') as modify
FROM questionnaire";
$rs = $db->GetAll($sql);
xhtml_table($rs,$columns,$titles);
}
xhtml_foot();
?>

View File

@@ -100,7 +100,8 @@ xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill")
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire";
FROM questionnaire
WHERE enabled = 1";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");

View File

@@ -110,7 +110,8 @@ xhtml_head(T_("Quota management"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire";
FROM questionnaire
WHERE enabled = 1";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");

View File

@@ -120,7 +120,8 @@ xhtml_head(T_("Quota row management"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire";
FROM questionnaire
WHERE enabled = 1";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");