规定word导入格式
1、[单选题][2024][一般]在团队合作中,以下哪个因素对于建立良好的团队关系最为重要?
A.技术能力
B.沟通技巧
C.领导风格
D.工作经验
答案:B
分数:2
考点还原:
答案解析:沟通技巧对于建立良好的团队关系最为重要。
2、[多选题][2024][困难]在团队管理中,以下哪些因素可以促进团队凝聚力和合作精神?
A.共同目标和愿景
B.适当的奖励和认可制度
C.开放的沟通渠道
D.严格的控制和监督
分数:2
答案:ABC
考点还原:
答案解析:
3、[填空题][2024][一般]项目管理中的三个基本约束是时间、成本和_________。
答案:范围
分数:3
考点还原:
答案解析:
4、[简答题][2024][一般]请列举并解释五个影响员工工作满意度的因素。
答案:影响员工工作满意度的因素包括工作环境、薪酬福利、职业发展机会、工作内容和上级领导。工作环境指的是员工工作的物理和社会环境,包括办公设施、团队氛围等;薪酬福利是指员工在工作中所获得的薪水、福利和奖励;职业发展机会指的是员工在职业生涯中所能获得的晋升和发展机会;工作内容是指员工所从事的具体工作任务和职责;上级领导是指员工的直接领导,他们的领导风格和管理能力会直接影响员工的工作满意度。
分数:5
设置关键词:工作环境、薪酬福利、职业发展机会、工作内容、上级领导
考点还原:
答案解析:
PHP获取word内容并导入数据库的代码:
<?php
public function import_word() {
$word = "question.docx";
$phpWord = \PhpOffice\PhpWord\IOFactory::load($word, 'Word2007', 'utf-8');
$sections = $phpWord->getSections();
$wordData = [];
//将内容分句子
foreach ($sections as $section) {
$elements = $section->getElements();
foreach ($elements as $element) {
if ($element instanceof \PhpOffice\PhpWord\Element\TextRun) {
$wordData[] = $element->getText();
foreach($element->getElements() as $text){
//导入每道题的图片
if ($text instanceof \PhpOffice\PhpWord\Element\Image) {
$file_path = './uploads/images'.uniqid().'.jpg';
file_put_contents($file_path, trim($text->getImageString()));
$wordData[] = 'image:'.Config::get('web_site_domain').ltrim($file_path, '.');
}
}
}
}
}
//拆分句子
$questionData = [];
$sectionData = [];
foreach($wordData as $val){
if($val){
if(strpos($val, "[单选题]") !== false){
if ($sectionData) {
$questionData[] = $sectionData;
$sectionData = [];
}
}else if(strpos($val, "[多选题]") !== false){
if ($sectionData) {
$questionData[] = $sectionData;
$sectionData = [];
}
}else if(strpos($val, "[填空题]") !== false){
if ($sectionData) {
$questionData[] = $sectionData;
$sectionData = [];
}
}else if(strpos($val, "[简答题]") !== false){
if ($sectionData) {
$questionData[] = $sectionData;
$sectionData = [];
}
}
$sectionData[] = $val;
}
}
if($sectionData){
$questionData[] = $sectionData;
}
//对试题数组过滤数据
$questions = [];
if ($questionData) {
foreach ($questionData as $key1=>$val1) {
$title = "";
$answer = "";
$options = "";
$score = 0;
$question_type = 0;
$year = 0;
$difficulty = 0;
$question_keywords = "";
$answer_key = "";
$title = trim($val1[0]);
$index1 = strpos($title, '[');
$title = substr($title, $index1);
if (strpos($title, "[单选题]") === 0) {
$question_type = 1;
$title = str_replace("[单选题]", "", $title);
} else if (strpos($title, "[多选题]") === 0) {
$question_type = 2;
$title = str_replace("[多选题]", "", $title);
} else if (strpos($title, "[填空题]") === 0) {
$question_type = 3;
$title = str_replace("[填空题]", "", $title);
} else if (strpos($title, "[简答题]") === 0) {
$question_type = 4;
$title = str_replace("[简答题]", "", $title);
}
preg_match_all("/\[\d+\]/", $title, $matchs);
if (isset($matchs[0][0]) && $matchs[0][0]) {
$year = str_replace(["[", "]"], "", $matchs[0][0]);
$title = str_replace("[{$year}]", "", $title);
} else {
$title = str_replace("[]", "", $title);
}
if (strpos($title, "[容易]") === 0) {
$difficulty = 1;
$title = str_replace("[容易]", "", $title);
} else if (strpos($title, "[一般]") === 0) {
$difficulty = 2;
$title = str_replace("[一般]", "", $title);
} else if (strpos($title, "[困难]") === 0) {
$difficulty = 3;
$title = str_replace("[困难]", "", $title);
} else {
$title = str_replace("[]", "", $title);
}
unset($val1[0]);
$optionData = [];
$images = [];
foreach ($val1 as $k1 => $v1) {
for ($i = 0; $i < 26; $i++) {
$option_id = chr($i + 65).".";
if (strpos($v1, $option_id) === 0) {
$optionData[] = str_replace($option_id, "", $v1);
}
}
if(strpos($v1, "image:") === 0) {
$images[] = str_replace("image:", "", $v1);
}
if (strpos($v1, "答案:") === 0) {
$answer = str_replace("答案:", "", $v1);
}
if (strpos($v1, "分数:") === 0) {
$score = str_replace("分数:", "", $v1);
}
if (strpos($v1, "答案解析:") === 0) {
$answer_key = str_replace("答案解析:", "", $v1);
}
if (strpos($v1, "设置关键词:") === 0) {
$question_keywords = str_replace("设置关键词:", "", $v1);
}
}
$question_num = $key1 + 1;
//判断每道题是否符合规则
if(!$title){
$this->error("第".$question_num."道题【标题有误】");
}
if(!$question_type){
$this->error("第".$question_num."道题【题型有误】");
}
if(!$answer){
$this->error("第".$question_num."道题【答案有误】");
}
if(!$difficulty){
$this->error("第".$question_num."道题【难度有误】");
}
if (in_array(trim($question_type), [1, 2])) {
if(!$optionData){
$this->error("第".$question_num."道题【选项有误】");
}
$options = [];
foreach ($optionData as $k2 => $v2) {
$options[$k2]['options_title'] = $v2;
$options[$k2]['options_value'] = 0;
}
$options = FreelistoftestquestionsModel::validateAnswer($options, trim($answer));
if(!$options){
$this->error("第".$question_num."道题【选项有误】");
}
}
$questions[] = [
'title' => trim($title),
'options' => $options,
'answer' => trim($answer),
'images' => implode(',', $images),
'question_type' => $question_type,
'year' => trim($year),
'score' => intval($score),
'question_keywords' => trim($question_keywords),
'difficulty' => $difficulty,
'answer_key' => trim($answer_key),
'status' => 1,
'create_time' => time(),
];
}
}
if ($questions) {
if (!QuestionsModel::insertAll($questions)) {
return false;
}
return true;
} else {
return false;
}
}