Skip to content

Instantly share code, notes, and snippets.

@stoneboyindc
Last active February 26, 2021 02:15
Show Gist options
  • Save stoneboyindc/a9468416600c81d15ce13dcc6b1d4491 to your computer and use it in GitHub Desktop.
Save stoneboyindc/a9468416600c81d15ce13dcc6b1d4491 to your computer and use it in GitHub Desktop.
function checkForPlagiarism (answers, textToCheck) {
for ( i = 0; i < answers.length; i++) {
let studentresponses = answers[i];
if (studentresponses.response.includes(textToCheck) && studentresponses.isEssayQuestion === true) {
return true;
}
}
return false;
}
function checkForPlagiarism(answers, snippet) {
let foundAnswer = 0;
let result = false;
for (let i=0; i<answers.length; i++) {
if (answers[i].response.includes(snippet)) {
foundAnswer = i;
result = true;
break;
}
}
if (result && answers[foundAnswer].isEssayQuestion) {
return true;
}
return false;
}
@ALaird42
Copy link

I got it! The submission was tripping over identifying the snippet in both non essay and essay questions. This pulls all the essay questions into a storage array and then checks those, which removes the non-essay questions all together.

function checkForPlagiarism(answers, snippet) {
let essayArray =[]
for (let i=0; i<answers.length; i++) {
if(answers[i].isEssayQuestion){
essayArray.push(answers[i])
}
}
for (let i = 0; i<essayArray.length; i++){
if (essayArray[i].response.includes(snippet)) {
return true;
}
}
return false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment