当前位置: 首页>>代码示例>>PHP>>正文


PHP assQuestion::_getSuggestedSolutionOutput方法代码示例

本文整理汇总了PHP中assQuestion::_getSuggestedSolutionOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP assQuestion::_getSuggestedSolutionOutput方法的具体用法?PHP assQuestion::_getSuggestedSolutionOutput怎么用?PHP assQuestion::_getSuggestedSolutionOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assQuestion的用法示例。


在下文中一共展示了assQuestion::_getSuggestedSolutionOutput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ilTestSessionFactory

 /**
  * Calculates the results of a test for a given user
  * and returns an array with all test results
  *
  * @return array An array containing the test results for the given user
  * @access public
  */
 function &getTestResult($active_id, $pass = NULL, $ordered_sequence = FALSE, $considerHiddenQuestions = true, $considerOptionalQuestions = true)
 {
     global $tree, $ilDB, $lng, $ilPluginAdmin;
     $results = $this->getResultsForActiveId($active_id);
     if (is_null($pass)) {
         $pass = $results['pass'];
     }
     require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
     $testSessionFactory = new ilTestSessionFactory($this);
     $testSession = $testSessionFactory->getSession($active_id);
     require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
     $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this);
     $testSequence = $testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
     if ($this->isDynamicTest()) {
         require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
         $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this);
         $dynamicQuestionSetConfig->loadFromDb();
         $testSequence->loadFromDb($dynamicQuestionSetConfig);
         $testSequence->loadQuestions($dynamicQuestionSetConfig, new ilTestDynamicQuestionSetFilterSelection());
         $sequence = $testSequence->getUserSequenceQuestions();
     } else {
         $testSequence->setConsiderHiddenQuestionsEnabled($considerHiddenQuestions);
         $testSequence->setConsiderOptionalQuestionsEnabled($considerOptionalQuestions);
         $testSequence->loadFromDb();
         $testSequence->loadQuestions();
         if ($ordered_sequence) {
             $sequence = $testSequence->getOrderedSequenceQuestions();
         } else {
             $sequence = $testSequence->getUserSequenceQuestions();
         }
     }
     $arrResults = array();
     $query = "\n\t\t\tSELECT\t\ttst_test_result.question_fi,\n\t\t\t\t\t\ttst_test_result.points reached,\n\t\t\t\t\t\ttst_test_result.hint_count requested_hints,\n\t\t\t\t\t\ttst_test_result.hint_points hint_points,\n\t\t\t\t\t\ttst_test_result.answered answered\n\t\t\t\n\t\t\tFROM\t\ttst_test_result\n\t\t\t\n\t\t\tLEFT JOIN\ttst_solutions\n\t\t\tON\t\t\ttst_solutions.active_fi = tst_test_result.active_fi\n\t\t\tAND\t\t\ttst_solutions.question_fi = tst_test_result.question_fi\n\t\t\t\n\t\t\tWHERE\t\ttst_test_result.active_fi = %s\n\t\t\tAND\t\t\ttst_test_result.pass = %s\n\t\t";
     $solutionresult = $ilDB->queryF($query, array('integer', 'integer'), array($active_id, $pass));
     while ($row = $ilDB->fetchAssoc($solutionresult)) {
         $arrResults[$row['question_fi']] = $row;
     }
     $numWorkedThrough = count($arrResults);
     require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     $IN_question_ids = $ilDB->in('qpl_questions.question_id', $sequence, false, 'integer');
     $query = "\n\t\t\tSELECT\t\tqpl_questions.*,\n\t\t\t\t\t\tqpl_qst_type.type_tag,\n\t\t\t\t\t\tqpl_sol_sug.question_fi has_sug_sol\n\t\t\t\n\t\t\tFROM\t\tqpl_qst_type,\n\t\t\t\t\t\tqpl_questions\n\t\t\t\n\t\t\tLEFT JOIN\tqpl_sol_sug\n\t\t\tON\t\t\tqpl_sol_sug.question_fi = qpl_questions.question_id\n\t\t\t\n\t\t\tWHERE\t\tqpl_qst_type.question_type_id = qpl_questions.question_type_fi\n\t\t\tAND\t\t\t{$IN_question_ids}\n\t\t";
     $result = $ilDB->query($query);
     $unordered = array();
     $key = 1;
     $obligationsAnswered = true;
     while ($row = $ilDB->fetchAssoc($result)) {
         $percentvalue = $row['points'] ? $arrResults[$row['question_id']]['reached'] / $row['points'] : 0;
         if ($percentvalue < 0) {
             $percentvalue = 0.0;
         }
         $data = array("nr" => "{$key}", "title" => ilUtil::prepareFormOutput($row['title']), "max" => round($row['points'], 2), "reached" => round($arrResults[$row['question_id']]['reached'], 2), 'requested_hints' => $arrResults[$row['question_id']]['requested_hints'], 'hint_points' => $arrResults[$row['question_id']]['hint_points'], "percent" => sprintf("%2.2f ", $percentvalue * 100) . "%", "solution" => $row['has_sug_sol'] ? assQuestion::_getSuggestedSolutionOutput($row['question_id']) : '', "type" => $row["type_tag"], "qid" => $row['question_id'], "original_id" => $row["original_id"], "workedthrough" => isset($arrResults[$row['question_id']]) ? 1 : 0, 'answered' => $arrResults[$row['question_id']]['answered']);
         if (!$arrResults[$row['question_id']]['answered']) {
             $obligationsAnswered = false;
         }
         $unordered[$row['question_id']] = $data;
         $key++;
     }
     $pass_max = 0;
     $pass_reached = 0;
     $pass_requested_hints = 0;
     $pass_hint_points = 0;
     $key = 1;
     $found = array();
     foreach ($sequence as $qid) {
         // building pass point sums based on prepared data
         // for question that exists in users qst sequence
         $pass_max += round($unordered[$qid]['max'], 2);
         $pass_reached += round($unordered[$qid]['reached'], 2);
         $pass_requested_hints += $unordered[$qid]['requested_hints'];
         $pass_hint_points += $unordered[$qid]['hint_points'];
         // pickup prepared data for question
         // that exists in users qst sequence
         $unordered[$qid]['nr'] = $key;
         array_push($found, $unordered[$qid]);
         // increment key counter
         $key++;
     }
     $unordered = null;
     if ($this->getScoreCutting() == 1) {
         if ($results['reached_points'] < 0) {
             $results['reached_points'] = 0;
         }
         if ($pass_reached < 0) {
             $pass_reached = 0;
         }
     }
     $found['pass']['total_max_points'] = $pass_max;
     $found['pass']['total_reached_points'] = $pass_reached;
     $found['pass']['total_requested_hints'] = $pass_requested_hints;
     $found['pass']['total_hint_points'] = $pass_hint_points;
     $found['pass']['percent'] = $pass_max > 0 ? $pass_reached / $pass_max : 0;
     $found['pass']['obligationsAnswered'] = $obligationsAnswered;
     $found['pass']['num_workedthrough'] = $numWorkedThrough;
//.........这里部分代码省略.........
开发者ID:bheyser,项目名称:qplskl,代码行数:101,代码来源:class.ilObjTest.php


注:本文中的assQuestion::_getSuggestedSolutionOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。