@@ -57,43 +57,28 @@ const matchingEngineManager = {
5757 return engine . metadata || { } ;
5858 } ,
5959
60- async fetchValidationReport ( userId , language = "en" ) {
60+ // fetchValidationReport and fetchQuizReport could probably be unified further to only expose fetchMatchingReport() TODO
61+ async fetchMatchingReport ( userId , rps , lang = "en" ) {
6162 if ( ! this . matchingEngineInstance ) {
62- await this . initMatchingEngine ( language ) ;
63+ await this . initMatchingEngine ( lang ) ;
6364 }
64-
65- const validationConfig = await resourceService . fetchResourceWithCache (
66- "assets/data/requirement-profiles/requirement-profiles.json"
67- ) ;
68-
6965 const userProfile = userManager . retrieveUserData ( userId ) ;
7066 const userProfileTurtle = await convertUserProfileToTurtle ( userProfile ) ;
67+ return this . matchingEngineInstance . matching ( userProfileTurtle , rps , FORMAT . JSON_LD ) ;
68+ } ,
69+
70+ async fetchValidationReport ( userId , language = "en" ) {
71+ const validationConfig = await resourceService . fetchResourceWithCache ( "assets/data/requirement-profiles/requirement-profiles.json" ) ;
7172 const requirementProfiles = [ ] ;
7273 for ( const { rpUri, behindFeatureFlag } of validationConfig [ "queries" ] ) {
7374 if ( behindFeatureFlag && ! featureFlags [ behindFeatureFlag ] ) continue ;
7475 requirementProfiles . push ( rpUri ) ;
7576 }
76-
77- const report = await this . matchingEngineInstance . matching (
78- userProfileTurtle ,
79- requirementProfiles ,
80- FORMAT . JSON_LD
81- ) ;
82-
83- return report ;
77+ return await this . fetchMatchingReport ( userId , requirementProfiles , language ) ;
8478 } ,
8579
8680 async fetchQuizReport ( userId , requirementProfiles , language = "en" ) {
87- if ( ! this . matchingEngineInstance ) {
88- await this . initMatchingEngine ( language ) ;
89- }
90- const userProfile = userManager . retrieveUserData ( userId ) ;
91- const userProfileTurtle = await convertUserProfileToTurtle ( userProfile ) ;
92- return this . matchingEngineInstance . matching (
93- userProfileTurtle ,
94- requirementProfiles . map ( rp => expand ( rp ) ) ,
95- FORMAT . JSON_LD
96- ) ;
81+ return await this . fetchMatchingReport ( userId , requirementProfiles . map ( rp => expand ( rp ) ) , language ) ;
9782 } ,
9883
9984 async fetchEvaluationGraph ( userId , requirementProfile , language = "en" ) {
0 commit comments