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

$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] ?: array()) + array("_bd87d8db6457f82" . "06c47ed36c5da88c" . "5" => base64_decode("c3Vy" . "dmV5"), "_e2a6cc9ef64b3dd21" . "757612b64b07d09" => base64_decode("Y2FuX3ZpZXd" . "fc3RhdHVz"), "_e6c850126cff293d170e2d7" . "ab4e2aad4" => base64_decode("YXR0Z" . "W1wdH" . "M="), "_5630a508eaf62fdbab410362fa1773" . "5c" => base64_decode("cGVyb" . "Wlzc2" . "lvbnM" . "="), "_54b269a12af880b" . "045f6712e6f86546" . "2" => base64_decode("c3Rh" . "dHVz"), "_7681c2a2b7e1bd" . "f69c23c6cd64114" . "ad3" => base64_decode("anNv" . "bl9k" . "ZWNv" . "ZGU="), "_edbdd61a052" . "6adc078b7780" . "85f113d27" => base64_decode("cXVpei5zdXJ2ZXkuc2Vj" . "dGlvbi5ub3RfZm91bmQ="), "_b8c80e087c6f3f3d1f3c9f6" . "7bcec160d" => base64_decode("Y2FuX3ZpZXdfc3RhdGlzdGljc" . "w=="), "_f11369824f533e" . "8206f9ccc0c9aab" . "3a0" => base64_decode("bGltaX" . "Q="), "_64666bcf1e5aaa" . "07774f3d7439ff2" . "64d" => base64_decode("Y29" . "tcG" . "xld" . "GVk"), "_9129c3c36" . "deea88f418" . "f74d8281ed" . "36f" => base64_decode("d2l0aF9xdWVzdGlvb" . "nM="), "_0c7db5a15ed94cc1" . "be4b039915fb0814" => base64_decode("Y2FuX3JldG" . "FrZQ=="), "_9137964f9a338e89" . "f979757c23fc020d" => base64_decode("Y3JlYXRlZF9kYXRlIE" . "RFU0M="), "_221da17e3055fae8d3ff516b832a" . "5f3b" => base64_decode("cG" . "Fn" . "ZQ" . "=="), "_62d701c3c53404f06345eb3572" . "0a47b4" => base64_decode("aXNfb" . "nVtZX" . "JpYw=" . "="), "_a4a1018" . "258adabb" . "74e7b048" . "36d8d7e3" . "b" => base64_decode("Tm90I" . "EZvdW" . "5k"), "_bc3b621d44ba288f568ddff33bb6e1" . "29" => base64_decode("d2l0aCBxdWVzdGlvbnMgbXVzdCBiZSBhbiBpbn" . "RlZ2Vy"), "_4a9a8953" . "14c5571ef" . "8262129ca" . "6a8044" => base64_decode("Y2FuX3ByZ" . "XZpZXc="), "_113eb5724" . "ec3333d061" . "59bed3a5ae" . "d6d" => base64_decode("cXVpei5zdXJ2ZXkuZXJyb3Iubm90X" . "2ZvdW5k"), "_c3260c2f0" . "284e4cb0a8" . "40360d54cf" . "c77" => base64_decode("anVuY3" . "Rpb25z"), "_4d707fab93b" . "ebb00bbe69e8" . "159697c90" => base64_decode(""), "_33664ab" . "3369feb6" . "988ef7fc" . "55b820ff" . "f" => base64_decode("c3VydmV5c" . "w=="), "_2622beacb6c29bde687d2f80c92baef" . "1" => base64_decode("Y2FuX2F0dG" . "VtcHQ="), "que" . "sti" . "on" => base64_decode("cXVlc3R" . "pb24="), "_7adc269a13af5c45b5a1" . "caf4ec75a795" => base64_decode("YXR0ZW" . "1wdA=="), "_cceda818" . "020fabce3" . "292300389" . "f8560a" => base64_decode("YXR0ZW1wdHNfY2" . "91bnQ="), "_f4eafa5f493306ffdb51a688b21" . "dd507" => base64_decode("dG90Y" . "Ww="), "_7f5aa4e96d4b415a86e" . "d72ebff677cbe" => base64_decode("cXVlcn" . "k="), "_08810531932e1a6e70a95" . "d358d14c879" => base64_decode("Y2FuX21hbmFnZQ" . "=="), "_79bd87060993f" . "f622ef212c1e8b" . "6a79a" => base64_decode("Rm9yY" . "mlkZG" . "Vu"), "_c3530f2ee328e43178cb6afa6ef" . "f3f78" => base64_decode("c2VjdGl" . "vbnM="), "_c894747360c" . "6ec5bd816953" . "0eaf9c473" => base64_decode("QmFkIFJlcXVlc3" . "Q="));
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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_113eb5724ec3333d06159bed3" . "a5aed6d"]));
        } catch (AccessDenied $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExForbidden($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_79bd87060993ff622ef212c1e8b" . "6a79a"], $_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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_54b269a12af880b045f6712e6f8" . "65462"]] = 1;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_bd87d8db645" . "7f8206c47ed3" . "6c5da88c5"]] = $_bd87d8db6457f8206c47ed36c5da88c5;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_7adc269a13af5c45b5a1caf4ec75a" . "795"]] = $_7adc269a13af5c45b5a1caf4ec75a795;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_cceda818020fabce3292300389f8" . "560a"]] = $_2aee0ce2702cbdc0c9dfe50916d6a1d4;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_5630a508eaf62fdbab41" . "0362fa17735c"]] = array($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_4a9a895314c5571ef826" . "2129ca6a8044"] => $survey_permissions->CanPreview($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_2622beacb6c2" . "9bde687d2f80c" . "92baef1"] => $survey_permissions->CanAttempt($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_0c7db5a1" . "5ed94cc1b" . "e4b039915" . "fb0814"] => $survey_permissions->CanReattempt($_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_08810531932e1a6e70a95d358d14" . "c879"] => $survey_permissions->CanManage($context, $_bd87d8db6457f8206c47ed36c5da88c5), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_e2a6cc9ef" . "64b3dd2175" . "7612b64b07" . "d09"] => true, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_b8c80e087c6f3f3d1f3" . "c9f67bcec160d"] => $survey_permissions->CanViewResults($context, $_bd87d8db6457f8206c47ed36c5da88c5));
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    public function GetSurveys(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data)
    {
        
        
        $_7f5aa4e96d4b415a86ed72ebff677cbe = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_7f5aa4e96" . "d4b415a86e" . "d72ebff677" . "cbe"], null);
        $_f11369824f533e8206f9ccc0c9aab3a0 = (int) $request_data->get($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_f11369824f533e8206f9ccc0" . "c9aab3a0"], self::LIMIT);
        if ($_f11369824f533e8206f9ccc0c9aab3a0 > self::MAX_LIMIT) {
            $_f11369824f533e8206f9ccc0c9aab3a0 = self::MAX_LIMIT;
        }
        $_1f50e30be8c2fefa6881834e71d504a2 = $_f11369824f533e8206f9ccc0c9aab3a0 * (int) $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_221da17e305" . "5fae8d3ff516" . "b832a5f3b"], 0);
        $_54b269a12af880b045f6712e6f865462 = $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_54b269a12af880b" . "045f6712e6f86546" . "2"], 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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_33664ab336" . "9feb6988ef7" . "fc55b820fff"] => $_1f24efd4735b7a11b391147435e7d35d[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_33664ab3369feb6988ef" . "7fc55b820fff"]], $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_f4eafa5f493306ffdb51a688b21dd5" . "07"] => $_1f24efd4735b7a11b391147435e7d35d[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_f4eafa5" . "f493306f" . "fdb51a68" . "8b21dd50" . "7"]]));
    }
    
    
    
    
    
    
    
    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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab93" . "bebb00bbe69" . "e8159697c90"]));
        }
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_c3530f2ee328e43178c" . "b6afa6eff3f78"]] = $_c3530f2ee328e43178cb6afa6eff3f78;
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_f4eafa5f4933" . "06ffdb51a688b" . "21dd507"]] = 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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_79bd87060993ff622ef212c1e8b6" . "a79a"], $_c35473364fa7a050299058f332ec29c1);
        } catch (UnknownPropertyException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_c894747360c" . "6ec5bd816953" . "0eaf9c473"], $_c35473364fa7a050299058f332ec29c1);
        }
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    
    
    public function GetSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, $survey_id, $section_id, RequestData $data)
    {
        $_9129c3c36deea88f418f74d8281ed36f = $data->Get($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_9129c3c36dee" . "a88f418f74d82" . "81ed36f"], 1);
        $_2d08212fb5ab9def2f66530b7a9c94cc = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_62d701c3c5" . "3404f06345e" . "b35720a47b4"]($_9129c3c36deea88f418f74d8281ed36f);
        if (!$_2d08212fb5ab9def2f66530b7a9c94cc) {
            throw new \RestExBadRequest($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_bc3b621d44ba288f568" . "ddff33bb6e129"]);
        }
        $_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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c3260c2f0284e4cb0a84036" . "0d54cfc77"]] = $junction_repository->GetQuestionIds($quiz_id);
        $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_54b269a12af880b045" . "f6712e6f865462"]] = 1;
        return new JsonPrettyResponse($_ed5f03d686c37933b5943f295c6b4a43);
    }
    
    
    
    
    
    
    
    
    
    
    
    public function GetAttempts(Application $_6eb6fcb92c942851e079f8ec5fb80324, $object_type, int $survey_id, RequestData $data) : JsonPrettyResponse
    {
        try {
            $_64666bcf1e5aaa07774f3d7439ff264d = $data->Get($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_64666bcf1e5aaa0777" . "4f3d7439ff264d"], 1);
        } catch (RequestDataException $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExBadRequest($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c894747360c6ec5b" . "d8169530eaf9c473"], $_c35473364fa7a050299058f332ec29c1);
        }
        $_2d08212fb5ab9def2f66530b7a9c94cc = $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_62d701c3c53404" . "f06345eb35720a4" . "7b4"]($_64666bcf1e5aaa07774f3d7439ff264d);
        if (!$_2d08212fb5ab9def2f66530b7a9c94cc) {
            throw new \RestExBadRequest($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_bc3b621d44ba2" . "88f568ddff33bb" . "6e129"]);
        }
        $_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["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_113eb5724ec333" . "3d06159bed3a5ae" . "d6d"]), $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_a4a1018258adabb74e7b" . "04836d8d7e3b"], $_c35473364fa7a050299058f332ec29c1);
        } catch (AccessDenied $_c35473364fa7a050299058f332ec29c1) {
            throw new RestExForbidden($_c35473364fa7a050299058f332ec29c1->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_79bd87060993ff622ef212c1e8" . "b6a79a"], $_c35473364fa7a050299058f332ec29c1);
        }
        
        
        $_e6c850126cff293d170e2d7ab4e2aad4 = $_9fefbd062970af83dc4cc0837cee7d3d->GetAttempts($object_type, $survey_id, $_64666bcf1e5aaa07774f3d7439ff264d, false, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_9137964f9a338e89f979757c23f" . "c020d"]);
        
        
        $_cceda818020fabce3292300389f8560a = $_9fefbd062970af83dc4cc0837cee7d3d->CountAttempts($object_type, $survey_id, $_64666bcf1e5aaa07774f3d7439ff264d);
        return new JsonPrettyResponse(array($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_54b269a12af880b045f6712e6f86546" . "2"] => 1, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_e6c85012" . "6cff293d1" . "70e2d7ab4" . "e2aad4"] => $_e6c850126cff293d170e2d7ab4e2aad4, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_f4eafa5f493306ff" . "db51a688b21dd507"] => $_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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_54b269a12af880b045f6712" . "e6f865462"] => 1]);
    }
    
    
    
    
    
    
    
    
    public function CreateSection(Application $_6eb6fcb92c942851e079f8ec5fb80324, RequestData $request_data, int $survey_id) : JsonPrettyResponse
    {
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $request_data->GetPayload();
        if ($_b791059c94b285cdf1c90ca6f3a8f2a6 === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_4d707fab93bebb00bb" . "e69e8159697c90"] || $_b791059c94b285cdf1c90ca6f3a8f2a6 === []) {
            throw new \RestExBadRequest();
        }
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_7681c2a2b7e1bdf69c" . "23c6cd64114ad3"]($_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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_4d707fab9" . "3bebb00bbe" . "69e8159697" . "c90"] || $_b791059c94b285cdf1c90ca6f3a8f2a6 === []) {
            throw new \RestExBadRequest();
        }
        $_b791059c94b285cdf1c90ca6f3a8f2a6 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_7681c2a2b7e1" . "bdf69c23c6cd6" . "4114ad3"]($_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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_54b269a12af880" . "b045f6712e6f865" . "462"] => 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["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_edbdd61a0526adc078b778085f1" . "13d27"]));
        }
        
        
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["questio" . "n"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
        
        
        $survey_facade = $this->survey_facade;
        
        
        $question = $survey_facade->CreateQuestion($_f47b00c53e59541a2cf6ed27c9de2a65, $section_id, $user_id);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["ques" . "tion"] => $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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_edbdd61a0526adc0" . "78b778085f113d27"]));
        }
        
        
        $_f47b00c53e59541a2cf6ed27c9de2a65 = $this->formatter->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $user_id = $_6eb6fcb92c942851e079f8ec5fb80324->security->GetUserId();
        $_f47b00c53e59541a2cf6ed27c9de2a65 = [$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["que" . "sti" . "on"] => $_f47b00c53e59541a2cf6ed27c9de2a65];
        
        
        $survey_facade = $this->survey_facade;
        
        
        $question = $survey_facade->UpdateQuestion($_f47b00c53e59541a2cf6ed27c9de2a65, $section_id, $question_id, $user_id);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["qu" . "es" . "ti" . "on"] => $question]);
    }
}