In this thread:
www.limesurvey.org/forum/can-i-do-this-w...ow-survey-data-total
someone asked (again) to access to the previous answers of a given token from the survey itself.
We're often asked for those kind of functionalities, so I did it to show how to proceed:
github.com/LimeSurvey/LimeSurvey/commit/...bda5204cdcc8750efe16
For now, it implies to change a bit the core (internal.php and LS_Twig_Extension.php), but we will make it modular in the upcoming versions of LimeSurvey.
As you can see, in LS_Twig_Extension you can add new twig functions, written in PHP, that can access the DB via the models. So from here, you can do what ever you want. The function in LS_Twig_Extension must be then made accessible in the Sand Box inside internal.php (for security reason). From here, you can call that function from any twig file (survey/question theme)