Skip to content

Commit

Permalink
feat: add raweb1 reference
Browse files Browse the repository at this point in the history
  • Loading branch information
stanlee974 committed Aug 12, 2024
1 parent 80a9f40 commit 1772a5b
Show file tree
Hide file tree
Showing 8 changed files with 5,664 additions and 5 deletions.
6 changes: 3 additions & 3 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import sharp from "sharp";
import { omit, pick, setWith, uniqBy } from "lodash";

import { PrismaService } from "../prisma.service";
import * as RGAA from "../rgaa.json";
import * as RAWEB1 from "../raweb1.json";
import { AuditReportDto } from "./dto/audit-report.dto";
import { CreateAuditDto } from "./dto/create-audit.dto";
import { CRITERIA_BY_AUDIT_TYPE } from "./criteria";
Expand Down Expand Up @@ -877,7 +877,7 @@ export class AuditService {
assistiveTechnology: e.assistiveTechnology,
browser: e.browser
})),
referencial: "RGAA Version 4.1",
referencial: "RAWEB 1",
samples: audit.pages
.map((p, i) => ({
name: p.name,
Expand Down Expand Up @@ -954,7 +954,7 @@ export class AuditService {
}
},

topicDistributions: RGAA.topics
topicDistributions: RAWEB1.topics
.map((t) => {
const total = CRITERIA_BY_AUDIT_TYPE[audit.auditType].filter(
(c) => c.topic === t.number
Expand Down
4 changes: 2 additions & 2 deletions confiture-rest-api/src/audits/criteria.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AuditType } from "@prisma/client";
import * as rgaa from "../rgaa.json";
import * as RAWEB1 from "../raweb1.json";

interface CriteriumId {
topic: number;
criterium: number;
}

export const CRITERIA = rgaa.topics.flatMap((topic) =>
export const CRITERIA = RAWEB1.topics.flatMap((topic) =>
topic.criteria.map((c) => ({
topic: topic.number,
criterium: c.criterium.number
Expand Down
5,593 changes: 5,593 additions & 0 deletions confiture-rest-api/src/raweb1.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions confiture-web-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ coverage
.env

accessibilite.numerique.gouv.fr
ReferentielAccessibiliteWeb
src/methodologies.json
src/criteres.json
1 change: 1 addition & 0 deletions confiture-web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"test:coverage": "vitest --coverage",
"lint": "eslint '{src,scripts}/**/*.{ts,vue}'",
"generate:rgaa": "node scripts/build-rgaa-files.js",
"generate:raweb": "node scripts/build-raweb-files.js",
"postinstall": "cp ../ROADMAP.md ../CHANGELOG.md ./src/assets"
},
"dependencies": {
Expand Down
62 changes: 62 additions & 0 deletions confiture-web-app/scripts/build-raweb-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* This scripts generates a file containing every RGAA tests methodology based
* on the https://github.com/DISIC/accessibilite.numerique.gouv.fr repository.
*
* The result file uses the JSON format and contains a mapping of test ids
* (ex: "1.2.3") with the associated methodology in Markdown.
*/

/* eslint-disable */
const child_process = require("node:child_process");
const util = require("node:util");
const path = require("path");
const fs = require("fs").promises;
const repositoryName = "ReferentielAccessibiliteWeb";
const jsonDirectoryName = "json";

const exec = util.promisify(child_process.exec);

async function cloneRgaaRepository() {
await exec("rm -rf " + repositoryName);
await exec(
"git clone https://github.com/accessibility-luxembourg/ReferentielAccessibiliteWeb"
);
}

async function generateMethodologies() {
const METHODOLOGIES_SOURCE = path.join(
__dirname,
"..",
"./" + repositoryName + "/" + jsonDirectoryName + "/methodologies.json"
);

const METHODOLOGIES_DESTINATION = path.join(
__dirname,
"..",
"./src/methodologies.json"
);

await fs.copyFile(METHODOLOGIES_SOURCE, METHODOLOGIES_DESTINATION);
}

async function generateCriteria() {
const CRITERIA_SOURCE = path.join(
__dirname,
"..",
"./" + repositoryName + "/" + jsonDirectoryName + "/criteres.json"
);

const CRITERIA_DESTINATION = path.join(
__dirname,
"..",
"./src/criteres.json"
);

await fs.copyFile(CRITERIA_SOURCE, CRITERIA_DESTINATION);
}

(async function main() {
await cloneRgaaRepository();
await generateMethodologies();
await generateCriteria();
})();
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function updateQuickWin(quickWin: boolean) {
// Get a unique id for a criterium per page (e.g. 1-1-8)
const uniqueId = computed(() => {
console.log(`${props.page.id}-${props.topicNumber}-${props.criterium.number}`)
return `${props.page.id}-${props.topicNumber}-${props.criterium.number}`;
});
Expand Down
1 change: 1 addition & 0 deletions confiture-web-app/src/store/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const useResultsStore = defineStore("results", {
*/
getCriteriumResult() {
return (pageId: number, topicNumber: number, criteriumNumber: number) => {
console.log(pageId, topicNumber, criteriumNumber, this.data);
if (
!this.data ||
!this.data[pageId] ||
Expand Down

0 comments on commit 1772a5b

Please sign in to comment.