测评题库和成长寄语

parent b2f71448
......@@ -120,6 +120,20 @@ export async function updateIsOpenSurvey(surveyId: number, isOpen: number) {
await updateManyData(TABLENAME.测评活动表, { id: surveyId }, {
is_open: isOpen ? true : false
});
// 通过模板id查询试卷,按创建时间倒序取最晚一条
let survey_template = await selectOneDataByParam(TABLENAME.测评活动表, {
is_temp: 2,
temp_id: surveyId,
"%orderDesc%": "created_at",
"%limit%": 1
});
if (hasData(survey_template)) {
let survey_id = (survey_template.data as any).id;
await updateManyData(TABLENAME.测评活动表, { id: survey_id }, {
is_open: isOpen ? true : false
});
}
return { isSuccess: true };
}
......@@ -152,10 +166,10 @@ export async function updateSurvey(param: {
if (!hasData(survey)) {
throw new BizError(ERRORENUM.未找到数据, '测评不存在');
}
await updateSurveyInfo(surveyId, surveyName, startTime, endTime, isOpen, description, questions);
// 若是没有更新开始时间,则同步更新试卷
if (survey.data.start_time === startTime) {
// 更新模板
await updateSurveyInfo(null, surveyId, surveyName, startTime, endTime, isOpen, description, questions);
// 通过模板id查询试卷,按创建时间倒序取最晚一条
let survey_template = await selectOneDataByParam(TABLENAME.测评活动表, {
is_temp: 2,
......@@ -166,10 +180,12 @@ export async function updateSurvey(param: {
if (hasData(survey_template)) {
let survey_id = (survey_template.data as any).id;
// 更新试卷信息
await updateSurveyInfo(survey_id, surveyName, startTime, endTime, isOpen, description, questions);
await updateSurveyInfo(null, survey_id, surveyName, startTime, endTime, isOpen, description, questions);
}
} else {
let semester = await getCurrentSemester();
// 更新模板
await updateSurveyInfo(semester.id, surveyId, surveyName, startTime, endTime, isOpen, description, questions);
// 若是更新开始时间,则通过模板创建试卷
let insertData = await insertSurveyInfo(semester.id, surveyName, startTime, endTime, isOpen, description, 2, surveyId);
let survey_id = (insertData as any).data.id;
......@@ -250,16 +266,21 @@ async function insertSurveyDetail(surveyId: number, questions: any[]){
}
}
// 内联方法,用于更新测评信息和题目列表
async function updateSurveyInfo(surveyId: number, surveyName: string, startTime: string,
async function updateSurveyInfo(semesterId: number, surveyId: number, surveyName: string, startTime: string,
endTime: string, isOpen: number, description: string, questions: any[]){
/**更新 survey 表 */
await updateManyData(TABLENAME.测评活动表, { id: surveyId }, {
let surveyParam:any = {
name: surveyName,
start_time: startTime || null,
end_time: endTime || null,
is_open: isOpen ? true : false,
description: description || null
});
};
if (semesterId) {
surveyParam.semester_id = semesterId;
}
/**更新 survey 表 */
await updateManyData(TABLENAME.测评活动表, { id: surveyId }, surveyParam);
/**操作 survey_question 表:先删后加 */
await delData(TABLENAME.测评题目表, { survey_id: surveyId });
......
......@@ -1046,6 +1046,34 @@ async function parseXmlResponse(xmlData: string): Promise<string | false> {
// 学生账号列表
students: [
{
user_id: 'nmzx2203040',
user_name: '何陈迹',
gender: '女',
user_type: '10010',
email: 'hecj@test.com',
phone: '13900000020',
class_name: '',
student_no: '',
is_youth_party_school: false,
middle_school: '',
parent_name: '',
parent_phone: ''
},
{
user_id: 'nmzx2203570',
user_name: '贾玉龙',
gender: '男',
user_type: '10010',
email: 'jiayl@test.com',
phone: '13900000021',
class_name: '',
student_no: '',
is_youth_party_school: false,
middle_school: '',
parent_name: '',
parent_phone: ''
},
{
user_id: 'nmzx2107510',
user_name: '葛颋宇',
gender: '男',
......
......@@ -12,7 +12,7 @@ export async function getAbilityComparison(
let abilityData = await post(systemConfig.abilitycomparison, { student_id: studentId }, {});
let abilityModel = transformAbilityData(abilityData);
let avatarInfo = extractAvatarInfo(abilityData);
let threeScores = calculateDirectionScoresFromDimensions(abilityModel.abilityScores);
let threeScores = calculateDirectionScoresFromDimensions(abilityModel.abilityBasicScores);
return {
abilityModel,
avatarInfo,
......@@ -42,6 +42,16 @@ function transformAbilityData(apiData: any) {
}
const data = apiData.data;
let abilityScores = [];
Object.entries(data.abilities).forEach(([key, value]: [string, any]) => {
abilityScores.push({
"key": key,
"curr": value.currentScore || 0,
"avg": value.averageScore || 0
});
});
return {
hasData: data.hasData,
message: data.message || '获取成功',
......@@ -49,9 +59,11 @@ function transformAbilityData(apiData: any) {
currentScore: data.totalScore?.currentScore || 0,
previousScore: data.totalScore?.previousScore || null,
yoyChange: data.totalScore?.yoyChange || null,
yoyPercent: data.totalScore?.yoyPercent || null
yoyPercent: data.totalScore?.yoyPercent || null,
abilityRank: data.totalScore?.abilityRank || "--"
},
abilityScores: {
abilityScores: abilityScores,
abilityBasicScores: {
jgqh: data.abilities?.jgqh?.currentScore || 0,
gjsy: data.abilities?.gjsy?.currentScore || 0,
zrdd: data.abilities?.zrdd?.currentScore || 0,
......
......@@ -2,7 +2,8 @@ import { post } from "../../util/request";
import { BizError } from "../../util/bizError";
import { ERRORENUM } from "../../config/errorEnum";
const BASE_URL = 'http://58.246.54.66:8000';
// const BASE_URL = 'http://58.246.54.66:8000';
const BASE_URL = 'https://nmzx-proxy.dev.yunstech.cn';
const CLIENT_ID = '1103b3776c534c0f98d38f1f7d6697f9';
let tokenQueue = "";
......@@ -39,6 +40,19 @@ async function callDianXinApi(url: string, params: Record<string, any>) {
return result;
}
/** 获取学生基础信息 */
export async function getStudentInfo(username: string, grade: string, classroom: string) {
let params: Record<string, any> = { username };
if (grade) {
params.grade = grade;
}
if (classroom) {
params.classroom = classroom;
}
let result:any = await callDianXinApi('/service/api/nmzx/student_info', params);
return result?.data || null;
}
/** 获取学生最近成绩(各科分数 + 总分 + 班级排名) */
export async function getStudentLatestScore(stuno: string, xuenian: string) {
let params: Record<string, any> = { stuno };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment