193 lines
6.5 KiB
PHP
Executable File
193 lines
6.5 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Onboarding_model extends CI_model {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->database();
|
|
$this->load->model('caregivers/Caregiver_model');
|
|
$this->load->model('hms_web_service/Service_head_model');
|
|
}
|
|
|
|
function token_details($token){
|
|
$this->db->order_by('id', 'DESC');
|
|
$this->db->where('token', $token);
|
|
$query = $this->db->get('caregiver_onboard_registration_token');
|
|
return $query->row();
|
|
}
|
|
function getCaregiverToken($cgid)
|
|
{
|
|
$this->db->order_by('id', 'DESC');
|
|
$this->db->where('user_id', $cgid);
|
|
$query = $this->db->get('caregiver_onboard_registration_token');
|
|
return $query->row();
|
|
}
|
|
function getNurseById($id) {
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('caregiver')->row();
|
|
return $query;
|
|
}
|
|
function onBoardContent($type)
|
|
{
|
|
$this->db->where('slug', $type);
|
|
$query = $this->db->get('onboardingdisplaycontent');
|
|
return $query->row();
|
|
}
|
|
function onBoardVideos($qualificationType,$uid)
|
|
{
|
|
|
|
$this->db->where('qualification_type', $qualificationType);
|
|
$query = $this->db->get('onboardvideo');
|
|
$videos = $query->result();
|
|
foreach($videos as $video)
|
|
{
|
|
|
|
$this->db->where('video_id', $video->id);
|
|
$this->db->where('user_id', $uid);
|
|
$examResultList = $this->db->get('quizexamresult');
|
|
$examRes = $examResultList->num_rows();
|
|
|
|
|
|
if($examRes > 0)
|
|
{
|
|
$video->watchStatus = 1;
|
|
}
|
|
else{
|
|
$video->watchStatus = 0;
|
|
}
|
|
|
|
}
|
|
return $videos;
|
|
}
|
|
function onBoardVideosById($id)
|
|
{
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('onboardvideo');
|
|
return $query->row();
|
|
}
|
|
function getQuizQuestionsByVideoId($vid)
|
|
{
|
|
$questionArray = array();
|
|
$this->db->where('relatedVideoId', $vid);
|
|
$questionQuery = $this->db->get('onboard_questions');
|
|
$questions = $questionQuery->result();
|
|
// _die();
|
|
foreach ($questions as $question) {
|
|
$this->db->where('question_id', $question->id);
|
|
$answerQuery = $this->db->get('onboard_ans');
|
|
$answers = $answerQuery->result();
|
|
|
|
$raw = array(
|
|
'question' => $question,
|
|
'answer' => $answers,
|
|
);
|
|
$questionArray[] = $raw;
|
|
}
|
|
return $questionArray;
|
|
}
|
|
|
|
function getQuizResult($vid,$token="",$user_id)
|
|
{
|
|
$this->db->where('video_id', $vid);
|
|
if($token != "")
|
|
$this->db->where('token', $token);
|
|
$this->db->where('user_id', $user_id);
|
|
$answerQuery = $this->db->get('quizresult_qa');
|
|
$quizResult = $answerQuery->result();
|
|
|
|
foreach($quizResult as $qrs)
|
|
{
|
|
$this->db->where('id', $qrs->question_id);
|
|
$answerQuery = $this->db->get('onboard_questions');
|
|
$question = $answerQuery->row();
|
|
$qrs->question = $question;
|
|
|
|
$this->db->where('question_id', $qrs->question_id);
|
|
$answerQuery = $this->db->get('onboard_ans');
|
|
$answers = $answerQuery->result();
|
|
$qrs->options = $answers;
|
|
}
|
|
return $quizResult;
|
|
}
|
|
function getQuizResultPrecent($vid,$token="",$user_id)
|
|
{
|
|
$this->db->where('video_id', $vid);
|
|
if($token != "")
|
|
$this->db->where('token', $token);
|
|
$this->db->where('user_id', $user_id);
|
|
$answerQuery = $this->db->get('quizexamresult');
|
|
$quizResult = $answerQuery->row();
|
|
return $quizResult;
|
|
}
|
|
|
|
function saveExamData($data)
|
|
{
|
|
$this->db->where('id', $data['question_id']);
|
|
$answerQuery = $this->db->get('onboard_questions');
|
|
$answers = $answerQuery->row();
|
|
$data['corr_answer_id'] = $answers->answer_id;
|
|
|
|
$this->db->where('id', $data['answer_id']);
|
|
$optionQuery = $this->db->get('onboard_ans');
|
|
$option = $optionQuery->row();
|
|
$data['corr_answer_text'] = $option->answer_text;
|
|
|
|
$this->db->insert('quizresult_qa', $data);
|
|
}
|
|
|
|
function saveQuizFinalResult($data)
|
|
{
|
|
$this->db->where('user_id', $data['user_id']);
|
|
$this->db->where('video_id', $data['video_id']);
|
|
$lastResult = $this->db->get('quizexamresult')->row();
|
|
|
|
if($lastResult){
|
|
$this->db->where('user_id', $data['user_id']);
|
|
$this->db->where('video_id', $data['video_id']);
|
|
return $this->db->update('quizexamresult', $data);
|
|
}else{
|
|
$this->db->insert('quizexamresult', $data);
|
|
return $this->db->insert_id();
|
|
}
|
|
// $this->db->insert('quizexamresult', $data);
|
|
// return $this->db->insert_id();
|
|
}
|
|
|
|
function getOnboardingDisclosure($uid,$ion_user_id,$type){
|
|
$disclosures=$this->Caregiver_model->getOnBoardingDocsByType($type);
|
|
$i=$pending_sign=0;
|
|
$siged=[];
|
|
foreach ($disclosures as $disclosure) {
|
|
// pre($disclosure);
|
|
$signature=null;
|
|
$signature=$this->Service_head_model->getSignatureDoc($uid,$ion_user_id,$disclosure['short_code']);
|
|
// pre($signature);die;
|
|
|
|
if($signature['signature_status']==1){
|
|
$disclosures[$i]['signature']=$signature['signature'];
|
|
$disclosures[$i]['signature_date']=$signature['signature_date'];
|
|
$disclosures[$i]['pdf_link']=$signature['pdf_link'];
|
|
$disclosures[$i]['verified_by_ionid']=$signature['verified_by_ionid'];
|
|
$disclosures[$i]['verified_on']=$signature['verified_on'];
|
|
array_push($siged,$disclosure['short_code']);
|
|
}
|
|
else{
|
|
$disclosures[$i]['signature']=null;
|
|
$disclosures[$i]['signature_date']=null;
|
|
$disclosures[$i]['pdf_link']='';
|
|
$pending_sign++;
|
|
}
|
|
$i++;
|
|
}
|
|
// pre($disclosures);
|
|
// die;
|
|
if($pending_sign>0){$output['pending']=true;}else{$output['pending']=false;}
|
|
$output['data']=$disclosures;
|
|
$output['signed']=$siged;
|
|
return $output;
|
|
}
|
|
}
|