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

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] ?: array()) + array("i" . "d" => base64_decode("aWQ" . "="), "_d054d8ac9359ad62ec" . "6ae6a8e108b578" => base64_decode("cXVpei5wb2xsLmVycm9yLm5v" . "X3F1ZXN0aW9u"), "_5630a508eaf62f" . "dbab410362fa177" . "35c" => base64_decode("cGVybWlzc2" . "lvbnM="), "_4d707fab" . "93bebb00b" . "be69e8159" . "697c90" => base64_decode(""), "_4d23920b3dd84f98af3028" . "a8a3aa25f9" => base64_decode("cXVpei5wb2xsL" . "mVycm9yLm5vdF" . "9mb3VuZA=="), "_f4eafa5f493306ffdb51a688b2" . "1dd507" => base64_decode("dG" . "90" . "YW" . "w="), "_9137964f9a338e89f9797" . "57c23fc020d" => base64_decode("Y3JlYXRlZF9kYXRlI" . "ERFU0M="), "_33f09d76394b074b" . "779265f857d5ec8a" => base64_decode("Y291bnRfc2FmZQ=" . "="), "_cceda818020fabce3292300" . "389f8560a" => base64_decode("YXR0Z" . "W1wdH" . "NfY29" . "1bnQ="), "_7f5aa4e96" . "d4b415a86e" . "d72ebff677" . "cbe" => base64_decode("cXVlcnk" . "="), "_e6c850126cff" . "293d170e2d7ab" . "4e2aad4" => base64_decode("YXR0ZW1w" . "dHM="), "_b8c80e087c6f3f3d1f" . "3c9f67bcec160d" => base64_decode("Y2FuX3ZpZXdfc3Rhd" . "GlzdGljcw=="), "_b3ee1ca" . "1d7e4bff" . "63ae7779" . "68483325" . "d" => base64_decode("cG9sb" . "A=="), "_4a9a895314c5571ef8262129ca6a804" . "4" => base64_decode("Y2FuX3ByZX" . "ZpZXc="), "_f113698" . "24f533e8" . "206f9ccc" . "0c9aab3a" . "0" => base64_decode("bGltaX" . "Q="), "_c894747360c6ec5bd8169530eaf9" . "c473" => base64_decode("QmFkIFJlcXVlc3Q" . "="), "_a2c1535293d" . "134e078c87c8" . "1de95f1d1" => base64_decode("cGhyYXN" . "l"), "_e2a6cc9ef64b3dd21757612b" . "64b07d09" => base64_decode("Y2FuX3ZpZXdfc3RhdH" . "Vz"), "po" . "ll" . "_i" . "d" => base64_decode("cG9sb" . "F9pZA" . "=="), "_0c7db5a15ed94cc1be4b03" . "9915fb0814" => base64_decode("Y2FuX3Jl" . "dGFrZQ=="), "_2e8e0758094679b3cb5171c8c3" . "d880f6" => base64_decode("WW91IGNhbiBhZGQgb25seSBvbmUgcXVlc3Rpb24gdG8g" . "dGhlIHBvbGw="), "_64666bcf1e5aaa07774f" . "3d7439ff264d" => base64_decode("Y29tcGxldG" . "Vk"), "_221da17e3055" . "fae8d3ff516b8" . "32a5f3b" => base64_decode("cGFnZ" . "Q=="), "_54b269a" . "12af880b" . "045f6712" . "e6f86546" . "2" => base64_decode("c3Rh" . "dHVz"), "_7adc269a13af5c45b5a1caf4ec75a79" . "5" => base64_decode("YXR0ZW1" . "wdA=="), "_79bd87060993ff622ef" . "212c1e8b6a79a" => base64_decode("Rm9yYml" . "kZGVu"), "_2622beacb6c29bde687d2f80c92ba" . "ef1" => base64_decode("Y2FuX2F0dGVtcH" . "Q="), "_4196faadc87" . "8e30e23a63bd" . "8ff6d84a9" => base64_decode("cXVpei5yZX" . "Bvc2l0b3J5" . "LnF1ZXN0aW" . "9u"), "ques" . "tion" . "s" => base64_decode("cXVlc3Rpb2" . "5z"), "_f2d41627" . "f09270f0d" . "bd21d27e0" . "2868d7" => base64_decode("cm" . "Vz" . "ZX" . "Q="), "qu" . "es" . "ti" . "on" => base64_decode("cXVl" . "c3Rp" . "b24="), "_f1af70b59fcba619" . "39cba0f49367d285" => base64_decode("cG9sb" . "HM="), "_08810531" . "932e1a6e7" . "0a95d358d" . "14c879" => base64_decode("Y2FuX21" . "hbmFnZQ" . "=="));
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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_7f5aa4e96d4" . "b415a86ed72e" . "bff677cbe"], $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d707fab93b" . "ebb00bbe69e8" . "159697c90"]);
        $_f11369824f533e8206f9ccc0c9aab3a0 = (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_f11369824f533e8" . "206f9ccc0c9aab3a" . "0"], self::DEFAULT_LIMIT);
        if ($_f11369824f533e8206f9ccc0c9aab3a0 > self::MAX_LIMIT) {
            $_f11369824f533e8206f9ccc0c9aab3a0 = self::MAX_LIMIT;
        }
        $_1f50e30be8c2fefa6881834e71d504a2 = $_f11369824f533e8206f9ccc0c9aab3a0 * (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_221da17e" . "3055fae8d" . "3ff516b83" . "2a5f3b"], 0);
        $_54b269a12af880b045f6712e6f865462 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_54b269a12af88" . "0b045f6712e6f8" . "65462"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_4d707fab93bebb0" . "0bbe69e8159697c9" . "0"]);
        $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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_4d23920b3dd84f98" . "af3028a8a3aa25f9"]));
        }
        $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["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e8159697c" . "90"]));
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_54b269a12af880b045f6712e" . "6f865462"]] = 1;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_b3ee1ca1" . "d7e4bff63" . "ae7779684" . "83325d"]] = $_b3ee1ca1d7e4bff63ae777968483325d;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_7adc269a13af5c45" . "b5a1caf4ec75a795"]] = $_7adc269a13af5c45b5a1caf4ec75a795;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_cceda818020fabce3292300389f85" . "60a"]] = $_2aee0ce2702cbdc0c9dfe50916d6a1d4;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_5630a508eaf62" . "fdbab410362fa1" . "7735c"]] = [$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4a9a895314c5571" . "ef8262129ca6a804" . "4"] => $this->poll_permission->CanPreview($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_2622beacb6c29bde687d2f80c92baef" . "1"] => $this->poll_permission->CanAttempt($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_0c7db5a15ed94" . "cc1be4b039915f" . "b0814"] => $this->poll_permission->CanReattempt($_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_08810531932e1a6e70a95d35" . "8d14c879"] => $this->poll_permission->CanManage($context, $_b3ee1ca1d7e4bff63ae777968483325d), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e2a6cc9ef64b3dd21757" . "612b64b07d09"] => true, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_b8c80e087c6f3f3d1f3c9f67b" . "cec160d"] => $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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_4d23920" . "b3dd84f9" . "8af3028a" . "8a3aa25f" . "9"]));
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["que" . "sti" . "ons"] => $_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["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_33f09d7639" . "4b074b77926" . "5f857d5ec8a"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["quest" . "ion"]]) > 1) {
                throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_2e8e0758094679b3cb5171c8c3" . "d880f6"]);
            }
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["ques" . "tion"]] = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_f2d4162" . "7f09270f" . "0dbd21d2" . "7e02868d" . "7"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["que" . "sti" . "on"]]);
            $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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_79bd87060993ff622ef21" . "2c1e8b6a79a"], $_fe441aa3ef350bfb1a1a1ad8520dd530);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_f1af70b59fcba61939cba0f49367d" . "285"] => [$_bc03a57aecaf90d056bc199b3782d415], $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f4eafa5f493306ffdb51a68" . "8b21dd507"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_33f09d76394b074b7" . "79265f857d5ec8a"]($_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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_33f09d76394b074" . "b779265f857d5ec8" . "a"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["questio" . "n"]]) > 1) {
                throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_2e8e0758094679b3cb5171c8c3" . "d880f6"]);
            }
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["que" . "sti" . "on"]] = $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_f2d4162" . "7f09270f" . "0dbd21d2" . "7e02868d" . "7"]($_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["ques" . "tion"]]);
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["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["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f1af70b59fcba61939cba0f49367d2" . "85"] => $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["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_54b269a12af880b0" . "45f6712e6f865462"] => $_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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["i" . "d"]] = $user_id;
            $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["que" . "sti" . "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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_d054d8ac9359ad6" . "2ec6ae6a8e108b57" . "8"]));
            }
            
            
            $question = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f2d41627f09270f0" . "dbd21d27e02868d7"]($question);
            $_f47b00c53e59541a2cf6ed27c9de2a65[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["i" . "d"]] = $question->GetId();
            $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["quest" . "ion"] => $_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["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["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["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_54b269a12af880b045" . "f6712e6f865462"] => $_4b43208a06070ee322599b3bb988db75]);
    }
    
    
    
    
    
    
    
    public function SearchQuestions(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data) : JsonPrettyResponse
    {
        
        
        
        
        
        $_864ec8f1fa467c206b6bb2b9c0f308bf = $_6eb6fcb92c942851e079f8ec5fb80324[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_4196faadc878e30" . "e23a63bd8ff6d84a" . "9"]];
        $poll_facade = $this->poll_facade;
        $_a2c1535293d134e078c87c81de95f1d1 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_a2c1535293d134e078c87c81de" . "95f1d1"]);
        $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["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_64666bcf1e5aa" . "a07774f3d7439f" . "f264d"]);
        } catch (RequestDataException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c894747360c6ec5bd8169530eaf" . "9c473"], $_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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d23920b3dd84" . "f98af3028a8a3a" . "a25f9"]));
        }
        
        
        if ((int) $_64666bcf1e5aaa07774f3d7439ff264d === 0) {
            $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $id, false, false, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_9137964f9a338e89f979757c2" . "3fc020d"], 25);
            $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $id, false);
        } else {
            $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $id, null, false, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_9137964f9a338e89f979757c23" . "fc020d"], 25);
            $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $id);
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_54b269a12" . "af880b045f" . "6712e6f865" . "462"] => 1, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e6c850126cff293d170e" . "2d7ab4e2aad4"] => $_e6c850126cff293d170e2d7ab4e2aad4, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_f4eafa5f493306ffdb5" . "1a688b21dd507"] => $_cceda818020fabce3292300389f8560a]);
    }
}