<?php
namespace Claromentis\Quiz\Repository;

$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] ?: array()) + array("_8d9b0819c2b801169776d6063e4dbb" . "2f" => base64_decode("c3VydmV5X2lkID0gaW" . "50OnN1cnZleV9pZA=="), "_8e15a2079" . "bcda2d8a31" . "ad8c8acf3c" . "aa3" => base64_decode("c29ydF9vcm" . "RlciBBU0M="), "_ce14087e679" . "7cbc3bf2db80" . "4bebe7754" => base64_decode("U0VMRUNUIENPVU5UKER" . "JU1RJTkNUIGlkKSBGUk" . "9NIA=="), "_84e7ca6b39887af1fa1ac" . "e5b00b40999" => base64_decode("U0VMRUNUIGlkIEZST0" . "0g"));
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["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_8d9b081" . "9c2b8011" . "69776d60" . "63e4dbb2" . "f"], $survey_id), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_8e15a2079" . "bcda2d8a31" . "ad8c8acf3c" . "aa3"]);
        return $sections;
    }
    
    
    
    
    
    public function CountSurveySections($survey_id)
    {
        if (!$survey_id) {
            return 0;
        }
        
        
        $_6555f4024e92c4a6b9140e99cd668e2b = $this->GetTable();
        
        
        $_30f942154645a3deca356c5cbdef7313 = new DAL\QueryBuilder($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_ce14087e6797cbc3bf" . "2db804bebe7754"] . $_6555f4024e92c4a6b9140e99cd668e2b);
        $_30f942154645a3deca356c5cbdef7313->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_8d9b0819" . "c2b801169" . "776d6063e" . "4dbb2f"], $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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_84e7ca6b39887af1fa1ace5b" . "00b40999"] . $_6555f4024e92c4a6b9140e99cd668e2b);
        $_30f942154645a3deca356c5cbdef7313->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_8d9b0819" . "c2b801169" . "776d6063e" . "4dbb2f"], $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());
    }
}