123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- class EnglishWeekController extends Controller
- {
- //单元的短语和词汇数量
- public function actionAjaxWordPhraseCount()
- {
- $unitId = Req::post('ids');
- $grade = Req::post('grade');
- if(empty($unitId) || empty($grade)){
- echo json_encode(array('status'=>0,'message'=>'参数错误'));exit;
- }
- //全学科逻辑
- $textbook_arr = array();
- $wordCount = 0;
- $phraseCount = 0;
- $generateCount = array();
- if($unitId){
- $unitArr = explode(",",$unitId);
- if($unitArr){
- foreach($unitArr as $unitIds){
- $tempIds = explode("_",$unitIds);
- if(isset($tempIds[2]) && $tempIds[2]){
- $textbook_arr[] = $tempIds[2];
- }
- }
- }
- }
- if($textbook_arr){
- $data=$this->apiPost('all_library/getWordCouByUnit',array('textbook'=>$textbook_arr,'is_unit'=>true));
- $data=json_decode(json_encode($data),true);
- if(isset($data['status']) && $data['status'] && isset($data['data']) && $data['data']){
- $wordCount = isset($data['data']['word_cou'])?$data['data']['word_cou']:0;
- $phraseCount = isset($data['data']['phrase_cou'])?$data['data']['phrase_cou']:0;
- }
- }
- $semesterId = $this->semesterId;
- $generateSql = "select s.class_id,count(s.id) as num FROM english_week_setting s inner join class c on s.class_id=c.class_id WHERE c.grade={$grade} and s.semester_id='{$semesterId}' AND s.node_ids like '%{$unitId}%' GROUP BY s.class_id;";
- $res = $this->sConn->createCommand($generateSql)->queryAll();
- foreach ($res as $item){
- $generateCount[$item['class_id']] = (int)$item['num'];
- }
- $data = array('wordCount'=>(int)$wordCount,'phraseCount'=>$phraseCount, 'classCount'=>$generateCount);
- echo json_encode(array('status'=>1,'data'=>$data));
- exit;
-
- /*老流程暂时注释
- $sql = "select single_word,phrase from en_unit_single_phrase where id='{$unitId}'";
- $rs = Yii::app()->enStuffDb->createCommand($sql)->queryRow();
- $wordCount = 0;
- $phraseCount = 0;
- if($rs){
- $words = isset($rs['single_word']) && !empty($rs['single_word']) ? json_decode($rs['single_word'],true) : array();
- $phraseCount = isset($rs['phrase']) && !empty($rs['phrase']) ? count(json_decode($rs['phrase'],true)) : 0;
- }
- if(isset($words) && !empty($words)){
- $wordsStr = implode(',',$words);
- if($grade==3){
- $wordSql = "select count(*) from en_single_word WHERE core_words=1 and type_id=2 and levels>=4 and single_word_id in ($wordsStr)";
- }else{
- $wordSql = "select count(*) from en_single_word WHERE core_words=1 and type_id=2 and single_word_id in ($wordsStr)";
- }
- $wordCount = Yii::app()->enStuffDb->createCommand($wordSql)->queryScalar();
- }
- $semesterId = $this->semesterId;
- $generateSql = "select s.class_id,count(s.id) as num FROM english_week_setting s inner join class c on s.class_id=c.class_id WHERE c.grade={$grade} and s.semester_id='{$semesterId}' AND s.node_ids like '%{$unitId}%' GROUP BY s.class_id;";
- $res = $this->sConn->createCommand($generateSql)->queryAll();
- $generateCount = array();
- foreach ($res as $item){
- $generateCount[$item['class_id']] = (int)$item['num'];
- }
- $data = array('wordCount'=>(int)$wordCount,'phraseCount'=>$phraseCount, 'classCount'=>$generateCount);
- echo json_encode(array('status'=>1,'data'=>$data));
- exit;
- * */
-
- }
- public function actionUnits(){
- $this->layout = false;
- $data = array();
- $data['ids'] = Req::get('ids');
- $data['str'] = Req::get('str');
- $textboookTree = new MongodbEnglishTree();
- $criteria = new EMongoCriteria();
- $textbookData = $textboookTree->find($criteria,array());
- if($textbookData){
- foreach ($textbookData as $doc) {
- foreach($doc->attributes as $key => $value){
- if($key !== '_id'){
- if(isset($value['textbook_id']) && isset($value['name'])){
- $data['textbookNames'][$value['textbook_id']] = $value['name'];
- if(!isset($textbookId)){
- $textbookId = $value['textbook_id'];
- }
- if($textbookId == $value['textbook_id']){
- if(isset($value['module']) && $value['module']){
- foreach($value['module'] as $kk=>$vv){
- $data['moduleNames'][$vv['textbook_module_id']] = $vv['name'];
- if(!isset($moduleId)){
- $moduleId = $vv['textbook_module_id'];
- }
- if($moduleId == $vv['textbook_module_id']){
- if(isset($vv['unit']) && $vv['unit']){
- foreach($vv['unit'] as $kkk=>$vvv){
- $data['unitNames'][$vvv['textbook_unit_id']] = $vvv['name'];
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- $this->render('units', $data);
- }
- /**
- * 全学科教材数据
- */
- public function actionQxkUnits(){
- $ids= Req::get('ids');
- $str= Req::get('str');
- $textbooks=$modules=$units=array();
- $textbookResult=$this->apiPost('all_textbook/textbook',array('subject_id'=>8,'query_type'=>2));
- $textbookResult=json_decode(json_encode($textbookResult),true);
- if(isset($textbookResult['status']) && $textbookResult['status'] && isset($textbookResult['data']) && $textbookResult['data']){
- $textbookResult=$textbookResult['data'];
- foreach($textbookResult as $textbookKey=>$textbookItem){
- $textbooks[]=array('textbook_id'=>$textbookItem['textbook_id'],'textbook_name'=>$textbookItem['textbook_name']);
- if($textbookKey==0 && isset($textbookItem['child']) && $textbookItem['child']){
- foreach($textbookItem['child'] as $moduleKey=>$moduleItem){
- $modules[]=array('textbook_id'=>$moduleItem['textbook_id'],'textbook_name'=>$moduleItem['textbook_name']);
- if($moduleKey==0 && isset($moduleItem['child']) && $moduleItem['child']){
- foreach($moduleItem['child'] as $unitItem){
- $units[]=array('textbook_id'=>$unitItem['textbook_id'],'textbook_name'=>$unitItem['textbook_name']);
- }
- }
- }
- }
- }
- }
- $data=array(
- 'textbooks'=>$textbooks,//版本
- 'modules'=>$modules,//模块
- 'units'=>$units,//单元
- 'ids'=>$ids,
- 'str'=>$str
- );
- $this->render('qxk_units', $data);
- }
- }
|