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

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] ?: array()) + array("_b8c80e087c6f3f3d1f3c9f67bc" . "ec160d" => base64_decode("Y2FuX3ZpZXdf" . "c3RhdGlzdGlj" . "cw=="), "_2622beacb6c29bde687d2f" . "80c92baef1" => base64_decode("Y2FuX2F0dGVt" . "cHQ="), "_08810531932e1a" . "6e70a95d358d14c" . "879" => base64_decode("Y2FuX21hbmFnZQ=" . "="), "_f4eafa5f493306f" . "fdb51a688b21dd50" . "7" => base64_decode("dG90Y" . "Ww="), "_e6c850126cff293d170e2d7ab4e2a" . "ad4" => base64_decode("YXR0ZW" . "1wdHM="), "_bd87d8db6457" . "f8206c47ed36c" . "5da88c5" => base64_decode("c3Vyd" . "mV5"), "_c3530f2ee328e43178cb6afa6" . "eff3f78" => base64_decode("c2VjdGlv" . "bnM="), "_bc3b621d44" . "ba288f568dd" . "ff33bb6e129" => base64_decode("d2l0aCBxdWVzdGlvbnMgbXVzdCBiZSBhbiBpbnRlZ2" . "Vy"), "_62d701c3c53404f06345eb" . "35720a47b4" => base64_decode("aXNfbn" . "VtZXJp" . "Yw=="), "_79bd87060993ff6" . "22ef212c1e8b6a79" . "a" => base64_decode("Rm9yYm" . "lkZGVu"), "_c3260c2f0284" . "e4cb0a840360d" . "54cfc77" => base64_decode("anVuY3Rpb" . "25z"), "_cceda818020fab" . "ce3292300389f85" . "60a" => base64_decode("YXR0ZW1wdHNfY291bn" . "Q="), "_e2a6cc9ef6" . "4b3dd217576" . "12b64b07d09" => base64_decode("Y2FuX" . "3ZpZX" . "dfc3R" . "hdHVz"), "_7681c2a2b7e1bdf69c23c6cd64114ad" . "3" => base64_decode("anNvbl9kZWNvZ" . "GU="), "_5630a508eaf62fdbab410362fa17735" . "c" => base64_decode("cGVybWlzc2lvb" . "nM="), "_edbdd61a0526a" . "dc078b778085f1" . "13d27" => base64_decode("cXVpei5zdXJ2ZXkuc2Vj" . "dGlvbi5ub3RfZm91bmQ="), "_9137964" . "f9a338e8" . "9f979757" . "c23fc020" . "d" => base64_decode("Y3JlYXRl" . "ZF9kYXRl" . "IERFU0M="), "_9129c3c36deea88f418f74d8281e" . "d36f" => base64_decode("d2l0a" . "F9xdW" . "VzdGl" . "vbnM="), "_0c7db5a15ed94cc" . "1be4b039915fb081" . "4" => base64_decode("Y2FuX3JldG" . "FrZQ=="), "_64666bc" . "f1e5aaa0" . "7774f3d7" . "439ff264" . "d" => base64_decode("Y29tc" . "GxldG" . "Vk"), "questio" . "n" => base64_decode("cXVlc" . "3Rpb2" . "4="), "_a4a1018258adab" . "b74e7b04836d8d7" . "e3b" => base64_decode("Tm90IE" . "ZvdW5k"), "_c894747360c6ec5bd8169530ea" . "f9c473" => base64_decode("QmFkIFJlcXVlc3" . "Q="), "_221da17e305" . "5fae8d3ff516" . "b832a5f3b" => base64_decode("cG" . "Fn" . "ZQ" . "=="), "_7f5aa4e96d4b415a86ed72ebff677cb" . "e" => base64_decode("cX" . "Vl" . "cn" . "k="), "_4d707fab93bebb00bbe69e8159697c9" . "0" => base64_decode(""), "_7adc269" . "a13af5c4" . "5b5a1caf" . "4ec75a79" . "5" => base64_decode("YXR" . "0ZW" . "1wd" . "A=="), "_54b269a12af880b045f6" . "712e6f865462" => base64_decode("c3Rh" . "dHVz"), "_33664ab3369fe" . "b6988ef7fc55b8" . "20fff" => base64_decode("c3Vyd" . "mV5cw" . "=="), "_4a9a895314c5571ef8262" . "129ca6a8044" => base64_decode("Y2FuX3B" . "yZXZpZX" . "c="), "_f11369824f533e8206f9ccc0c9aa" . "b3a0" => base64_decode("bGl" . "taX" . "Q="), "_113eb5724ec3333d" . "06159bed3a5aed6d" => base64_decode("cXVpei5zdXJ2ZXkuZXJyb3Iubm90X2Zvd" . "W5k"));
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\Repository\Exception\UnknownPropertyException;
use Claromentis\Core\REST\RestFormatter;
use Claromentis\Core\TextUtil\ClaText;
use Claromentis\People\Exception\PermissionException;
use Claromentis\Quiz\Exception\AccessDenied;
use Claromentis\Quiz\Facade;
use Claromentis\Quiz\Permissions\SurveyPermissions;
use Claromentis\Quiz\Plugin;
use Claromentis\Quiz\Repository;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ServerRequestInterface;
use RestExBadRequest;
use RestExForbidden;
use RestExNotFound;
class SurveyController
{
    const LIMIT = 20;
    const MAX_LIMIT = 200;
    
    
    
    
    protected $formatter;
    
    
    
    
    protected $survey_facade;
    
    
    
    
    protected $section_repo;
    
    
    protected $lmsg;
    
    
    protected $attempt_facade;
    
    
    protected $attempt_repo;
    
    
    protected $survey_permissions;
    
    
    protected $junction_repository;
    protected ClaText $cla_text;
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function __construct(RestFormatter $formatter, Facade\SurveyFacade $survey_facade, Repository\SectionRepository $section_repo, Lmsg $lmsg, Facade\AttemptFacade $attempt_facade, Repository\AttemptRepository $attempt_repo, SurveyPermissions $survey_permissions, Repository\QuizQuestionRepository $junction_repository, ClaText $cla_text)
    {
        $this->formatter = $formatter;
        $this->survey_facade = $survey_facade;
        $this->section_repo = $section_repo;
        $this->lmsg = $lmsg;
        $this->attempt_facade = $attempt_facade;
        $this->attempt_repo = $attempt_repo;
        $this->survey_permissions = $survey_permissions;
        $this->junction_repository = $junction_repository;
        $this->cla_text = $cla_text;
    }
    
    
    
    
    
    
    
    
    
    
    public function GetSurvey(Application $_6eb6fcb92c942851e079f8ec5fb80324, $survey_id)
    {
        $_ed5f03d686c37933b5943f295c6b4a43 = [];
        $context = $_6eb6fcb92c942851e079f8ec5fb80324->security;
        $user_id = $context->GetUserId();
        
        
        
        
        
        
        
        $attempt_facade = $this->attempt_facade;
        $survey_facade = $this->survey_facade;
        $attempt_repo = $this->attempt_repo;
        $survey_permissions = $this->survey_permissions;
        try {
            $_bd87d8db6457f8206c47ed36c5da88c5 = $survey_facade->GetEntireSurvey($context, $survey_id);
        } catch (NotFoundException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_113eb5724ec3333d06159" . "bed3a5aed6d"]));
        } catch (AccessDenied $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExForbidden($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_79bd87060993ff622ef" . "212c1e8b6a79a"], $_c35473364fa7a050299058f332ec29c1);
        }
        $_7adc269a13af5c45b5a1caf4ec75a795 = $attempt_facade->GetLatestAttempt($user_id, Plugin::AGGREGATION_SURVEY, $survey_id);
        $_2aee0ce2702cbdc0c9dfe50916d6a1d4 = (int) $attempt_repo->CountUserAttempts($user_id, Plugin::AGGREGATION_SURVEY, $survey_id);
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_54b269a12af880b045f6712e6f865" . "462"]] = 1;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_bd87d8db6457f8206c47ed36c5da" . "88c5"]] = $_bd87d8db6457f8206c47ed36c5da88c5;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_7adc269a13af5c" . "45b5a1caf4ec75a" . "795"]] = $_7adc269a13af5c45b5a1caf4ec75a795;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_cceda818020fabce3" . "292300389f8560a"]] = $_2aee0ce2702cbdc0c9dfe50916d6a1d4;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_5630a508eaf62fdbab410362fa1" . "7735c"]] = array($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4a9a895314" . "c5571ef8262" . "129ca6a8044"] => $survey_permissions->CanPreview($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_2622beacb6c29bde687d2f80c92" . "baef1"] => $survey_permissions->CanAttempt($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0c7db5a15ed94cc1be4b03" . "9915fb0814"] => $survey_permissions->CanReattempt($_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_08810531932e1a6e70a" . "95d358d14c879"] => $survey_permissions->CanManage($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_e2a6cc9ef64b3dd21757612b64b" . "07d09"] => true, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_b8c80e087c6f3f3d1f3c9f67bce" . "c160d"] => $survey_permissions->CanViewResults($context, $_bd87d8db6457f8206c47ed36c5da88c5));
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    public function GetSurveys(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data)
    {
        
        
        $_7f5aa4e96d4b415a86ed72ebff677cbe = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_7f5aa4e96d4b415a86ed72ebff677cb" . "e"], null);
        $_f11369824f533e8206f9ccc0c9aab3a0 = (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_f11369824" . "f533e8206f" . "9ccc0c9aab" . "3a0"], self::LIMIT);
        if ($_f11369824f533e8206f9ccc0c9aab3a0 > self::MAX_LIMIT) {
            $_f11369824f533e8206f9ccc0c9aab3a0 = self::MAX_LIMIT;
        }
        $_1f50e30be8c2fefa6881834e71d504a2 = $_f11369824f533e8206f9ccc0c9aab3a0 * (int) $request_data->Get($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_221da17" . "e3055fae" . "8d3ff516" . "b832a5f3" . "b"], 0);
        $_54b269a12af880b045f6712e6f865462 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_54b269a12af8" . "80b045f6712e6" . "f865462"], null);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        
        
        $survey_facade = $this->survey_facade;
        $_1f24efd4735b7a11b391147435e7d35d = $survey_facade->GetSurveys($user_id, $_54b269a12af880b045f6712e6f865462, $_7f5aa4e96d4b415a86ed72ebff677cbe, $_f11369824f533e8206f9ccc0c9aab3a0, $_1f50e30be8c2fefa6881834e71d504a2);
        return new JsonPrettyResponse(array($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_33664ab3369feb6988ef7fc55b820" . "fff"] => $_1f24efd4735b7a11b391147435e7d35d[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_33664ab3369feb6988ef7fc55b820f" . "ff"]], $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_f4eafa5f493306ffdb51a688b21d" . "d507"] => $_1f24efd4735b7a11b391147435e7d35d[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_f4eafa5f493306ffdb51a688b21d" . "d507"]]));
    }
    
    
    
    
    
    
    
    public function CreateSurvey(Application $_6eb6fcb92c942851e079f8ec5fb80324, ServerRequestInterface $_b791059c94b285cdf1c90ca6f3a8f2a6)
    {
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        
        
        $survey_facade = $this->survey_facade;
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        try {
            $_bd87d8db6457f8206c47ed36c5da88c5 = $survey_facade->CreateSurvey($_b791059c94b285cdf1c90ca6f3a8f2a6, $user_id);
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse($_bd87d8db6457f8206c47ed36c5da88c5);
    }
    
    
    
    
    
    
    
    
    
    public function UpdateSurvey(Application $_6eb6fcb92c942851e079f8ec5fb80324, ServerRequestInterface $_b791059c94b285cdf1c90ca6f3a8f2a6, $survey_id)
    {
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        
        
        $survey_facade = $this->survey_facade;
        try {
            $_bd87d8db6457f8206c47ed36c5da88c5 = $survey_facade->UpdateSurvey($_b791059c94b285cdf1c90ca6f3a8f2a6, $survey_id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse($_bd87d8db6457f8206c47ed36c5da88c5);
    }
    public function GetSections(Application $_6eb6fcb92c942851e079f8ec5fb80324, $survey_id)
    {
        $_ed5f03d686c37933b5943f295c6b4a43 = [];
        
        
        
        
        $survey_facade = $this->survey_facade;
        $_c3530f2ee328e43178cb6afa6eff3f78 = $survey_facade->GetSurveySections((int) $survey_id);
        foreach ($_c3530f2ee328e43178cb6afa6eff3f78 as $_7d8349934215833a7b750e580b17133a) {
            $_7d8349934215833a7b750e580b17133a->SetDescription($this->cla_text->ParseLinks($_7d8349934215833a7b750e580b17133a->description ?? $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4d707fab93b" . "ebb00bbe69e8" . "159697c90"]));
        }
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_c3530f2ee328e4" . "3178cb6afa6eff3" . "f78"]] = $_c3530f2ee328e43178cb6afa6eff3f78;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_f4eafa5f493306ffdb51a68" . "8b21dd507"]] = 1;
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    public function GetPreviewInfo(Application $_6eb6fcb92c942851e079f8ec5fb80324, $survey_id)
    {
        $context = $_6eb6fcb92c942851e079f8ec5fb80324->security;
        
        
        
        
        $survey_facade = $this->survey_facade;
        try {
            $_ed5f03d686c37933b5943f295c6b4a43 = $survey_facade->GetPreviewInfo((int) $survey_id, $context);
        } catch (AccessDenied $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExForbidden($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_79bd87060993ff622ef212c1e8b6a79" . "a"], $_c35473364fa7a050299058f332ec29c1);
        } catch (UnknownPropertyException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_c894747360c6e" . "c5bd8169530eaf" . "9c473"], $_c35473364fa7a050299058f332ec29c1);
        }
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    
    
    public function GetSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, $survey_id, $section_id, RequestData $data)
    {
        $_9129c3c36deea88f418f74d8281ed36f = $data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_9129c3c36deea88f418f74" . "d8281ed36f"], 1);
        $_2d08212fb5ab9def2f66530b7a9c94cc = $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_62d701c3c" . "53404f0634" . "5eb35720a4" . "7b4"]($_9129c3c36deea88f418f74d8281ed36f);
        if (!$_2d08212fb5ab9def2f66530b7a9c94cc) {
            throw new \RestExBadRequest($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_bc3b621d44ba288f568ddff33bb6e1" . "29"]);
        }
        $_9129c3c36deea88f418f74d8281ed36f = (int) $_9129c3c36deea88f418f74d8281ed36f === 1;
        
        
        
        
        $survey_facade = $this->survey_facade;
        $_7d8349934215833a7b750e580b17133a = $survey_facade->GetSection((int) $section_id, $_9129c3c36deea88f418f74d8281ed36f);
        return new JsonPrettyResponse($_7d8349934215833a7b750e580b17133a);
    }
    
    
    
    
    
    
    public function GetQuestionIds(Application $_6eb6fcb92c942851e079f8ec5fb80324, $quiz_id)
    {
        $_ed5f03d686c37933b5943f295c6b4a43 = [];
        
        
        
        
        $junction_repository = $this->junction_repository;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_c3260c2f0284e4cb0a840" . "360d54cfc77"]] = $junction_repository->GetQuestionIds($quiz_id);
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_54b269a12af880b045f6712e6f86" . "5462"]] = 1;
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    
    
    
    public function GetAttempts(Application $_6eb6fcb92c942851e079f8ec5fb80324, $object_type, int $survey_id, RequestData $data) : JsonPrettyResponse
    {
        try {
            $_64666bcf1e5aaa07774f3d7439ff264d = $data->Get($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_64666bcf1e5aaa077" . "74f3d7439ff264d"], 1);
        } catch (RequestDataException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_c8947473" . "60c6ec5bd" . "8169530ea" . "f9c473"], $_c35473364fa7a050299058f332ec29c1);
        }
        $_2d08212fb5ab9def2f66530b7a9c94cc = $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_62d701c3c534" . "04f06345eb357" . "20a47b4"]($_64666bcf1e5aaa07774f3d7439ff264d);
        if (!$_2d08212fb5ab9def2f66530b7a9c94cc) {
            throw new \RestExBadRequest($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_bc3b621d44ba288f568ddff" . "33bb6e129"]);
        }
        $_64666bcf1e5aaa07774f3d7439ff264d = (int) $_64666bcf1e5aaa07774f3d7439ff264d === 1;
        
        
        
        
        
        $survey_facade = $this->survey_facade;
        $_9fefbd062970af83dc4cc0837cee7d3d = $this->attempt_repo;
        
        
        try {
            $survey_facade->GetEntireSurvey($_6eb6fcb92c942851e079f8ec5fb80324->security, $survey_id, false);
        } catch (NotFoundException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_113eb5724ec3333d06159bed3a5a" . "ed6d"]), $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_a4a1018258ada" . "bb74e7b04836d8" . "d7e3b"], $_c35473364fa7a050299058f332ec29c1);
        } catch (AccessDenied $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExForbidden($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_79bd87060993ff622ef212c" . "1e8b6a79a"], $_c35473364fa7a050299058f332ec29c1);
        }
        
        
        $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $survey_id, $_64666bcf1e5aaa07774f3d7439ff264d, false, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_9137964f9a338e89f979" . "757c23fc020d"]);
        
        
        $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $survey_id, $_64666bcf1e5aaa07774f3d7439ff264d);
        return new JsonPrettyResponse(array($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_54b269a12af880b045f671" . "2e6f865462"] => 1, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_e6c850126c" . "ff293d170e2" . "d7ab4e2aad4"] => $_e6c850126cff293d170e2d7ab4e2aad4, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_f4eafa5f493306ffdb" . "51a688b21dd507"] => $_cceda818020fabce3292300389f8560a));
    }
    
    
    
    
    
    
    
    public function DeleteSurvey(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $survey_id) : JsonPrettyResponse
    {
        
        
        $survey_facade = $this->survey_facade;
        try {
            $survey_facade->DeleteSurvey($survey_id);
        } catch (\Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_54b269a12af880b045f6712e" . "6f865462"] => 1]);
    }
    
    
    
    
    
    
    
    
    public function CreateSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data, int $survey_id) : JsonPrettyResponse
    {
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $request_data->GetPayload();
        if ($_b791059c94b285cdf1c90ca6f3a8f2a6 === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93beb" . "b00bbe69e81596" . "97c90"] || $_b791059c94b285cdf1c90ca6f3a8f2a6 === []) {
            throw new \RestExBadRequest();
        }
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_7681c2a2b7e1bdf69c23c6cd64114ad" . "3"]($_b791059c94b285cdf1c90ca6f3a8f2a6, true);
        if ($_b791059c94b285cdf1c90ca6f3a8f2a6 === null) {
            throw new \RestExBadRequest();
        }
        
        
        $survey_facade = $this->survey_facade;
        try {
            $_7d8349934215833a7b750e580b17133a = $survey_facade->CreateSection($_b791059c94b285cdf1c90ca6f3a8f2a6, $survey_id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse($_7d8349934215833a7b750e580b17133a);
    }
    
    
    
    
    
    
    
    
    
    
    public function UpdateSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data, int $survey_id, int $section_id) : JsonPrettyResponse
    {
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $request_data->GetPayload();
        if ($_b791059c94b285cdf1c90ca6f3a8f2a6 === $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_4d707fab93bebb00bbe69" . "e8159697c90"] || $_b791059c94b285cdf1c90ca6f3a8f2a6 === []) {
            throw new \RestExBadRequest();
        }
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_7681c2a2b7e1bdf69c23c6cd64114ad" . "3"]($_b791059c94b285cdf1c90ca6f3a8f2a6, true);
        
        
        $survey_facade = $this->survey_facade;
        try {
            $_bd87d8db6457f8206c47ed36c5da88c5 = $survey_facade->UpdateSection($_b791059c94b285cdf1c90ca6f3a8f2a6, $survey_id, $section_id);
        } catch (NotFoundException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        } catch (\InvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExBadRequest($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse($_bd87d8db6457f8206c47ed36c5da88c5);
    }
    
    
    
    
    
    
    
    
    public function DeleteSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $survey_id, int $section_id) : JsonPrettyResponse
    {
        
        
        $survey_facade = $this->survey_facade;
        try {
            $survey_facade->DeleteSection($survey_id, $section_id);
        } catch (\Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw new \RestExNotFound($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
        }
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_54b269a12af880b045f6712e6f8" . "65462"] => 1]);
    }
    
    
    
    
    
    
    
    
    
    public function CreateQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_b791059c94b285cdf1c90ca6f3a8f2a6, int $section_id) : JsonPrettyResponse
    {
        
        
        try {
            $this->section_repo->Get($section_id);
        } catch (NotFoundException $_c35473364fa7a050299058f332ec29c1) {
            throw new \RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_edbdd61a0" . "526adc078b" . "778085f113" . "d27"]));
        }
        
        
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["ques" . "tion"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
        
        
        $survey_facade = $this->survey_facade;
        
        
        $question = $survey_facade->CreateQuestion($_f47b00c53e59541a2cf6ed27c9de2a65, $section_id, $user_id);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["questio" . "n"] => $question]);
    }
    
    
    
    
    
    
    
    public function GetQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, int $section_id, int $question_id) : JsonPrettyResponse
    {
        
        
        $survey_facade = $this->survey_facade;
        $question = $survey_facade->GetQuestion($section_id, $question_id);
        return new JsonPrettyResponse($question);
    }
    
    
    
    
    
    
    
    
    
    
    public function UpdateQuestion(Application $_6eb6fcb92c942851e079f8ec5fb80324, Request $_b791059c94b285cdf1c90ca6f3a8f2a6, $section_id, $question_id)
    {
        
        
        try {
            $this->section_repo->Get($section_id);
        } catch (NotFoundException $_c35473364fa7a050299058f332ec29c1) {
            throw new \RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_edbdd61" . "a0526adc" . "078b7780" . "85f113d2" . "7"]));
        }
        
        
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["que" . "sti" . "on"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
        
        
        $survey_facade = $this->survey_facade;
        
        
        $question = $survey_facade->UpdateQuestion($_f47b00c53e59541a2cf6ed27c9de2a65, $section_id, $question_id, $user_id);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["questio" . "n"] => $question]);
    }
}