新增答卷调整
This commit is contained in:
@@ -2434,4 +2434,223 @@ class Reviewer extends Base
|
||||
Db::commit();
|
||||
return json_encode(['status' => 1,'msg' => "Reviewer's field has been successfully modified"]);
|
||||
}
|
||||
|
||||
public function questionSubmitNew()
|
||||
{
|
||||
//接受参数,查询基础数据
|
||||
$data = $this->request->post();
|
||||
|
||||
//必填参数验证
|
||||
//审稿记录表主键ID
|
||||
$art_rev_id = empty($data['art_rev_id']) ? 0 : $data['art_rev_id'];
|
||||
if(empty($art_rev_id)){
|
||||
return jsonError('No reviewer selected');
|
||||
}
|
||||
//问卷状态
|
||||
$recommend = empty($data['recommend']) ? 0 : $data['recommend'];
|
||||
if(empty($recommend)){
|
||||
return jsonError('The answer status cannot be empty');
|
||||
}
|
||||
//获取审稿人记录
|
||||
$art_rev_info = $this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->find();
|
||||
if(empty($art_rev_info)){
|
||||
return jsonError("The reviewer was not invited to review");
|
||||
}
|
||||
//获取文章信息
|
||||
$article_info = $this->article_obj->where('article_id', $art_rev_info['article_id'])->find();
|
||||
if(empty($article_info)){
|
||||
return jsonError("The article does not exist");
|
||||
}
|
||||
//获取期刊信息
|
||||
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
|
||||
if(empty($journal_info)){
|
||||
return jsonError("The journal to which the article belongs does not exist");
|
||||
}
|
||||
//获取期刊编辑信息
|
||||
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
|
||||
|
||||
//不可重复提交答案的验证
|
||||
$check_question = $this->article_reviewer_question_obj->where('art_rev_id',$data['art_rev_id'])->find();
|
||||
if($check_question){
|
||||
return jsonError("Non repeatable review");
|
||||
}
|
||||
|
||||
//数据处理-答题处理
|
||||
$sMsg = '';
|
||||
//答卷评分
|
||||
$iScore = 0;//初试分数值
|
||||
$aScore = [
|
||||
'qu1' => [1 => 1,2 => 0.5,3 => 0,4 => -0.5],
|
||||
'qu2' => [1 => 1,2 => 0.5,3 => 0,4 => -0.5],
|
||||
'qu3' => ['true' => 0.5,'false' => -10],
|
||||
'qu4' => [1 => 1,2 => 0.5,3 => 0,4 => -0.5],
|
||||
'qu5' => ['true' => 0.5,'false' => 0],
|
||||
'qu6' => ['true' => 0.5,'false' => 0],
|
||||
'qu7' => ['true' => 0.5,'false' => 0],
|
||||
'qu8' => ['true' => 0.5,'false' => 0],
|
||||
'qu9' => ['true' => 0.5,'false' => 0],
|
||||
'qu10' => ['true' => 0.5,'false' => 0],
|
||||
'qu11' => ['true' => 0.5,'false' => 0],
|
||||
'qu12' => ['true' => 1,'false' => 0],
|
||||
'qu13' => ['true' => 1,'false' => 0],
|
||||
'qu14' => ['true' => 1,'false' => 0],
|
||||
'qu15' => ['true' => 0.5,'false' => 0]
|
||||
];
|
||||
for ($i = 1; $i <= 15; $i++) {
|
||||
$sField = 'qu'.$i;
|
||||
if(isset($data[$sField])){
|
||||
$insert_data[$sField] = $data[$sField];
|
||||
if(in_array($insert_data[$sField], ['true','false'])){
|
||||
$insert_data[$sField] = $insert_data[$sField] == 'true' ? 1 : 0;
|
||||
}
|
||||
$iScore += empty($aScore[$sField][$data[$sField]]) ? 0 : $aScore[$sField][$data[$sField]];
|
||||
}
|
||||
$sFieldContents = $sField.'contents';
|
||||
if(isset($data[$sFieldContents])){
|
||||
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $data[$sFieldContents])>0){//验证是否包含中文
|
||||
$sMsg = $sFieldContents.':Cannot contain Chinese';
|
||||
break;
|
||||
}
|
||||
$insert_data[$sField.'_contents'] = $data[$sFieldContents];
|
||||
}
|
||||
}
|
||||
if(!empty($sMsg)){
|
||||
return jsonError($sMsg);
|
||||
}
|
||||
//其他参数组装
|
||||
$sMsg = '';
|
||||
$aField = ['rated','recommend','other','confidential','comments','is_anonymous','art_rev_id'];
|
||||
foreach ($aField as $value) {
|
||||
if(isset($data[$value])){
|
||||
$insert_data[$value] = $data[$value];
|
||||
}
|
||||
}
|
||||
|
||||
//答卷类型
|
||||
$insert_data['type'] = empty($data['type']) ? 1 : $data['type'];
|
||||
if($insert_data['type'] == 2){
|
||||
$insert_data['score'] = $iScore;
|
||||
}
|
||||
//判断字数是否符合要求comment
|
||||
$aContent = empty($data['comment']) ? [] : explode(' ', $data['comment']);
|
||||
//字数限制
|
||||
$iWordNum = $journal_info['journal_id'] == 1 ? 150 : 100;
|
||||
if(count($aContent) < $iWordNum){
|
||||
return jsonError("We encourage you to enrich your comment further to help improve the peer paper (at least ".$iWordNum." words).");
|
||||
}
|
||||
$insert_data['comments'] = empty($aContent) ? '' : implode(' ', $aContent);
|
||||
//判断是新增还是修改
|
||||
$rev_qu_id = empty($data['rev_qu_id']) ? 0 : $data['rev_qu_id'];
|
||||
if (empty($rev_qu_id)) { //新增
|
||||
$insert_data['ctime'] = time();
|
||||
$res = $this->article_reviewer_question_obj->insert($insert_data);
|
||||
} else { //更新
|
||||
$res = $this->article_reviewer_question_obj->where('rev_qu_id', $rev_qu_id)->update($insert_data);
|
||||
}
|
||||
|
||||
//根据recommend问题,改变此实例的状态,并且更改act消息提醒状态
|
||||
$artrevstate = 2;
|
||||
if($recommend == 1){
|
||||
$artrevstate = 3;
|
||||
}
|
||||
if($recommend == 2) {
|
||||
$artrevstate = 1;
|
||||
}
|
||||
|
||||
//审稿加审稿时间 chengxiaoling start 20250612
|
||||
$this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->update(['state' => $artrevstate, 'reviewer_act' => 1,'review_time' => time()]);
|
||||
//审稿加审稿时间 chengxiaoling end 20250612
|
||||
|
||||
//文章是从初始状态到其他状态,增加审稿人成功审核次数
|
||||
if ($art_rev_info['state'] == 0) {
|
||||
$this->user_obj->where('user_id', $art_rev_info['reviewer_id'])->setInc('rs_num');
|
||||
//更新审核数量 chengxl 20250409 start
|
||||
$this->reviewNum($art_rev_info['reviewer_id']);
|
||||
//更新审核数量 chengxl 20250409 end
|
||||
}
|
||||
|
||||
//添加文章状态信息
|
||||
$in_data['article_id'] = $article_info['article_id'];
|
||||
$in_data['content'] = 'Comments from the reviewer has been received';
|
||||
$in_data['state_from'] = $article_info['state'];
|
||||
$in_data['state_to'] = $article_info['state'];
|
||||
$in_data['ctime'] = time();
|
||||
// $this->article_msg_obj->insert($in_data);
|
||||
|
||||
//记录log
|
||||
//生成pdf文件
|
||||
// $reviewer_pdf = self::pdftest($journal_info['title']);
|
||||
$reviewer_ZS = self::createReviewerZS($data['art_rev_id']);
|
||||
|
||||
//发送email->编辑
|
||||
$tt = 'Dear editor,<br>';
|
||||
$tt .= 'Please check the new comments from the reviewer.<br>';
|
||||
$tt .= 'Journal:' . $journal_info['title'] . ' and article title:' . $article_info['title'];
|
||||
|
||||
$sendEditor = [
|
||||
'title' => $journal_info['title'], // 邮件标题
|
||||
'content' => $tt, //邮件内容
|
||||
'user_id' => $journal_info['editor_id'], //收件人ID
|
||||
'email' => $editor_info['email'], // 收件人邮箱
|
||||
'journal_id' => $journal_info['journal_id'], // 期刊ID
|
||||
'sendEmail' => $journal_info['email'], // 期刊邮箱
|
||||
'sendPassword' => $journal_info['epassword'], // 期刊密码
|
||||
'from_name' => $journal_info['title']
|
||||
];
|
||||
// Queue::push('app\api\job\domail@fire', $sendEditor, 'domail');
|
||||
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
|
||||
|
||||
//发送email感谢reviewer并携带附件
|
||||
$reviewer_info = $this->user_obj->where('user_id', $art_rev_info['reviewer_id'])->find();
|
||||
$tt1 = 'You have reviewed 1 submission in the journal ' . $journal_info['title'] . ' during ' . date('Y') . '.Thank you for your support to our journal. This contribution is greatly appreciated.<br><br>';
|
||||
$tt1 .= 'Regards<br>Editorial Office<br>' . $journal_info['title'] . '<br><br>';
|
||||
$tt1 .= 'Contact us<br>TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>Telephone: +64 02108293806<br>E-mail: publisher@tmrjournals.com';
|
||||
|
||||
|
||||
//为审稿人增加积分
|
||||
$score = 0;
|
||||
if($journal_info['level']=='A'){
|
||||
$score = 0.3;
|
||||
}elseif($journal_info['level']=="B"){
|
||||
$score = 0.2;
|
||||
}else{
|
||||
$score = 0.1;
|
||||
}
|
||||
addUserScoreLog($art_rev_info['reviewer_id'],$score,"add score ".$score." for review article",time());
|
||||
$this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->setInc('score',$score);
|
||||
|
||||
$sendReviewer = [
|
||||
'title' => 'Your contribution is greatly appreciated', // 邮件标题
|
||||
'content' => $tt1, //邮件内容
|
||||
'user_id' => $reviewer_info['user_id'], //收件人ID
|
||||
'email' => $reviewer_info['email'], // 收件人邮箱
|
||||
'journal_id' => $journal_info['journal_id'], // 期刊ID
|
||||
'sendEmail' => $journal_info['email'], // 期刊邮箱
|
||||
'sendPassword' => $journal_info['epassword'], // 期刊密码
|
||||
'from_name' => $journal_info['title'],
|
||||
'attachment_url' => $reviewer_ZS
|
||||
];
|
||||
// Queue::push('app\api\job\domail@fire', $sendReviewer, 'domail');
|
||||
|
||||
sendEmail($reviewer_info['email'], 'Your contribution is greatly appreciated', $journal_info['title'], $tt1, $journal_info['email'], $journal_info['epassword'], $reviewer_ZS);
|
||||
//记录usermsg
|
||||
add_usermsg($journal_info['editor_id'], 'Feedback questionnaire be uploaded:'.$article_info['accept_sn']."(".$reviewer_info['account'].":".$reviewer_info['email'].")", '/articleReviewerDetail?id=' . $data['art_rev_id']);
|
||||
|
||||
//审稿人提交答卷之后进行审稿行为评分 chengxiaoling 20250617 start
|
||||
if(!empty($artrevstate) && in_array($artrevstate, [1,2,3])){
|
||||
//文章ID
|
||||
$iArticleId = empty($art_rev_info['article_id']) ? 0 : $art_rev_info['article_id'];
|
||||
//审稿人ID
|
||||
$iReviewerId = empty($art_rev_info['reviewer_id']) ? 0 : $art_rev_info['reviewer_id'];
|
||||
//主键ID
|
||||
$iArtRevId = empty($art_rev_info['art_rev_id']) ? 0 : $art_rev_info['art_rev_id'];
|
||||
if(!empty($iArticleId) && !empty($iReviewerId) && !empty($iArtRevId)){
|
||||
$aParam = ['article_id' => $iArticleId,'reviewer_id' => $iReviewerId,'art_rev_id' => $iArtRevId];
|
||||
$iSeconds = 180;//3分钟后执行
|
||||
Queue::later($iSeconds,'app\api\job\ReviewerScore@fire',$aParam, 'ReviewerScore');
|
||||
}
|
||||
}
|
||||
//审稿人提交答卷之后进行审稿行为评分 chengxiaoling 20250617 end
|
||||
return json(['code' => 0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user