/** * 查询一道试题[资料题] * * @param int $sourceid 资料题主键 * @pram array */ public function selectMaterial($sourceid) { //读取缓存 $key = 'data-question-' . $sourceid; $info = S($key); //if($info) return $info; //查询数据库 $material = D('Teaching/QuestionMaterial'); $field = 'id, material, material_desc, sourceid'; $info = $material->info($sourceid, $filed); //处理图片 $info['material'] = question_image2text($info['material'], $info['material_desc'], 'material2'); //子题列表 $class = D('QuestionClass'); $field = 'id, body, bd_desc, options, description, dp_desc, answer, wrongans, optiontype, qyear, views, rorate, updatetime'; $field .= ', bigtype, smalltype, pointtype, tagids, errnums, collects, values, loglist, sourceid'; $sonlist = $this->sonList($info['sourceid'], $filed); foreach ($sonlist as $key => $val) { //处理图片 $val['body'] = question_image2text($val['body'], $val['bd_desc'], 'body2'); $val['description'] = question_image2text($val['description'], $val['dp_desc'], 'desc2'); //知识点(三级名称) $val['pointname'] = $class->where('id = ' . $val['pointtype'])->getField('title'); $val['bigtype1'] = $class->where('id = ' . $val['bigtype'])->getField('title'); $val['smalltype1'] = $class->where('id = ' . $val['smalltype'])->getField('title'); $sonlist[$key] = $val; } $info['sonlist'] = $sonlist; //写入缓存 S($key, $info); return $info; }
/** * 客观题 **表单 */ public function objective_form() { $id = I('get.id', 0, 'int'); //知识点分类 $cls = D('Teaching/QuestionClass', 'Logic'); if ($id > 0) { $q = D('question'); $info = $q->find($id); //选项 $info['options'] = json_decode(strip_tags($info['options']), true); $info['form_list2'] = $cls->getTree($info['bigtype'], 1); $info['form_list3'] = $cls->getTree($info['smalltype'], 2); $info['body1'] = question_image2text($info['body'], $info['bd_desc'], 'body2'); $info['description1'] = question_image2text($info['description'], $info['dp_desc'], 'desc2'); } $info['form_list1'] = $cls->getTree(); $this->info = $info; $this->display(); }
public function index() { $json = '{"info":{"qnums":135},"navs":[{"title":"常识判断", "nums":"20", "key":"0"},{"title":"言语理解与表达", "nums":"40", "key":"1"},{"title":"数量关系", "nums":"15", "key":"2"},{"title":"判断推理", "nums":"40", "key":"3"},{"title":"资料分析", "nums":"20", "key":"4"}],"item":{"0":[{"qid":"60495"},{"qid":"60496"},{"qid":"60497"},{"qid":"60498"},{"qid":"60500"},{"qid":"60501"},{"qid":"60503"},{"qid":"60504"},{"qid":"60506"},{"qid":"60507"},{"qid":"60508"},{"qid":"60511"},{"qid":"60514"},{"qid":"60517"},{"qid":"60518"},{"qid":"60513"},{"qid":"60510"},{"qid":"60505"},{"qid":"60502"},{"qid":"60499"}],"1":[{"qid":"60509"},{"qid":"60512"},{"qid":"60516"},{"qid":"60519"},{"qid":"60520"},{"qid":"60524"},{"qid":"60528"},{"qid":"60531"},{"qid":"60535"},{"qid":"60539"},{"qid":"60547"},{"qid":"60559"},{"qid":"60568"},{"qid":"60572"},{"qid":"60577"},{"qid":"60580"},{"qid":"60585"},{"qid":"60588"},{"qid":"60593"},{"qid":"60600"},{"qid":"60521"},{"qid":"60525"},{"qid":"60527"},{"qid":"60530"},{"qid":"60532"},{"qid":"60534"},{"qid":"60538"},{"qid":"60540"},{"qid":"60543"},{"qid":"60555"},{"qid":"60560"},{"qid":"60569"},{"qid":"60571"},{"qid":"60573"},{"qid":"60576"},{"qid":"60579"},{"qid":"60581"},{"qid":"60584"},{"qid":"60587"},{"qid":"60591"}],"2":[{"qid":"60480"},{"qid":"60484"},{"qid":"60485"},{"qid":"60481"},{"qid":"60486"},{"qid":"60482"},{"qid":"60487"},{"qid":"60483"},{"qid":"60488"},{"qid":"60489"},{"qid":"60490"},{"qid":"60491"},{"qid":"60492"},{"qid":"60493"},{"qid":"60494"}],"3":[{"qid":"60523"},{"qid":"60529"},{"qid":"60533"},{"qid":"60537"},{"qid":"60542"},{"qid":"60562"},{"qid":"60575"},{"qid":"60582"},{"qid":"60589"},{"qid":"60603"},{"qid":"60605"},{"qid":"60607"},{"qid":"60606"},{"qid":"60604"},{"qid":"60602"},{"qid":"60601"},{"qid":"60594"},{"qid":"60590"},{"qid":"60586"},{"qid":"60583"},{"qid":"60578"},{"qid":"60574"},{"qid":"60570"},{"qid":"60561"},{"qid":"60551"},{"qid":"60536"},{"qid":"60541"},{"qid":"60526"},{"qid":"60515"},{"qid":"60522"},{"qid":"60613"},{"qid":"60614"},{"qid":"60616"},{"qid":"60617"},{"qid":"60619"},{"qid":"60620"},{"qid":"60622"},{"qid":"60621"},{"qid":"60618"},{"qid":"60615"}],"4":[{"qid":"2479", "son":"5"},{"qid":"2480", "son":"5"},{"qid":"2481", "son":"5"},{"qid":"2483", "son":"5"}]}}'; $pid = I('get.pid', 0, 'int'); if ($pid == 0) { print 'pid == 0'; exit; } $pp = D('Paper'); $info = $pp->find($pid); if ($info['dataview'] == '') { print 'dataview == null'; exit; } $arr = json_decode($info['dataview'], true); $qt = D('Question'); foreach ($arr['navs'] as $k => $v) { //print $v['title'] . '<br />'; $list = $arr['item'][$v['key']]; foreach ($list as $kk => $val) { if (intval($val['son']) == 0) { $where = 'sourceid=' . $val['qid']; $row = $qt->where($where)->find(); $row['body'] = question_image2text($row['body'], $row['bd_desc'], 'body2'); $row['description'] = question_image2text($row['description'], $row['dp_desc'], 'desc2'); } else { $where = 'materialid in (' . $val['qid'] . ')'; $rowlist = $qt->where($where)->select(); foreach ($rowlist as $key => $vl) { $vl['body'] = question_image2text($vl['body'], $vl['bd_desc'], 'body2'); $vl['description'] = question_image2text($vl['description'], $vl['dp_desc'], 'desc2'); $rowlist[$key] = $vl; } $row = $rowlist; } /*print $row['sourceid']; print $row['body']; print $row['options']; print $row['description']; print '<br /><br /><br /><br />';*/ //var_dump($row); $list[$kk]['info'] = $row; } $arr['item'][$v['key']] = $list; } $this->info = $info; $this->list = $arr; $this->display(); }