엑셀 채점결과 파일 출력 부분 수정
This commit is contained in:
@@ -19,25 +19,25 @@ const scoringJson = require('./DIC_2503B.json');
|
||||
|
||||
// --------------------------------------------------------
|
||||
// const answerFilesDir = './output/A/DIC';
|
||||
// const answerFilesDir = './output/B/DIC';
|
||||
const answerFilesDir = './output/B/DIC';
|
||||
// const answerFilesDir = './output/C/DIC';
|
||||
// const answerFilesDir = './output/D/DIC';
|
||||
|
||||
// TEST
|
||||
// const answerFilesDir = './output/A/TEST';
|
||||
const answerFilesDir = './output/B/TEST';
|
||||
// const answerFilesDir = './output/B/TEST';
|
||||
// const answerFilesDir = './output/C/TEST';
|
||||
// const answerFilesDir = './output/D/TEST';
|
||||
|
||||
// --------------------------------------------------------
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503A_채점결과.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503B_채점결과.xlsx';
|
||||
const outputExcelFile = './'+todayDate+'_DIC_2503B_채점결과.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503C_채점결과.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503D_채점결과.xlsx';
|
||||
|
||||
// TEST
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503A_TEST.xlsx';
|
||||
const outputExcelFile = './'+todayDate+'_DIC_2503B_TEST.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503B_TEST.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503C_TEST.xlsx';
|
||||
// const outputExcelFile = './'+todayDate+'_DIC_2503D_TEST.xlsx';
|
||||
|
||||
@@ -150,14 +150,15 @@ studentDirs.forEach(student => {
|
||||
*/
|
||||
function prepareExcelData(scoringResultList) {
|
||||
return scoringResultList.map(student => {
|
||||
const flattened = { "학생": student["0"] }; // 학생 이름을 첫 번째 열로 설정
|
||||
// const flattened = { "학생": student["0"] }; // 학생 이름을 첫 번째 열로 설정
|
||||
const flattened = { "문항": student["0"] }; // 행열을 변환 할 경우 첫 행의 제목을 "문항"으로 설정
|
||||
|
||||
// 제외할 키와 서브키 정의
|
||||
const exceptKeys = [
|
||||
"0", // 학생 이름 제외
|
||||
// "1", // psd1
|
||||
// "2", // psd2
|
||||
];
|
||||
];
|
||||
const exceptSubkeys = ["videoStartTime", "openingStartTime"]; // 제외할 서브키
|
||||
|
||||
// 학생 데이터 순회
|
||||
@@ -194,37 +195,37 @@ function transposeData(data) {
|
||||
const keys = Object.keys(data[0]);
|
||||
|
||||
// 행과 열을 변환
|
||||
const transposed = keys.map(key => {
|
||||
const row = { "항목": key }; // 각 열 제목을 "항목"으로 설정
|
||||
data.forEach((item, index) => {
|
||||
//console.log(data[index]['학생']);
|
||||
row[data[index]['학생']] = item[key]; // 각 학생의 데이터를 열로 추가
|
||||
const transposed = keys.map(key => {
|
||||
const row = { "항목": key }; // 각 열 제목을 "항목"으로 설정
|
||||
data.forEach((item, index) => {
|
||||
//console.log(data[index]['문항']);
|
||||
row[data[index]['문항']] = item[key]; // 각 학생의 데이터를 열로 추가
|
||||
});
|
||||
return row;
|
||||
});
|
||||
return row;
|
||||
});
|
||||
|
||||
return transposed;
|
||||
return transposed;
|
||||
}
|
||||
|
||||
// const transposedData = transposeData(flattenedData);
|
||||
const transposedData = transposeData(flattenedData).slice(1);
|
||||
const transposedData = transposeData(flattenedData);
|
||||
// const transposedData = transposeData(flattenedData).slice(1)
|
||||
|
||||
// 엑셀 파일 생성
|
||||
// const worksheet = XLSX.utils.json_to_sheet(flattenedData);
|
||||
const worksheet = XLSX.utils.json_to_sheet(transposedData);
|
||||
const worksheet = XLSX.utils.json_to_sheet(transposedData, {skipHeader: true});
|
||||
const workbook = XLSX.utils.book_new();
|
||||
|
||||
// 열 너비 계산
|
||||
// const columnWidths = Object.keys(flattenedData[0]).map(key => {
|
||||
// const maxLength = Math.max(
|
||||
// key.length, // 열 제목의 길이
|
||||
// ...flattenedData.map(row => (row[key] ? row[key].toString().length : 0)) // 각 셀의 데이터 길이
|
||||
// );
|
||||
// return { wch: maxLength + 1 }; // 여유 공간 추가
|
||||
// });
|
||||
const columnWidths = Object.keys(transposedData[0]).map(key => {
|
||||
const maxLength = Math.max(
|
||||
// key.length, // 열 제목의 길이
|
||||
// ...transposedData.map(row => (row[key] ? row[key].toString().length : 0)) // 각 셀의 데이터 길이
|
||||
4 // 고정 너비
|
||||
);
|
||||
return { wch: maxLength + 1 }; // 여유 공간 추가
|
||||
});
|
||||
|
||||
// 열 너비 설정
|
||||
// worksheet['!cols'] = columnWidths;
|
||||
worksheet['!cols'] = columnWidths;
|
||||
// Add the worksheet to the workbook
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, '채점 결과');
|
||||
|
||||
@@ -541,10 +542,10 @@ function getGmepScore(gmepData, scoringJson, index) {
|
||||
|
||||
// 문제의 타입이 video(동영상자막) 또는 opening(오프닝자막)일 경우
|
||||
else if (type == "video" || type == "opening") {
|
||||
|
||||
|
||||
// 찾으려는 자막이 존재하지 않는 경우
|
||||
// (2-28) 문항의 경우 오프닝 자막이 없어도 xpath구문의 sum함수 결과값이 0이 반환되는것을 방지
|
||||
if ( trackClipNode === undefined && clipIndex === null ) {
|
||||
if (trackClipNode === undefined && clipIndex === null) {
|
||||
scoringResult[key] = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -706,7 +707,7 @@ function getScore(psdData, scoring, index) {
|
||||
}
|
||||
if (type == "size") {
|
||||
// console.log(`result ${result.length}`);
|
||||
if ( result[0].height == value['height'] && result[0].width == value['width'] ) {
|
||||
if (result[0].height == value['height'] && result[0].width == value['width']) {
|
||||
scoringResult[key] = point;
|
||||
totalScore += point;
|
||||
}
|
||||
@@ -730,7 +731,7 @@ function getScore(psdData, scoring, index) {
|
||||
// }
|
||||
|
||||
// console.log(`color: ${color}`);
|
||||
if ( color === value ) {
|
||||
if (color === value) {
|
||||
scoringResult[key] = point;
|
||||
totalScore += point;
|
||||
}
|
||||
@@ -746,7 +747,7 @@ function getScore(psdData, scoring, index) {
|
||||
// console.log(`result ${result}`);
|
||||
// console.log(`font: ${font}`);
|
||||
|
||||
if ( font === value ) {
|
||||
if (font === value) {
|
||||
scoringResult[key] = point;
|
||||
totalScore += point;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user