In my previous question to LimeSurvey, I had inquired if it was possible to
limit open survey results to 3 entries per IP per 24 hours
. A few days later, I did fix it myself (as
seen on my site
), but to do so, I both modified the core to add a PluginEvent and wrote a plugin. When plugin functionality exists, I prefer that to forking, but I didn't see another way, other than hoping for a feature request. Here is my core change from 2.67.3:
Code:
--- application/helpers/frontend_helper.php
+++ application/helpers/frontend_helper.php
@@ -1631,7 +1631,13 @@
if($scenarios['tokenRequired']){
doFRender('/survey/frontpage/enterToken', $aEnterTokenData, false);
} else {
- App()->getController()->renderPartial('/survey/frontpage/enterCaptcha', $aEnterTokenData);
+ $event = new PluginEvent('beforeCaptcha');
+ $event->set('surveyId', $surveyid);
+ App()->getPluginManager()->dispatchEvent($event);
+
+ if(!$event->get('hideCaptcha')){
+ App()->getController()->renderPartial('/survey/frontpage/enterCaptcha', $aEnterTokenData);
+ }
}
echo templatereplace(file_get_contents($sTemplateViewPath."endpage.pstpl"),array(),$redata,'frontend_helper[1645]');
I don't know that this is the best method, to simply hide the captcha rather than terminating the session. The plugin does give pretty error messages, but there seems like there should be some better way.
If you want to
see the result, have at it
. My
site that pulls data from the poll
isn't serious, so bogus entries won't cause a problem.
Is there a better way to approach? Should this diff be included for LimeSurvey 3?