{"id":5287,"date":"2013-05-08T12:01:08","date_gmt":"2013-05-08T16:01:08","guid":{"rendered":"https:\/\/www.caskeys.com\/dc\/?p=5287"},"modified":"2017-01-15T15:21:58","modified_gmt":"2017-01-15T20:21:58","slug":"class-training","status":"publish","type":"post","link":"https:\/\/www.caskeys.com\/dc\/class-training\/","title":{"rendered":"Class &#8211; Training"},"content":{"rendered":"<pre class=\"brush: php; title: Code:; notranslate\" title=\"Code:\">\r\n&lt;?php\r\n\r\nclass class_training\r\n{    \r\n\r\n\t\/*\r\n\tconstants\r\n\tDamon Vaughn Caskey\r\n\t2012_12_18\r\n\t\r\n\tGlobal constants. \r\n\t*\/\t\t\r\n\t\t\r\n\tprivate\t$oDB\t\t= NULL;\t\/\/Class object: Database.\r\n\tprivate $oDBA\t\t= NULL;\t\/\/Class object: Database (answers).\r\n\tprivate $oSes\t\t= NULL;\t\/\/Class object: Session.\r\n\tprivate\t$oUtl\t\t= NULL;\t\/\/Class object: Filter.\r\n\tprivate\t$oErr\t\t= NULL;\t\/\/Class object: Error.\r\n\tprivate $oFrm\t\t= NULL;\t\/\/Class object: Forms. \t\t\r\n\tprivate $cQuery\t\t= NULL;\r\n\tprivate $cParams\t= NULL;\r\n\tprivate $cTVarsTD\t= NULL;\t\/\/Class variable ID array.\r\n\tprivate $cTVars\t\t= NULL;\r\n\t\r\n\tfunction __construct($oDep)\r\n\t{\r\n\t\t\/*\r\n\t\tConstructor\r\n\t\tDamon Vaughn Caskey\r\n\t\t2012_12_29\r\n\t\t\r\n\t\tClass constructor.\r\n\t\t*\/\r\n\t\t\r\n\t\t\/* Import object dependencies. *\/\r\n\t\t$this-&gt;oSes\t= $oDep&#x5B;'Ses'];\r\n\t\t$this-&gt;oDB \t= $oDep&#x5B;'DB'];\r\n\t\t$this-&gt;oFrm\t= $oDep&#x5B;'Frm'];\r\n\t\t$this-&gt;oFil\t= $oDep&#x5B;'Fil'];\r\n\t\t$this-&gt;oErr\t= $oDep&#x5B;'Err'];\r\n\t\t$this-&gt;oDBA\t= new class_db(array('Utl' =&gt; $oDep&#x5B;'Utl'], 'Err' =&gt; $oDep&#x5B;'Err']));\r\n\t\t\t\t\r\n\t\t\/* Verify object dependencies. *\/\r\n\t\tif(!$this-&gt;oDBA)\ttrigger_error(&quot;Missing object dependency: Database (Ans).&quot;, E_USER_ERROR);\r\n\t\tif(!$this-&gt;oDB)\t\ttrigger_error(&quot;Missing object dependency: Database.&quot;, E_USER_ERROR);\r\n\t\tif(!$this-&gt;oSes)\ttrigger_error(&quot;Missing object dependency: Session.&quot;, E_USER_ERROR);\t\r\n\t\tif(!$this-&gt;oFrm)\ttrigger_error(&quot;Missing object dependency: Forms.&quot;, E_USER_ERROR);\t\r\n\t\tif(!$this-&gt;oFil)\ttrigger_error(&quot;Missing object dependency: Filter.&quot;, E_USER_ERROR);\t\t\r\n\t\tif(!$this-&gt;oErr)\ttrigger_error(&quot;Missing object dependency: Error.&quot;, E_USER_ERROR);\t\t\r\n\t}\r\n\t\r\n\tpublic function training_quiz_grade($cQuizID)\r\n\t{\r\n\t\t$cQuestionCount = NULL;\r\n\t\t$cQuestionRight = NULL;\t\r\n\t\t$val\t\t\t= NULL;\t\r\n\t\t$iQueCnt\t\t= 0;\r\n\t\t$cResponse\t\t= NULL;\r\n\t\t$cQuizGradeStr\t= NULL;\r\n\t\t$ans\t\t\t= 0;\r\n\t\t$cPercentage\t= 0;\r\n\t\t\t\t\t\t\t\t\r\n\t\t$cQuestionCount = $this-&gt;oSes-&gt;session_get('quiz_question_count');\r\n\t\t$cQuestionRight = $this-&gt;oSes-&gt;session_get('quiz_answer_right');\r\n\t\t\r\n\t\t$cQuestionRight = str_replace (&quot; &quot;, &quot;&quot;, $cQuestionRight);\t\/\/Remove spaces.\r\n\t\t$cQuestionRight = explode(&quot;,&quot;, $cQuestionRight);\t\t\t\/\/Break into array.\r\n\t\t\r\n\t\tforeach($cQuestionRight as $val)\t\t\t\t\/\/Loop array collection.\r\n\t\t{\t\t\r\n\t\t\t\/* Increment counter. *\/\r\n\t\t\t$iQueCnt++;\t\t\t\t\t\r\n\t\t\t\r\n\t\t\t\/* Get question response *\/\r\n\t\t\t$cResponse = $this-&gt;oFil-&gt;utl_get_post(&quot;Q&quot;.$iQueCnt);\r\n\t\t\t\t\t\t\t\r\n\t\t\t$cQuizGradeStr.= &quot;Question &quot;.$iQueCnt.&quot; response: &quot;;\t\r\n\t\t\t\r\n\t\t\tif (!$cResponse)\r\n\t\t\t{\r\n\t\t\t\t$cQuizGradeStr.= &quot;No answer.&lt;br\/&gt;&quot;;\r\n\t\t\t}\r\n\t\t\telse\t\t\t\t\r\n\t\t\t{\r\n\t\t\t\tif ($cResponse == $val)\r\n\t\t\t\t{\r\n\t\t\t\t\t$cQuizGradeStr.= $cResponse.&quot; - Correct.&lt;br\/&gt;&quot;;\r\n\t\t\t\t\t$ans++;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t$cQuizGradeStr.= $cResponse.&quot; - Incorrect.&lt;br\/&gt;&quot;;\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\t\t\t\t\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t$cPercentage\t= round(($ans \/ $iQueCnt)*100);\r\n\t\t\t\r\n\t\t$cQuizGradeStr.= &quot;&lt;br \/&gt;You answered &quot;.$ans. &quot; of &quot;.$iQueCnt. &quot; correctly (&quot;.$cPercentage.&quot;%).&lt;br \/&gt;&lt;br \/&gt;&quot;;\r\n\t\t\t\t\t\r\n\t\t$array&#x5B;&quot;ans&quot;] \t\t\t= $ans;\r\n\t\t$array&#x5B;&quot;percentage&quot;] \t= $cPercentage;\r\n        $array&#x5B;&quot;text&quot;] \t\t\t= $cQuizGradeStr;\r\n        \t\t\t\r\n\t\treturn $array;\t\t\r\n\t\t\r\n\t}\r\n\t\t\r\n\tpublic function training_quiz_questions($cQuizID, $cOrder=NULL, $cQuantity=NULL)\r\n\t{\r\n\t\t\/*\r\n\t\ttraining_quiz_questions\r\n\t\tDamon V. Caskey\r\n\t\t2011_11_29\r\n\t\t~2012_12_23: DB Class.\r\n\t\t\r\n\t\tPopulate question list and possible answers from database from Quiz ID.\r\n\t\t\r\n\t\t$cQuizID:\tQuiz ID to get quiz questions from. \r\n\t\t*\/\t\t\r\n  \t\t\t\t\t\r\n\t\t$cQuizStr \t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Final output string to be placed into page.\r\n\t\t$QuestionID\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Current question ID in question loop.\t\r\n\t\t$cQuestionCount\t\t= 0;\t\t\t\t\t\t\t\t\/\/Include ID into question header.\t\t\r\n\t\t$cQuestionRight\t\t= NULL;\t\t\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\tif(!$cOrder)\r\n\t\t{\r\n\t\t\t$cOrder = NULL;\t\/\/Order in table.\t\r\n\t\t}\r\n\t\telse if($cOrder == 1)\r\n\t\t{\r\n\t\t\t$cOrder = &quot;ORDER BY\tquestion_order&quot;;\t\/\/User specified order.\r\n\t\t}\r\n\t\telse if($cOrder == 2)\r\n\t\t{\r\n\t\t\t$cOrder = &quot;ORDER BY\tnewid()&quot;;\t\/\/Random order\t\r\n\t\t}\r\n\t\t\r\n\t\t$cQuantity = $cQuantity ? &quot;TOP &quot;.$cQuantity : NULL;\r\n\t\t\r\n\t\t\/* Construct questions query string. *\/\r\n\t\t$this-&gt;cQuery = &quot;SELECT &quot;\r\n\t\t\t.$cQuantity\r\n\t\t\t.&quot; *\r\n\t\t\tFROM \t\ttbl_class_train_questions\r\n\t\t\tWHERE\t\tfk_tbl_class_train_parameters_guid_id = ? &quot;\r\n\t\t\t.$cOrder;\t\r\n\t\t\r\n\t\t\/* Apply parameters. *\/\r\n\t\t$this-&gt;cParams = array(&amp;$cQuizID);\r\n\t\t\r\n\t\t\/* Execute questions query. *\/\r\n\t\t$this-&gt;oDB-&gt;db_basic_select($this-&gt;cQuery, $this-&gt;cParams);\r\n\t\t\r\n\t\t\/* Construct answers query string. *\/\r\n\t\t$this-&gt;cQuery = &quot;SELECT \r\n\t\t\t* \r\n\t\t\tFROM \ttbl_class_train_answers\r\n\t\t\tWHERE\tfk_tbl_class_train_questions_guid_id = ?\r\n\t\t\tORDER BY answer_order, value&quot;;\r\n\t\t\r\n\t\t\/* Apply parameters. *\/\r\n\t\t$this-&gt;cParams = array(&amp;$QuestionID);\r\n\t\t\r\n\t\twhile($this-&gt;oDB-&gt;db_line())\r\n\t\t{\r\n\t\t\t$QuestionID = $this-&gt;oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;];\r\n\t\t\t\r\n\t\t\t\/*\tGet answer set matching current question ID. *\/\r\n\t\t\t$this-&gt;cParams = array(&amp;$QuestionID);\r\n\t\t\t\r\n\t\t\t\/*Record answer array. First element will be blank. ( &quot;, A, C, B, A, etc.&quot;) *\/\r\n\t\t\tif($cQuestionRight)\r\n\t\t\t{\r\n\t\t\t\t$cQuestionRight .= &quot;, &quot; .$this-&gt;oDB-&gt;cDBLine&#x5B;&quot;right_answer&quot;];\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t$cQuestionRight = $this-&gt;oDB-&gt;cDBLine&#x5B;&quot;right_answer&quot;];\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\/* Build question string. *\/\r\n\t\t\t$cQuizStr \t.=&quot;&lt;p&gt;&lt;span class='TrainQuestionHeader'&gt;&quot;\r\n\t\t\t\t\t\t.&quot;Question &quot;.++$cQuestionCount\t\t\t\r\n\t\t\t\t\t\t.&quot;&lt;\/span&gt;&lt;br \/&gt;&quot;\r\n\t\t\t\t\t\t.&quot;&lt;span class='TrainQuestionText'&gt;&quot;\t\t\t\r\n\t\t\t\t\t\t.$this-&gt;oDB-&gt;cDBLine&#x5B;&quot;question&quot;]\t\t\r\n\t\t\t\t\t\t.&quot;&lt;\/span&gt;&lt;br \/&gt;&quot;;\t\t\t\r\n\t\t\t\r\n\t\t\t\/* Execute answers query. *\/\r\n\t\t\t$this-&gt;oDBA-&gt;db_basic_select($this-&gt;cQuery, $this-&gt;cParams);\r\n\t\t\t\r\n\t\t\twhile ($this-&gt;oDBA-&gt;db_line())\r\n    \t\t{\t\t\t\r\n\t\t\t\t$cQuizStr\t.=\t&quot;&lt;input type='radio' name='Q&quot;\t\t\t\t\t\r\n\t\t\t\t\t\t\t.$cQuestionCount\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t.&quot;' value='&quot;\t\r\n\t\t\t\t\t\t\t.$this-&gt;oDBA-&gt;cDBLine&#x5B;&quot;value&quot;]\t\r\n\t\t\t\t\t\t\t.&quot;' \/&gt;&quot;\r\n\t\t\t\t\t\t\t.&quot;&lt;span class='TrainQuestionAnswerHeader'&gt;&quot;\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t.$this-&gt;oDBA-&gt;cDBLine&#x5B;&quot;value&quot;]\r\n\t\t\t\t\t\t\t.&quot;)&lt;\/span&gt; &quot;\r\n\t\t\t\t\t\t\t.&quot;&lt;span class='TrainQuestionAnswerText'&gt;&quot;\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t.$this-&gt;oDBA-&gt;cDBLine&#x5B;&quot;text&quot;]\r\n\t\t\t\t\t\t\t.&quot;&lt;\/span&gt;&lt;br \/&gt;&quot;;\t\t\t\t\t\t\t\r\n\t\t\t}\t\t\t\t\t\t\r\n\t\t}\t\t\t\r\n\t\t\r\n\t\tif(!$cQuizStr)\r\n\t\t{\r\n\t\t\t$cQuizStr = &quot;&lt;h2&gt;&lt;span class='alert'&gt;No questions available.&lt;\/span&gt;&lt;\/h2&gt;&quot;;\r\n\t\t}\r\n\t\t\r\n\t\t$this-&gt;oSes-&gt;session_set('quiz_answer_right', $cQuestionRight);\r\n\t\t$this-&gt;oSes-&gt;session_set('quiz_question_count', $cQuestionCount);\r\n\t\t\t\t\r\n\t\treturn $cQuizStr;\r\n\t}\r\n\t\r\n\tpublic function training_quiz_questions_setup($cQuizID, $cOrder=NULL, $cQuantity=NULL)\r\n\t{\t\t\r\n\t\t\/*\r\n\t\tclass_quiz_questions_0003\r\n\t\tDamon V. Caskey\r\n\t\t2012_10_04\r\n\t\t\r\n\t\tCreate form to modifiy questions and answers.\r\n\t\t\r\n\t\t$cQuizID:\tQuiz ID to get quiz questions from. \r\n\t\t*\/\t\t\r\n  \t\t\t\r\n\t\t$cQuizStr \t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Final output string to be placed into page.\r\n\t\t$cQuery\t\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Query string.\r\n\t\t$cParams\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Parameter array.\r\n\t\t$oDBA\t\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Database class object (answers). \r\n\t\t$QuestionID\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Current question ID in question loop.\t\r\n\t\t$cOrderLst\t\t\t= NULL;\t\t\t\t\t\t\t\t\/\/Droplist values for question order.\r\n\t\t$cAnswerValLst\t\t= NULL;\r\n\t\t\r\n\t\t\/* Initialize database class objects. *\/\r\n\t\t$oDBA\t= new class_db(array(&quot;Utl&quot; =&gt; $oUtl, &quot;Err&quot; =&gt; $oErr));\t\t\t\t\t\/\/Database class object (Answers).\r\n\t\t\r\n\t\t\/* Prepare answer dropdown list values *\/\r\n\t\t$cAnswerValLst \t\t= array_merge(array(&quot;-&quot; =&gt; &quot;-&quot;), range('A', 'Z'));\r\n\t\t\t\t\r\n\t\t\/* Construct questions query. *\/\r\n\t\t$cQuery = &quot;SELECT &quot;\r\n\t\t\t.$cQuantity\r\n\t\t\t.&quot; *\r\n\t\t\tFROM \t\ttbl_class_train_questions\r\n\t\t\tWHERE\t\tfk_tbl_class_train_parameters_guid_id = ? \r\n\t\t\tORDER BY\tquestion_order&quot;;\t\r\n\t\t\t\t\t\t\r\n\t\t\/* Apply question parameters. *\/\r\n\t\t$cParams = array(&amp;$cQuizID);\r\n\t\t\r\n\t\t\/* Execute questions query *\/\r\n\t\t$oDB-&gt;db_basic_select($cQuery, $cParams);\t\t\t\t\t\t\r\n\t\t\r\n\t\t$cQuery = &quot;SELECT \r\n\t\t\t\t\t\t* \r\n\t\t\t\t\t\tFROM \ttbl_class_train_answers\r\n\t\t\t\t\t\tWHERE\tfk_tbl_class_train_questions_guid_id = ?\r\n\t\t\t\t\t\tORDER BY answer_order, value&quot;;\r\n\t\t\r\n\t\t\/* Apply answer parameters. *\/\r\n\t\t$cParams = array(&amp;$QuestionID);\r\n\t\t\r\n\t\t\/* Prepare question order dropdown list values *\/\r\n\t\t$cOrderLst = range(1, $oDB-&gt;iDBRowCount);\r\n\t\t\t\r\n\t\twhile($oDB-&gt;db_line())\r\n\t\t{\r\n\t\t\t$QuestionID = $oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;];\t\t\t\t\t\t\r\n\t\t\t$cAnswers = NULL;\t\t\t\t\t  \r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t$oDBA-&gt;db_basic_select($cQuery, $cParams);\r\n\t\t\t\r\n\t\t\twhile($oDBA-&gt;db_line())\r\n\t\t\t{\t\t\t\r\n\t\t\t\t$cAnswers .= &quot;  \r\n\t\t\t\t\t\r\n\t\t\t\t\t&lt;form name='frm_answer_update' id='frm_answer_update_&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' method='post' action='&quot;.$_SERVER&#x5B;'PHP_SELF'].&quot;#a_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;].&quot;'&gt;\r\n\t\t\t\t\t\t&lt;input type='hidden' name='EditMode' value='1'  \/&gt;\r\n\t\t\t\t\t\t&lt;input type='hidden' name='id_guid' value='&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' \/&gt;\r\n\t\t\t\t\t\t  &lt;table width='100%' border='0' cellspacing='0' cellpadding='2' bgcolor='#DDDDFF'&gt;\r\n\t\t\t\t\t\t\t&lt;tr&gt;\r\n\t\t\t\t\t\t\t  &lt;td width='10%'&gt;\r\n\t\t\t\t\t\t\t\t  &lt;select name='frm_lst_answer_val' id='frm_lst_answer_val_&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;&quot;\r\n\t\t\t\t\t\t\t\t\t.$this-&gt;oFrm-&gt;forms_select_options($cAnswerValLst, NULL, $oDBA-&gt;cDBLine&#x5B;&quot;value&quot;], FALSE).\r\n\t\t\t\t\t\t\t\t  &quot;&lt;\/select&gt;\r\n\t\t\t\t\t\t\t  &lt;\/td&gt;\r\n\t\t\t\t\t\t\t  &lt;td width='70%'&gt;&lt;textarea name='frm_ta_answer_text' id='frm_ta_answer_text_&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' cols='35' rows='1'&gt;&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;text&quot;].&quot;&lt;\/textarea&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t  &lt;td width='10%' align='center'&gt;&lt;input type='image' src='\/media\/image\/icon_save_0001.png' name='frm_btn_ans_save' id='frm_btn_save_ans_&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' value='Save' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t  &lt;td width='10%' align='center'&gt;&lt;input type='image' src='\/media\/image\/icon_delete_0001.png' name='frm_btn_ans_delete' id='frm_btn_delete_ans_&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' value='Delete' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t&lt;\/tr&gt;\r\n\t\t\t\t\t\t  &lt;\/table&gt;\r\n\t\t\t\t\t&lt;\/form&gt;&lt;br \/&gt;&quot;;\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t}\t\t\t\t  \r\n\t\t  \r\n\t\t\t$cAnswers .= &quot;&lt;div id='new_answer_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;\r\n\r\n\t\t  \t&lt;form name='frm_answer_new' id='frm_answer_new_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' method='post' action='&quot;.$_SERVER&#x5B;'PHP_SELF'].&quot;#a_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;].&quot;'&gt;\r\n\t\t\t\t\t&lt;input type='hidden' name='EditMode' value='1'  \/&gt;\r\n\t\t\t\t\t&lt;input type='hidden' name='id_guid' value='&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' \/&gt;\r\n\t\t\t\t\t  &lt;table width='100%' border='0' cellspacing='0' cellpadding='2' bgcolor='#DDDDFF'&gt;\r\n\t\t\t\t\t\t&lt;tr&gt;\r\n\t\t\t\t\t\t  &lt;td width='10%'&gt;                          \r\n\t\t\t\t\t\t\t  &lt;select name='frm_lst_answer_val' id='frm_lst_answer_val_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' &gt;&quot;\r\n\t\t\t\t\t\t\t   .$this-&gt;oFrm-&gt;forms_select_options($cAnswerValLst, NULL, &quot;-&quot;, FALSE). \r\n\t\t\t\t\t\t\t  &quot;&lt;\/select&gt;\r\n\t\t\t\t\t\t  &lt;\/td&gt;\r\n\t\t\t\t\t\t  &lt;td width='70%'&gt;&lt;textarea name='frm_ta_answer_text' id='frm_ta_answer_text_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' cols='35' rows='1'&gt;&lt;\/textarea&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t  &lt;td width='20%' align='center'&gt;&lt;input type='image' src='\/media\/image\/icon_save_0001.png' name='frm_btn_ans_add' id='frm_btn_ans_add_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' value='Add' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t&lt;\/tr&gt;\r\n\t\t\t\t\t  &lt;\/table&gt;\r\n\t\t\t\t&lt;\/form&gt;&lt;\/div&gt;&quot;;\r\n\t\t  \r\n\t\t\t  $cQuizStr \t.= &quot;\r\n\t\t\t  &lt;br \/&gt;\r\n\t\t\t  &lt;div id='question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;\r\n\t\t\t  &lt;table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#F0F0FF'&gt;\r\n\t\t\t\t&lt;tr&gt;\r\n\t\t\t\t  &lt;td&gt;\r\n\t\t\t\t  \r\n\t\t\t\t\t  &lt;a name='a_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;].&quot;' id='a_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;].&quot;'&gt;&lt;\/a&gt;\r\n\t\t\t\t\t  &lt;form name='frm_question_update' id='frm_question_update_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'  method='post' action='&quot;.$_SERVER&#x5B;'PHP_SELF'].&quot;#a_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;].&quot;'&gt;\t\t\t\t\t\t\t  \r\n\t\t\t\t\t  &lt;input type='hidden' name='EditMode' value='1'  \/&gt;\r\n\t\t\t\t\t  &lt;input type='hidden' name='id_guid' value='&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' \/&gt;\r\n\t\t\t\t\t\t&lt;table width='100%' border='0' cellspacing='0' cellpadding='1' &gt;\r\n\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t&lt;th colspan='2'&gt;&lt;table width='100%' border='0' cellspacing='0' cellpadding='0'&gt;\r\n\t\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t\t&lt;td width='77%' align='left'&gt;Question\r\n\t\t\t\t\t\t\t\t  &lt;select name='frm_lst_order' id='frm_lst_order_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;&quot;\r\n\t\t\t\t\t\t\t\t\t.$this-&gt;oFrm-&gt;forms_select_options($cOrderLst, NULL, $oDB-&gt;cDBLine&#x5B;&quot;question_order&quot;], FALSE).\r\n\t\t\t\t\t\t\t\t  &quot;&lt;\/select&gt;\r\n\t\t\t\t\t\t\t\t  \r\n\t\t\t\t\t\t\t\t  &lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t&lt;td width='11%'&gt;&lt;input type='submit' name='frm_btn_que_save' id='frm_btn_que_save_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' value='Save' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t&lt;td width='12%'&gt;&lt;input type='submit' name='frm_btn_que_delete' id='frm_btn_que_delete_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' value='Delete' onclick='return confirmSubmit()' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t\t&lt;\/table&gt;&lt;\/th&gt;\r\n\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t&lt;td&gt;&lt;label for='frm_ta_question_val'&gt;Question Text&lt;\/label&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t&lt;td&gt;&lt;textarea name='frm_ta_question_val' id='frm_ta_question_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' cols='45' rows='5'&gt;&quot;.$oDB-&gt;cDBLine&#x5B;&quot;question&quot;].&quot;&lt;\/textarea&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t&lt;td&gt;&lt;label for='frm_lst_right_answer'&gt;Correct Response&lt;\/label&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t&lt;td&gt;&lt;select name='frm_lst_right_answer' id='frm_lst_right_answer_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' &gt;&quot;\r\n\t\t\t\t\t\t\t  .$this-&gt;oFrm-&gt;forms_select_options($cAnswerValLst, NULL, $oDB-&gt;cDBLine&#x5B;&quot;right_answer&quot;], FALSE).\r\n\t\t\t\t\t\t\t&quot;&lt;\/select&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t&lt;\/table&gt;\r\n\t\t\t\t\t  &lt;\/form&gt;&lt;br \/&gt;&quot;\r\n\t\t\t\t\t  \r\n\t\t\t\t\t  .&quot;&lt;div id='answers_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;&quot;\r\n\t\t\t\t\t  .$cAnswers\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t  .&quot;&lt;\/div&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;\/tr&gt;\r\n\t\t\t  &lt;\/table&gt;&lt;\/div&gt;&quot;;\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t}\t\r\n\t\t\r\n\t\t\t$cOrderLst&#x5B;$oDB-&gt;iDBRowCount+1] = $oDB-&gt;iDBRowCount+1; \/\/Add one more to the order list.\r\n\t\t\r\n\t\t\t$cQuizStr .= &quot;&lt;br \/&gt;\r\n\t\t\t\t\t  &lt;div id='question_new'&gt;\r\n\t\t\t\t\t  &lt;table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#F0F0FF'&gt;\r\n\t\t\t\t\t\t&lt;tr&gt;\r\n\t\t\t\t\t\t  &lt;td&gt;\t\t\t\t\t\t  \r\n\t\t\t\t\t\t\t  &lt;a name='a_question_&quot;.($oDB-&gt;iDBRowCount+1).&quot;' id='a_question_&quot;.($oDB-&gt;iDBRowCount+1).&quot;'&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\t\t  &lt;form name='frm_question_new' id='frm_question_new'  method='post' action='&quot;.$_SERVER&#x5B;'PHP_SELF'].&quot;#a_question_&quot;.($oDB-&gt;iDBRowCount+1).&quot;'&gt;\r\n\t\t\t\t\t\t\t  &lt;input type='hidden' name='trigger_type' value='question_add'  \/&gt;\r\n\t\t\t\t\t\t\t  &lt;input type='hidden' name='id_guid' value='&quot;.$oDBA-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;' \/&gt;\r\n\t\t\t\t\t\t\t  &lt;input type='hidden' name='EditMode' value='1'  \/&gt;\r\n\t\t\t\t\t\t\t  \t&lt;table width='100%' border='0' cellspacing='0' cellpadding='1' &gt;\r\n\t\t\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;th colspan='2'&gt;&lt;table width='100%' border='0' cellspacing='0' cellpadding='0'&gt;\r\n\t\t\t\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t\t\t\t&lt;td width='77%' align='left'&gt;Question\r\n\t\t\t\t\t\t\t\t\t\t  &lt;select name='frm_lst_order' id='frm_lst_order_&quot;.$oDB-&gt;cDBLine&#x5B;&quot;guid_id&quot;].&quot;'&gt;&quot;\r\n\t\t\t\t\t\t\t\t\t\t\t.$this-&gt;oFrm-&gt;forms_select_options($cOrderLst, NULL, ($oDB-&gt;iDBRowCount+1), FALSE).\r\n\t\t\t\t\t\t\t\t\t\t  &quot;&lt;\/select&gt;\r\n\t\t\t\t\t\t\t\t\t\t  \r\n\t\t\t\t\t\t\t\t\t\t  &lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t\t\t&lt;td width='11%'&gt;&lt;input type='submit' name='frm_btn_que_add' id='frm_btn_que_add' value='Add' \/&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;\/table&gt;&lt;\/th&gt;\r\n\t\t\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;td&gt;&lt;label for='frm_ta_question_val'&gt;Question Text&lt;\/label&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;td&gt;&lt;textarea name='frm_ta_question_val' id='frm_ta_question_val' cols='45' rows='5'&gt;&lt;\/textarea&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t\t\t  &lt;tr&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;td&gt;&lt;label for='frm_lst_right_answer'&gt;Correct Response&lt;\/label&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t\t&lt;td&gt;&lt;select name='frm_lst_right_answer' id='frm_lst_right_answer' &gt;&quot;\r\n\t\t\t\t\t\t\t\t\t  .$this-&gt;oFrm-&gt;forms_select_options($cAnswerValLst, NULL, NULL, FALSE).\r\n\t\t\t\t\t\t\t\t\t&quot;&lt;\/select&gt;&lt;\/td&gt;\r\n\t\t\t\t\t\t\t\t  &lt;\/tr&gt;\r\n\t\t\t\t\t\t\t\t&lt;\/table&gt;\r\n\t\t\t\t\t\t\t  &lt;\/form&gt;\r\n\t\t\t\t\t\t\t&lt;\/td&gt;\r\n\t\t\t\t\t\t&lt;\/tr&gt;\r\n\t\t\t\t\t  &lt;\/table&gt;&lt;\/div&gt;&quot;;\r\n\t\t\r\n\t\tif(!$cQuizStr)\r\n\t\t{\r\n\t\t\t$cQuizStr = &quot;&lt;h2&gt;&lt;span class='alert'&gt;No questions available.&lt;\/span&gt;&lt;\/h2&gt;&quot;;\r\n\t\t}\r\n\t\t\t\r\n\t\treturn $cQuizStr;\r\n\t}\r\n\t\r\n\tpublic function training_class_record($cTrainingParams)\r\n\t{\t\t\r\n\t\t\/*\r\n\t\ttraining_class_record_0001\r\n\t\tDamon Vaughn Caskey\r\n\t\t2013-03-27 (Converted to function class_record_0001 include)\r\n\t\t\r\n\t\tInserts user variables into class participant database.\t\r\n\t\t*\/\r\n\t\t\r\n\t\t$cQuery\t\t= NULL;\t\/\/Query string.\r\n\t\t$cParams\t= NULL;\t\/\/Parameter array.\r\n\t\t$cClassID\t= NULL;\t\/\/Class ID.\r\n\t\t$p_id\t\t= NULL;\t\/\/Participant ID.\r\n\t\t$listing_id\t= NULL;\t\/\/Class listing ID.\r\n\t\t\r\n\t\t\/* Build query string. *\/\r\n\t\t$cQuery =&quot;MERGE INTO tbl_class_participant\r\n\t\tUSING \r\n\t\t\t(SELECT ? AS Search_Col) AS SRC\r\n\t\tON \r\n\t\t\ttbl_class_participant.account = SRC.Search_Col\r\n\t\tWHEN MATCHED THEN\r\n\t\t\tUPDATE SET\r\n\t\t\t\tname_l\t\t\t\t= ?,\r\n\t\t\t\tname_f\t\t\t\t= ?,\t\t\t\t\t\t\t\t\t\r\n\t\t\t\troom\t\t\t\t= ?,\r\n\t\t\t\tstatus\t\t\t\t= ?,\r\n\t\t\t\tphone\t\t\t\t= ?,\t\t\t\t\t\t\t\t\t\r\n\t\t\t\tdepartment\t\t\t= ?,\r\n\t\t\t\tsupervisor_name_f\t= ?,\r\n\t\t\t\tsupervisor_name_l\t= ?\r\n\t\tWHEN NOT MATCHED THEN\r\n\t\t\tINSERT (account, name_l, name_f, room, status, phone, department, supervisor_name_f, supervisor_name_l)\r\n\t\t\tVALUES (SRC.Search_Col, ?, ?, ?, ?, ?, ?, ?, ?)\r\n\t\t\tOUTPUT INSERTED.id_int;&quot;;\t\t\r\n\t\t\r\n\t\t\/* Apply parameters. *\/\r\n\t\t$cParams = array(&amp;$cTrainingParams&#x5B;'account'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'name_l'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'name_f'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'room'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'status'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'phone'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'department'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'supervisor_name_f'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'supervisor_name_l'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'name_l'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'name_f'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'room'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'status'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'phone'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'department'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'supervisor_name_f'],\r\n\t\t\t\t\t\t&amp;$cTrainingParams&#x5B;'supervisor_name_l']);\t\r\n\t\t\r\n\t\t\/* Execute query. *\/\t\r\n\t\t$this-&gt;oDB-&gt;db_basic_action($cQuery, $cParams, TRUE);\r\n\t\t\r\n\t\t\/* Get ID of created\/updated record. *\/\r\n\t\t$p_id = $this-&gt;oDB-&gt;cDBLine&#x5B;&quot;id_int&quot;];\r\n\t\t\r\n\t\t\/* \tUser demographics have now been found or inserted. Now we will deal with class type, instructor and time. *\/\t\t\r\n\t\t$cQuery = &quot;INSERT INTO\ttbl_class\r\n\t\t\r\n\t\t\t\t\t\t\t\t(class_type,\r\n\t\t\t\t\t\t\t\ttrainer_id,\r\n\t\t\t\t\t\t\t\tclass_date)\r\n\t\t\t\t\tOUTPUT INSERTED.class_id\r\n\t\t\t\t\t\t\t\tVALUES\t(?, ?, ?)&quot;;\t\r\n\t\t\r\n\t\t$cParams = array(&amp;$cTrainingParams&#x5B;'class'],\r\n\t\t\t&amp;$cTrainingParams&#x5B;'trainer'],\r\n\t\t\t&amp;$cTrainingParams&#x5B;'taken']);\r\n\t\t\t\t\t\t\r\n\t\t\/* Execute query. *\/\t\r\n\t\t$this-&gt;oDB-&gt;db_basic_action($cQuery, $cParams, TRUE);\r\n\t\t\r\n\t\t\/* Get ID of new record. *\/\t\t\r\n\t\t$cClassID = $this-&gt;oDB-&gt;cDBLine&#x5B;&quot;class_id&quot;];\r\n\t\t\t\t\t\r\n\t\t\/* Insert newly created id and participant id to class listing table. *\/\t\t\r\n\t\t$cQuery = &quot;INSERT INTO tbl_class_listing\r\n\t\t\r\n\t\t\t\t\t\t\t\t(participant_id,\r\n\t\t\t\t\t\t\t\tclass_id)\r\n\t\t\t\t\tOUTPUT INSERTED.id_int\r\n\t\t\t\t\t\t\t\tVALUES (?, ?)&quot;;\t\r\n\t\t\r\n\t\t$cParams = array(&amp;$p_id,\r\n\t\t\t\t\t\t&amp;$cClassID);\r\n\t\t\t\t\t\t\r\n\t\t\/* Execute query. *\/\t\r\n\t\t$this-&gt;oDB-&gt;db_basic_action($cQuery, $cParams, TRUE);\r\n\t\t\r\n\t\t\/* Get ID of new record. *\/\t\t\r\n\t\treturn $this-&gt;oDB-&gt;cDBLine&#x5B;&quot;id_int&quot;];\t\t\t  \r\n\t}\r\n\t\r\n\tpublic function training_vars_get()\r\n\t{\r\n\t\t\/\/foreach ($this-&gt;cClassVars as $key =&gt; $val)\r\n\t\t\/\/{\r\n\t\t\/\/\t$this \t\t\r\n\t\t\/\/}\r\n\t}\r\n}\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Training class.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[71],"tags":[27,234],"class_list":["post-5287","post","type-post","status-publish","format-standard","hentry","category-technology-temerity","tag-coding","tag-coding-php"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5lNM5-1nh","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/posts\/5287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/comments?post=5287"}],"version-history":[{"count":2,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/posts\/5287\/revisions"}],"predecessor-version":[{"id":6181,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/posts\/5287\/revisions\/6181"}],"wp:attachment":[{"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/media?parent=5287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/categories?post=5287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caskeys.com\/dc\/wp-json\/wp\/v2\/tags?post=5287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}