Skip to content

Commit

Permalink
feat(junior): display identified learner on every relevant pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rouxxi authored and aurelie-crouillebois committed Jan 16, 2025
1 parent be52f04 commit 177a8b6
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/security/authenticate_external_IDP.puml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ participant DB
end box

== Connexion au GAR ==
utilisateur -> navigateur: saisit identifiant et mot de passe \net clique sur "Login"
utilisateur -> navigateur: saisit identifiant et mot de passe \net clique sur "IdentifiedLearner"
navigateur -> GAR : POST /auth/login \nQP: email=<EMAIL>&password=<PASSWORD>
GAR -> navigateur: 302_FOUND Header Set-Cookie: oneSessionId="090967(..)khpt0TA="
navigateur -> GAR : GET / \n Header Cookie: oneSessionId="090967(..)khpt0TA="
Expand Down
46 changes: 25 additions & 21 deletions junior/app/components/challenge/challenge.gjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { action } from '@ember/object';
import { service } from '@ember/service';
import {action} from '@ember/object';
import {service} from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';
import { pageTitle } from 'ember-page-title';
import {tracked} from '@glimmer/tracking';
import {t} from 'ember-intl';
import {pageTitle} from 'ember-page-title';
import ENV from 'junior/config/environment';

import Bubble from '../bubble';
import DelayedElement from '../delayed-element';
import RobotDialog from '../robot-dialog';
import ChallengeContent from './challenge-content';
import ChallengeLayout from './challenge-layout';
import IdentifiedLearner from '../identified-learner';
const CHALLENGE_DISPLAY_DELAY = ENV.APP.CHALLENGE_DISPLAY_DELAY;

