View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
09066Feature requestsPluginspublic2015-08-21 15:51
ReporterDenisChenu Assigned ToDenisChenu  
PrioritynormalSeverity@50@ 
Status closedResolutionfixed 
Summary09066: afterSurveyComplete aren't call from Quota
Description

Quota don't send afterSurveyComplete plugin event

Steps To Reproduce

Activate a plugin using afterSurveyComplete (demo plugin is OK).
Add a survey with quota and try survey with this quota : the plugin event don't happen.

Additional Information

Not sure we need exactly same event, but a new set 'quota'/'completed' seems good.

TagsNo tags attached.
Bug heat6
Story point estimate
Users affected %

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2014-06-06 16:15

administrator   ~30069

Well, a survey is not complete if a quota is fulfilled. So a new event is needed.

DenisChenu

DenisChenu

2014-06-06 17:47

developer   ~30073

This quota system need some rewrite, and move to a specific controllers and/or helpers.
I never know if it's best to use helper or controller ;).

Did a core system (not a plugin) can use plugin event ? Here : we can use beforeSurveyPage (i think) for test quota/set token to Q/ show the page to the user.

mdekker

mdekker

2014-06-11 15:39

reporter   ~30080

I found an error with quota: i added the same question with multiple answers

example: register for event 1) morning, 2) afternoon, 3) all day
I want to count all in the morning so i need to add 1 and 3
and for afternoon i count 2 and 3
This does not show correct in the quota screen. I also noticed that checking during survey is done in fontend_helper -> checkQuota and for admin display on common_helper -> getquotacompletedcount

These two should be merged into one, preferrably on one of the models (survey or quota, i don't really care)

mdekker

mdekker

2014-06-11 15:46

reporter   ~30081

(No time to investigate further, and no git at hand... this is my edited common_helper:

/**

  • Returns the number of answers matching the quota
  • @param int $iSurveyId - Survey identification number
  • @param int $quotaid - quota id for which you want to compute the completed field
  • @return mixed - Integer of matching entries in the result DB or 'N/A'
    */
    function getQuotaCompletedCount($iSurveyId, $quotaid)
    {
    $result = "N/A";
    if(!tableExists("survey{$iSurveyId}")) // Yii::app()->db->schema->getTable('{{survey' . $iSurveyId . '}}' are not updated even after Yii::app()->db->schema->refresh();
    return $result;
    $quota_info = getQuotaInformation($iSurveyId, Survey::model()->findByPk($iSurveyId)->language, $quotaid);
    $quota = $quotainfo[0];
    if (Yii::app()->db->schema->getTable('{{survey
    ' . $iSurveyId . '}}') &&
    count($quota['members']) > 0)
    {
    // Keep a list of fields for easy reference
    $fields_list = array();

    // Construct an array of value for each $quota['members']['fieldnames']
    $fields_query = array();
    
    foreach ($quota['members'] as $member)
    {
        foreach ($member['fieldnames'] as $fieldname)
        {
            if (!in_array($fieldname, $fields_list))
                $fields_list[] = $fieldname;
    
            $fields_query[$fieldname][] = $member['value'];
        }
    
    }
    
    $criteria = new CDbCriteria;
    
    foreach ($fields_list as $fieldname) {
         $criteria->addInCondition(Yii::app()->db->quoteColumnName($fieldname), $fields_query[$fieldname]);
    }
    $criteria->mergeWith(array('condition'=>"submitdate IS NOT NULL"));
    $result = SurveyDynamic::model($iSurveyId)->count($criteria);

    }

    return $result;
    }

DenisChenu

DenisChenu

2014-06-11 17:06

developer   ~30084

Seems beter here, and surely rigth ... not same function for same behaviour ... :)

DenisChenu

DenisChenu

2014-07-01 18:19

developer   ~30253

Last edited: 2014-07-01 18:21

Rewriting checkQuota, using getQuotaCompletedCount then we can update getQuotaCompletedCount with better count

@mdekker : You can report the second problem with quota on multi question type ?

DenisChenu

DenisChenu

2014-07-02 18:36

developer   ~30257

@mdekker : with some inspiration from your fix : http://bugs.limesurvey.org/plugin.php?page=Source/view&id=14308

Some other thing to do in quota

DenisChenu

DenisChenu

2014-07-05 17:15

developer   ~30278

Documentation :http://manual.limesurvey.org/AfterSurveyQuota

Related Changesets

LimeSurvey: master 0bbcb174

2014-07-02 16:34:45

DenisChenu

Details Diff
Fixed issue 09127: Invalid quota broke quota view
Fixed issue : Miscalculation of completed quota for Multi Question type
Dev: see :http://bugs.limesurvey.org/view.php?id=9066#c30080 for miscalculation
Dev: Todo : use getQuotaCompletedCount in checkQuota function
Dev: Todo remove quota members when removing a sub question, but allways need a fix for old survey
Affected Issues
09066, 09127
mod - application/helpers/common_helper.php Diff File

LimeSurvey: master 53503581

2014-07-05 15:03:12

DenisChenu

Details Diff
Fixed issue 07895: Quota are not tested for hidden question (relevance to 1)
New feature 09066: afterSurveyComplete aren't call from Quota : afterSurveyQuota
Dev: update all function needed for quota system
Affected Issues
07895, 09066
mod - application/helpers/common_helper.php Diff File
mod - application/helpers/expressions/em_manager_helper.php Diff File
mod - application/helpers/frontend_helper.php Diff File

LimeSurvey: master 2bef7def

2014-07-05 15:28:14

DenisChenu

Details Diff
Dev: 09066 child : use autoload_url for quota Affected Issues
07895, 09066
mod - application/helpers/frontend_helper.php Diff File

Issue History

Date Modified Username Field Change
2014-06-04 11:58 DenisChenu New Issue
2014-06-06 16:15 c_schmitz Note Added: 30069
2014-06-06 17:47 DenisChenu Note Added: 30073
2014-06-11 15:39 mdekker Note Added: 30080
2014-06-11 15:46 mdekker Note Added: 30081
2014-06-11 17:06 DenisChenu Note Added: 30084
2014-07-01 18:19 DenisChenu Note Added: 30253
2014-07-01 18:20 DenisChenu Note Edited: 30253
2014-07-01 18:21 DenisChenu Note Edited: 30253
2014-07-02 18:36 DenisChenu Changeset attached => LimeSurvey master 0bbcb174
2014-07-02 18:36 DenisChenu Note Added: 30257
2014-07-02 18:37 DenisChenu Assigned To => DenisChenu
2014-07-02 18:37 DenisChenu Status new => assigned
2014-07-05 17:14 DenisChenu Changeset attached => LimeSurvey master 53503581
2014-07-05 17:14 DenisChenu Project Bug reports => Feature requests
2014-07-05 17:15 DenisChenu Status assigned => resolved
2014-07-05 17:15 DenisChenu Fixed in Version => 2.05+
2014-07-05 17:15 DenisChenu Resolution open => fixed
2014-07-05 17:15 DenisChenu Note Added: 30278
2014-07-05 17:15 DenisChenu Status resolved => feedback
2014-07-05 17:15 DenisChenu Resolution fixed => reopened
2014-07-05 17:16 DenisChenu Status feedback => resolved
2014-07-05 17:16 DenisChenu Resolution reopened => fixed
2014-07-05 17:30 DenisChenu Changeset attached => LimeSurvey master 2bef7def
2015-08-21 15:51 c_schmitz Status resolved => closed