axyseo 2.0.0-alpha.0.0.28 → 2.0.0-alpha.0.0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/const/analysis.js +1 -1
- package/build/const/analysis.js.map +1 -1
- package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js +1 -0
- package/build/scoring/assessments/readability/RelatedKeywordsAssessment.js.map +1 -1
- package/build/scoring/assessors/contentAssessor.js.map +1 -1
- package/package.json +1 -1
package/build/const/analysis.js
CHANGED
|
@@ -16,5 +16,5 @@ const statusRate = exports.statusRate = {
|
|
|
16
16
|
bad: 0
|
|
17
17
|
};
|
|
18
18
|
const technicalSEOCategory = exports.technicalSEOCategory = ['singleH1', 'metaDescriptionLength', 'urlLength', 'internalLinks', 'externalLinks', 'titleWidth', 'textImages', 'schema', 'singleTitle'];
|
|
19
|
-
const contentSEOCategory = exports.contentSEOCategory = ['introductionKeyword', 'sentenceBeginnings', 'textSentenceLength', 'textLength', 'titleKeyword', 'keyphraseLength', 'textTransitionWords', 'keyphraseDensity', 'slugKeyword', 'keyphrase', 'textParagraphTooLong', 'subheadingsKeyword', 'images', 'numberTitle', 'metaDescriptionKeyword', '
|
|
19
|
+
const contentSEOCategory = exports.contentSEOCategory = ['introductionKeyword', 'sentenceBeginnings', 'textSentenceLength', 'textLength', 'titleKeyword', 'keyphraseLength', 'textTransitionWords', 'keyphraseDensity', 'slugKeyword', 'keyphrase', 'textParagraphTooLong', 'subheadingsKeyword', 'images', 'numberTitle', 'metaDescriptionKeyword', 'relatedKeywords'];
|
|
20
20
|
//# sourceMappingURL=analysis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analysis.js","names":["POINT","exports","priorityRate","high","medium","low","statusRate","good","improve","bad","technicalSEOCategory","contentSEOCategory"],"sources":["../../src/const/analysis.js"],"sourcesContent":["export const POINT = 100;\nexport const priorityRate = {\n high: 1,\n medium: 0.75,\n low: 0.5\n};\nexport const statusRate = {\n good: 1,\n improve: 0.5,\n bad: 0\n};\n\nexport const technicalSEOCategory = [\n 'singleH1',\n 'metaDescriptionLength',\n 'urlLength',\n 'internalLinks',\n 'externalLinks',\n 'titleWidth',\n 'textImages',\n 'schema',\n 'singleTitle'\n];\n\nexport const contentSEOCategory = [\n 'introductionKeyword',\n 'sentenceBeginnings',\n 'textSentenceLength',\n 'textLength',\n 'titleKeyword',\n 'keyphraseLength',\n 'textTransitionWords',\n 'keyphraseDensity',\n 'slugKeyword',\n 'keyphrase',\n 'textParagraphTooLong',\n 'subheadingsKeyword',\n 'images',\n 'numberTitle',\n 'metaDescriptionKeyword',\n '
|
|
1
|
+
{"version":3,"file":"analysis.js","names":["POINT","exports","priorityRate","high","medium","low","statusRate","good","improve","bad","technicalSEOCategory","contentSEOCategory"],"sources":["../../src/const/analysis.js"],"sourcesContent":["export const POINT = 100;\nexport const priorityRate = {\n high: 1,\n medium: 0.75,\n low: 0.5\n};\nexport const statusRate = {\n good: 1,\n improve: 0.5,\n bad: 0\n};\n\nexport const technicalSEOCategory = [\n 'singleH1',\n 'metaDescriptionLength',\n 'urlLength',\n 'internalLinks',\n 'externalLinks',\n 'titleWidth',\n 'textImages',\n 'schema',\n 'singleTitle'\n];\n\nexport const contentSEOCategory = [\n 'introductionKeyword',\n 'sentenceBeginnings',\n 'textSentenceLength',\n 'textLength',\n 'titleKeyword',\n 'keyphraseLength',\n 'textTransitionWords',\n 'keyphraseDensity',\n 'slugKeyword',\n 'keyphrase',\n 'textParagraphTooLong',\n 'subheadingsKeyword',\n 'images',\n 'numberTitle',\n 'metaDescriptionKeyword',\n 'relatedKeywords'\n];\n"],"mappings":";;;;;;AAAO,MAAMA,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,GAAG;AACjB,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG;EAC1BC,IAAI,EAAE,CAAC;EACPC,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE;AACP,CAAC;AACM,MAAMC,UAAU,GAAAL,OAAA,CAAAK,UAAA,GAAG;EACxBC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,GAAG;EACZC,GAAG,EAAE;AACP,CAAC;AAEM,MAAMC,oBAAoB,GAAAT,OAAA,CAAAS,oBAAA,GAAG,CAClC,UAAU,EACV,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,aAAa,CACd;AAEM,MAAMC,kBAAkB,GAAAV,OAAA,CAAAU,kBAAA,GAAG,CAChC,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,wBAAwB,EACxB,iBAAiB,CAClB","ignoreList":[]}
|
|
@@ -105,6 +105,7 @@ class RelatedKeywordsAssessment extends _assessment.default {
|
|
|
105
105
|
* @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.
|
|
106
106
|
*/
|
|
107
107
|
isApplicable(paper, researcher) {
|
|
108
|
+
console.log(paper.hasRelatedKeywords());
|
|
108
109
|
return paper.hasRelatedKeywords();
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelatedKeywordsAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_AssessmentResult","_assessment","_RelatedKeywordsDescription","e","__esModule","default","RelatedKeywordsAssessment","Assessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","merge","calculateResult","paper","relatedKeywords","i18n","data","getData","totalWordUsed","words","isWordUsedExceeding","status","related_keywords","length","score","getScore","body","createElement","getResult","researcher","getResearch","result","assessmentResult","AssessmentResult","setScore","setStatus","setBody","isApplicable","hasRelatedKeywords","exports"],"sources":["../../../../src/scoring/assessments/readability/RelatedKeywordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\n\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\nimport RelatedKeywordsDescription from '@axyseo/components/RelatedKeywordsDescription';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'relatedKeywords',\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#duplicate-title',\n priority: 'high',\n title: 'Related keywords',\n content: {\n good: 'Related keyword density is optimized',\n bad:\n 'Consider using at least a related keyword in your page to establish topical relevance.',\n improve: 'Too high related keyword density. Keep related keyword density from 0.5% - 1%.'\n }\n };\n\n this.identifier = 'relatedKeywords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param relatedKeywords\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, relatedKeywords, i18n) {\n const data = paper.getData();\n const {totalWordUsed, words, isWordUsedExceeding} = relatedKeywords;\n let status = 'good';\n if (!data?.related_keywords?.length || totalWordUsed <= 0) {\n status = 'bad';\n }\n\n if (isWordUsedExceeding) {\n status = 'improve';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: <RelatedKeywordsDescription {...{words, i18n}} />\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n\n const result = this.calculateResult(paper, relatedKeywords, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n return paper.hasRelatedKeywords();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,2BAAA,GAAAH,sBAAA,CAAAF,OAAA;AAAuF,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvF;AACA;AACA;AACe,MAAMG,yBAAyB,SAASC,mBAAU,CAAC;EAChE;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,iBAAiB;MACrBC,WAAW,EAAE,aAAa;MAC1BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,6FAA6F;MAC/FC,QAAQ,EAAE,MAAM;MAChBC,KAAK,EAAE,kBAAkB;MACzBC,OAAO,EAAE;QACPC,IAAI,EAAE,sCAAsC;QAC5CC,GAAG,EACD,wFAAwF;QAC1FC,OAAO,EAAE;MACX;IACF,CAAC;IAED,IAAI,CAACC,UAAU,GAAG,iBAAiB;IACnC,IAAI,CAACC,OAAO,GAAG,IAAAC,aAAK,EAACb,aAAa,EAAED,MAAM,CAAC;EAC7C;;EAEA;A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IAErC,OAAOM,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACxB,KAAK,EAAEgB,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"RelatedKeywordsAssessment.js","names":["_lodash","require","_react","_interopRequireDefault","_AssessmentResult","_assessment","_RelatedKeywordsDescription","e","__esModule","default","RelatedKeywordsAssessment","Assessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","title","content","good","bad","improve","identifier","_config","merge","calculateResult","paper","relatedKeywords","i18n","data","getData","totalWordUsed","words","isWordUsedExceeding","status","related_keywords","length","score","getScore","body","createElement","getResult","researcher","getResearch","result","assessmentResult","AssessmentResult","setScore","setStatus","setBody","isApplicable","console","log","hasRelatedKeywords","exports"],"sources":["../../../../src/scoring/assessments/readability/RelatedKeywordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\n\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\n\nimport RelatedKeywordsDescription from '@axyseo/components/RelatedKeywordsDescription';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class RelatedKeywordsAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'relatedKeywords',\n fixPosition: 'description',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#duplicate-title',\n priority: 'high',\n title: 'Related keywords',\n content: {\n good: 'Related keyword density is optimized',\n bad:\n 'Consider using at least a related keyword in your page to establish topical relevance.',\n improve: 'Too high related keyword density. Keep related keyword density from 0.5% - 1%.'\n }\n };\n\n this.identifier = 'relatedKeywords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n *\n * @param paper\n * @param relatedKeywords\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateResult(paper, relatedKeywords, i18n) {\n const data = paper.getData();\n const {totalWordUsed, words, isWordUsedExceeding} = relatedKeywords;\n let status = 'good';\n if (!data?.related_keywords?.length || totalWordUsed <= 0) {\n status = 'bad';\n }\n\n if (isWordUsedExceeding) {\n status = 'improve';\n }\n\n const score = this.getScore(this._config.priority, status);\n\n return {\n score,\n status,\n body: <RelatedKeywordsDescription {...{words, i18n}} />\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const relatedKeywords = researcher.getResearch('checkRelatedKeywords');\n\n const result = this.calculateResult(paper, relatedKeywords, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(result.score);\n assessmentResult.setStatus(result.status);\n assessmentResult.setBody(result.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n console.log(paper.hasRelatedKeywords());\n return paper.hasRelatedKeywords();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,2BAAA,GAAAH,sBAAA,CAAAF,OAAA;AAAuF,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvF;AACA;AACA;AACe,MAAMG,yBAAyB,SAASC,mBAAU,CAAC;EAChE;AAC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AACA;AACA;AACA;AACA;EACEa,SAASA,CAAC;IAACf,KAAK;IAAEgB,UAAU;IAAEd;EAAI,CAAC,EAAE;IACnC,MAAMD,eAAe,GAAGe,UAAU,CAACC,WAAW,CAAC,sBAAsB,CAAC;IAEtE,MAAMC,MAAM,GAAG,IAAI,CAACnB,eAAe,CAACC,KAAK,EAAEC,eAAe,EAAEC,IAAI,CAAC;IACjE,MAAMiB,gBAAgB,GAAG,IAAIC,yBAAgB,CAAC;MAACpC,MAAM,EAAE,IAAI,CAACa;IAAO,CAAC,CAAC;IAErEsB,gBAAgB,CAACE,QAAQ,CAACH,MAAM,CAACP,KAAK,CAAC;IACvCQ,gBAAgB,CAACG,SAAS,CAACJ,MAAM,CAACV,MAAM,CAAC;IACzCW,gBAAgB,CAACI,OAAO,CAACL,MAAM,CAACL,IAAI,CAAC;IAErC,OAAOM,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEK,YAAYA,CAACxB,KAAK,EAAEgB,UAAU,EAAE;IAC9BS,OAAO,CAACC,GAAG,CAAC1B,KAAK,CAAC2B,kBAAkB,CAAC,CAAC,CAAC;IACvC,OAAO3B,KAAK,CAAC2B,kBAAkB,CAAC,CAAC;EACnC;AACF;AAACC,OAAA,CAAAhD,OAAA,GAAAC,yBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentAssessor.js","names":["_lodash","require","_assessor","_interopRequireDefault","_ParagraphTooLongAssessment","_SentenceLengthInTextAssessment","_SentenceBeginningsAssessment","_TransitionWordsAssessment","_scoreToRating","_RelatedKeywordsAssessment","e","__esModule","default","ContentAssessor","Assessor","constructor","researcher","config","type","_assessments","ParagraphTooLong","SentenceLengthInText","TransitionWords","SentenceBeginnings","RelatedKeywordsAssessment","calculatePenaltyPointsFullSupport","rating","calculatePenaltyPointsPartialSupport","_allAssessmentsSupported","numberOfAssessments","length","applicableAssessments","getApplicableAssessments","calculatePenaltyPoints","results","getValidResults","penaltyPoints","map","result","scoreToRating","getScore","bind","sum","_ratePenaltyPoints","totalPenaltyPoints","calculateOverallScore","exports"],"sources":["../../../src/scoring/assessors/contentAssessor.js"],"sourcesContent":["import {map, sum} from 'lodash';\nimport Assessor from './assessor.js';\nimport ParagraphTooLong from '../assessments/readability/ParagraphTooLongAssessment.js';\nimport SentenceLengthInText from '../assessments/readability/SentenceLengthInTextAssessment.js';\nimport SentenceBeginnings from '../assessments/readability/SentenceBeginningsAssessment.js';\nimport TransitionWords from '../assessments/readability/TransitionWordsAssessment.js';\nimport scoreToRating from '../interpreters/scoreToRating.js';\nimport RelatedKeywordsAssessment from '
|
|
1
|
+
{"version":3,"file":"contentAssessor.js","names":["_lodash","require","_assessor","_interopRequireDefault","_ParagraphTooLongAssessment","_SentenceLengthInTextAssessment","_SentenceBeginningsAssessment","_TransitionWordsAssessment","_scoreToRating","_RelatedKeywordsAssessment","e","__esModule","default","ContentAssessor","Assessor","constructor","researcher","config","type","_assessments","ParagraphTooLong","SentenceLengthInText","TransitionWords","SentenceBeginnings","RelatedKeywordsAssessment","calculatePenaltyPointsFullSupport","rating","calculatePenaltyPointsPartialSupport","_allAssessmentsSupported","numberOfAssessments","length","applicableAssessments","getApplicableAssessments","calculatePenaltyPoints","results","getValidResults","penaltyPoints","map","result","scoreToRating","getScore","bind","sum","_ratePenaltyPoints","totalPenaltyPoints","calculateOverallScore","exports"],"sources":["../../../src/scoring/assessors/contentAssessor.js"],"sourcesContent":["import {map, sum} from 'lodash';\nimport Assessor from './assessor.js';\nimport ParagraphTooLong from '../assessments/readability/ParagraphTooLongAssessment.js';\nimport SentenceLengthInText from '../assessments/readability/SentenceLengthInTextAssessment.js';\nimport SentenceBeginnings from '../assessments/readability/SentenceBeginningsAssessment.js';\nimport TransitionWords from '../assessments/readability/TransitionWordsAssessment.js';\nimport scoreToRating from '../interpreters/scoreToRating.js';\nimport RelatedKeywordsAssessment from '../assessments/readability/RelatedKeywordsAssessment';\n\n/**\n * The ContentAssessor class is used for the readability analysis.\n */\nexport default class ContentAssessor extends Assessor {\n /**\n * Creates a new ContentAssessor instance.\n * @param {Researcher}\tresearcher\tThe researcher to use.\n * @param {Object}\t\t[config]\tThe assessor config.\n */\n constructor(researcher, config) {\n super(researcher, config);\n this.type = 'contentAssessor';\n\n this._assessments = [\n new ParagraphTooLong(),\n new SentenceLengthInText(),\n new TransitionWords(),\n new SentenceBeginnings(),\n new RelatedKeywordsAssessment()\n ];\n }\n\n /**\n * Calculates the weighted rating for languages that have all assessments based on a given rating.\n *\n * @param {string} rating The rating to be weighted.\n * @returns {number} The weighted rating.\n */\n calculatePenaltyPointsFullSupport(rating) {\n switch (rating) {\n case 'bad':\n return 3;\n case 'ok':\n return 2;\n default:\n case 'good':\n return 0;\n }\n }\n\n /**\n * Calculates the weighted rating for languages that don't have all assessments based on a given rating.\n *\n * @param {string} rating The rating to be weighted.\n * @returns {number} The weighted rating.\n */\n calculatePenaltyPointsPartialSupport(rating) {\n switch (rating) {\n case 'bad':\n return 4;\n case 'ok':\n return 2;\n default:\n case 'good':\n return 0;\n }\n }\n\n /**\n * Determines whether a language is fully supported. If a language supports 7 content assessments,\n * it is fully supported\n *\n * @returns {boolean} True if fully supported.\n */\n _allAssessmentsSupported() {\n const numberOfAssessments = this._assessments.length;\n const applicableAssessments = this.getApplicableAssessments();\n return applicableAssessments.length === numberOfAssessments;\n }\n\n /**\n * Calculates the penalty points based on the assessment results.\n *\n * @returns {number} The total penalty points for the results.\n */\n calculatePenaltyPoints() {\n const results = this.getValidResults();\n\n const penaltyPoints = map(\n results,\n function(result) {\n const rating = scoreToRating(result.getScore());\n\n if (this._allAssessmentsSupported()) {\n return this.calculatePenaltyPointsFullSupport(rating);\n }\n\n return this.calculatePenaltyPointsPartialSupport(rating);\n }.bind(this)\n );\n\n return sum(penaltyPoints);\n }\n\n /**\n * Rates the penalty points\n *\n * @param {number} totalPenaltyPoints The amount of penalty points.\n * @returns {number} The score based on the amount of penalty points.\n *\n * @private\n */\n _ratePenaltyPoints(totalPenaltyPoints) {\n if (this.getValidResults().length === 1) {\n // If we have only 1 result, we only have a \"no content\" result\n return 30;\n }\n\n if (this._allAssessmentsSupported()) {\n // Determine the total score based on the total penalty points.\n if (totalPenaltyPoints > 6) {\n // A red indicator.\n return 30;\n }\n\n if (totalPenaltyPoints > 4) {\n // An orange indicator.\n return 60;\n }\n } else {\n if (totalPenaltyPoints > 4) {\n // A red indicator.\n return 30;\n }\n\n if (totalPenaltyPoints > 2) {\n // An orange indicator.\n return 60;\n }\n }\n // A green indicator.\n return 90;\n }\n\n /**\n * Calculates the overall score based on the assessment results.\n *\n * @returns {number} The overall score.\n */\n calculateOverallScore() {\n const results = this.getValidResults();\n\n // If you have no content, you have a red indicator.\n if (results.length === 0) {\n return 30;\n }\n\n const totalPenaltyPoints = this.calculatePenaltyPoints();\n\n return this._ratePenaltyPoints(totalPenaltyPoints);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,+BAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,6BAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,0BAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,cAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,0BAAA,GAAAN,sBAAA,CAAAF,OAAA;AAA6F,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7F;AACA;AACA;AACe,MAAMG,eAAe,SAASC,iBAAQ,CAAC;EACpD;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,MAAM,EAAE;IAC9B,KAAK,CAACD,UAAU,EAAEC,MAAM,CAAC;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