Skip to content

Commit

Permalink
Fix revert categories
Browse files Browse the repository at this point in the history
  • Loading branch information
ravimeijerrig committed Nov 11, 2024
1 parent bcf2062 commit 777c38a
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 3,227 deletions.
8 changes: 4 additions & 4 deletions decision-tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ conclusions:
- source: Artikel 111 - Reeds in de handel gebrachte of in gebruik gestelde AI-systemen
url: https://eur-lex.europa.eu/legal-content/NL/TXT/HTML/?uri=OJ:L_202401689#d1e8928-1-1
- conclusionId: "14.0.3"
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een AI-systeem zonder hoog-risico. Het AI-systeem moet voldoen aan transparantieverplichtingen."
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een niet-hoog-risico AI-systeem. Het AI-systeem moet voldoen aan transparantieverplichtingen."
obligation: "
Verplichtingen voor alle AI-systemen: \n
- AI-geletterdheid (Artikel 4)\n
Expand All @@ -1582,7 +1582,7 @@ conclusions:
- source: Artikel 111 - Reeds in de handel gebrachte of in gebruik gestelde AI-systemen
url: https://eur-lex.europa.eu/legal-content/NL/TXT/HTML/?uri=OJ:L_202401689#d1e8928-1-1
- conclusionId: "14.0.4"
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een AI-systeem zonder hoog-risico."
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een niet-hoog-risico AI-systeem."
obligation: "
Verplichtingen voor alle AI-systemen: \n
- AI-geletterdheid (Artikel 4)\n
Expand Down Expand Up @@ -1774,7 +1774,7 @@ conclusions:
url: https://eur-lex.europa.eu/legal-content/NL/TXT/HTML/?uri=OJ:L_202401689#d1e8928-1-1
- source: Overweging 179 - Ingangtreding verordening
- conclusionId: "14.1.3"
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een AI-systeem voor algemene doeleinden zonder hoog-risico. Het AI-systeem moet voldoen aan transparantieverplichtingen."
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een niet-hoog-risico AI-systeem voor algemene doeleinden. Het AI-systeem moet voldoen aan transparantieverplichtingen."
obligation: "
Verplichtingen voor alle AI-systemen: \n
- AI-geletterdheid (Artikel 4)\n
Expand Down Expand Up @@ -1813,7 +1813,7 @@ conclusions:
url: https://eur-lex.europa.eu/legal-content/NL/TXT/HTML/?uri=OJ:L_202401689#d1e8928-1-1
- source: Overweging 179 - Ingangtreding verordening
- conclusionId: "14.1.4"
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een AI-systeem voor algemene doeleinden zonder hoog-risico."
conclusion: "Je bent een gebruiksverantwoordelijke en aanbieder van een niet-hoog-risico AI-systeem voor algemene doeleinden."
obligation: "
Verplichtingen voor alle AI-systemen: \n
- AI-geletterdheid (Artikel 4)\n
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/categories.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"questionId": "1.2", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.3", "category": "AI verordening van toepassing?", "subcategory": "Rol"}, {"questionId": "1.4", "category": "AI verordening van toepassing?", "subcategory": "In gebruik"}, {"questionId": "1.5", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.6", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.7", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.8", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "2", "category": "Welke risicogroep?", "subcategory": "Risicogroep"}, {"questionId": "2.4.1", "category": "Welke risicogroep?", "subcategory": "Conformiteitsbeoordeling"}, {"questionId": "2.4.2", "category": "Welke risicogroep?", "subcategory": "Conformiteitsbeoordeling"}, {"questionId": "2.8", "category": "Welke risicogroep?", "subcategory": "Systeemrisico"}, {"questionId": "2.9", "category": "Welke risicogroep?", "subcategory": "Transparantieverplichting"}, {"questionId": "2.10", "category": "Welke risicogroep?", "subcategory": "Transparantieverplichting"}, {"questionId": "2.11", "category": "Welke risicogroep?", "subcategory": "Open source"}, {"questionId": "10", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "11", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "12", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "13", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "14", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "15", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "16", "category": "Conclusie", "subcategory": "Conclusie"}]
[{"questionId": "1.2", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.3", "category": "AI verordening van toepassing?", "subcategory": "Rol"}, {"questionId": "1.4", "category": "AI verordening van toepassing?", "subcategory": "Operationeel"}, {"questionId": "1.5", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.6", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.7", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "1.8", "category": "AI verordening van toepassing?", "subcategory": "Soort toepassing"}, {"questionId": "2", "category": "Welke risicogroep?", "subcategory": "Risicogroep"}, {"questionId": "2.4.1", "category": "Welke risicogroep?", "subcategory": "Conformiteitsbeoordeling"}, {"questionId": "2.4.2", "category": "Welke risicogroep?", "subcategory": "Conformiteitsbeoordeling"}, {"questionId": "2.8", "category": "Welke risicogroep?", "subcategory": "Systeemrisico"}, {"questionId": "2.9", "category": "Welke risicogroep?", "subcategory": "Transparantieverplichting"}, {"questionId": "2.10", "category": "Welke risicogroep?", "subcategory": "Transparantieverplichting"}, {"questionId": "2.11", "category": "Welke risicogroep?", "subcategory": "Open source"}, {"questionId": "10", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "11", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "12", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "13", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "14", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "15", "category": "Conclusie", "subcategory": "Conclusie"}, {"questionId": "16", "category": "Conclusie", "subcategory": "Conclusie"}]
6 changes: 3 additions & 3 deletions frontend/src/components/BeslisboomForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const questionStore = useQuestionStore()
const { AcceptedDisclaimer, QuestionId, ConclusionId } = storeToRefs(questionStore)
const categoryStore = useCategoryStore()
const { categoryState, previousCategory } = storeToRefs(categoryStore)
const { categoryState, previousSubCategory} = storeToRefs(categoryStore)
const data_questions = ref<Questions>([])
const data_conclusions = ref<Conclusions>([])
Expand Down Expand Up @@ -129,7 +129,7 @@ function handleNextStep(object: Answer | Redirect) {
if (object.nextConclusionId) {
questionStore.setConclusionId(String(object.nextConclusionId))
}
categoryStore.updateCurrentCategory(currentCategory.value?.category)
categoryStore.updateCurrentCategory(currentCategory.value?.category, currentCategory.value?.subcategory)
}
async function givenAnswer(answer: Answer) {
Expand Down Expand Up @@ -161,7 +161,7 @@ function reset() {
}
function back() {
questionStore.revertAnswer(previousCategory.value)
questionStore.revertAnswer(previousSubCategory.value)
categoryStore.revertCurrentCategory()
}
Expand Down
77 changes: 70 additions & 7 deletions frontend/src/stores/CategoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import { defineStore } from 'pinia'

export const useCategoryStore = defineStore('category', () => {
const startCategory = 'AI verordening van toepassing?'
const startSubCategory = 'Soort toepassing'
const initialPreviousCategory = localStorage.getItem('previousCategory') ?? startCategory
const initialPreviousSubCategory = localStorage.getItem('previousSubCategory') ?? startSubCategory
const initialCurrentCategory = localStorage.getItem('currentCategory') ?? startCategory
const initialCurrentSubCategory = localStorage.getItem('currentSubCategory') ?? startSubCategory
const initialCategoryTrace = JSON.parse(localStorage.getItem('categoryTrace') ?? '[]')
const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '[]')
const initialCategoryStateString = `{
"ai_act_applicable_state": "doing",
"risk_group_state": "incomplete"
Expand All @@ -14,22 +18,53 @@ export const useCategoryStore = defineStore('category', () => {
'AI verordening van toepassing?': 'ai_act_applicable_state',
'Welke risicogroep?': 'risk_group_state'
}
const initialCategoryState = JSON.parse(localStorage.getItem('categoryState') ?? initialCategoryStateString)

const subCategoryCategoryMapper = {
'Rol': 'ai_act_applicable_state',
'Operationeel': 'ai_act_applicable_state',
'Soort toepassing': 'ai_act_applicable_state',
'Risicogroep': 'risk_group_state',
'Conformiteitsbeoordeling': 'risk_group_state',
'Systeemrisico': 'risk_group_state',
'Transparantieverplichting': 'risk_group_state'
}

const subCategoryCategoryMapperString = {
'Rol': 'AI verordening van toepassing?',
'Operationeel': 'AI verordening van toepassing?',
'Soort toepassing': 'AI verordening van toepassing?',
'Risicogroep': 'Welke risicogroep?',
'Conformiteitsbeoordeling': 'Welke risicogroep?',
'Systeemrisico': 'Welke risicogroep?',
'Transparantieverplichting': 'Welke risicogroep?'
}

const initialCategoryState = JSON.parse(localStorage.getItem('categoryState') ?? initialCategoryStateString)
// const initialSubCategoryState = JSON.parse(localStorage.getItem('subCategoryState') ?? initialSubCategoryStateString)
const previousCategory = ref(String(initialPreviousCategory))
const previousSubCategory = ref(String(initialPreviousSubCategory))
const currentCategory = ref(String(initialCurrentCategory))
const currentSubCategory = ref(String(initialCurrentSubCategory))
const categoryTrace = ref(initialCategoryTrace)
const subCategoryTrace = ref(initialSubCategoryTrace)
const categoryState = ref(initialCategoryState)
// const subCategoryState = ref(initialSubCategoryState)


function updateCurrentCategory(category: string | undefined) {
if(category) {
function updateCurrentCategory(category: string | undefined, subcategory: string |undefined) {
if(category && subcategory) {
previousCategory.value = currentCategory.value
previousSubCategory.value = currentSubCategory.value
currentCategory.value = category
currentSubCategory.value = subcategory
categoryTrace.value.push(category)
subCategoryTrace.value.push(subcategory)
localStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value))
localStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value))
localStorage.setItem('previousCategory', previousCategory.value)
localStorage.setItem('previousSubCategory', previousSubCategory.value)
localStorage.setItem('currentCategory', currentCategory.value)
localStorage.setItem('currentSubCategory', currentSubCategory.value)
updateCategoryState()
}
}
Expand All @@ -51,9 +86,9 @@ export const useCategoryStore = defineStore('category', () => {
/**
* Update the CategoryState by looking at the currentCategory only
*/
if (previousCategory.value != currentCategory.value) {
const currentCategoryKey = categoryMapper[currentCategory.value as keyof typeof categoryMapper]
const previousCategoryKey = categoryMapper[previousCategory.value as keyof typeof categoryMapper]
const currentCategoryKey = categoryMapper[currentCategory.value as keyof typeof categoryMapper]
const previousCategoryKey = categoryMapper[previousCategory.value as keyof typeof categoryMapper]
if (previousCategoryKey != currentCategoryKey) {
categoryState.value[currentCategoryKey] = "incomplete"
categoryState.value[previousCategoryKey] = "doing"
localStorage.setItem('categoryState', JSON.stringify(categoryState.value))
Expand All @@ -63,34 +98,62 @@ export const useCategoryStore = defineStore('category', () => {
function revertCurrentCategory() {
/**
* Set the currentCategory back to incomplete when the previousCategory is different
* TODO: subcategory?
*/
// Categories section
revertCategoryState()
if(categoryTrace.value.length - 2 > 0){
currentCategory.value = categoryTrace.value[categoryTrace.value.length - 2]
}else{
currentCategory.value = startCategory
}
categoryTrace.value.pop()

if(categoryTrace.value.length - 2 > 0) {
previousCategory.value = categoryTrace.value[categoryTrace.value.length - 2]
} else {
previousCategory.value = startCategory
}
// Subcategories section
if(subCategoryTrace.value.length - 2 > 0){
currentSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2]
}else{
currentSubCategory.value = startSubCategory
}
subCategoryTrace.value.pop()

if(subCategoryTrace.value.length - 2 > 0) {
previousSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2]
} else {
previousSubCategory.value = startSubCategory
}

localStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value))
localStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value))
localStorage.setItem('previousCategory', previousCategory.value)
localStorage.setItem('previousSubCategory', previousSubCategory.value)
localStorage.setItem('currentCategory', currentCategory.value)
localStorage.setItem('currentSubCategory', currentSubCategory.value)
}

function reset() {
currentCategory.value = startCategory
currentSubCategory.value = startSubCategory
previousCategory.value = startCategory
previousSubCategory.value = startSubCategory
categoryState.value = JSON.parse(initialCategoryStateString)
// subCategoryState.value = JSON.parse(initialSubCategoryStateString)
categoryTrace.value = []
subCategoryTrace.value = []
localStorage.removeItem('currentCategory')
localStorage.removeItem('currentSubCategory')
localStorage.removeItem('previousCategory')
localStorage.removeItem('previousSubCategory')
localStorage.removeItem('categoryState')
localStorage.removeItem('subCategoryState')
localStorage.removeItem('categoryTrace')
localStorage.removeItem('subCategoryTrace')
}

return { categoryState, previousCategory, revertCurrentCategory, updateCurrentCategory, reset }
return { categoryState, previousSubCategory, revertCurrentCategory, updateCurrentCategory, reset }
})
8 changes: 4 additions & 4 deletions frontend/src/stores/QuestionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ export const useQuestionStore = defineStore('question', () => {
localStorage.setItem('answers', JSON.stringify(answers.value))
}

function revertAnswer(previousCategory: string) {
function revertAnswer(previousSubCategory: string) {
QuestionId.value = answers.value[answers.value.length - 1]
answers.value.pop()
if (labels.value[QuestionId.value]) {
const label: string = labels.value[QuestionId.value]
LabelsBySubCategory.value[previousCategory].pop(label)
if (LabelsBySubCategory.value[previousCategory].length === 0) {
LabelsBySubCategory.value[previousCategory].push('nader te bepalen')
LabelsBySubCategory.value[previousSubCategory].pop(label)
if (LabelsBySubCategory.value[previousSubCategory].length === 0) {
LabelsBySubCategory.value[previousSubCategory].push('nader te bepalen')
}
delete labels.value[QuestionId.value]
}
Expand Down
Loading

0 comments on commit 777c38a

Please sign in to comment.