<?php
namespace Claromentis\Quiz\Controller\Rest\V2;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] ?: array()) + array("_5630a508eaf" . "62fdbab41036" . "2fa17735c" => base64_decode("cGVybWlzc2" . "lvbnM="), "_7adc269a13af5c45b5a1caf4" . "ec75a795" => base64_decode("YXR0Z" . "W1wdA" . "=="), "que" . "sti" . "ons" => base64_decode("cXVlc3Rpb" . "25z"), "_4d707fab93bebb00bbe69e8159697c" . "90" => base64_decode(""), "_b3ee1ca1d7e4bff63ae77" . "7968483325d" => base64_decode("cG9sbA" . "=="), "_79bd87060993ff622ef212c1e8b6a79" . "a" => base64_decode("Rm9y" . "Ymlk" . "ZGVu"), "_e6c850126cff293d170e2d7" . "ab4e2aad4" => base64_decode("YXR0ZW" . "1wdHM="), "_221da17e3055fae8d3ff516b" . "832a5f3b" => base64_decode("cGFnZQ" . "=="), "_9137964f9a338e89" . "f979757c23fc020d" => base64_decode("Y3JlYXRlZ" . "F9kYXRlIE" . "RFU0M="), "_33f09d76394b074b779" . "265f857d5ec8a" => base64_decode("Y291bnR" . "fc2FmZQ" . "=="), "_b8c80e087c6f3f3d1f3c9f67b" . "cec160d" => base64_decode("Y2FuX3ZpZXdfc3RhdGlzdGlj" . "cw=="), "_d054d8ac9359ad6" . "2ec6ae6a8e108b57" . "8" => base64_decode("cXVpei5wb" . "2xsLmVycm" . "9yLm5vX3F" . "1ZXN0aW9u"), "_7f5aa4e96d4b415a8" . "6ed72ebff677cbe" => base64_decode("cX" . "Vl" . "cn" . "k="), "_4a9a895314c5571ef" . "8262129ca6a8044" => base64_decode("Y2FuX3ByZXZpZ" . "Xc="), "i" . "d" => base64_decode("aW" . "Q="), "poll_i" . "d" => base64_decode("cG9sbF9pZA" . "=="), "_0c7db5a15ed94cc1be4b" . "039915fb0814" => base64_decode("Y2FuX3" . "JldGFr" . "ZQ=="), "_c894747360c6ec5bd8169530ea" . "f9c473" => base64_decode("QmFkIF" . "JlcXVl" . "c3Q="), "_f11369824f533e8206f9ccc0c" . "9aab3a0" => base64_decode("bGltaXQ" . "="), "_2622beacb6c" . "29bde687d2f8" . "0c92baef1" => base64_decode("Y2FuX2F0dGVt" . "cHQ="), "_f2d41627f09270f0d" . "bd21d27e02868d7" => base64_decode("cmVzZX" . "Q="), "_08810531932e1a" . "6e70a95d358d14c" . "879" => base64_decode("Y2FuX21hbmFnZQ" . "=="), "_e2a6cc9e" . "f64b3dd21" . "757612b64" . "b07d09" => base64_decode("Y2FuX3Z" . "pZXdfc3" . "RhdHVz"), "_f1af70b59fcba" . "61939cba0f4936" . "7d285" => base64_decode("cG9sbHM" . "="), "_2e8e0758094679b3cb5171c8c3" . "d880f6" => base64_decode("WW91IGNhbiBhZGQgb25seSBvbmUgcXVlc3Rpb24gdG8gdGhl" . "IHBvbGw="), "_a2c1535293d134e0" . "78c87c81de95f1d1" => base64_decode("cG" . "hy" . "YX" . "Nl"), "_f4eafa5f49330" . "6ffdb51a688b21" . "dd507" => base64_decode("dG90YWw" . "="), "_64666bcf1e5aaa07774f3d7439ff" . "264d" => base64_decode("Y29tcGxldGV" . "k"), "quest" . "ion" => base64_decode("cXVlc3Rpb" . "24="), "_54b269a12af880b045" . "f6712e6f865462" => base64_decode("c3" . "Rh" . "dH" . "Vz"), "_cceda818020f" . "abce329230038" . "9f8560a" => base64_decode("YXR0ZW" . "1wdHNf" . "Y291bn" . "Q="), "_4196faadc878e30e23a63bd" . "8ff6d84a9" => base64_decode("cXVpei5yZXBvc2l0b3J5Ln" . "F1ZXN0aW9u"), "_4d23920b3dd84f98af3028a8a3aa25f" . "9" => base64_decode("cXVpei5wb2xsLmVycm9yLm5vdF9mb3" . "VuZA=="));
use Claromentis\Core\Application;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Http\RequestData;
use Claromentis\Core\Http\RequestDataException;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Repository\Exception\NotFoundException;
use Claromentis\Core\REST\RestFormatter;
use Claromentis\People\Exception\PermissionException;
use Claromentis\Quiz\Facade;
use Claromentis\Quiz\Model\Poll;
use Claromentis\Quiz\Permissions\PollPermissions;
use Claromentis\Quiz\Plugin;
use Claromentis\Quiz\Repository;
use Claromentis\Core\TextUtil\ClaText;
use Psr\Http\Message\ServerRequestInterface as Request;
use RestExForbidden;
use RestExNotFound;
use RestExBadRequest;




