<?php
namespace Claromentis\Quiz\Repository;

$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] ?: array()) + array("_8d9b0819c2b801169776d606" . "3e4dbb2f" => base64_decode("c3VydmV5X2lkID0gaW50OnN1cnZl" . "eV9pZA=="), "_8e15a207" . "9bcda2d8a" . "31ad8c8ac" . "f3caa3" => base64_decode("c29ydF9v" . "cmRlciBB" . "U0M="), "_84e7ca6b39887af1fa1ace5b00b4099" . "9" => base64_decode("U0VMRUN" . "UIGlkIE" . "ZST00g"), "_ce14087e6" . "797cbc3bf2" . "db804bebe7" . "754" => base64_decode("U0VMRUNUIENPVU5UKERJU1RJTkNUIGlkK" . "SBGUk9NIA=="));
use Claromentis\Core\DAL;
use Claromentis\Core\Repository\Repository;
use Claromentis\Core\Repository\RepositoryItem;
use Claromentis\Quiz\Model;
use ObjectsStorage;





class SectionRepository extends Repository
{
    
    
    
    
    
    
    
    
    
    public function GetSurveySections($survey_id)
    {
        if (!$survey_id) {
            return [];
        }
        
        
        
        
        $sections = $this->GetObjects(new DAL\QueryPart($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_8d9b0819c2b" . "801169776d60" . "63e4dbb2f"], $survey_id), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_8e15a2079bcda2d8a31ad" . "8c8acf3caa3"]);
        return $sections;
    }
    
    
    
    
    
    public function CountSurveySections($survey_id)
    {
        if (!$survey_id) {
            return 0;
        }
        
        
        $_6555f4024e92c4a6b9140e99cd668e2b = $this->GetTable();
        
        
        $_30f942154645a3deca356c5cbdef7313 = new DAL\QueryBuilder($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_ce14087e6797cbc3bf2db804be" . "be7754"] . $_6555f4024e92c4a6b9140e99cd668e2b);
        $_30f942154645a3deca356c5cbdef7313->AddWhereAndClause($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_8d9b0819c2b8011" . "69776d6063e4dbb2" . "f"], $survey_id);
        
        
        $_d69bc5256e082f5dee25c2438a6ddc93 = $this->db->query($_30f942154645a3deca356c5cbdef7313->GetQuery())->fetchAllValues();
        return !empty($_d69bc5256e082f5dee25c2438a6ddc93) ? $_d69bc5256e082f5dee25c2438a6ddc93[0] : 0;
    }
    
    
    
    
    
    
    
    
    
    public function GetSurveySectionsIds($survey_id)
    {
        if (!$survey_id) {
            return [];
        }
        $_9cee5807b5bab08d25cd4213e63cb764 = [];
        
        
        $_6555f4024e92c4a6b9140e99cd668e2b = $this->GetTable();
        $_30f942154645a3deca356c5cbdef7313 = new DAL\QueryBuilder($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_84e7ca6b39887" . "af1fa1ace5b00b" . "40999"] . $_6555f4024e92c4a6b9140e99cd668e2b);
        $_30f942154645a3deca356c5cbdef7313->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_8d9b0819c2b80" . "1169776d6063e4" . "dbb2f"], $survey_id);
        $_9cee5807b5bab08d25cd4213e63cb764 = $this->db->query($_30f942154645a3deca356c5cbdef7313->GetQuery())->fetchAllValues();
        return $_9cee5807b5bab08d25cd4213e63cb764;
    }
    
    
    
    
    
    
    
    public function Get($section_id)
    {
        if ($section_id) {
            
            
            
            
            $_7d8349934215833a7b750e580b17133a = parent::Get($section_id);
            return $_7d8349934215833a7b750e580b17133a;
        }
        return null;
    }
    
    
    
    
    public function Create() : RepositoryItem
    {
        return $this->NewObject();
    }
    
    
    
    
    
    
    public function NewObject()
    {
        
        
        
        
        $_7d8349934215833a7b750e580b17133a = parent::NewObject();
        return $_7d8349934215833a7b750e580b17133a;
    }
    
    
    
    
    
    
    protected function GetTable()
    {
        return ObjectsStorage::I()->GetDbTable($this->NewObject());
    }
}