This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#457] [FEATURE] Ajout du score et du niveau par compétences sur le p…
…rofil utilisateur côté API (US-574). (#457) * [US-574] [FEATURE] Creating a default account with pix@contact.com / MyPix123# * [US-574] [FIX] Fixing a test that was not compiling * [US-574] [TECH] Assessement-controller tests improvements * [US-574] [TECH] Moving the token creation method in a specific service * [US-574] [TECH] Extracting methods to the token service * [US-574] [TECH] Authorization header must 'Bearer' not 'bearer' * [US-574] [FEATURE] An assessment is now linked to a user if connected * [US-574] [TECH] Moving assessment-controller_test.js from controller folder to assessment folder * [US-574] [FEATURE] Updating assessment table with two new columns: estimatedLevel and pixScore * [US-574] [TECH] Fixing linting issues * [US-574] [TECH] Refactoring the way we set pixScore and estimatedLevel in Assessment * [US-574] [FEATURE] Saving assessment with level and score * [US-574] [FEATURE] Retrieving linked Competences with a course from Airtable * WIP * [US-574] [FEATURE] Add getByUserId in Assessment repository and add competences to course object in serializer * [US-574] [FEATURE] Assigning level and score for each competence * [US-574] [FEATURE] Exposing level and score by competence on /api/users * [US-574] [CLEANUP] Auto code review * [#574] [TECH] change field pixScore to pix-score in endpoint get /users * [#574] [CLEANUP] Use sinon.sandbox if too many stubs in test files
- Loading branch information
Brandone MARTINS
committed
Jul 7, 2017
1 parent
ac672d3
commit 0756037
Showing
36 changed files
with
1,099 additions
and
424 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
api/db/migrations/20170703105035_create_link_between_user_and_assessment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const TABLE_NAME = 'assessments'; | ||
|
||
exports.up = function(knex, Promise) { | ||
return Promise.all([ | ||
knex.schema.table(TABLE_NAME, function (table) { | ||
table.bigInteger('userId').index().references('users.id'); | ||
table.dropColumn('userName'); | ||
table.dropColumn('userEmail'); | ||
}) | ||
]); | ||
}; | ||
|
||
exports.down = function(knex, Promise) { | ||
return Promise.all([ | ||
knex.schema.table(TABLE_NAME, function (table) { | ||
table.dropColumn('userId'); | ||
table.string('userName').notNull(); | ||
table.string('userEmail').notNull(); | ||
}) | ||
]); | ||
}; |
19 changes: 19 additions & 0 deletions
19
api/db/migrations/20170703163243_update_assessment_with_level_and_score.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const TABLE_NAME = 'assessments'; | ||
|
||
exports.up = function(knex, Promise) { | ||
return Promise.all([ | ||
knex.schema.table(TABLE_NAME, function (table) { | ||
table.integer('estimatedLevel'); | ||
table.integer('pixScore'); | ||
}) | ||
]); | ||
}; | ||
|
||
exports.down = function(knex, Promise) { | ||
return Promise.all([ | ||
knex.schema.table(TABLE_NAME, function (table) { | ||
table.dropColumn('estimatedLevel'); | ||
table.dropColumn('pixScore'); | ||
}) | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
const _ = require('lodash'); | ||
|
||
class Profile { | ||
constructor(user, competences, areas) { | ||
constructor(user, competences, areas, assessments, courses) { | ||
this.user = user; | ||
this.competences = competences; | ||
this.areas = areas; | ||
this.setLevelToCompetences(); | ||
this.initCompetenceLevel(); | ||
this.setLevelToCompetences(assessments, courses); | ||
} | ||
|
||
setLevelToCompetences() { | ||
if(this.competences) { | ||
initCompetenceLevel() { | ||
if (this.competences) { | ||
this.competences.forEach((competence) => competence['level'] = -1); | ||
} | ||
} | ||
|
||
setLevelToCompetences(assessments, courses) { | ||
assessments.forEach((assessment) => { | ||
const courseId = assessment.get('courseId'); | ||
|
||
const course = _.find(courses, function(course) { | ||
return course.id === courseId; | ||
}); | ||
|
||
course.competences.forEach((competenceId) => { | ||
const linkedCompetence = _.find(this.competences, function(competence) { | ||
return competence.id === competenceId; | ||
}); | ||
|
||
linkedCompetence.level = assessment.get('estimatedLevel'); | ||
linkedCompetence.pixScore = assessment.get('pixScore'); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Profile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.