class PollController
{
    const DEFAULT_LIMIT = 20;
    const MAX_LIMIT = 200;
    
    
    protected $formatter;
    
    
    protected $poll_permission;
    
    
    protected $lmsg;
    
    
    protected $poll_facade;
    
    
    protected $attempt_repo;
    
    
    protected $attempt_facade;
    protected ClaText $cla_text;
    public function __construct(RestFormatter $formatter, PollPermissions $poll_permissions, Lmsg $lmsg, Facade\PollFacade $poll_facade, Repository\AttemptRepository $attempt_repo, Facade\AttemptFacade $attempt_facade, ClaText $cla_text)
    {
        $this->formatter = $formatter;
        $this->poll_permission = $poll_permissions;
        $this->lmsg = $lmsg;
        $this->poll_facade = $poll_facade;
        $this->attempt_repo = $attempt_repo;
        $this->attempt_facade = $attempt_facade;
        $this->cla_text = $cla_text;
    }
    
    
    
    
    
    
    
    
    public function GetPolls(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_b791059c94b285cdf1c90ca6f3a8f2a6, RequestData $request_data) : JsonPrettyResponse
    {
        $_7f5aa4e96d4b415a86ed72ebff677cbe = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_7f5aa4e96d4b415" . "a86ed72ebff677cb" . "e"], $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4d707fab93" . "bebb00bbe69" . "e8159697c90"]);
        $_f11369824f533e8206f9ccc0c9aab3a0 = (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_f11369824f533e820" . "6f9ccc0c9aab3a0"], self::DEFAULT_LIMIT);
        if ($_f11369824f533e8206f9ccc0c9aab3a0 > self::MAX_LIMIT) {
            $_f11369824f533e8206f9ccc0c9aab3a0 = self::MAX_LIMIT;
        }
        $_1f50e30be8c2fefa6881834e71d504a2 = $_f11369824f533e8206f9ccc0c9aab3a0 * (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_221da17e3055fae8d3ff516" . "b832a5f3b"], 0);
        $_54b269a12af880b045f6712e6f865462 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_54b269a12af880b045f6712e6" . "f865462"], $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d707fab93bebb00bbe69e815969" . "7c90"]);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        
        
        $poll_facade = $this->poll_facade;
        $_f1af70b59fcba61939cba0f49367d285 = $poll_facade->GetPolls($user_id, $_54b269a12af880b045f6712e6f865462, $_7f5aa4e96d4b415a86ed72ebff677cbe, $_f11369824f533e8206f9ccc0c9aab3a0, $_1f50e30be8c2fefa6881834e71d504a2);
        return new JsonPrettyResponse($_f1af70b59fcba61939cba0f49367d285);
    }
    
    
    
    
    
    
    
    
    public function GetPoll(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $id) : JsonPrettyResponse
    {
        $_ed5f03d686c37933b5943f295c6b4a43 = [];
        $context = $_6eb6fcb92c942851e079f8ec5fb80324->security;
        
        
        
        
        
        
        $_876ca2097b275e704d71e00d36b3e7c5 = $this->attempt_facade;
        $poll_facade = $this->poll_facade;
        $attempt_repo = $this->attempt_repo;
        try {
            
            
            $_b3ee1ca1d7e4bff63ae777968483325d = $poll_facade->GetPoll($context, $id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4d23920b3dd84f98af3028a8a3aa25" . "f9"]));
        }
        $user_id = $context->GetUserId();
        $_7adc269a13af5c45b5a1caf4ec75a795 = null;
        $_2aee0ce2702cbdc0c9dfe50916d6a1d4 = 0;
        if (!$_b3ee1ca1d7e4bff63ae777968483325d->anonymous) {
            
            
            $_7adc269a13af5c45b5a1caf4ec75a795 = $_876ca2097b275e704d71e00d36b3e7c5->GetLatestAttempt($user_id, Plugin::AGGREGATION_POLL, $id);
            $_2aee0ce2702cbdc0c9dfe50916d6a1d4 = (int) $attempt_repo->CountUserAttempts($user_id, Plugin::AGGREGATION_POLL, $id);
        }
        $_b3ee1ca1d7e4bff63ae777968483325d->setDescription($this->cla_text->ParseLinks($_b3ee1ca1d7e4bff63ae777968483325d->description ?? $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_4d707fab93bebb00bbe69e8159697" . "c90"]));
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_54b269a12af880b045f6712e6f" . "865462"]] = 1;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_b3ee1ca1d7e4bff63ae777968483325" . "d"]] = $_b3ee1ca1d7e4bff63ae777968483325d;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_7adc269a13af5c45b5a1caf4ec75a" . "795"]] = $_7adc269a13af5c45b5a1caf4ec75a795;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_cceda8180" . "20fabce329" . "2300389f85" . "60a"]] = $_2aee0ce2702cbdc0c9dfe50916d6a1d4;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_5630a508eaf62fdbab410362fa1773" . "5c"]] = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_4a9a895314c5571ef8262129ca6a8" . "044"] => $this->poll_permission->CanPreview($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_2622beacb6c2" . "9bde687d2f80c" . "92baef1"] => $this->poll_permission->CanAttempt($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0c7db5a15ed94cc1be4b039915fb081" . "4"] => $this->poll_permission->CanReattempt($_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_08810531932e1a6e70a95d35" . "8d14c879"] => $this->poll_permission->CanManage($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_e2a6cc9ef64b3dd" . "21757612b64b07d0" . "9"] => true, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_b8c80e087c6f3f3d" . "1f3c9f67bcec160d"] => $this->poll_permission->CanViewResults($context, $_b3ee1ca1d7e4bff63ae777968483325d)];
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    public function GetQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $id) : JsonPrettyResponse
    {
        
        
        $poll_facade = $this->poll_facade;
        try {
            
            
            $_b3ee1ca1d7e4bff63ae777968483325d = $poll_facade->GetPoll($_6eb6fcb92c942851e079f8ec5fb80324->security, $id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d23920b3dd84f" . "98af3028a8a3aa2" . "5f9"]));
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["ques" . "tion" . "s"] => $_b3ee1ca1d7e4bff63ae777968483325d->getQuestion()]);
    }
    
    
    
    
    
    
    
    
    
    public function CreatePoll(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_f47b00c53e59541a2cf6ed27c9de2a65) : JsonPrettyResponse
    {
        
        
        
        $poll_facade = $this->poll_facade;
        
        
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_f47b00c53e59541a2cf6ed27c9de2a65);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        
        
        try {
            $_b3ee1ca1d7e4bff63ae777968483325d = $poll_facade->CreatePoll($_f47b00c53e59541a2cf6ed27c9de2a65, $user_id);
            $poll_id = $_b3ee1ca1d7e4bff63ae777968483325d->id ?: null;
            if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_33f09d76394b074b7" . "79265f857d5ec8a"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["ques" . "tion"]]) > 1) {
                throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_2e8e0758094679b3cb5" . "171c8c3d880f6"]);
            }
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["qu" . "es" . "ti" . "on"]] = $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_f2d41627" . "f09270f0d" . "bd21d27e0" . "2868d7"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["quest" . "ion"]]);
            $poll_facade->CreateQuestionForPoll($_f47b00c53e59541a2cf6ed27c9de2a65, $poll_id, $user_id);
            
            
            $_bc03a57aecaf90d056bc199b3782d415 = $poll_facade->GetPoll($_6eb6fcb92c942851e079f8ec5fb80324->security, $poll_id, true);
            
            
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (PermissionException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new RestExForbidden($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage(), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_79bd8706099" . "3ff622ef212c" . "1e8b6a79a"], $_fe441aa3ef350bfb1a1a1ad8520dd530);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f1af70b59fcba61939cba0" . "f49367d285"] => [$_bc03a57aecaf90d056bc199b3782d415], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_f4eafa5f493306ffdb51a688b" . "21dd507"] => $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_33f09d76394b074b779" . "265f857d5ec8a"]($_bc03a57aecaf90d056bc199b3782d415)]);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function EditPoll(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_f47b00c53e59541a2cf6ed27c9de2a65, int $id) : JsonPrettyResponse
    {
        
        
        $poll_facade = $this->poll_facade;
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_f47b00c53e59541a2cf6ed27c9de2a65);
        try {
            $poll_facade->EditPoll($id, $_f47b00c53e59541a2cf6ed27c9de2a65);
            if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_33f09d76394" . "b074b779265f" . "857d5ec8a"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["quest" . "ion"]]) > 1) {
                throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_2e8e0758094679b3cb5171c8c3d" . "880f6"]);
            }
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["questi" . "on"]] = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f2d41627f09270f0dbd21d" . "27e02868d7"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["qu" . "es" . "ti" . "on"]]);
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["poll_" . "id"]] = $id;
            $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
            
            
            $poll_facade->EditQuestionPoll($_f47b00c53e59541a2cf6ed27c9de2a65, $user_id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f1af70b59fcba61939" . "cba0f49367d285"] => $poll_facade->GetPoll($_6eb6fcb92c942851e079f8ec5fb80324->security, $id, true)]);
    }
    
    
    
    
    
    
    
    
    
    public function DeletePoll(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $id) : JsonPrettyResponse
    {
        
        
        $poll_facade = $this->poll_facade;
        try {
            $_4b5e91a0a6f7f822ac389ad9a3fb0ee2 = $poll_facade->DeletePoll($id);
        } catch (\Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_54b269a12af880b045f6712e6f86546" . "2"] => $_4b5e91a0a6f7f822ac389ad9a3fb0ee2]);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function CreateQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_f47b00c53e59541a2cf6ed27c9de2a65, int $id) : JsonPrettyResponse
    {
        
        
        $poll_facade = $this->poll_facade;
        
        
        try {
            $poll_facade->GetPoll($_6eb6fcb92c942851e079f8ec5fb80324->security, $id, true);
            
            
            $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_f47b00c53e59541a2cf6ed27c9de2a65);
            $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
            
            
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["i" . "d"]] = $user_id;
            $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["que" . "sti" . "on"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
            
            
            $poll_facade->CreateQuestionForPoll($_f47b00c53e59541a2cf6ed27c9de2a65, $id, $user_id);
            
            
            $question = $poll_facade->GetQuestionForPoll($id, true);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (PermissionException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExForbidden($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["questi" . "on"] => $question]);
    }
    
    
    
    
    
    
    
    
    
    
    public function UpdateQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_f47b00c53e59541a2cf6ed27c9de2a65, int $id) : JsonPrettyResponse
    {
        
        
        
        $poll_facade = $this->poll_facade;
        
        
        try {
            
            
            $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_f47b00c53e59541a2cf6ed27c9de2a65);
            
            
            $question = $poll_facade->GetQuestionForPoll($id);
            
            
            if (empty($question)) {
                throw new NotFoundException(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_d054d8ac9359ad62ec6ae" . "6a8e108b578"]));
            }
            
            
            $question = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_f2d41627f0927" . "0f0dbd21d27e02" . "868d7"]($question);
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["i" . "d"]] = $question->GetId();
            $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["questi" . "on"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
            $context = $_6eb6fcb92c942851e079f8ec5fb80324->security;
            $user_id = $context->GetUserId();
            
            
            $question = $poll_facade->EditQuestionPoll($_f47b00c53e59541a2cf6ed27c9de2a65, $user_id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["ques" . "tion"] => $question]);
    }
    
    
    
    
    
    
    
    public function DeleteQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $id) : JsonPrettyResponse
    {
        
        
        $poll_facade = $this->poll_facade;
        $_4b43208a06070ee322599b3bb988db75 = $poll_facade->DeleteQuestion($id);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_54b269a12af880b045f6712e6f8654" . "62"] => $_4b43208a06070ee322599b3bb988db75]);
    }
    
    
    
    
    
    
    
    public function SearchQuestions(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data) : JsonPrettyResponse
    {
        
        
        
        
        
        $_864ec8f1fa467c206b6bb2b9c0f308bf = $_6eb6fcb92c942851e079f8ec5fb80324[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4196faadc" . "878e30e23a" . "63bd8ff6d8" . "4a9"]];
        $poll_facade = $this->poll_facade;
        $_a2c1535293d134e078c87c81de95f1d1 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_a2c1535293d134e078c87c81de95" . "f1d1"]);
        $questions = $_864ec8f1fa467c206b6bb2b9c0f308bf->Search($_a2c1535293d134e078c87c81de95f1d1);
        
        
        foreach ($questions as $question) {
            $options = $poll_facade->GetOptionsForQuestion($question);
            foreach ($options as $_ab3f4d20f08bd694b2839e5c36c149a2) {
                $_ab3f4d20f08bd694b2839e5c36c149a2->show_sensitive = true;
            }
            $question->SetOptions($options);
        }
        return new JsonPrettyResponse($questions);
    }
    
    
    
    
    
    
    
    
    
    
    public function GetAttempts(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $id, int $object_type, RequestData $data) : JsonPrettyResponse
    {
        try {
            $_64666bcf1e5aaa07774f3d7439ff264d = $data->Get($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_64666bcf1e5aaa07" . "774f3d7439ff264d"]);
        } catch (RequestDataException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_c894747360c6ec5bd81" . "69530eaf9c473"], $_c35473364fa7a050299058f332ec29c1);
        }
        
        
        $_9fefbd062970af83dc4cc0837cee7d3d = $this->attempt_repo;
        
        
        $poll_facade = $this->poll_facade;
        try {
            $poll_facade->GetPoll($_6eb6fcb92c942851e079f8ec5fb80324->security, $id, true);
        } catch (NotFoundException $_c35473364fa7a050299058f332ec29c1) {
            throw new \RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d23920" . "b3dd84f9" . "8af3028a" . "8a3aa25f" . "9"]));
        }
        
        
        if ((int) $_64666bcf1e5aaa07774f3d7439ff264d === 0) {
            $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $id, false, false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_9137964" . "f9a338e8" . "9f979757" . "c23fc020" . "d"], 25);
            $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $id, false);
        } else {
            $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $id, null, false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_9137964f9a338e89f" . "979757c23fc020d"], 25);
            $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $id);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_54b269a12af880b045" . "f6712e6f865462"] => 1, $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_e6c850126cff29" . "3d170e2d7ab4e2a" . "ad4"] => $_e6c850126cff293d170e2d7ab4e2aad4, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_f4eafa5f493306" . "ffdb51a688b21dd" . "507"] => $_cceda818020fabce3292300389f8560a]);
    }
}