<?php
namespace Claromentis\Quiz\Service\DataTable;

$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] ?: array()) + array("_67a0d624ae" . "bcceb0abd5c" . "e56a53ff06f" => base64_decode("ZGF0" . "ZQ=="), "_a848977a8b89eec21b" . "2e7f0adfa6667c" => base64_decode("cXVpei5zdGF0aXN0aWNzLm5hbW" . "U="), "_8dabb06efc95df4cff7c4afe" . "91857b53" => base64_decode("bm" . "Ft" . "ZQ" . "=="), "_c7f63fb39546fbf" . "14a63bba74acf0b2" . "3" => base64_decode("cXVpei5zdGF0aXN0aWNzLm" . "RhdGU="), "_4d707fab93bebb00bb" . "e69e8159697c90" => base64_decode(""), "_9137964f9a338e8" . "9f979757c23fc020" . "d" => base64_decode("Y3JlYXRl" . "ZF9kYXRl" . "IERFU0M="), "_fc4332281354cbd9808cb1a2c9" . "4c383d" => base64_decode("YW5zd2" . "Vy"), "question" . "_id" => base64_decode("cXVlc3Rpb25f" . "aWQ="), "survey_" . "id" => base64_decode("c3VydmV5X" . "2lk"), "_49c6565477ee9f822b499a53e6d29" . "95f" => base64_decode("YXJyYXlfa2V5" . "X2V4aXN0cw=="), "_cbc21fb0aa9efa81a0ac7c8beabd6" . "8a8" => base64_decode("cXVpei5zdGF" . "0aXN0aWNzLm" . "Fuc3dlcg=="), "_b0ed79db6e1fd6" . "5ddbfe9918c9643" . "c82" => base64_decode("cXVpei5zdXJ2ZXku" . "YW5vbnltb3Vz"));
use Claromentis\Core\DataTable;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\TextUtil\ClaText;
use Claromentis\Quiz\Facade\AttemptFacade;
use Claromentis\Quiz\Facade\SurveyFacade;
use Claromentis\Quiz\Service\DataTable\Decorator\PlainText;
use Claromentis\Core\Security\SecurityContext;
use User;
class SurveyStatisticsSource implements DataTable\Contract\DataSource
{
    
    
    
    
    use DataTable\Shared\ColumnHelper;
    protected $survey_facade;
    protected $attempt_facade;
    protected $row_count = 0;
    protected $lmsg;
    protected $cla_text;
    public function __construct(SurveyFacade $survey_facade, AttemptFacade $attempt_facade, Lmsg $lmsg, ClaText $cla_text)
    {
        $this->survey_facade = $survey_facade;
        $this->attempt_facade = $attempt_facade;
        $this->lmsg = $lmsg;
        $this->cla_text = $cla_text;
    }
    public function Columns(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915 = null)
    {
        $_a42c86642011ef739b88ee80672c387d = [[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_67a0d624aebcceb0abd5c" . "e56a53ff06f"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c7f63fb395" . "46fbf14a63b" . "ba74acf0b23"]), new PlainText()], [$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_8dabb06efc95df4cff7c4a" . "fe91857b53"], ($this->lmsg)($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_a848977a8b89eec21" . "b2e7f0adfa6667c"]), new PlainText()], [$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_fc4332281354cbd" . "9808cb1a2c94c383" . "d"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_cbc21fb0aa9ef" . "a81a0ac7c8beab" . "d68a8"]), new DataTable\Decorator\TextUnsafe()]];
        return $this->CreateWithColumns($_a42c86642011ef739b88ee80672c387d);
    }
    public function Data(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_03e9164d0a343b742df4793268b80767)
    {
        $survey_id = $_4c4d12d3e4f6cac68e3eecffe9887915->GetValue($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["sur" . "vey" . "_id"]);
        $question_id = $_4c4d12d3e4f6cac68e3eecffe9887915->GetValue($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["question_" . "id"]);
        $_1f50e30be8c2fefa6881834e71d504a2 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetOffset();
        $_f11369824f533e8206f9ccc0c9aab3a0 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetLimit();
        $_e6c850126cff293d170e2d7ab4e2aad4 = $this->attempt_facade->GetSurveyAttempts($survey_id, true, false, $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_9137964f9a338e89f979757c23fc020" . "d"], $_f11369824f533e8206f9ccc0c9aab3a0, $_1f50e30be8c2fefa6881834e71d504a2, $question_id);
        $_a0006f2e6058ce959e86bebdcded2da8 = [];
        foreach ($_e6c850126cff293d170e2d7ab4e2aad4 as $_7adc269a13af5c45b5a1caf4ec75a795) {
            $_438a59ff9a606f4fff68fbed8a95d9fa = $this->attempt_facade->GetAttemptAnswers($_7adc269a13af5c45b5a1caf4ec75a795);
            if (!$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_49c6565477ee9f822b499a53e" . "6d2995f"]($question_id, $_438a59ff9a606f4fff68fbed8a95d9fa)) {
                continue;
            }
            $_fc4332281354cbd9808cb1a2c94c383d = $_438a59ff9a606f4fff68fbed8a95d9fa[$question_id];
            $_64666bcf1e5aaa07774f3d7439ff264d = new \Date($_7adc269a13af5c45b5a1caf4ec75a795->completed_date);
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_67a0d624aebcceb0abd5ce56a53ff" . "06f"]] = $_64666bcf1e5aaa07774f3d7439ff264d->getDate(DATE_FORMAT_ISO);
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_8dabb06efc95df4cff7c4a" . "fe91857b53"]] = User::GetNameById($_7adc269a13af5c45b5a1caf4ec75a795->user_id) ?: ($this->lmsg)($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_b0ed79db6e1" . "fd65ddbfe991" . "8c9643c82"]);
            $_b8cfc2e06d9d1fec1893ea4a054002bf[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_fc43322" . "81354cbd" . "9808cb1a" . "2c94c383" . "d"]] = $this->cla_text->ParseLinks($_fc4332281354cbd9808cb1a2c94c383d->GetResponseText() ?? $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_4d707fab93bebb" . "00bbe69e8159697" . "c90"]);
            $_a0006f2e6058ce959e86bebdcded2da8[] = $_b8cfc2e06d9d1fec1893ea4a054002bf;
        }
        
        
        $this->row_count = $this->attempt_facade->CountSurveyQuestionAnswers($survey_id, $question_id, true);
        return $_a0006f2e6058ce959e86bebdcded2da8;
    }
    
    
    
    
    
    
    
    
    
    public function Count(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_e0bd284b1527841bc9c635873b56303b)
    {
        return $this->row_count;
    }
    
    
    
    
    
    
    public function Filters() : array
    {
        return [];
    }
}