| Server IP : 162.214.74.102 / Your IP : 216.73.216.59 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/leve/application/plugins/module_teammanagement/models/ |
Upload File : |
<?php
include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/QuestionFactory.php";
class QuestionModel extends My_Model
{
/**
* @var string
*/
public $table = 'module_teammanagement_quiz_questions';
public function createQuestion($data)
{
$category = self::create();
$category->default=0;
QuestionFactory::create($data, $category,true);
$category->save();
return $category;
}
public function updateQuestion($data, $category)
{
ORM::for_table($this->table)->create($category);
QuestionFactory::create($data, $category);
$category->save();
return $category;
}
public function deleteQuestion($category)
{
ORM::for_table($this->table)->create($category);
$category->delete();
return $category;
}
public function getNewQuestion($quizRegister,$cat)
{
$questions= ORM::for_table($this->table)
->where("module_teammanagement_quiz_cat_id",$cat->id)
->where("level", $quizRegister->level)
->where_not_equal("id",$quizRegister->module_teammanagement_quiz_question_id==null||empty($quizRegister->module_teammanagement_quiz_question_id)?0:$quizRegister->module_teammanagement_quiz_question_id."")
->find_many();
if(count($questions)>0){
$q=$questions[mt_rand ( 0 , count($questions)-1 )];
//registra a questão no quiz responser do usuário
$quizRegister->module_teammanagement_quiz_question_id=$q->id;
$quizRegister->save();
return $q;
}else {
$quizRegister->module_teammanagement_quiz_question_id=0;
$quizRegister->save();
return false;
}
}
public function getQuestionForLevel($quizRegister,$cat)
{
$questions= ORM::for_table($this->table)
->where("module_teammanagement_quiz_cat_id",$cat->id)
->where("level", $quizRegister->level)
->find_many();
return count($questions);
}
}