Commit a60035dd authored by liujiangnan's avatar liujiangnan

feat: 评测分析

parent 05373ff7
...@@ -626,6 +626,7 @@ body { ...@@ -626,6 +626,7 @@ body {
} }
#recorder-text{ #recorder-text{
position: relative;
width: 98%; width: 98%;
height: 50%; height: 50%;
overflow-x: inherit; overflow-x: inherit;
...@@ -664,7 +665,7 @@ body { ...@@ -664,7 +665,7 @@ body {
overflow-y: auto; overflow-y: auto;
margin-top: 0.4rem; margin-top: 0.4rem;
text-align: left; text-align: left;
padding: 0.2rem 0.8rem; padding: 0.2rem 0.4rem;
margin-left: 5%; margin-left: 5%;
object-fit: contain; object-fit: contain;
font-family: DroidSansFallback; font-family: DroidSansFallback;
...@@ -677,4 +678,31 @@ body { ...@@ -677,4 +678,31 @@ body {
color: #ffffff; color: #ffffff;
background-color: #2c8a1e; background-color: #2c8a1e;
border-radius: 0.3rem; border-radius: 0.3rem;
}
.err-grammar-number {
position: absolute;
background: #dcc077;
top: -0.01rem;
width: 0.3rem;
height: 0.3rem;
font-size: 0.10rem;
border-radius: 0.3rem;
line-height: 0.26rem;
text-align: center;
font-family: Aileron-Bold;
transform: translate(-0.1rem);
}
.err-grammar-index{
display: inline-block;
background: #dcc077;
width: 0.4rem;
height: 0.4rem;
font-size: 0.10rem;
border-radius: 0.4rem;
line-height: 0.35rem;
text-align: center;
font-family: Aileron-Bold;
transform: translate(-0.1rem, -0.05rem);
} }
\ No newline at end of file
...@@ -868,13 +868,36 @@ function drawResult(data, text) { ...@@ -868,13 +868,36 @@ function drawResult(data, text) {
fontColor = 'nicetry'; fontColor = 'nicetry';
} }
const {annotationHtml, evaluateHtml} = annotation(text, temp.detail);
$(".tips").empty().append(tips).addClass(fontColor); $(".tips").empty().append(tips).addClass(fontColor);
$("#medal").attr('src', imgSrc); $("#medal").attr('src', imgSrc);
$("#score").empty().append(score); $("#score").empty().append(score);
$("#recorder-text").empty().append(text); $("#recorder-text").html(annotationHtml);
$("#evaluation").empty().append(temp.evaluate); $("#evaluation").html(evaluateHtml);
} }
function insertString(string, insert, index){
return string.substring(0, index)+insert+string.substr(index);
}
function annotation(text, detail){
let annotationHtml = text.trim();
const allFeatureAdvice = detail.AllFeatureAdvice;
let evaluateHtml = `${allFeatureAdvice.WordDiversity};${allFeatureAdvice.Structure};${allFeatureAdvice.Spelling};${allFeatureAdvice.Grammar}<br>`;
const errorPosInfos = detail.essayFeedback.sentsFeedback[0].errorPosInfos;
for(let i=errorPosInfos.length-1; i>=0; i--){
const errPos = errorPosInfos[i];
const startPos = errPos.startPos;
annotationHtml = insertString(annotationHtml, `<span class="err-grammar-number">${i+1}</span>`, startPos);
}
for(let i=0; i<errorPosInfos.length; i++){
const errPos = errorPosInfos[i];
const reason = errPos.reason;
evaluateHtml += `<br><span class="err-grammar-index">${i+1}</span>&nbsp;${reason}`;
}
return {annotationHtml, evaluateHtml};
}
function scoreByText(text, keyWords, timeLen) { function scoreByText(text, keyWords, timeLen) {
const smallText = text.toLowerCase(); const smallText = text.toLowerCase();
...@@ -926,5 +949,8 @@ function scoreByText(text, keyWords, timeLen) { ...@@ -926,5 +949,8 @@ function scoreByText(text, keyWords, timeLen) {
const fluency = Math.round( rate2 * 100) / 100; // 流利度 const fluency = Math.round( rate2 * 100) / 100; // 流利度
return {integrity, fluency}; return {
integrity: integrity || 0,
fluency: fluency || 0
};
} }
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