Discussion:
[limesurvey-developers] Quotas on lime 2.05+
Andrea Suisani
2015-03-24 14:14:04 UTC
Permalink
Hi all,

sorry for bothering on the dev mailing list but I think this is
something quite critical.

Limesurvey quota managment doesn't work with postgresql since build
140717, the last working build is 140703.

Tha main problem is that even if the quota limit is reached for a
given Quota group, instead of being redirected to the "over quota"
page the user continue to the next question as if the quota is not set.

Everything work like a charm if mysql is used instead of postgresql.

I've just reported an issue on the bugtracker with all the needed step
to reproduce the problem (I've attached a survey lss file to reproduce
the problem).

http://bugs.limesurvey.org/view.php?id=9587

As I already said in the report I'm not familiar enough either
with limesurvey codebase or with php, hence I'm not able to fix
the problem at hand on my own.

I'm available to perform any kind of needed tests or provide any
further info, though.

regards,
Andrea Suisani.
Andrea Suisani
2015-03-24 15:23:50 UTC
Permalink
All,
Post by Andrea Suisani
Hi all,
[snip]
Post by Andrea Suisani
Tha main problem is that even if the quota limit is reached for a
given Quota group, instead of being redirected to the "over quota"
page the user continue to the next question as if the quota is not set.
Everything work like a charm if mysql is used instead of postgresql.
I've just reported an issue on the bugtracker with all the needed step
to reproduce the problem (I've attached a survey lss file to reproduce
the problem).
http://bugs.limesurvey.org/view.php?id=9587
fixed by d25b7357dddbee3d02a1fa21e975098fe2ce5f8b.

kudos to Denis.

regards,

Andrea
Andrea Suisani
2015-03-26 09:37:29 UTC
Permalink
All,
Post by Andrea Suisani
All,
Post by Andrea Suisani
Hi all,
[snip]
Post by Andrea Suisani
Tha main problem is that even if the quota limit is reached for a
given Quota group, instead of being redirected to the "over quota"
page the user continue to the next question as if the quota is not set.
Everything work like a charm if mysql is used instead of postgresql.
I've just reported an issue on the bugtracker with all the needed step
to reproduce the problem (I've attached a survey lss file to reproduce
the problem).
http://bugs.limesurvey.org/view.php?id=9587
fixed by d25b7357dddbee3d02a1fa21e975098fe2ce5f8b.
kudos to Denis.
I think that the problem is still there.

The aforementioned commit fix the problem only because qlimit was setted to 0
in the test-case survey, and 0 is treated as a special case in the code
(https://github.com/LimeSurvey/LimeSurvey/commit/d25b7357dddbee3d02a1fa21e975098fe2ce5f8b#diff-4f4265af29f654380fbda47407b84a09R1956)

if((int)$aQuotaInfo['qlimit'] < 1){
$aMatchedQuotas[]=$aQuotaInfo;
}else{
$iCompleted=getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);// Return a string
if(ctype_digit($iCompleted) && ((int)$iCompleted >= (int)$aQuotaInfo['qlimit'])) // This remove invalid quota and not completed
$aMatchedQuotas[]=$aQuotaInfo;
}

if qlimit is > 0 the code in the else branch will be executed
and ctype_digit($isCompleted) will be always retun false due to
the fact the $iCompleted, in case you're using postgres, is a
an integer rather than a string.

A workaround could be dropping the ctype_digit check on $iCompelted
assuming that it will be always castable to int (as the code
already doeas in the 'if' condition).

For what is worth I've read the code of yii 1.1.16 (see https://github.com/yiisoft/yii/blob/1.1.16/framework/db/ar/CActiveRecord.php#L1597)
and the value of iCompleted will be always castable to int and the
reason why AR count method return a string is due to willingness to
keep max. precision possible.

regards,
Andrea
Andrea Suisani
2015-03-26 10:12:54 UTC
Permalink
Post by Andrea Suisani
All,
[snip]
Post by Andrea Suisani
Post by Andrea Suisani
Post by Andrea Suisani
http://bugs.limesurvey.org/view.php?id=9587
fixed by d25b7357dddbee3d02a1fa21e975098fe2ce5f8b.
kudos to Denis.
I think that the problem is still there.
The aforementioned commit fix the problem only because qlimit was setted to 0
in the test-case survey, and 0 is treated as a special case in the code
(https://github.com/LimeSurvey/LimeSurvey/commit/d25b7357dddbee3d02a1fa21e975098fe2ce5f8b#diff-4f4265af29f654380fbda47407b84a09R1956)
if((int)$aQuotaInfo['qlimit'] < 1){
$aMatchedQuotas[]=$aQuotaInfo;
}else{
$iCompleted=getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);// Return a string
if(ctype_digit($iCompleted) && ((int)$iCompleted >= (int)$aQuotaInfo['qlimit'])) // This remove invalid quota and not completed
$aMatchedQuotas[]=$aQuotaInfo;
}
if qlimit is > 0 the code in the else branch will be executed
and ctype_digit($isCompleted) will be always retun false due to
the fact the $iCompleted, in case you're using postgres, is a
an integer rather than a string.
A workaround could be dropping the ctype_digit check on $iCompelted
assuming that it will be always castable to int (as the code
already doeas in the 'if' condition).
A "thinko" here, in the main 'if' condition there's no cast of $iCompleted to int.
Nonetheless I think that the proposed workaorund is still valid.

