NEW CHANGE

This commit is contained in:
velz 2018-11-03 17:24:13 +05:30
parent 96dd7addb1
commit 8e146294dd
6 changed files with 101 additions and 13 deletions

View File

@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto
// define login route name for token verification
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors
defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllQuestions/:any)'); // no errors
defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getTemplateCategories'); // no errors
/*********************AWS resources Constants*************************************************/
defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic');
@ -324,5 +324,8 @@ defined('COMMONMASTERID') OR define('COMMONMASTERID','log_id');
defined('QUESTIONGROUP') OR define('QUESTIONGROUP','m_question_group');
defined('QUESTIONGROUPID') OR define('QUESTIONGROUPID','question_group_id');
defined('TEMPLATEGROUP') OR define('TEMPLATEGROUP','m_template_group');
defined('TEMPLATEGROUPID') OR define('TEMPLATEGROUPID','template_group_id');

View File

@ -108,6 +108,7 @@ $route['getTemplateCategories'] = 'Template_Management_Controller/getTemplateCat
$route['getTemplateQuestionAnswers'] = 'Template_Management_Controller/getTemplateQuestionAnswers';
$route['getListOfCategories'] = 'Template_Management_Controller/getListOfCategories';
$route['getQuestionsForTemplateCreation'] = 'Template_Management_Controller/getQuestionsForTemplateCreation';
$route['getCategoryGroupCombinations'] = 'Template_Management_Controller/getCategoryGroupCombinations';
//QUESTION MANAGEMENT
$route['(listAllQuestions/:any)'] = 'Question_Management_Controller/listAllQuestions/';

View File

@ -144,15 +144,41 @@ class Template_Management_Controller extends REST_Controller {
{
if($template_category_detail['template_category_weightage_id'] != null || $template_category_detail['template_category_weightage_id'] != "")
{
$groups = $template_category_detail['groups'];
unset($template_category_detail['groups']);
$where_condition_array = array('template_category_weightage_id'=>$template_category_detail['template_category_weightage_id']);
$modified = $this->Template_Management_Model->updateRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE,$where_condition_array);
if($modified != "" || $modified != null){ $count++; }
//Groups insert/update
foreach($groups as $group_key => $group)
{
if($group['template_group_id'] != null || $group['template_group_id'] != "")
{
$where_condition_array = array('template_group_id'=>$group['template_group_id']);
$modified = $this->Template_Management_Model->updateRecords($group,TEMPLATEGROUP,$where_condition_array);
}
else
{
$template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP);
}
}
}
//Insert Categories
else
{
unset($template_category_detail['template_category_weightage_id']);
$groups = $template_category_detail['groups'];
unset($template_category_detail['groups']);
$id = $this->Template_Management_Model->saveRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE);
if($id != "" || $id != null){ $count++; }
//Groups insert
foreach($groups as $group_key => $group)
{
$template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP);
}
}
}
@ -396,4 +422,35 @@ class Template_Management_Controller extends REST_Controller {
}
}
//Get Categories and questions group compinations
public function getCategoryGroupCombinations_get()
{
$fields = array('question_category_id','category_name');
$where_condition_array = array('isactive' => 1);
$result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONCATEGORY);
if(count($result_data))
{
foreach($result_data as $key => $result)
{
$groups = $this->Template_Management_Model->getCategoryGroupCombinations($result['question_category_id']);
$result_data[$key]['gropus'] = $groups;
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = "No Categories Found!";
$this->response($data,REST_Controller::HTTP_OK);
}
}
}

View File

@ -458,9 +458,7 @@ class PD_Model extends SPARQ_Model {
//print_r( $categories);
if(count($categories))
{
/*
DATE_FORMAT(TEMPLATEQUESTION.createdon,"%d/%m/%Y") as createdon, TEMPLATEQUESTION.fk_createdby, DATE_FORMAT(TEMPLATEQUESTION.updatedon,"%d/%m/%Y") as updatedon, TEMPLATEQUESTION.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby
*/
foreach($categories as $category_key => $category)
{
@ -474,6 +472,7 @@ class PD_Model extends SPARQ_Model {
// $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATEQUESTION.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATEQUESTION.fk_template_question_category_id',$category['fk_question_category_id']);
$this->db->WHERE('TEMPLATEQUESTION.fk_template_id', $template_id);
$this->db->ORDER_BY('QUESTIONS.question_id');
//$this->db->WHERE('TEMPLATEQUESTION.fk_template_id',$template_id);
$questions = $this->db->GET()->result_array();

View File

@ -14,7 +14,7 @@ class Question_Management_Model extends SPARQ_Model {
{
$this->db->SELECT('QUESTIONS.question_id,QUESTIONGROUP.question_group_id,QUESTIONGROUP.group_name, QUESTIONS.question, QUESTIONS.description, QUESTIONS.fk_question_category,QUESTIONCATEGORY.category_name, QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,QUESTIONS.isactive, QUESTIONS.createdon, QUESTIONS.fk_createdby, QUESTIONS.updatedon, QUESTIONS.fk_updatedby,concat(USERPROFILE.first_name," " ,USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->SELECT('QUESTIONS.question_id,QUESTIONS.fk_question_group_id,QUESTIONGROUP.group_name, QUESTIONS.question, QUESTIONS.description, QUESTIONS.fk_question_category,QUESTIONCATEGORY.category_name, QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,QUESTIONS.isactive, QUESTIONS.createdon, QUESTIONS.fk_createdby, QUESTIONS.updatedon, QUESTIONS.fk_updatedby,concat(USERPROFILE.first_name," " ,USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby');
$this->db->FROM(QUESTIONS.' as QUESTIONS');
$this->db->JOIN(QUESTIONANSWERTYPE.' as QUESTIONANSWERTYPE','QUESTIONS.fk_question_answertype = QUESTIONANSWERTYPE.question_answer_type_id');
$this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','QUESTIONS.fk_question_category = QUESTIONCATEGORY.question_category_id');
@ -32,7 +32,7 @@ class Question_Management_Model extends SPARQ_Model {
foreach($result as $key => $r)
{
$this->db->SELECT('QUESTIONANSWERS.question_answer_id, QUESTIONANSWERS.fk_question_id, QUESTIONANSWERS.answer, QUESTIONANSWERS.createdon, QUESTIONANSWERS.fk_createdby, QUESTIONANSWERS.updatedon, QUESTIONANSWERS.fk_updatedby, QUESTIONANSWERS.isactive');
$this->db->SELECT('QUESTIONANSWERS.question_answer_id, QUESTIONANSWERS.fk_question_id, QUESTIONANSWERS.fk_question_group_id,QUESTIONANSWERS.answer, QUESTIONANSWERS.createdon, QUESTIONANSWERS.fk_createdby, QUESTIONANSWERS.updatedon, QUESTIONANSWERS.fk_updatedby, QUESTIONANSWERS.isactive');
$this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS');
$this->db->JOIN(QUESTIONS.' as QUESTIONS','QUESTIONANSWERS.fk_question_id = QUESTIONS.question_id');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','QUESTIONANSWERS.fk_createdby = USERPROFILE.userid ');

View File

@ -85,8 +85,19 @@ class Template_Management_Model extends SPARQ_Model {
// $this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATECATEGORYWEIGHTAGE.fk_createdby = USERPROFILE.userid','LEFT');
//$this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATECATEGORYWEIGHTAGE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATECATEGORYWEIGHTAGE.fk_template_id',$template_id);
$data = $this->db->GET()->result_array();
return $data;
$categories = $this->db->GET()->result_array();
if(count($categories))
{
foreach($categories as $ckey => $category)
{
$this->db->SELECT('template_group_id,fk_question_group_id');
$this->db->FROM(TEMPLATEGROUP);
$this->db->WHERE(TEMPLATEGROUP.'.fk_template_category_weightage_id',$category['template_category_weightage_id']);
$groups = $this->db->GET()->result_array();
$categories[$ckey]['groups'] = $groups;
}
}
return $categories;
}
@ -148,13 +159,13 @@ class Template_Management_Model extends SPARQ_Model {
}
public function getListOfQuestions($template_id,$category_id)
public function getListOfQuestions($template_id,$category_id,$group_id)
{
$questions = array();
if(($template_id != "" || $template_id != null) && ($category_id != "" || $category_id != null))
{
$fields = array('fk_question_id');
$where_condition_array = array('fk_template_question_category_id' => $category_id,'fk_template_id' => $template_id);
$where_condition_array = array('fk_template_question_category_id' => $category_id,'fk_template_id' => $template_id,'fk_question_group_id'=>$group_id);
$result_data = $this->selectCustomRecords($fields,$where_condition_array,TEMPLATEQUESTION);
if(count($result_data))
@ -169,6 +180,7 @@ class Template_Management_Model extends SPARQ_Model {
$this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question');
$this->db->FROM(QUESTIONS.' as QUESTIONS');
$this->db->WHERE('QUESTIONS.fk_question_category',$category_id);
$this->db->WHERE('QUESTIONS.fk_question_group_id',$group_id);
$this->db->WHERE('QUESTIONS.isactive',1);
$this->db->WHERE_NOT_IN('QUESTIONS.question_id',$temp_array);
$questions = $this->db->GET()->result_array();
@ -179,9 +191,10 @@ class Template_Management_Model extends SPARQ_Model {
foreach($questions as $answer_key => $question)
{
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer');
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,QUESTIONANSWERS.fk_question_group_id');
$this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS');
$this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']);
$this->db->WHERE('QUESTIONANSWERS.isactive',1);
$answers = $this->db->GET()->result_array();
// Attach TEMPLATEANSWERWEIGHTAGE table keys for front purpose
@ -208,6 +221,7 @@ class Template_Management_Model extends SPARQ_Model {
$this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question');
$this->db->FROM(QUESTIONS.' as QUESTIONS');
$this->db->WHERE('QUESTIONS.fk_question_category',$category_id);
$this->db->WHERE('QUESTIONS.fk_question_group_id',$group_id);
$this->db->WHERE('QUESTIONS.isactive',1);
$questions = $this->db->GET()->result_array();
@ -218,7 +232,7 @@ class Template_Management_Model extends SPARQ_Model {
foreach($questions as $answer_key => $question)
{
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer');
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,QUESTIONANSWERS.fk_question_group_id');
$this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS');
$this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']);
$answers = $this->db->GET()->result_array();
@ -252,5 +266,19 @@ class Template_Management_Model extends SPARQ_Model {
return $questions;
}
public function getCategoryGroupCombinations($question_category_id)
{
$this->db->DISTINCT();
$this->db->SELECT('QUESTIONGROUP.question_group_id,QUESTIONGROUP.group_name');
$this->db->FROM(QUESTIONS.' as QUESTIONS');
$this->db->JOIN(QUESTIONGROUP.' as QUESTIONGROUP','QUESTIONS.fk_question_group_id = QUESTIONGROUP.question_group_id');
$this->db->WHERE('QUESTIONS.fk_question_category',$question_category_id);
$groups = $this->db->GET()->result_array();
return $groups;
}
}