View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 12622 | Feature requests | _ Unknown | public | 2017-08-23 13:36 | 2017-08-23 13:49 |
| Reporter | crest | Assigned To | |||
| Priority | none | Severity | feature | ||
| Status | new | Resolution | open | ||
| Summary | 12622: New feature "Response rate" in admin survey list | ||||
| Description | Hi, as i already described in the forum[1], it would be great if you can re-implement the feature "Response Rate" which get lost after updating from 1.91 to 2.xx version of Limesurvey. LouisGac suggested to open a feature request. the Feature was implemented in: "Changes from 1.87+ (build 8518) to 1.90+ (build 9561) Legend: # updated feature, - bug fix": and is not available anymore in the 2.xx branch. I try to migrate the code from the 1.91 branch version 2.67.3 of limesurvey. A patch which i used to implement the feature in our production environment and a screenshot of the working code is attached. Thanks, | ||||
| Tags | No tags attached. | ||||
| Attached Files | responserate_diff.txt (2,636 bytes)
diff --git a/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php b/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
index e1463106c..5c8d41a7a 100644
--- a/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
+++ b/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
@@ -127,6 +127,14 @@
),
array(
+ 'header' => gT('Response Rate'),
+ 'name' => 'response_rate',
+ 'type' => 'raw',
+ 'value'=>'CHtml::link($data->responseRate . "%", Yii::app()->createUrl("admin/survey/sa/view/",array("surveyid"=>$data->sid)))',
+ 'htmlOptions' => array('class' => 'has-link'),
+ ),
+
+ array(
'header' => '',
'name' => 'actions',
'value'=>'$data->buttons',
diff --git a/application/models/Survey.php b/application/models/Survey.php
index 75fe90480..8b98b8397 100644
--- a/application/models/Survey.php
+++ b/application/models/Survey.php
@@ -106,6 +106,7 @@ class Survey extends LSActiveRecord
private $fac;
private $pac;
+ private $responseRate;
/**
* init to set default
@@ -1323,4 +1324,36 @@ class Survey extends LSActiveRecord
$criteria->addNotInCondition('title', CHtml::listData($validSubQuestion,'title','title'));
Question::model()->deleteAll($criteria);// Must log count of deleted ?
}
+
+ public function getResponseRate()
+ {
+ if ($this->responseRate!=null)
+ {
+ return $this->responseRate;
+ }
+ else {
+ $table = '{{tokens_' . $this->sid . '}}';
+ if (tableExists("$table"))
+ {
+ $tokencount = Yii::app()->db->createCommand('SELECT count(tid) FROM ' . $table )->queryScalar();
+ //get the number of COMLETED tokens for each survey
+ $tokencompleted = $this->getCountTotalAnswers();
+
+ if($tokencompleted != 0 && $tokencount != 0)
+ {
+ $tokenpercentage = round(($tokencompleted / $tokencount) * 100, 1);
+ }
+ else
+ {
+ $tokenpercentage = 0;
+ }
+ }
+ else
+ {
+ $tokenpercentage = 0;
+ }
+ $this->responseRate = $tokenpercentage;
+ return $tokenpercentage;
+ }
+ }
}
| ||||
| Bug heat | 2 | ||||
| Story point estimate | |||||
| Users affected % | |||||
|
Ups I just take a look at my screenshot and recongnizes that there are responserates > 100%. I accidentally used $tokencompleted = $this->getCountFullAnswers(); instead of $tokencompleted = $this->getCountTotalAnswers(); fixed patch with updated screenshot attached. Regards, responserate.diff (2,633 bytes)
diff --git a/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php b/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
index e1463106c..5c8d41a7a 100644
--- a/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
+++ b/application/extensions/admin/survey/ListSurveysWidget/views/listSurveys.php
@@ -127,6 +127,14 @@
),
array(
+ 'header' => gT('Response Rate'),
+ 'name' => 'response_rate',
+ 'type' => 'raw',
+ 'value'=>'CHtml::link($data->responseRate . "%", Yii::app()->createUrl("admin/survey/sa/view/",array("surveyid"=>$data->sid)))',
+ 'htmlOptions' => array('class' => 'has-link'),
+ ),
+
+ array(
'header' => '',
'name' => 'actions',
'value'=>'$data->buttons',
diff --git a/application/models/Survey.php b/application/models/Survey.php
index 75fe90480..a5ee1fac2 100644
--- a/application/models/Survey.php
+++ b/application/models/Survey.php
@@ -106,6 +106,7 @@ class Survey extends LSActiveRecord
private $fac;
private $pac;
+ private $responseRate;
/**
* init to set default
@@ -1323,4 +1324,35 @@ class Survey extends LSActiveRecord
$criteria->addNotInCondition('title', CHtml::listData($validSubQuestion,'title','title'));
Question::model()->deleteAll($criteria);// Must log count of deleted ?
}
+
+ public function getResponseRate()
+ {
+ if ($this->responseRate!=null)
+ {
+ return $this->responseRate;
+ }
+ else {
+ $table = '{{tokens_' . $this->sid . '}}';
+ if (tableExists("$table"))
+ {
+ $tokencount = Yii::app()->db->createCommand('SELECT count(tid) FROM ' . $table )->queryScalar();
+ //get the number of COMLETED tokens for each survey
+ $tokencompleted = $this->getCountFullAnswers();
+ if($tokencompleted != 0 && $tokencount != 0)
+ {
+ $tokenpercentage = round(($tokencompleted / $tokencount) * 100, 1);
+ }
+ else
+ {
+ $tokenpercentage = 0;
+ }
+ }
+ else
+ {
+ $tokenpercentage = 0;
+ }
+ $this->responseRate = $tokenpercentage;
+ return $tokenpercentage;
+ }
+ }
}
|
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2017-08-23 13:36 | crest | New Issue | |
| 2017-08-23 13:36 | crest | File Added: responserate_diff.txt | |
| 2017-08-23 13:36 | crest | File Added: responserate.PNG | |
| 2017-08-23 13:49 | crest | File Added: responserate-2.PNG | |
| 2017-08-23 13:49 | crest | File Added: responserate.diff | |
| 2017-08-23 13:49 | crest | Note Added: 44336 |