概述
程序文件路径 /src/AppBundle/Component/Export/Course/StudentExporter.php
技术开发 QQ 2446503032
public function getTitles()
{
$userFields = $this->getUserFieldService()->getEnabledFieldsOrderBySeq();
$userFieldsTitle = empty($userFields) ? array() :
ArrayToolkit::column($userFields, 'title');
$fields = array(
'学员ID',
'user.fields.username_label',
'user.fields.truename_label',
'user.fields.gender_label',
'user.fileds.qq',
'user.fileds.wechat',
'user.fields.mobile_label',
'user.fields.company_label',
'user.fields.career_label',
'user.fields.title_label',
'user.fields.email_label',
'student.profile.weibo',
'培训批次ID',
'task.learn_data_detail.createdTime',
'学习时长',
'开始时间',
'结束时间',
'course.plan_task.study_rate',
'成绩',
'考试通过时间',
);
return array_merge($fields, $userFieldsTitle);
}
public function getContent($start, $limit)
{
$course = $this->getCourseService()->getCourse($this->parameter['courseId']);
$translator = $this->container->get('translator');
$gender = array(
'female' => $translator->trans('user.fields.gender.female'),
'male' => $translator->trans('user.fields.gender.male'),
'secret' => $translator->trans('user.fields.gender.secret'),
);
$courseMembers = $this->getCourseMemberService()->searchMembers(
$this->conditions,
array('createdTime' => 'DESC'),
$start,
$limit
);
$studentUserIds = ArrayToolkit::column($courseMembers, 'userId');
$users = $this->getUserService()->findUsersByIds($studentUserIds);
$profiles = $this->getUserService()->findUserProfilesByIds($studentUserIds);
foreach ($courseMembers as $key => $member) {
$progress = $this->getLearningDataAnalysisService()->
makeProgress($member['learnedCompulsoryTaskNum'],
$course['compulsoryTaskNum']);
$courseMembers[$key]['learningProgressPercent'] = $progress['percent'];
}
$fields = $this->getUserFieldService()->getEnabledFieldsOrderBySeq();
$fields = ArrayToolkit::column($fields, 'fieldName');
$datas = array();
foreach ($courseMembers as $courseMember) {
$member = array();
$userId = $courseMember['userId'];
$profile = $profiles[$userId];
$user = $users[$userId];
$connect = mysqli_connect("localhost","root","root","edusoho");
$sql = "select paperName,testId,userId,courseId,score,usedTime from
testpaper_result_v8 where userId=".$userId." and
courseId=".$courseMember['courseId']." order by id desc";
$result = mysqli_query($connect,$sql);
$row = mysqli_fetch_row($result);
$member[] = $profile['kid'];
$member[] = $user['nickname'];
$member[] = $profile['truename'] ? $profile['truename'] : '-';
$member[] = $gender[$profile['gender']];
$member[] = $profile['qq'] ? $profile['qq'] : '-';
$member[] = $profile['weixin'] ? $profile['weixin'] : '-';
$member[] = $profile['mobile'] ? $profile['mobile'] : '-';
$member[] = $profile['company'] ? $profile['company'] : '-';
$member[] = $profile['job'] ? $profile['job'] : '-';
$member[] = $user['title'] ? $user['title'] : '-';
$member[] = $profile['weibo'] ? $profile['weibo'] : '-';
$member[] = $user['email'];
$member[] = $courseMember['courseId'];
$member[] = date('Y-n-d H:i:s', $courseMember['createdTime']);
$member[] = $courseMember['learnedNum'];
$member[] = date('Y-m-d H:i:s',$courseMember['createdTime']);
$member[] = date('Y-m-d H:i:s',$courseMember['lastLearnTime']);
$member[] = $courseMember['learningProgressPercent'].'%';
$member[] = $row['score'];
$member[] = $row['stickyTime'];
foreach ($fields as $value) {
$member[] = $profile[$value] ? str_replace(array(PHP_EOL, '"'), '',
$profile[$value]) : '-';
}
$datas[] = $member;
}
return $datas;
}
最后
以上就是奋斗小熊猫为你收集整理的edusoho二次开发增加用户信息导出功能的全部内容,希望文章能够帮你解决edusoho二次开发增加用户信息导出功能所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复