Skip to content

Commit

Permalink
Bugfix and works with Limesurvey Version 3.15.6+190108
Browse files Browse the repository at this point in the history
tt33tt
  • Loading branch information
tt33tt committed Jun 4, 2019
1 parent bc546ed commit c5e4706
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Reportico.php
@@ -1,5 +1,5 @@
<?php
class Reportico extends \ls\pluginmanager\PluginBase {
class Reportico extends LimeSurvey\PluginManager\PluginBase {


protected $storage = 'DbStorage';
Expand All @@ -9,7 +9,7 @@ class Reportico extends \ls\pluginmanager\PluginBase {
public $engine;
private $_assetsUrl;

public function __construct(PluginManager $manager, $id) {
public function __construct(LimeSurvey\PluginManager\PluginManager $manager, $id) {
parent::__construct($manager, $id);

/**
Expand Down
2 changes: 1 addition & 1 deletion ReporticoAdminMenuItem.php
@@ -1,5 +1,5 @@
<?php
class ReporticoAdminMenuItem extends \ls\menu\MenuItem {
class ReporticoAdminMenuItem extends LimeSurvey\Menu\MenuItem {

public function __construct($options) {
parent::__construct($options);
Expand Down
2 changes: 1 addition & 1 deletion ReporticoMainMenu.php
@@ -1,5 +1,5 @@
<?php
class ReporticoMainMenu extends \ls\menu\Menu {
class ReporticoMainMenu extends LimeSurvey\Menu\Menu {

public function __construct($options) {
parent::__construct($options);
Expand Down
2 changes: 1 addition & 1 deletion ReporticoMenuItem.php
@@ -1,5 +1,5 @@
<?php
class ReporticoMenuItem extends \ls\menu\MenuItem {
class ReporticoMenuItem extends LimeSurvey\Menu\MenuItem {

public function __construct($options) {
parent::__construct($options);
Expand Down
2 changes: 0 additions & 2 deletions components/reportico.php
Expand Up @@ -8913,8 +8913,6 @@ function get_value_delimiter()

}



// Setup SESSION
//set_up_reportico_session();

Expand Down
81 changes: 81 additions & 0 deletions components/reportico_defaults.php
Expand Up @@ -155,4 +155,85 @@ function reportico_defaults($reportico)
$reportico->create_page_footer("F1", 2, "Page: {PAGE}{STYLE border-width: 1 0 0 0; margin: 40 0 0 0; font-style: italic; }" );
}
}

/*
* Creates a denormalized representation of lime_survey_xxxxx table
* for easy joining row by row questions, answers and actual responses
* Creates a temporary table
*
* Parameters
* engine - reference to the reportico process in order yo
*/

function denormalize_survey_responses($engine)
{
$survey = $engine->get_criteria_value("survey");
$group = $engine->get_criteria_value("group");

$swhere = "";
$gwhere = "";
if ( $survey ) $swhere = " AND s.sid in ( $survey )";
if ( $group ) $gwhere = " AND g.gid in ( $group )";
$sql = "select s.sid, g.gid, q.qid,
g.group_name,
q.title,
q.question,
q.type,
cq.title ch_title,
CASE
WHEN cq.title IS NOT NULL THEN concat(s.sid, 'X', g.gid, 'X', q.qid, cq.title )
ELSE concat(s.sid, 'X', g.gid, 'X', q.qid )
END id
from lime_surveys s
join lime_groups g ON g.sid = s.sid $swhere $gwhere
join lime_questions q ON q.gid = g.gid AND q.parent_qid = 0
left join lime_questions cq ON cq.parent_qid = q.qid
where 1 = 1
";

$stmt = Yii::app()->db->createCommand($sql)->queryAll();
//echo "<PRE>";
$unions = [];
foreach ( $stmt as $row )
{
$unions[] = sprintf("SELECT '%s' group_name, \n
'%s' title, \n
'%s' question, \n
'%s' type, \n
'%s' id, \n
'%s' qid, \n
'%s' gid, \n
'%s' ch_title, \n
s.%s code, \n
0 count
FROM lime_survey_%s AS s \n
LEFT JOIN lime_answers AS a \n
ON a.code = s.%s
AND a.qid = '%s' \n",
$row["group_name"],
$row["title"],
preg_replace("/'/", "/\'/", $row["question"]),
$row["type"],
$row["id"],
$row["qid"],
$row["gid"],
$row["ch_title"],
$row["id"],
$row["sid"],
$row["id"],
$row["qid"]);
}

$union = implode( "\nUNION ALL\n", $unions);

$union = "CREATE TEMPORARY TABLE t_answers AS $union";
$stmt = Yii::app()->db->createCommand($union)->execute();

//echo "<PRE>";
//echo $the_union;
//echo "</PRE>";

$sql = "UPDATE t_answers SET count = 1 WHERE code IS NOT NULL";
return Yii::app()->db->createCommand($sql)->execute();
}
?>
2 changes: 1 addition & 1 deletion components/reportico_report_html.php
Expand Up @@ -142,7 +142,7 @@ function finish ()
function abs_paging_height($height_string)
{
$height = (int)$height_string;
if ( strstr($height_string, "%" ) )
if ( $this->page_height && strstr($height_string, "%" ) ) //Bugfix
{
$height = (int)
( $this->page_height * $height_string ) / 100;
Expand Down
1 change: 0 additions & 1 deletion config.php
Expand Up @@ -10,7 +10,6 @@
'path_to_assets' => 'packages/reportico/reportico',

// Path relative to laravel pase or fully where projects will be created
//'path_to_projects' => __DIR__."/components/projects",
'path_to_projects' => Yii::app()->getRuntimePath()."/reportico/projects",

// Path relative to laravel pase or fully where admin project will be stored
Expand Down

0 comments on commit c5e4706

Please sign in to comment.