src/utils/GradingScale.js
import Moods from './Moods';
/**
* Grades and related functions to get common information about each grading.
* @type {Object[]}
*/
const gradingScale = [
{
grade: Moods.NOTANSWERED,
description: 'Ikke besvart',
legend: 'Eeeeeh',
emojiImage: require('../assets/emojis/emojiNone.png'),
speech: null,
},
{
grade: Moods.BAD,
description: 'Dårlig',
legend: 'Det var ikke gøy.',
emojiImage: require('../assets/emojis/emojiBad.png'),
speech: 'ikkegoy_dialog',
},
{
grade: Moods.OK,
description: 'Ok',
legend: 'Det var OK.',
emojiImage: require('../assets/emojis/emojiOK.png'),
speech: 'ok_dialog',
},
{
grade: Moods.GOOD,
description: 'Bra',
legend: 'Det var gøy!',
emojiImage: require('../assets/emojis/emojiGood.png'),
speech: 'goy_dialog',
},
];
/**
* Return the grading object from the scale, corresponding to the specified
* grading.
* @param {number} grading - The grading that is to be retrieved
* @returns {Object} corresponding grading object.
*/
function getGrade(grading) {
return gradingScale.find(grade => grade.grade === grading);
}
/**
* Get the legend of the corresponding grading.
* @param {number} grading - The grading of the object contiaining the legend
* @returns {string} the legend of the corresponding grading object
*/
function getLegend(grading) {
return getGrade(grading).legend;
}
/**
* Get the source of the image of the emoji corresponding to the
* specified grading.
* @param {number} grading - The grading of the object contiaining the emoji
* @returns {Object} source of image
*/
function getEmojiImage(grading) {
return getGrade(grading).emojiImage;
}
/**
* Get the speech sound for the specified grading
* @param {number} grading - The grading of the object contiaining the speech
* @returns {string} the path of speech of the corresponding grading object
*/
function getSpeech(grading) {
return getGrade(grading).speech;
}
export {getLegend, getEmojiImage, getSpeech};