|
@@ -21,7 +21,7 @@ class WordapiController extends CController
|
|
set_time_limit(0);
|
|
set_time_limit(0);
|
|
//$this->ucloud = new Ucloud();
|
|
//$this->ucloud = new Ucloud();
|
|
$this->ucloud = new Qcloud();
|
|
$this->ucloud = new Qcloud();
|
|
- $this->webSiteUrl = Yii::app()->params['siteurl'];
|
|
|
|
|
|
+ $this->webSiteUrl = Yii::app()->params['teacherSiteurl'];
|
|
$this->flag = isset($_GET['flag']) ? intval($_GET['flag']) : 1;
|
|
$this->flag = isset($_GET['flag']) ? intval($_GET['flag']) : 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -38,8 +38,7 @@ class WordapiController extends CController
|
|
// $busDsn = 'mysql:host=' . Yii::app()->params["default_server"]['addr'] . ';dbname=' . Yii::app()->params["default_db"]['name'] . ';';
|
|
// $busDsn = 'mysql:host=' . Yii::app()->params["default_server"]['addr'] . ';dbname=' . Yii::app()->params["default_db"]['name'] . ';';
|
|
// $busdbh = new PDO($busDsn, Yii::app()->params["default_server"]['username'], Yii::app()->params["default_server"]['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";'));
|
|
// $busdbh = new PDO($busDsn, Yii::app()->params["default_server"]['username'], Yii::app()->params["default_server"]['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";'));
|
|
$busdbh = Yii::app()->businessDb;
|
|
$busdbh = Yii::app()->businessDb;
|
|
- $getDataBase = $busdbh->query('SELECT * FROM `database` WHERE `school_id`=' . $school_id);
|
|
|
|
- $dataBaseInfo = $getDataBase->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
|
+ $dataBaseInfo = $busdbh->createCommand('SELECT * FROM `database` WHERE `school_id`=' . $school_id)->queryOne();
|
|
if (empty($dataBaseInfo)) {
|
|
if (empty($dataBaseInfo)) {
|
|
exit('未找到数据库链接信息!');
|
|
exit('未找到数据库链接信息!');
|
|
}
|
|
}
|
|
@@ -905,50 +904,48 @@ class WordapiController extends CController
|
|
*/
|
|
*/
|
|
public function actionAllSubjectCoach()
|
|
public function actionAllSubjectCoach()
|
|
{
|
|
{
|
|
- $apiTopics = array();
|
|
|
|
|
|
+ $apiTopics = array();
|
|
// 获取curl过来值
|
|
// 获取curl过来值
|
|
- $word_id = isset($_GET['wid']) ? intval($_GET['wid']) : 0;
|
|
|
|
- $school_id = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
|
|
|
|
- if (empty($word_id) || empty($school_id)) {
|
|
|
|
- exit('未找到word Id或者学校id');
|
|
|
|
- }
|
|
|
|
|
|
+ $word_id = isset($_GET['wid']) ? intval($_GET['wid']) : 0;
|
|
|
|
+ $school_id = isset($_GET['sid']) ? intval($_GET['sid']) : 0;
|
|
|
|
+ if (empty($word_id) || empty($school_id)) {
|
|
|
|
+ exit('未找到word Id或者学校id');
|
|
|
|
+ }
|
|
// 连接业务库
|
|
// 连接业务库
|
|
- $busDsn = 'mysql:host=' . Yii::app()->params["default_server"]['addr'] . ';dbname=' . Yii::app()->params["default_db"]['name'] . ';';
|
|
|
|
- $busdbh = new PDO($busDsn, Yii::app()->params["default_server"]['username'], Yii::app()->params["default_server"]['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";'));
|
|
|
|
- $getDataBase = $busdbh->query('SELECT * FROM `database` WHERE `school_id`=' . $school_id);
|
|
|
|
- $dataBaseInfo = $getDataBase->fetch(PDO::FETCH_ASSOC);
|
|
|
|
- if (empty($dataBaseInfo)) {
|
|
|
|
- exit('未找到数据库链接信息!');
|
|
|
|
- }
|
|
|
|
- $busdbh = null;
|
|
|
|
-
|
|
|
|
- // 连接学校库
|
|
|
|
- $schDsn = 'mysql:host=' . $dataBaseInfo['database_host'] . ';dbname=' . $dataBaseInfo['database_name'] . ';';
|
|
|
|
- $schdbh = new PDO($schDsn, $dataBaseInfo['database_user'], $dataBaseInfo['database_password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";'));
|
|
|
|
- $wordInfo = $schdbh->query('SELECT `word_id`,`word_name`,`subject_id`,`uploader_id`,`exam_group_id` FROM `topic_word` WHERE `word_id`=' . $word_id)->fetch(PDO::FETCH_ASSOC);
|
|
|
|
- if (empty($wordInfo)) {
|
|
|
|
- exit('未找到上传word信息!');
|
|
|
|
- }
|
|
|
|
|
|
+ $busDsn = Yii::app()->businessDb;
|
|
|
|
+ $dataBaseInfo = $busDsn->createCommand('SELECT * FROM `database` WHERE `school_id`=' . $school_id)->queryOne();
|
|
|
|
+ if (empty($dataBaseInfo)) {
|
|
|
|
+ exit('未找到数据库链接信息!');
|
|
|
|
+ }
|
|
|
|
+ $busdbh = null;
|
|
|
|
+
|
|
|
|
+ // 连接学校库
|
|
|
|
+ $schDsn = 'mysql:host=' . $dataBaseInfo['database_host'] . ';dbname=' . $dataBaseInfo['database_name'] . ';';
|
|
|
|
+ $schdbh = new PDO($schDsn, $dataBaseInfo['database_user'], $dataBaseInfo['database_password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "utf8";'));
|
|
|
|
+ $wordInfo = $schdbh->query('SELECT `word_id`,`word_name`,`subject_id`,`uploader_id`,`exam_group_id` FROM `topic_word` WHERE `word_id`=' . $word_id)->fetch(PDO::FETCH_ASSOC);
|
|
|
|
+ if (empty($wordInfo)) {
|
|
|
|
+ exit('未找到上传word信息!');
|
|
|
|
+ }
|
|
|
|
|
|
$getWordJson = file_get_contents('php://input');
|
|
$getWordJson = file_get_contents('php://input');
|
|
- $jsonArray = json_decode($getWordJson, true);
|
|
|
|
|
|
+ $jsonArray = json_decode($getWordJson, true);
|
|
if (empty($jsonArray) || $jsonArray['errcode'] == 1 || empty($jsonArray['items'])) {
|
|
if (empty($jsonArray) || $jsonArray['errcode'] == 1 || empty($jsonArray['items'])) {
|
|
- $errMsg = array();
|
|
|
|
- if (isset($jsonArray['errmsgs']) && $jsonArray['errmsgs']) {
|
|
|
|
- if (is_array($jsonArray['errmsgs'])) {
|
|
|
|
- foreach ($jsonArray['errmsgs'] as $msg) {
|
|
|
|
- $errMsg[] = key($msg) . ':' . implode(', ', $msg[key($msg)]);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- $errMsg[] = $jsonArray['errmsgs'];
|
|
|
|
- }
|
|
|
|
|
|
+ $errMsg = array();
|
|
|
|
+ if (isset($jsonArray['errmsgs']) && $jsonArray['errmsgs']) {
|
|
|
|
+ if (is_array($jsonArray['errmsgs'])) {
|
|
|
|
+ foreach ($jsonArray['errmsgs'] as $msg) {
|
|
|
|
+ $errMsg[] = key($msg) . ':' . implode(', ', $msg[key($msg)]);
|
|
}
|
|
}
|
|
-
|
|
|
|
- $errMsg = $errMsg ? implode('<br/>', $errMsg) : '解析异常';
|
|
|
|
- $stmt = $schdbh->prepare('UPDATE `topic_word` SET `status` = 3,`wrong_reason` = :reason,`content` = :content,`file_path` = :path,parse_time=:time WHERE `word_id` =:wid');
|
|
|
|
- $stmt->execute(array(':wid' => $word_id, ':reason' => $errMsg, ':content' => $getWordJson, ':path' => '', ':time' => time()));
|
|
|
|
- exit('解析失败!');
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+ $errMsg[] = $jsonArray['errmsgs'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $errMsg = $errMsg ? implode('<br/>', $errMsg) : '解析异常';
|
|
|
|
+ $stmt = $schdbh->prepare('UPDATE `topic_word` SET `status` = 3,`wrong_reason` = :reason,`content` = :content,`file_path` = :path,parse_time=:time WHERE `word_id` =:wid');
|
|
|
|
+ $stmt->execute(array(':wid' => $word_id, ':reason' => $errMsg, ':content' => $getWordJson, ':path' => '', ':time' => time()));
|
|
|
|
+ exit('解析失败!');
|
|
|
|
+ } else {
|
|
// 获取科目题型
|
|
// 获取科目题型
|
|
$tempTypeName = array(1=>'选择题','2'=>'多选题',11=>'多选题',5=>'填空题',7=>'解答题');
|
|
$tempTypeName = array(1=>'选择题','2'=>'多选题',11=>'多选题',5=>'填空题',7=>'解答题');
|
|
$apiParam = Yii::app()->params['api'][0];
|
|
$apiParam = Yii::app()->params['api'][0];
|
|
@@ -1030,41 +1027,6 @@ class WordapiController extends CController
|
|
exit('题型不存在');
|
|
exit('题型不存在');
|
|
}
|
|
}
|
|
|
|
|
|
- // 验证试卷题型是否和解析题型完全匹配
|
|
|
|
- /*if ($relate_topic_type && $parse_topic_type) {
|
|
|
|
- foreach ($relate_topic_type as $rttId) {
|
|
|
|
- if (in_array($rttId, $parse_topic_type)) {
|
|
|
|
- array_splice($parse_topic_type,array_search($rttId ,$parse_topic_type),1);
|
|
|
|
- } else {
|
|
|
|
- $topic_type_error[] = "上传Word未包含考试创建的题型({$rttId})";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (count($parse_topic_type) > 0) {
|
|
|
|
- $topic_type_error[] = '上传的题型与试卷题型不一致';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ($topic_type_error) {
|
|
|
|
- $stmt = $schdbh->prepare('UPDATE `topic_word` SET `status` = 3,`wrong_reason` = :reason,`content` = :content, parse_time=:time WHERE `word_id` =:wid');
|
|
|
|
- $stmt->execute(array(':wid' => $word_id, ':reason' => implode('<br/>', $topic_type_error),':content' => $getWordJson, ':time' => time()));
|
|
|
|
- exit('上传的题型与试卷题型不一致');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 验证题型数量
|
|
|
|
- $validate_topic_info = array();
|
|
|
|
- foreach ($p_topic_type_num as $vtnKey => $vtnVal) {
|
|
|
|
- if (!isset($topic_type_num[$vtnKey]) || count($vtnVal) != count($topic_type_num[$vtnKey])) {
|
|
|
|
- $validate_topic_info[] = 'word'.$tempTypeName[$vtnKey].'题量与试卷的题量不同';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ($validate_topic_info) {
|
|
|
|
- $stmt = $schdbh->prepare('UPDATE `topic_word` SET `status` = 3,`wrong_reason` = :reason,`content` = :content,parse_time=:time WHERE `word_id` =:wid');
|
|
|
|
- $stmt->execute(array(':wid' => $word_id, ':reason' => implode('<br/>', $validate_topic_info),':content' => $getWordJson, ':time' => time()));
|
|
|
|
- exit(implode("<br/>",$validate_topic_info));
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
// 获取默认文件夹id
|
|
// 获取默认文件夹id
|
|
$defaultFolder = $schdbh->query('SELECT `folder_id` FROM `topic_folder` WHERE `is_system`=1')->fetch(PDO::FETCH_ASSOC);
|
|
$defaultFolder = $schdbh->query('SELECT `folder_id` FROM `topic_folder` WHERE `is_system`=1')->fetch(PDO::FETCH_ASSOC);
|
|
$folderId = empty($defaultFolder['folder_id']) ? 0 : $defaultFolder['folder_id'];
|
|
$folderId = empty($defaultFolder['folder_id']) ? 0 : $defaultFolder['folder_id'];
|
|
@@ -1156,18 +1118,12 @@ class WordapiController extends CController
|
|
$resPro = $schdbh->prepare("INSERT INTO `exam_process` (`exam_group_id`, `action_type`, `action_time`) VALUES (:exam_group_id, :tempType, :time)");
|
|
$resPro = $schdbh->prepare("INSERT INTO `exam_process` (`exam_group_id`, `action_type`, `action_time`) VALUES (:exam_group_id, :tempType, :time)");
|
|
$resPro->execute(array(':exam_group_id' => $wordInfo['exam_group_id'], ':tempType' => 4, ':time' => time()));
|
|
$resPro->execute(array(':exam_group_id' => $wordInfo['exam_group_id'], ':tempType' => 4, ':time' => time()));
|
|
|
|
|
|
- // 监控日志
|
|
|
|
- BMonitorLog::model()->addLog(array(
|
|
|
|
- 'school_id' => $school_id,
|
|
|
|
- 'teacher_id' => $wordInfo['uploader_id'],
|
|
|
|
- 'log_content' => array('助教','上传了',$wordInfo['word_name'],'试卷')
|
|
|
|
- ));
|
|
|
|
|
|
|
|
$schdbh = null;
|
|
$schdbh = null;
|
|
- if($apiTopics){
|
|
|
|
- //调用试题检索接口
|
|
|
|
- $this->searchTopics($apiTopics,$school_id);
|
|
|
|
- }
|
|
|
|
|
|
+ if($apiTopics){
|
|
|
|
+ //调用试题检索接口
|
|
|
|
+ $this->searchTopics($apiTopics,$school_id);
|
|
|
|
+ }
|
|
exit('解析完成!');
|
|
exit('解析完成!');
|
|
}
|
|
}
|
|
|
|
|