Skip to content

Commit

Permalink
Merge pull request #64 from clpetersonucf/issue/54-special-characters…
Browse files Browse the repository at this point in the history
…-in-folders-cause-problems

Resolves special character matching in score module
  • Loading branch information
clpetersonucf authored Oct 4, 2024
2 parents 1ef862b + cd380a5 commit 6536a5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/_score/score_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public function check_answer($log)
$answers = $this->questions[$log->item_id]->answers;
foreach($answers as $answer)
{
if ($log->text == $answer['text'])
// ensure string values are in parity. The answer value (coming from the qset) may include html entities.
$log_sanitized = html_entity_decode(strtolower(trim($log->text)));
$answer_sanitized = html_entity_decode(strtolower(trim($answer['text'])));

if ($log_sanitized == $answer_sanitized)
{
return $answer['value'];
}
Expand Down
15 changes: 10 additions & 5 deletions src/scoreScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ SortItOut.controller('SortItOutScoreCtrl', [
$scope.questionValue = 100 / qset.items.length

for (let item of qset.items) {
const folderName = item.answers[0].text
const folderName = sanitizeHelper.desanitize(item.answers[0].text)
if (item.options.image) {
imageMap[item.questions[0].text] = Materia.ScoreCore.getMediaUrl(item.options.image)
imageMap[sanitizeHelper.desanitize(item.questions[0].text)] = Materia.ScoreCore.getMediaUrl(item.options.image)
}
if (folderNames[folderName] == undefined) {
folderNames[folderName] = folders.length
Expand All @@ -56,7 +56,12 @@ SortItOut.controller('SortItOutScoreCtrl', [
}

for (let entry of scoreTable) {
const [text, userFolderName, correctFolderName] = entry.data
let [text, userFolderName, correctFolderName] = entry.data

// ensure string values are properly decoded
text = sanitizeHelper.desanitize(text)
userFolderName = sanitizeHelper.desanitize(userFolderName)
correctFolderName = sanitizeHelper.desanitize(correctFolderName)

const correctFolderIndex = folderNames[correctFolderName]
const userFolderIndex = folderNames[userFolderName]
Expand All @@ -65,7 +70,7 @@ SortItOut.controller('SortItOutScoreCtrl', [
folders[userFolderIndex].placeCount++

const item = {
text: sanitizeHelper.desanitize(text),
text: text,
correct,
userFolderName,
image: imageMap[text] || false
Expand All @@ -78,7 +83,7 @@ SortItOut.controller('SortItOutScoreCtrl', [
} else {
folders[correctFolderIndex].items.push(item)
folders[userFolderIndex].extraItems.push({
text: sanitizeHelper.desanitize(text),
text: text,
image: imageMap[text] || false,
correctFolderName
})
Expand Down

0 comments on commit 6536a5c

Please sign in to comment.