<?php require_once('includes/requirecompere.inc.php'); $CMD_TMPL_NAME='question.manage'; $qn_id=TGET('qn_id'); $op=TGET('op'); $mb_id=current_mb_id(); if (!$qn_id) { redirect("qx-cmd-question.manage-focus-questionnaire.html"); return; } $dataset['QUESTIONNAIRE-SETTING']=array(0); $dataset['qn_id']=$qn_id; $DBConn->connect(true); $questionnaire=db_load_questionnaire_by_id($DBConn,$qn_id,$mb_id); $dataset+=$questionnaire; $questions=db_load_questions($DBConn,$mb_id); $id2question=rowset2map($questions,'q_id'); $questionnaire_questions=db_load_questionnaires_questions($DBConn,$qn_id); $questionnaire_q_ids=array_projection($questionnaire_questions,'q_id'); $q_id2qnq=rowset2map($questionnaire_questions,'q_id'); $dataset['QUESTION']=array(); $nextordinal=0; foreach ($q_id2qnq as $q_id=>$qnq) { $q=$id2question[$q_id]; $q['SELECTED']=array(0); $q['REQUIRED']=$qnq['qnq_required']?array(0):array(); $q+=$qnq; $nextordinal=max($nextordinal,$qnq['qnq_ordinal']); array_push($dataset['QUESTION'],$q); } foreach ($questions as $q) { if (!$q_id2qnq[$q['q_id']]) { $q['qnq_ordinal']=++$nextordinal; array_push($dataset['QUESTION'],$q); } } foreach ($dataset['QUESTION'] as &$q) { $q['TYPE-'.$q['q_type']]=array(0); } $dataset['QUESTION-NONE']=$dataset['QUESTION']?array():array(0); $dataset['QUESTIONNAIRE-SETTING-SAVED']=$op=='saved'?array(0):array(); $courses=db_load_course_by_owner($DBConn,$mb_id,false); $qncs=db_load_questionnaire_course_ids($DBConn,$qn_id); $dataset['COURSE']=$courses; foreach ($dataset['COURSE'] as &$c) { $c['SELECTED']=in_array($c['cs_id'],$qncs)?array(0):array(); } ?>