[snip]

regards,
Andrea
Denis Chenu
2015-03-26 14:22:07 UTC
Permalink
Hi Andrea,

I always use bug report and follow it . Then no need to crosspot here :).
http://bugs.limesurvey.org/view.php?id=9587#c31915

Denis
Post by Andrea Suisani
Post by Andrea Suisani
All,
[snip]
Post by Andrea Suisani
Post by Andrea Suisani
Post by Andrea Suisani
http://bugs.limesurvey.org/view.php?id=9587
fixed by d25b7357dddbee3d02a1fa21e975098fe2ce5f8b.
kudos to Denis.
I think that the problem is still there.
The aforementioned commit fix the problem only because qlimit was setted to 0
in the test-case survey, and 0 is treated as a special case in the code
(https://github.com/LimeSurvey/LimeSurvey/commit/d25b7357dddbee3d02a1fa21e975098fe2ce5f8b#diff-4f4265af29f654380fbda47407b84a09R1956)
if((int)$aQuotaInfo['qlimit'] < 1){
$aMatchedQuotas[]=$aQuotaInfo;
}else{
$iCompleted=getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);// Return a string
if(ctype_digit($iCompleted) && ((int)$iCompleted >= (int)$aQuotaInfo['qlimit'])) // This remove invalid quota and not completed
$aMatchedQuotas[]=$aQuotaInfo;
}
if qlimit is > 0 the code in the else branch will be executed
and ctype_digit($isCompleted) will be always retun false due to
the fact the $iCompleted, in case you're using postgres, is a
an integer rather than a string.
A workaround could be dropping the ctype_digit check on $iCompelted
assuming that it will be always castable to int (as the code
already doeas in the 'if' condition).
A "thinko" here, in the main 'if' condition there's no cast of $iCompleted to int.
Nonetheless I think that the proposed workaorund is still valid.
[snip]
regards,
Andrea
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
limesurvey-developers mailing list
https://lists.sourceforge.net/lists/listinfo/limesurvey-developers
Andrea Suisani
2015-03-26 14:48:02 UTC
Permalink
Ok got it.

sorry for the noise.

Andrea
Post by Denis Chenu
Hi Andrea,
I always use bug report and follow it . Then no need to crosspot here :).
http://bugs.limesurvey.org/view.php?id=9587#c31915
Denis
Post by Andrea Suisani
Post by Andrea Suisani
All,
[snip]
Post by Andrea Suisani
Post by Andrea Suisani
Post by Andrea Suisani
http://bugs.limesurvey.org/view.php?id=9587
fixed by d25b7357dddbee3d02a1fa21e975098fe2ce5f8b.
kudos to Denis.
I think that the problem is still there.
The aforementioned commit fix the problem only because qlimit was setted to 0
in the test-case survey, and 0 is treated as a special case in the code
(https://github.com/LimeSurvey/LimeSurvey/commit/d25b7357dddbee3d02a1fa21e975098fe2ce5f8b#diff-4f4265af29f654380fbda47407b84a09R1956)
if((int)$aQuotaInfo['qlimit'] < 1){
$aMatchedQuotas[]=$aQuotaInfo;
}else{
$iCompleted=getQuotaCompletedCount($surveyid, $aQuotaInfo['id']);// Return a string
if(ctype_digit($iCompleted) && ((int)$iCompleted >= (int)$aQuotaInfo['qlimit'])) // This remove invalid quota and not completed
$aMatchedQuotas[]=$aQuotaInfo;
}
if qlimit is > 0 the code in the else branch will be executed
and ctype_digit($isCompleted) will be always retun false due to
the fact the $iCompleted, in case you're using postgres, is a
an integer rather than a string.
A workaround could be dropping the ctype_digit check on $iCompelted
assuming that it will be always castable to int (as the code
already doeas in the 'if' condition).
A "thinko" here, in the main 'if' condition there's no cast of $iCompleted to int.
Nonetheless I think that the proposed workaorund is still valid.
[snip]
regards,
Andrea
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
limesurvey-developers mailing list
https://lists.sourceforge.net/lists/listinfo/limesurvey-developers
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
limesurvey-developers mailing list
https://lists.sourceforge.net/lists/listinfo/limesurvey-developers
Loading...