export default class Challenge extends Component {
Expand Down Expand Up @@ -141,22 +142,25 @@ export default class Challenge extends Component {
<template>
{{pageTitle (t "pages.challenge.title")}}
<ChallengeLayout>
<RobotDialog @class={{this.robotMood}}>
{{#each @challenge.instructions as |instruction index|}}
<DelayedElement @shouldDisplayIn={{this.bubbleDisplayDelay index}}>
<Bubble @message={{instruction}} @oralization={{@oralization}} />
</DelayedElement>
{{/each}}

{{#if this.robotFeedback.message}}
<Bubble
@message={{this.robotFeedback.message}}
@status={{this.robotFeedback.status}}
@oralization={{@oralization}}
aria-live="polite"
/>
{{/if}}
</RobotDialog>
<div class="header_container">
<RobotDialog @class={{this.robotMood}}>
{{#each @challenge.instructions as |instruction index|}}
<DelayedElement @shouldDisplayIn={{this.bubbleDisplayDelay index}}>
<Bubble @message={{instruction}} @oralization={{@oralization}} />
</DelayedElement>
{{/each}}

{{#if this.robotFeedback.message}}
<Bubble
@message={{this.robotFeedback.message}}
@status={{this.robotFeedback.status}}
@oralization={{@oralization}}
aria-live="polite"
/>
{{/if}}
</RobotDialog>
<IdentifiedLearner />
</div>
<DelayedElement @shouldDisplayIn={{this.challengeItemDisplayDelay}}>
<ChallengeContent
@setAnswerValue={{this.setAnswerValue}}
Expand Down
32 changes: 32 additions & 0 deletions junior/app/components/identified-learner.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import PixButton from '@1024pix/pix-ui/components/pix-button';
import PixIcon from '@1024pix/pix-ui/components/pix-icon';
import {action} from '@ember/object';
import {service} from '@ember/service';
import Component from '@glimmer/component';
import {t} from 'ember-intl';

export default class IdentifiedLearner extends Component {
@service router;
@service currentLearner;

get currentUserDisplayName() {
return this.currentLearner.learner.displayName;
}

@action
disconnect() {
this.router.transitionTo(this.currentLearner.learner.schoolUrl);
}

<template>
<div class="identified-learner">
<div class="identified-learner__informations">
<p>{{this.currentUserDisplayName}}</p>
<PixButton @variant="tertiary" @iconBefore="logout" @triggerAction={{this.disconnect}}>
{{t "components.login.logout-button"}}
</PixButton>
</div>
<PixIcon class="identified-learner__icon" @name="userCircle" />
</div>
</template>
}
1 change: 1 addition & 0 deletions junior/app/controllers/school/students.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class Students extends Controller {
identifyUser(learner) {
this.currentLearner.setLearner({
id: learner.id,
displayName: learner.displayName,
schoolUrl: this.model.schoolUrl,
});
styleToolkit.backgroundBlob.reset();
Expand Down
2 changes: 2 additions & 0 deletions junior/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@import 'globals/fonts';

// Components
@import 'components/challenge/challenge';
@import 'components/challenge/challenge-actions';
@import 'components/challenge/challenge-embed-simulator';
@import 'components/challenge/challenge-content';
Expand All @@ -23,6 +24,7 @@
@import 'components/bubble';
@import 'components/footer';
@import 'components/issue';
@import 'components/identified-learner';
@import 'components/oralization-button';
@import 'components/robot-dialog';

Expand Down
11 changes: 11 additions & 0 deletions junior/app/styles/components/challenge/challenge.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.header_container {
display: flex;
justify-content: space-between;
align-items: flex-start;

.identified-learner {
// Negative margin to set identified user outside the container on the far right
// Equals half of the total margin outside the challenge content + offset
margin-right: calc(((100% - 100vw) / 2) + 45px);
}
}
30 changes: 30 additions & 0 deletions junior/app/styles/components/identified-learner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.identified-learner {
align-items: center;
display: flex;
gap: var(--pix-spacing-3x);
font-weight: var(--font-medium);

&__informations {
display: flex;
flex-direction: column;
align-items: end;

button {
padding: 0;
}

p {
font-weight: var(--pix-font-bold);
white-space: nowrap;
}
}

&__icon {
background-color: var(--pix-primary-300);
border-radius: 50%;
fill: var(--pix-neutral-0);
padding: var(--pix-spacing-1x);
height: 40px;
width: 40px;
}
}
6 changes: 6 additions & 0 deletions junior/app/styles/pages/identified/missions/introduction.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
flex-direction: column;
align-content: center;

.header_container {
display: flex;
justify-content: space-between;
align-items: flex-start;
}

.button-actions__icon {
width: 20px;
height: 20px;
Expand Down
6 changes: 6 additions & 0 deletions junior/app/styles/pages/identified/missions/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@
}
}
}

.header_container {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
6 changes: 6 additions & 0 deletions junior/app/styles/pages/identified/missions/mission.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.mission-page {
margin-top: 20px;

.header_container {
display: flex;
justify-content: space-between;
align-items: flex-start;
}

&__body {
display: flex;
margin-top: 16px;
Expand Down
9 changes: 6 additions & 3 deletions junior/app/templates/assessment/results.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{page-title (t "pages.missions.end-page.title")}}
<div class="mission-page">
<RobotDialog @class={{this.robotMood}}>
<Bubble @message={{t this.resultMessage}} @status="success" />
</RobotDialog>
<div class="header_container">
<RobotDialog @class={{this.robotMood}}>
<Bubble @message={{t this.resultMessage}} @status="success" />
</RobotDialog>
<IdentifiedLearner />
</div>
<div class="mission-page__body">
<MissionCard::CompletedMissionCard
@missionLabelStatus={{t "pages.missions.list.status.completed.label"}}
Expand Down
24 changes: 13 additions & 11 deletions junior/app/templates/identified/missions/list.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{{page-title (t "pages.missions.list.title")}}
<div>
<RobotDialog>
<Bubble @message={{t "pages.missions.list.instruction" prenom=this.model.organizationLearner.firstName}} />
<Bubble
@message={{t
"pages.missions.list.back-to-students"
prenom=this.model.organizationLearner.firstName
backUrl=this.schoolUrl
}}
/>
</RobotDialog>

<div class="header_container">
<RobotDialog>
<Bubble @message={{t "pages.missions.list.instruction" prenom=this.model.organizationLearner.firstName}} />
<Bubble
@message={{t
"pages.missions.list.back-to-students"
prenom=this.model.organizationLearner.firstName
backUrl=this.schoolUrl
}}
/>
</RobotDialog>
<IdentifiedLearner />
</div>
<div class="cards">
{{#each this.orderedMissionList as |mission|}}
<PixButton @triggerAction={{fn this.goToMission mission.id}} class="card">
Expand Down
9 changes: 6 additions & 3 deletions junior/app/templates/identified/missions/mission/index.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{page-title (t "pages.missions.start-page.title")}}
<div class="mission-page">
<RobotDialog>
<Bubble @message={{t "pages.missions.start-page.welcome"}} />
</RobotDialog>
<div class="header_container">
<RobotDialog>
<Bubble @message={{t "pages.missions.start-page.welcome"}} />
</RobotDialog>
<IdentifiedLearner />
</div>
<div class="mission-page__body">

<MissionCard::MissionCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

<Challenge::ChallengeLayout>
<div class="mission-introduction">
<RobotDialog>
<Bubble
@message={{t "pages.missions.introduction-page.welcome"}}
@oralization={{@model.learnerHasOralizationFeature}}
/>
</RobotDialog>
<div class="header_container">
<RobotDialog>
<Bubble
@message={{t "pages.missions.introduction-page.welcome"}}
@oralization={{@model.learnerHasOralizationFeature}}
/>
</RobotDialog>
<IdentifiedLearner />
</div>
<div class="mission-introduction__container">
<div class="mission-introduction__media">
<Challenge::Content::ChallengeMedia
Expand Down
3 changes: 3 additions & 0 deletions junior/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"label": "Lire la consigne à haute voix",
"play": "J'écoute",
"stop": "Stop"
},
"login": {
"logout-button": "Se déconnecter"
}
},
"navigation": {
Expand Down

0 comments on commit 177a8b6

Please sign in to comment.