-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from CMU-313/priority
Backend integration code for flagging priority questions for faculty issue #12 + NPM test code coverage fix
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
// Mapping of priority levels to numerical values | ||
const PRIORITY_MAP = { | ||
'low priority': 1, | ||
'medium priority': 2, | ||
'high priority': 3, | ||
}; | ||
|
||
// Function to check for priority levels in the content and return the corresponding value | ||
module.exports = function priorityflag(content) { | ||
// Convert content to lowercase for case-insensitive matching | ||
content = content.toLowerCase(); | ||
// Check if any priority level exists in the content | ||
for (const [priority, value] of Object.entries(PRIORITY_MAP)) { | ||
if (content.includes(priority)) { | ||
return value; | ||
} | ||
} | ||
// Return 0 if no priority string is found | ||
return 0; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters