From c93df902d3858759203834b7fe7c8ab80d6cfb21 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 15:06:33 +0200 Subject: [PATCH 001/207] aff dossier godbox --- heroku_deploy/api/libs/python/bib.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/libs/python/bib.py b/heroku_deploy/api/libs/python/bib.py index 111e166..4107ac5 100644 --- a/heroku_deploy/api/libs/python/bib.py +++ b/heroku_deploy/api/libs/python/bib.py @@ -145,12 +145,12 @@ def getNumberImage(self): PATH = "pictures/" print(os.getcwd()) - cpt = 0 - for image in os.listdir(PATH): - if image.endswith(".png"): - cpt += 1 + # cpt = 0 + # for image in os.listdir(PATH): + # if image.endswith(".png"): + # cpt += 1 - self.numberImage = cpt - self.nbMatriceResult + # self.numberImage = cpt - self.nbMatriceResult def extractImage(self): From 3495c9fec3922a1f9fedf7e9aee832d138da01e4 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 15:13:45 +0200 Subject: [PATCH 002/207] first commit --- heroku_deploy/api/libs/python/bib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/libs/python/bib.py b/heroku_deploy/api/libs/python/bib.py index 4107ac5..ef367e6 100644 --- a/heroku_deploy/api/libs/python/bib.py +++ b/heroku_deploy/api/libs/python/bib.py @@ -144,7 +144,7 @@ def initSizeImages(self): def getNumberImage(self): PATH = "pictures/" - print(os.getcwd()) + print(os.listdir("/box")) # cpt = 0 # for image in os.listdir(PATH): # if image.endswith(".png"): From 6d8d867c9c1e9154d3e5f42b0f2fd99e8ed1e99e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:09:42 +0200 Subject: [PATCH 003/207] img godbox --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 1522906..8c6b411 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -63,8 +63,14 @@ export class GodBoxRepository { } zip.addFile(`main${language.extension}`, Buffer.from(code)); + if(true){ + throw new InternalServerErrorException("COUCOU"); + } + const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something + + imageBuffers.map((image, index) => { zip.addFile( `pictures/${image.filename || `picture-${index}`}`, From a6831a8ec43c4fc6b412df8a9d28698c85adc254 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:15:06 +0200 Subject: [PATCH 004/207] img godbox --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 8c6b411..d49be13 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -63,15 +63,17 @@ export class GodBoxRepository { } zip.addFile(`main${language.extension}`, Buffer.from(code)); - if(true){ - throw new InternalServerErrorException("COUCOU"); - } + const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something + if(true){ + throw new InternalServerErrorException(imageBuffers); + } imageBuffers.map((image, index) => { + zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, From 2d374a932d4df217d19db8c5d5ccdb08d658cb13 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:19:12 +0200 Subject: [PATCH 005/207] img godbox --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index d49be13..ee1262d 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -68,12 +68,12 @@ export class GodBoxRepository { const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something - if(true){ - throw new InternalServerErrorException(imageBuffers); - } - imageBuffers.map((image, index) => { + imageBuffers.map((image, index) => { + if(true){ + throw new InternalServerErrorException(image.filename); + } zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, From 0ab1df4c0b998ba2c3a5462dd933ced24b6b408e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:34:21 +0200 Subject: [PATCH 006/207] img godbox --- heroku_deploy/api/libs/python/bib.py | 10 +++---- .../api/src/exec-server/godbox.repository.ts | 27 +++---------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/heroku_deploy/api/libs/python/bib.py b/heroku_deploy/api/libs/python/bib.py index ef367e6..31cf711 100644 --- a/heroku_deploy/api/libs/python/bib.py +++ b/heroku_deploy/api/libs/python/bib.py @@ -145,12 +145,12 @@ def getNumberImage(self): PATH = "pictures/" print(os.listdir("/box")) - # cpt = 0 - # for image in os.listdir(PATH): - # if image.endswith(".png"): - # cpt += 1 + cpt = 0 + for image in os.listdir(PATH): + if image.endswith(".png"): + cpt += 1 - # self.numberImage = cpt - self.nbMatriceResult + self.numberImage = cpt - self.nbMatriceResult def extractImage(self): diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index ee1262d..e66819b 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -61,19 +61,11 @@ export class GodBoxRepository { if (language.name === 'cpp') { zip.addLocalFile('/usr/src/app/conf/CMakeLists.txt'); } - zip.addFile(`main${language.extension}`, Buffer.from(code)); - - + zip.addFile(language.mainFileName, Buffer.from(code)); const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something - - - imageBuffers.map((image, index) => { - if(true){ - throw new InternalServerErrorException(image.filename); - } zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, @@ -83,24 +75,13 @@ export class GodBoxRepository { return zip.toBuffer().toString('base64'); } - formatPhasesResults(phases: GodboxPhaseOutputDTO[]): GodboxPhaseOutputDTO { - const res = phases[phases.length - 1]; - return { - ...res, - status: res.name === 'Execution' ? res.status : -1, - }; - } - async execute( code: string, bootstrap: ExecBootstrap, ): Promise { const language = await this.languagesService.findByName(bootstrap.language); - const completeCode = bootstrap.tests.includes('// USER_CODE') - ? bootstrap.tests.replace('// USER_CODE', code) - : `${bootstrap.tests}\n${code}`; - + const completeCode = `${bootstrap.tests}\n${code}`; const payload = { phases: language.phases, files: await this.bundleExec(completeCode, language, bootstrap), @@ -109,11 +90,11 @@ export class GodBoxRepository { try { const { data }: { data: { phases: GodboxPhaseOutputDTO[] } } = await axios.post(`${godboxConfig.baseUrl}/run`, payload); - return this.formatPhasesResults(data.phases); + return data.phases[data.phases.length - 1]; } catch (err) { throw new InternalServerErrorException( err?.response?.data?.message || err?.message || 'Unkown reason.', ); } } -} +} \ No newline at end of file From 8283dfeb44a9a84b92fda4f7c116b4b969aeaf25 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:40:29 +0200 Subject: [PATCH 007/207] img godbox --- .../api/src/exec-server/godbox.repository.ts | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index e66819b..d840e43 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -17,31 +17,24 @@ export class GodBoxRepository { private readonly challengeService: ChallengesService, ) {} - async fetchImagesBuffers( - bootstrap: ExecBootstrap, - ): Promise<{ filename: string; buffer: Buffer }[]> { + async fetchImagesBuffers(bootstrap: ExecBootstrap): Promise { const pictures = ( await this.challengeService.findOne({ id: bootstrap.challenge }, true) ).pictures; - return await Promise.all( - pictures.map((pic) => { - const fetchPicture = async () => { - return { - buffer: ( - await axios.request({ - responseType: 'arraybuffer', - url: pic.file, - method: 'get', - }) - ).data, - filename: pic.execFileName, - }; - }; - return fetchPicture(); - }), - ); + return ( + await Promise.all( + pictures.map((pic) => + axios.request({ + responseType: 'arraybuffer', + url: pic.file, + method: 'get', + }), + ), + ) + ).map((result) => result.data); } + async extractZipFileBase64(archivePath: string): Promise { return (await fs.readFile(archivePath)).toString('base64'); } @@ -61,11 +54,19 @@ export class GodBoxRepository { if (language.name === 'cpp') { zip.addLocalFile('/usr/src/app/conf/CMakeLists.txt'); } - zip.addFile(language.mainFileName, Buffer.from(code)); + zip.addFile(`main${language.extension}`, Buffer.from(code)); + + const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something + + + imageBuffers.map((image, index) => { + if(true){ + throw new InternalServerErrorException("SUCESS !!!"); + } zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, @@ -75,13 +76,24 @@ export class GodBoxRepository { return zip.toBuffer().toString('base64'); } + formatPhasesResults(phases: GodboxPhaseOutputDTO[]): GodboxPhaseOutputDTO { + const res = phases[phases.length - 1]; + return { + ...res, + status: res.name === 'Execution' ? res.status : -1, + }; + } + async execute( code: string, bootstrap: ExecBootstrap, ): Promise { const language = await this.languagesService.findByName(bootstrap.language); - const completeCode = `${bootstrap.tests}\n${code}`; + const completeCode = bootstrap.tests.includes('// USER_CODE') + ? bootstrap.tests.replace('// USER_CODE', code) + : `${bootstrap.tests}\n${code}`; + const payload = { phases: language.phases, files: await this.bundleExec(completeCode, language, bootstrap), @@ -90,11 +102,11 @@ export class GodBoxRepository { try { const { data }: { data: { phases: GodboxPhaseOutputDTO[] } } = await axios.post(`${godboxConfig.baseUrl}/run`, payload); - return data.phases[data.phases.length - 1]; + return this.formatPhasesResults(data.phases); } catch (err) { throw new InternalServerErrorException( err?.response?.data?.message || err?.message || 'Unkown reason.', ); } } -} \ No newline at end of file +} From 3c285fc89a5ea397abee885ecc3d6bbebf4f89b3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:44:11 +0200 Subject: [PATCH 008/207] img godbox --- .../api/src/exec-server/godbox.repository.ts | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index d840e43..69f41bc 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -17,23 +17,35 @@ export class GodBoxRepository { private readonly challengeService: ChallengesService, ) {} - async fetchImagesBuffers(bootstrap: ExecBootstrap): Promise { + async fetchImagesBuffers( + bootstrap: ExecBootstrap, + ): Promise<{ filename: string; buffer: Buffer }[]> { const pictures = ( await this.challengeService.findOne({ id: bootstrap.challenge }, true) ).pictures; - return ( - await Promise.all( - pictures.map((pic) => - axios.request({ - responseType: 'arraybuffer', - url: pic.file, - method: 'get', - }), - ), - ) - ).map((result) => result.data); - } + if(true){ + throw new InternalServerErrorException(pictures); + } + + return await Promise.all( + pictures.map((pic) => { + const fetchPicture = async () => { + return { + buffer: ( + await axios.request({ + responseType: 'arraybuffer', + url: pic.file, + method: 'get', + }) + ).data, + filename: pic.execFileName, + }; + }; + return fetchPicture(); + }), + ); + } async extractZipFileBase64(archivePath: string): Promise { return (await fs.readFile(archivePath)).toString('base64'); @@ -64,9 +76,7 @@ export class GodBoxRepository { imageBuffers.map((image, index) => { - if(true){ - throw new InternalServerErrorException("SUCESS !!!"); - } + zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, From e792f0cc196d6b4aae1dc945f5aef32b28eb3924 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:47:34 +0200 Subject: [PATCH 009/207] img godbox --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 69f41bc..3ae52a9 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -25,7 +25,9 @@ export class GodBoxRepository { ).pictures; if(true){ - throw new InternalServerErrorException(pictures); + throw new InternalServerErrorException(( + await this.challengeService.findOne({ id: bootstrap.challenge }, true) + )); } return await Promise.all( From 16d35c3e9c700e987f45a7c36ccea1d4ee0cbb95 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:55:26 +0200 Subject: [PATCH 010/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index bbb6c6c..c8b4b25 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -81,6 +81,11 @@ export class ChallengesService { throw new NotFoundException('Speicified challenge does not exists'); } + if(true){ + throw new NotFoundException(challenge); + } + + const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ id: challenge._id.toString(), From 9ae491f42cb73b2a657ba7e9adfa310ac218769a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:58:55 +0200 Subject: [PATCH 011/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index c8b4b25..a95af9e 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -77,7 +77,9 @@ export class ChallengesService { await this.challengeModel.findById(findByIdDTO.id).exec() )?.toObject(); - if (!challenge) { + if (challenge) { + throw new NotFoundException(challenge); + throw new NotFoundException('Speicified challenge does not exists'); } From 0a28e0618fec2909a2f0f7f793f3c6e7f5e2981c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 19:59:40 +0200 Subject: [PATCH 012/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index a95af9e..61ab6a8 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -83,11 +83,6 @@ export class ChallengesService { throw new NotFoundException('Speicified challenge does not exists'); } - if(true){ - throw new NotFoundException(challenge); - } - - const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ id: challenge._id.toString(), From 249408ff21b1a4cb7b70c77ca4b96077311f01ba Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:05:15 +0200 Subject: [PATCH 013/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 5 +++-- heroku_deploy/api/src/exec-server/godbox.repository.ts | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index 61ab6a8..4cf200f 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -73,13 +73,14 @@ export class ChallengesService { findByIdDTO: FindByIdDTO, fromInternalSource = false, ): Promise { + + throw new NotFoundException(findByIdDTO.id); + const challenge = await ( await this.challengeModel.findById(findByIdDTO.id).exec() )?.toObject(); if (challenge) { - throw new NotFoundException(challenge); - throw new NotFoundException('Speicified challenge does not exists'); } diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 3ae52a9..8711d6e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -24,11 +24,6 @@ export class GodBoxRepository { await this.challengeService.findOne({ id: bootstrap.challenge }, true) ).pictures; - if(true){ - throw new InternalServerErrorException(( - await this.challengeService.findOne({ id: bootstrap.challenge }, true) - )); - } return await Promise.all( pictures.map((pic) => { From 48c0e397932d3393751f7a18a1c2b4d35c48310c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:10:11 +0200 Subject: [PATCH 014/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index 4cf200f..c8000fe 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -74,7 +74,7 @@ export class ChallengesService { fromInternalSource = false, ): Promise { - throw new NotFoundException(findByIdDTO.id); + // throw new NotFoundException(findByIdDTO.id); const challenge = await ( await this.challengeModel.findById(findByIdDTO.id).exec() From 4184b16f0a4cbc128eb7e72fd638275d422946c5 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:19:14 +0200 Subject: [PATCH 015/207] img godbox --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 8711d6e..cccd928 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -23,8 +23,6 @@ export class GodBoxRepository { const pictures = ( await this.challengeService.findOne({ id: bootstrap.challenge }, true) ).pictures; - - return await Promise.all( pictures.map((pic) => { const fetchPicture = async () => { @@ -65,15 +63,9 @@ export class GodBoxRepository { } zip.addFile(`main${language.extension}`, Buffer.from(code)); - - const imageBuffers = await this.fetchImagesBuffers(bootstrap); // later add some format extension or something - - - imageBuffers.map((image, index) => { - zip.addFile( `pictures/${image.filename || `picture-${index}`}`, image.buffer, @@ -116,4 +108,4 @@ export class GodBoxRepository { ); } } -} +} \ No newline at end of file From 88641a4c44c2d7f5ce5644ad498a23731ccfe215 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:23:29 +0200 Subject: [PATCH 016/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 5 +---- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index c8000fe..bbb6c6c 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -73,14 +73,11 @@ export class ChallengesService { findByIdDTO: FindByIdDTO, fromInternalSource = false, ): Promise { - - // throw new NotFoundException(findByIdDTO.id); - const challenge = await ( await this.challengeModel.findById(findByIdDTO.id).exec() )?.toObject(); - if (challenge) { + if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index cccd928..1522906 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -108,4 +108,4 @@ export class GodBoxRepository { ); } } -} \ No newline at end of file +} From c4fa6c7b96ffc733d153a017a45f73904e01b6d0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:27:52 +0200 Subject: [PATCH 017/207] img godbox --- heroku_deploy/api/src/challenges/challenges.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index bbb6c6c..328045b 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -80,6 +80,7 @@ export class ChallengesService { if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } + throw new NotFoundException(challenge); const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ From e893c3bdb232ac59680530e1996bf93cc26ed8d2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:36:32 +0200 Subject: [PATCH 018/207] logs node --- heroku_deploy/api/src/challenges/challenges.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index 328045b..5a865ae 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -76,11 +76,11 @@ export class ChallengesService { const challenge = await ( await this.challengeModel.findById(findByIdDTO.id).exec() )?.toObject(); + console.log("COUCOU"); if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } - throw new NotFoundException(challenge); const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ From a8cfaab41eaf99b395360af3ac34ee61a0334a1a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 20:40:14 +0200 Subject: [PATCH 019/207] logs node --- heroku_deploy/api/src/challenges/challenges.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index 5a865ae..b3aa464 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -76,11 +76,11 @@ export class ChallengesService { const challenge = await ( await this.challengeModel.findById(findByIdDTO.id).exec() )?.toObject(); - console.log("COUCOU"); if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } + console.log(challenge); const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ From db12e8a8c5f0fc07b9fef95e246a555fa579f41f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:18:07 +0200 Subject: [PATCH 020/207] logs node --- heroku_deploy/api/src/challenges/challenges.service.ts | 1 - heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index b3aa464..bbb6c6c 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -80,7 +80,6 @@ export class ChallengesService { if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } - console.log(challenge); const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 47402d1..63be11d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -43,8 +43,10 @@ export class PicturesService { ): Promise { const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { + const pictureObject = picture.toObject(); const file = fromInternal + ? this.objectStorageService.generateInternalServerAddress( pictureObject.url, ) @@ -52,6 +54,8 @@ export class PicturesService { pictureObject.url, ); + console.log(pictureObject.url) + return { _id: pictureObject._id, file: file, From 90c4890d4b6a817abe71b912f5f7db2930f804b7 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:25:40 +0200 Subject: [PATCH 021/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 63be11d..386a89e 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,6 +41,8 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { + console.log("COUCOU1") + const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { From e4f9887b5580a09d5643334f79350deb4649c2a0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:37:42 +0200 Subject: [PATCH 022/207] logs node --- heroku_deploy/api/src/object-storage/object-storage.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/object-storage/object-storage.service.ts b/heroku_deploy/api/src/object-storage/object-storage.service.ts index 245d3fa..7b526ee 100644 --- a/heroku_deploy/api/src/object-storage/object-storage.service.ts +++ b/heroku_deploy/api/src/object-storage/object-storage.service.ts @@ -22,6 +22,8 @@ export default class ObjectStorageService { } public generateExternalServerAddress(endOfLink: string) { + console.log("COUCOUTUTU") + // https://minio.picspy.vagahbond.com/minio/picspy-challenges/AyoubTest/c5b3f69c-5222-4623-9993-792f7d8487491627296856152.PNG return `http${config.MINIO_USESSL ? 's' : ''}://${ config.MINIO_EXTERNAL_ENDPOINT From e6700bdc485c9755ec172520df4bf35dd7a875a8 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:41:23 +0200 Subject: [PATCH 023/207] logs node --- .../api/src/object-storage/object-storage.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/object-storage/object-storage.service.ts b/heroku_deploy/api/src/object-storage/object-storage.service.ts index 7b526ee..a7b5ab0 100644 --- a/heroku_deploy/api/src/object-storage/object-storage.service.ts +++ b/heroku_deploy/api/src/object-storage/object-storage.service.ts @@ -16,13 +16,15 @@ export default class ObjectStorageService { constructor(private readonly minioService: MinioService) {} public generateInternalServerAddress(endOfLink: string) { + console.log("COUCOUTUTUINT") + return `http${config.MINIO_USESSL ? 's' : ''}://${ config.MINIO_INTERNAL_ENDPOINT }/${endOfLink}`; } public generateExternalServerAddress(endOfLink: string) { - console.log("COUCOUTUTU") + console.log("COUCOUTUTUEXT") // https://minio.picspy.vagahbond.com/minio/picspy-challenges/AyoubTest/c5b3f69c-5222-4623-9993-792f7d8487491627296856152.PNG return `http${config.MINIO_USESSL ? 's' : ''}://${ From f48d08b92df8893c220fa01311cb21f5de82c730 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:46:34 +0200 Subject: [PATCH 024/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 386a89e..1479c08 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,10 +41,10 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("COUCOU1") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { + console.log("STOP") const pictureObject = picture.toObject(); const file = fromInternal @@ -56,7 +56,7 @@ export class PicturesService { pictureObject.url, ); - console.log(pictureObject.url) + console.log(pictureObject) return { _id: pictureObject._id, From 945ec76a0611637ea78ba98b6e5a87eba1c2fd83 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:50:47 +0200 Subject: [PATCH 025/207] logs node --- heroku_deploy/api/src/challenges/challenges.service.ts | 1 + heroku_deploy/api/src/pictures/pictures.service.ts | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index bbb6c6c..4e2eefc 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -80,6 +80,7 @@ export class ChallengesService { if (!challenge) { throw new NotFoundException('Speicified challenge does not exists'); } + console.log("findOne OK") const execBootstraps = await this.execBootstrapService.findExecBootstrapsLanguagesByChallenge({ diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 1479c08..e1c7228 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,10 +41,10 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { + console.log("findExternalUrlsByChallenge OK") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { - console.log("STOP") const pictureObject = picture.toObject(); const file = fromInternal @@ -56,8 +56,6 @@ export class PicturesService { pictureObject.url, ); - console.log(pictureObject) - return { _id: pictureObject._id, file: file, From b45183571d086673e4cf8e3c5165a62de97d54b5 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:54:23 +0200 Subject: [PATCH 026/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index e1c7228..ed644bd 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -56,6 +56,10 @@ export class PicturesService { pictureObject.url, ); + console.log(pictureObject.url) + + console.log("findExternalUrlsByChallenge END") + return { _id: pictureObject._id, file: file, From 3c5f5463db0ef95a979ff7ea2ccdfd544ee549e5 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 9 Oct 2021 23:58:38 +0200 Subject: [PATCH 027/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index ed644bd..98bfe59 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -56,9 +56,10 @@ export class PicturesService { pictureObject.url, ); - console.log(pictureObject.url) - console.log("findExternalUrlsByChallenge END") + + console.log(pictureObject.url) + console.log("findExternalUrlsByChallenge END 1 return") return { _id: pictureObject._id, @@ -67,6 +68,9 @@ export class PicturesService { }; }, ); + + console.log(pictures) + console.log("findExternalUrlsByChallenge END 2nd return") return pictures; } From c0f686523307fda14e8639e15fb6aa175ba18340 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:03:43 +0200 Subject: [PATCH 028/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 98bfe59..920f6e1 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -42,6 +42,7 @@ export class PicturesService { fromInternal = false, ): Promise { console.log("findExternalUrlsByChallenge OK") + console.log("test commit") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { From d04b5084d0a5b802b5a53f477b17a79539e8f12b Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:12:51 +0200 Subject: [PATCH 029/207] logs node --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 920f6e1..1178a6e 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,7 +41,7 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("findExternalUrlsByChallenge OK") + console.log("findExternalUrlsByChallenge OK22") console.log("test commit") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( From f082c64688af9800c8546e6a96428c1a7d014142 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:13:03 +0200 Subject: [PATCH 030/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 1178a6e..36cd2a5 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,7 +41,7 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("findExternalUrlsByChallenge OK22") + console.log("findExternalUrlsByChallenge OK22 ") console.log("test commit") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( From a7e20ca952a82bcac568406baa97ee12bd7f7cfe Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:26:42 +0200 Subject: [PATCH 031/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 36cd2a5..862b821 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,8 +41,9 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("findExternalUrlsByChallenge OK22 ") - console.log("test commit") + console.log("findExternalUrlsByChallenge OK") + console.log(this.objectStorageService) + console.log("objectStorageService ci dessus") const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { @@ -59,7 +60,6 @@ export class PicturesService { - console.log(pictureObject.url) console.log("findExternalUrlsByChallenge END 1 return") return { From d9011fe646a579abed94819800e9d82758c9b83e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:34:21 +0200 Subject: [PATCH 032/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 862b821..713fba2 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,6 +44,8 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") console.log(this.objectStorageService) console.log("objectStorageService ci dessus") + console.log("Challenge ci dessous") + console.log(challenge) const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { From 5a388263fd9f47ae21a587bcb12b980bc4c715c4 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:43:08 +0200 Subject: [PATCH 033/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 713fba2..f537bd9 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -42,15 +42,17 @@ export class PicturesService { fromInternal = false, ): Promise { console.log("findExternalUrlsByChallenge OK") - console.log(this.objectStorageService) - console.log("objectStorageService ci dessus") + // console.log(this.objectStorageService) + // console.log("objectStorageService ci dessus") console.log("Challenge ci dessous") console.log(challenge) const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { - + console.log("pictureObject") const pictureObject = picture.toObject(); + console.log(pictureObject) + const file = fromInternal ? this.objectStorageService.generateInternalServerAddress( From 40f9e879a86fb9f33f1830ca785e16ba0a1e1f52 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:46:57 +0200 Subject: [PATCH 034/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index f537bd9..24ca4cd 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,7 +44,7 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - console.log("Challenge ci dessous") + console.log("Challenge ci dessous v2") console.log(challenge) const pictures = (await this.pictureModel.find({ challenge }).exec()).map( From c4691e3834754ba6240bba648e13850de134095a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 00:53:37 +0200 Subject: [PATCH 035/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 24ca4cd..b8372bb 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,6 +46,8 @@ export class PicturesService { // console.log("objectStorageService ci dessus") console.log("Challenge ci dessous v2") console.log(challenge) + const picturesList = (await this.pictureModel.findAll()) + console.log(picturesList) const pictures = (await this.pictureModel.find({ challenge }).exec()).map( (picture) => { From 5e307ee5e37e9fe6b4fd6ada37a8f2e2dec5e51c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:01:00 +0200 Subject: [PATCH 036/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index b8372bb..3c89fa6 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,10 +46,9 @@ export class PicturesService { // console.log("objectStorageService ci dessus") console.log("Challenge ci dessous v2") console.log(challenge) - const picturesList = (await this.pictureModel.findAll()) - console.log(picturesList) + // const picturesList = (await this.pictureModel.findAll()) - const pictures = (await this.pictureModel.find({ challenge }).exec()).map( + const pictures = (await this.pictureModel.find({ challenge }, 'url').exec()).map( (picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From e59b9903d141158f40b61a54914f0149bf0bd99e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:07:43 +0200 Subject: [PATCH 037/207] logs node2 --- .../api/src/pictures/pictures.service.ts | 52 ++++++------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 3c89fa6..050ef21 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,42 +41,22 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("findExternalUrlsByChallenge OK") - // console.log(this.objectStorageService) - // console.log("objectStorageService ci dessus") - console.log("Challenge ci dessous v2") - console.log(challenge) - // const picturesList = (await this.pictureModel.findAll()) - - const pictures = (await this.pictureModel.find({ challenge }, 'url').exec()).map( - (picture) => { - console.log("pictureObject") - const pictureObject = picture.toObject(); - console.log(pictureObject) - - const file = fromInternal - - ? this.objectStorageService.generateInternalServerAddress( - pictureObject.url, - ) - : this.objectStorageService.generateExternalServerAddress( - pictureObject.url, - ); - - - - console.log("findExternalUrlsByChallenge END 1 return") - - return { - _id: pictureObject._id, - file: file, - execFileName: pictureObject.execFileName, - }; - }, - ); - - console.log(pictures) - console.log("findExternalUrlsByChallenge END 2nd return") + const pictures = ( + await this.pictureModel.find({ challenge }, 'url').exec() + ).map((picture) => { + const pictureObject = picture.toObject(); + const file = fromInternal + ? this.objectStorageService.generateInternalServerAddress( + pictureObject.url, + ) + : this.objectStorageService.generateExternalServerAddress( + pictureObject.url, + ); + return { + _id: pictureObject._id, + file: file, + }; + }); return pictures; } From 03f90bef4c31c83811c190204f4bb839944549e0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:12:38 +0200 Subject: [PATCH 038/207] logs node2 --- .../api/src/pictures/pictures.service.ts | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 050ef21..42b6c2d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,22 +41,42 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - const pictures = ( - await this.pictureModel.find({ challenge }, 'url').exec() - ).map((picture) => { - const pictureObject = picture.toObject(); - const file = fromInternal - ? this.objectStorageService.generateInternalServerAddress( - pictureObject.url, - ) - : this.objectStorageService.generateExternalServerAddress( - pictureObject.url, - ); - return { - _id: pictureObject._id, - file: file, - }; - }); + console.log("findExternalUrlsByChallenge OK") + // console.log(this.objectStorageService) + // console.log("objectStorageService ci dessus") + console.log("Challenge ci dessous v2") + console.log(challenge) + // const picturesList = (await this.pictureModel.findAll()) + + const pictures = ( + await this.pictureModel.find({ challenge }, 'url').exec() + ).map((picture) => { + console.log("pictureObject") + const pictureObject = picture.toObject(); + console.log(pictureObject) + + const file = fromInternal + + ? this.objectStorageService.generateInternalServerAddress( + pictureObject.url, + ) + : this.objectStorageService.generateExternalServerAddress( + pictureObject.url, + ); + console.log("findExternalUrlsByChallenge END 1 return") + + return { + _id: pictureObject._id, + file: file, + execFileName: pictureObject.execFileName, + }; + }, + ); + + + + console.log(pictures) + console.log("findExternalUrlsByChallenge END 2nd return") return pictures; } From ebe0ad34eaa23a8963607e1ae473aa3222308ae6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:23:14 +0200 Subject: [PATCH 039/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 42b6c2d..1bf11cc 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,12 +44,12 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - console.log("Challenge ci dessous v2") + console.log("Challenge ci dessous v3") console.log(challenge) // const picturesList = (await this.pictureModel.findAll()) const pictures = ( - await this.pictureModel.find({ challenge }, 'url').exec() + await this.pictureModel.find("a", 'url').exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 07e844ee47ee1f1b64ff445d57a7124b73e853ac Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:25:38 +0200 Subject: [PATCH 040/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 1bf11cc..4324c9a 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -47,9 +47,9 @@ export class PicturesService { console.log("Challenge ci dessous v3") console.log(challenge) // const picturesList = (await this.pictureModel.findAll()) - + challenge = "a"; const pictures = ( - await this.pictureModel.find("a", 'url').exec() + await this.pictureModel.find({ challenge }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 96877121ee17e6db4d4e19264c81ebd2e2e41912 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:33:04 +0200 Subject: [PATCH 041/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 4324c9a..8d862fa 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,10 +44,12 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - console.log("Challenge ci dessous v3") - console.log(challenge) - // const picturesList = (await this.pictureModel.findAll()) - challenge = "a"; + + const picturesList = (await this.pictureModel.find({ challenge }).exec()) + console.log("Challenge LIST ci dessous v3") + + console.log(picturesList) + const pictures = ( await this.pictureModel.find({ challenge }).exec() ).map((picture) => { From 3b077f9a919de072ada6bc9d43d5a456ca0ac443 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:39:19 +0200 Subject: [PATCH 042/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 8d862fa..b697e79 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,10 +44,9 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - - const picturesList = (await this.pictureModel.find({ challenge }).exec()) - console.log("Challenge LIST ci dessous v3") + const picturesList = (await this.pictureModel.find(challenge).exec()) + console.log("Challenge LIST ci dessous v3") console.log(picturesList) const pictures = ( From d58a07332052443d4447f76ca10ba6e564e7fc35 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:42:09 +0200 Subject: [PATCH 043/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index b697e79..8d862fa 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -44,9 +44,10 @@ export class PicturesService { console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - - const picturesList = (await this.pictureModel.find(challenge).exec()) + + const picturesList = (await this.pictureModel.find({ challenge }).exec()) console.log("Challenge LIST ci dessous v3") + console.log(picturesList) const pictures = ( From 67a18030d88cecb96b91b2f5f6d2df890981ca90 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:47:57 +0200 Subject: [PATCH 044/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 8d862fa..10b46c5 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,7 +45,7 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find({ challenge }).exec()) + const picturesList = (await this.findAll()) console.log("Challenge LIST ci dessous v3") console.log(picturesList) From 3c8fbfdb184d4d76ce04589e24e206e738823700 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:48:14 +0200 Subject: [PATCH 045/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 10b46c5..5fb0088 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,7 +46,7 @@ export class PicturesService { // console.log("objectStorageService ci dessus") const picturesList = (await this.findAll()) - console.log("Challenge LIST ci dessous v3") + console.log("Challenge LIST ci dessous v4") console.log(picturesList) From fb1469fede76cc1ddbf64d7f7fda4249c92b086e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:56:29 +0200 Subject: [PATCH 046/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 5fb0088..3ac9178 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,7 +45,7 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.findAll()) + const picturesList = (await this.pictureModel.findAll()) console.log("Challenge LIST ci dessous v4") console.log(picturesList) From 67a6466347d59848a260c2839902172a59c0479e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 01:56:49 +0200 Subject: [PATCH 047/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 3ac9178..8a0476d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,7 +46,7 @@ export class PicturesService { // console.log("objectStorageService ci dessus") const picturesList = (await this.pictureModel.findAll()) - console.log("Challenge LIST ci dessous v4") + console.log("Challenge LIST ci dessous v5") console.log(picturesList) From 58939bd083e324860818f8c05cc8e8d71c224d0f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:01:53 +0200 Subject: [PATCH 048/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 8a0476d..cbc6665 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,8 +45,10 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.findAll()) - console.log("Challenge LIST ci dessous v5") + const picturesList = (await this.pictureModel.find().exec()).map((picture) => + picture.toObject()) + + console.log("Challenge LIST ci dessous v6") console.log(picturesList) From 09845c885575d78c601308527216076122cac5be Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:05:32 +0200 Subject: [PATCH 049/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index cbc6665..c2661b8 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,10 +45,10 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find().exec()).map((picture) => + const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) => picture.toObject()) - console.log("Challenge LIST ci dessous v6") + console.log("Challenge LIST ci dessous v7") console.log(picturesList) From 8746c3a3b59fc361832a8ec3ae8566b2ec13c264 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:13:57 +0200 Subject: [PATCH 050/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index c2661b8..291ef6c 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,8 +45,12 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) => - picture.toObject()) + const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) =>{ + if (picture.challenge == challenge){ + picture.toObject(); + } + } + ) console.log("Challenge LIST ci dessous v7") From 74df93a454d2a660567ec4e542beb12916c20f1e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:19:37 +0200 Subject: [PATCH 051/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 291ef6c..a082c0c 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -41,11 +41,17 @@ export class PicturesService { challenge: string, fromInternal = false, ): Promise { - console.log("findExternalUrlsByChallenge OK") + // console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) =>{ + console.log("picture.challenge OK") + console.log(picture.challenge) + console.log("challenge OK") + console.log(challenge) + + console.log("findExternalUrlsByChallenge OK") if (picture.challenge == challenge){ picture.toObject(); } From b214bb727bf231c2a35cdb1ea442003b3a0c1050 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:23:10 +0200 Subject: [PATCH 052/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index a082c0c..6cdf273 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,7 +45,7 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) =>{ + const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ console.log("picture.challenge OK") console.log(picture.challenge) console.log("challenge OK") From 323988a24840f0a7bd2ea3253b4d0529c9624222 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:32:18 +0200 Subject: [PATCH 053/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 6cdf273..f90b1ae 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -50,9 +50,8 @@ export class PicturesService { console.log(picture.challenge) console.log("challenge OK") console.log(challenge) - console.log("findExternalUrlsByChallenge OK") - if (picture.challenge == challenge){ + if (picture.challenge === challenge){ picture.toObject(); } } From a019548159efe19dac317ddb0e41a9222744d902 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:35:59 +0200 Subject: [PATCH 054/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index f90b1ae..342a007 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,12 +46,13 @@ export class PicturesService { // console.log("objectStorageService ci dessus") const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ - console.log("picture.challenge OK") - console.log(picture.challenge) - console.log("challenge OK") - console.log(challenge) - console.log("findExternalUrlsByChallenge OK") + // console.log("picture.challenge OK") + // console.log(picture.challenge) + // console.log("challenge OK") + //console.log(challenge) + // console.log("findExternalUrlsByChallenge OK") if (picture.challenge === challenge){ + console.log("INSERT") picture.toObject(); } } From 65cc586d0324239282aab20d858dad0db96460b2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:40:06 +0200 Subject: [PATCH 055/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 342a007..8538a6d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -14,6 +14,7 @@ import { InsertPictureDTO } from './dto/insert-picture.dto'; import { PictureUrlDTO } from './dto/picture-url.dto'; import { UpdatePictureDTO } from './dto/update-picture.dto'; import { Picture, PictureDocument } from './picture.schema'; +import {Types } from 'mongoose'; Injectable(); export class PicturesService { @@ -38,7 +39,7 @@ export class PicturesService { } async findExternalUrlsByChallenge( - challenge: string, + challenge: Types.ObjectId, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") @@ -58,7 +59,7 @@ export class PicturesService { } ) - console.log("Challenge LIST ci dessous v7") + console.log("Challenge LIST ci dessous v8") console.log(picturesList) From 4adcc66cfd7b0fa63a60c752de901ee46d4bce3e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:45:06 +0200 Subject: [PATCH 056/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 8538a6d..0aeccea 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -39,7 +39,7 @@ export class PicturesService { } async findExternalUrlsByChallenge( - challenge: Types.ObjectId, + challenge: String, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") @@ -52,14 +52,14 @@ export class PicturesService { // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - if (picture.challenge === challenge){ - console.log("INSERT") picture.toObject(); - } + console.log(typeof picture.challenge); + } ) - console.log("Challenge LIST ci dessous v8") + console.log("Challenge LIST ci dessous v9") + console.log(typeof challenge); console.log(picturesList) From e78f1c109f2092992919866f8e15c856ef6a79bb Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:48:03 +0200 Subject: [PATCH 057/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 0aeccea..88aa1ba 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -14,7 +14,7 @@ import { InsertPictureDTO } from './dto/insert-picture.dto'; import { PictureUrlDTO } from './dto/picture-url.dto'; import { UpdatePictureDTO } from './dto/update-picture.dto'; import { Picture, PictureDocument } from './picture.schema'; -import {Types } from 'mongoose'; +import { Types } from 'mongoose'; Injectable(); export class PicturesService { @@ -39,7 +39,7 @@ export class PicturesService { } async findExternalUrlsByChallenge( - challenge: String, + challenge: string, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") @@ -52,14 +52,14 @@ export class PicturesService { // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") + if (picture.challenge === challenge){ + console.log("INSERT") picture.toObject(); - console.log(typeof picture.challenge); - + } } ) - console.log("Challenge LIST ci dessous v9") - console.log(typeof challenge); + console.log("Challenge LIST ci dessous v10") console.log(picturesList) From 26ed8721125dc4258b7f1c1c47c88c2f9a92dc39 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:51:11 +0200 Subject: [PATCH 058/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 88aa1ba..6a00bc4 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -52,6 +52,8 @@ export class PicturesService { // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") + console.log(typeof challenge) + console.log(typeof picture.challenge) if (picture.challenge === challenge){ console.log("INSERT") picture.toObject(); @@ -59,6 +61,7 @@ export class PicturesService { } ) + console.log("Challenge LIST ci dessous v10") console.log(picturesList) From 9699165ca165f7f0c358417cb4e94e47ba11ab55 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:55:06 +0200 Subject: [PATCH 059/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 6a00bc4..dafd06e 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,7 +45,7 @@ export class PicturesService { // console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - + challenge = Types.ObjectId(challenge) const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) @@ -62,7 +62,7 @@ export class PicturesService { ) - console.log("Challenge LIST ci dessous v10") + console.log("Challenge LIST ci dessous v11") console.log(picturesList) From 992d161d91a679c8c74b768154507769a4fe1c95 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 02:58:54 +0200 Subject: [PATCH 060/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index dafd06e..790ac39 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -45,16 +45,16 @@ export class PicturesService { // console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - challenge = Types.ObjectId(challenge) + const id_challenge = Types.ObjectId(challenge) const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - console.log(typeof challenge) + console.log(typeof id_challenge) console.log(typeof picture.challenge) - if (picture.challenge === challenge){ + if (picture.challenge == id_challenge){ console.log("INSERT") picture.toObject(); } @@ -67,7 +67,7 @@ export class PicturesService { console.log(picturesList) const pictures = ( - await this.pictureModel.find({ challenge }).exec() + await this.pictureModel.find({ id_challenge }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 572e05403822a01c44632119d0b1c9bbd40ea761 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:00:56 +0200 Subject: [PATCH 061/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 790ac39..59d44a8 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -54,10 +54,10 @@ export class PicturesService { // console.log("findExternalUrlsByChallenge OK") console.log(typeof id_challenge) console.log(typeof picture.challenge) - if (picture.challenge == id_challenge){ + // if (picture.challenge == id_challenge){ console.log("INSERT") picture.toObject(); - } + // } } ) From 6cc985ddb366ca9acfdb14424dccd89559a727c6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:06:05 +0200 Subject: [PATCH 062/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 59d44a8..cac620c 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -39,20 +39,20 @@ export class PicturesService { } async findExternalUrlsByChallenge( - challenge: string, + string_challenge: string, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const id_challenge = Types.ObjectId(challenge) + const challenge = Types.ObjectId(string_challenge) const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - console.log(typeof id_challenge) + console.log(typeof challenge) console.log(typeof picture.challenge) // if (picture.challenge == id_challenge){ console.log("INSERT") @@ -67,7 +67,7 @@ export class PicturesService { console.log(picturesList) const pictures = ( - await this.pictureModel.find({ id_challenge }).exec() + await this.pictureModel.find({ challenge }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 21d083cd22ecb205e5685c2ab224ffda9b6b6ddd Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:14:47 +0200 Subject: [PATCH 063/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index cac620c..e1e48de 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -39,30 +39,26 @@ export class PicturesService { } async findExternalUrlsByChallenge( - string_challenge: string, + challenge: string, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const challenge = Types.ObjectId(string_challenge) + const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - console.log(typeof challenge) - console.log(typeof picture.challenge) - // if (picture.challenge == id_challenge){ - console.log("INSERT") + picture.toObject(); - // } } ) - console.log("Challenge LIST ci dessous v11") + console.log("Challenge LIST ci dessous v10") console.log(picturesList) From 7fdd7d52fea326d77ebb034a9b7b1402b4c31650 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:20:29 +0200 Subject: [PATCH 064/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index e1e48de..515200f 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,15 +46,16 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ - // console.log("picture.challenge OK") + const picturesList = (await this.pictureModel.find().exec()).map((picture) => + // console.log("picture.challenge OK" // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - picture.toObject(); - } + picture.toObject(), + + ) From 9c84e902608ecd40a87f1863cd43d632057dffb0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:21:06 +0200 Subject: [PATCH 065/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 515200f..7f7109d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,16 +46,16 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find().exec()).map((picture) => - // console.log("picture.challenge OK" + const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ + // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - picture.toObject(), + return picture.toObject(); - + } ) From 23faf2534da5f97667d70a8ed98d78f4b0487b93 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:25:05 +0200 Subject: [PATCH 066/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 7f7109d..d2ce521 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,7 +46,7 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ + const picturesList = (await this.pictureModel.find().exec({ challenge })).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") @@ -59,7 +59,7 @@ export class PicturesService { ) - console.log("Challenge LIST ci dessous v10") + console.log("Challenge LIST ci dessous v11") console.log(picturesList) From f7b3cce88ce2f1d875c4cf8dabff35dd524f43d8 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:27:34 +0200 Subject: [PATCH 067/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index d2ce521..8e7d651 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,7 +46,7 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find().exec({ challenge })).map((picture) =>{ + const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") From 45ae96d50a230ffa26a90f7be6c94c1125d1fe0c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:31:53 +0200 Subject: [PATCH 068/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 8e7d651..403cf79 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -46,13 +46,14 @@ export class PicturesService { // console.log(this.objectStorageService) // console.log("objectStorageService ci dessus") - const picturesList = (await this.pictureModel.find({ challenge }).exec()).map((picture) =>{ + const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ // console.log("picture.challenge OK") // console.log(picture.challenge) // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - + console.log(challenge) + console.log(picture.challenge) return picture.toObject(); } From b9447694c4768d07297da0f5eca6dbba9eaa472b Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:35:53 +0200 Subject: [PATCH 069/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 403cf79..d1e9616 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -54,6 +54,9 @@ export class PicturesService { // console.log("findExternalUrlsByChallenge OK") console.log(challenge) console.log(picture.challenge) + if(challenge==picture.challenge){ + console.log("EQUIVALENT") + } return picture.toObject(); } From b5f29c0b01eb2c664d323e156f832531f29d2b84 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:39:35 +0200 Subject: [PATCH 070/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index d1e9616..d9e12b1 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -56,8 +56,9 @@ export class PicturesService { console.log(picture.challenge) if(challenge==picture.challenge){ console.log("EQUIVALENT") + return picture.toObject(); + } - return picture.toObject(); } ) From bf6df7c1103c7bc36f14973111e87e2b89e9283a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:44:58 +0200 Subject: [PATCH 071/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index d9e12b1..ed2aefe 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -69,7 +69,7 @@ export class PicturesService { console.log(picturesList) const pictures = ( - await this.pictureModel.find({ challenge }).exec() + await this.pictureModel.find({ challenge: challenge }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 6d435ffd54358d8a58362733f16d5de5e10616ec Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:45:42 +0200 Subject: [PATCH 072/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index ed2aefe..cc9b77b 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -52,10 +52,10 @@ export class PicturesService { // console.log("challenge OK") //console.log(challenge) // console.log("findExternalUrlsByChallenge OK") - console.log(challenge) - console.log(picture.challenge) + // console.log(challenge) + // console.log(picture.challenge) if(challenge==picture.challenge){ - console.log("EQUIVALENT") + // console.log("EQUIVALENT") return picture.toObject(); } From ce3554be8ce4ff61e52e7520d8ff1b8e1337050d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:50:50 +0200 Subject: [PATCH 073/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index cc9b77b..3b07e06 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -64,12 +64,12 @@ export class PicturesService { ) - console.log("Challenge LIST ci dessous v11") + console.log("Challenge LIST ci dessous v12") console.log(picturesList) const pictures = ( - await this.pictureModel.find({ challenge: challenge }).exec() + await this.pictureModel.find({ challenge: "6161902bb298960003ca2b1d" }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From f9ddcf14292cd5ace3bdf376cc60d415eb837d27 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 03:55:20 +0200 Subject: [PATCH 074/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 3b07e06..b4c9010 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -69,7 +69,7 @@ export class PicturesService { console.log(picturesList) const pictures = ( - await this.pictureModel.find({ challenge: "6161902bb298960003ca2b1d" }).exec() + await this.pictureModel.find({ execFileName: "option4.png" }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 0d2b8b9b456072e69cbd3c8a2da37aaa5049b8d6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:00:03 +0200 Subject: [PATCH 075/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index b4c9010..2ebf200 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -39,7 +39,7 @@ export class PicturesService { } async findExternalUrlsByChallenge( - challenge: string, + challenge_id: string, fromInternal = false, ): Promise { // console.log("findExternalUrlsByChallenge OK") @@ -54,11 +54,11 @@ export class PicturesService { // console.log("findExternalUrlsByChallenge OK") // console.log(challenge) // console.log(picture.challenge) - if(challenge==picture.challenge){ + // if(challenge==picture.challenge){ // console.log("EQUIVALENT") - return picture.toObject(); +// return picture.toObject(); - } + // } } ) @@ -69,7 +69,7 @@ export class PicturesService { console.log(picturesList) const pictures = ( - await this.pictureModel.find({ execFileName: "option4.png" }).exec() + await this.pictureModel.find({ challenge: challenge_id }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From cff5f24541f574b70ba8e062084a3dab761d9025 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:00:15 +0200 Subject: [PATCH 076/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 2ebf200..1eec414 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -64,7 +64,7 @@ export class PicturesService { ) - console.log("Challenge LIST ci dessous v12") + console.log("Challenge LIST ci dessous v13") console.log(picturesList) From 95f02cd07ff303c1da7696c0eff311e634ac6e68 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:07:27 +0200 Subject: [PATCH 077/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 1eec414..5a7212d 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -68,8 +68,10 @@ export class PicturesService { console.log(picturesList) + var o_id = new Types.ObjectID(challenge_id); + const pictures = ( - await this.pictureModel.find({ challenge: challenge_id }).exec() + await this.pictureModel.find({ challenge: o_id }).exec() ).map((picture) => { console.log("pictureObject") const pictureObject = picture.toObject(); From 4bd068c8f54292458bc2c268a025a58a0c8f6bdd Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:10:11 +0200 Subject: [PATCH 078/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 5a7212d..187ca03 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -68,7 +68,7 @@ export class PicturesService { console.log(picturesList) - var o_id = new Types.ObjectID(challenge_id); + var o_id = new Types.ObjectId(challenge_id); const pictures = ( await this.pictureModel.find({ challenge: o_id }).exec() From 56008cfe458882a0bcad09621b3768f4c15a907c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:16:22 +0200 Subject: [PATCH 079/207] logs node2 --- heroku_deploy/api/src/pictures/pictures.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 187ca03..342a285 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -68,9 +68,11 @@ export class PicturesService { console.log(picturesList) - var o_id = new Types.ObjectId(challenge_id); - const pictures = ( + var mongo = require('mongodb'); + var o_id = new mongo.ObjectID(challenge_id); + + const pictures = ( await this.pictureModel.find({ challenge: o_id }).exec() ).map((picture) => { console.log("pictureObject") From 43fcb5c4f1c02dd1e0cfd72bcd5d470ef6f31ed3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:20:04 +0200 Subject: [PATCH 080/207] fix bug image --- .../api/src/pictures/pictures.service.ts | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 342a285..43181b7 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -42,32 +42,6 @@ export class PicturesService { challenge_id: string, fromInternal = false, ): Promise { - // console.log("findExternalUrlsByChallenge OK") - // console.log(this.objectStorageService) - // console.log("objectStorageService ci dessus") - - const picturesList = (await this.pictureModel.find().exec()).map((picture) =>{ - // console.log("picture.challenge OK") - // console.log(picture.challenge) - // console.log("challenge OK") - //console.log(challenge) - // console.log("findExternalUrlsByChallenge OK") - // console.log(challenge) - // console.log(picture.challenge) - // if(challenge==picture.challenge){ - // console.log("EQUIVALENT") -// return picture.toObject(); - - // } - - } - ) - - - console.log("Challenge LIST ci dessous v13") - - console.log(picturesList) - var mongo = require('mongodb'); var o_id = new mongo.ObjectID(challenge_id); @@ -75,9 +49,7 @@ export class PicturesService { const pictures = ( await this.pictureModel.find({ challenge: o_id }).exec() ).map((picture) => { - console.log("pictureObject") const pictureObject = picture.toObject(); - console.log(pictureObject) const file = fromInternal @@ -87,7 +59,6 @@ export class PicturesService { : this.objectStorageService.generateExternalServerAddress( pictureObject.url, ); - console.log("findExternalUrlsByChallenge END 1 return") return { _id: pictureObject._id, @@ -97,10 +68,6 @@ export class PicturesService { }, ); - - - console.log(pictures) - console.log("findExternalUrlsByChallenge END 2nd return") return pictures; } From 3c81f5616ecc7b7faf593974f2d7aa65eb374555 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 04:46:00 +0200 Subject: [PATCH 081/207] fix bug image --- heroku_deploy/api/libs/python/bib.py | 1 - heroku_deploy/api/src/pictures/pictures.service.ts | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/libs/python/bib.py b/heroku_deploy/api/libs/python/bib.py index 31cf711..77d1356 100644 --- a/heroku_deploy/api/libs/python/bib.py +++ b/heroku_deploy/api/libs/python/bib.py @@ -144,7 +144,6 @@ def initSizeImages(self): def getNumberImage(self): PATH = "pictures/" - print(os.listdir("/box")) cpt = 0 for image in os.listdir(PATH): if image.endswith(".png"): diff --git a/heroku_deploy/api/src/pictures/pictures.service.ts b/heroku_deploy/api/src/pictures/pictures.service.ts index 43181b7..023913b 100644 --- a/heroku_deploy/api/src/pictures/pictures.service.ts +++ b/heroku_deploy/api/src/pictures/pictures.service.ts @@ -72,10 +72,15 @@ export class PicturesService { } async findInternalUrlsByChallenge( - challenge: string, + challenge_id: string, ): Promise { + + + var mongo = require('mongodb'); + var o_id = new mongo.ObjectID(challenge_id); + const pictures = ( - await this.pictureModel.find({ challenge }, 'url').exec() + await this.pictureModel.find({ o_id: o_id }).exec() ).map((picture) => { const pictureObject = picture.toObject(); return { From e9cae786a509f902c7e8cb7ba80fadb731fffc9e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 19:27:08 +0200 Subject: [PATCH 082/207] =?UTF-8?q?test=20int=C3=A9gration=20algo=20:1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/Dockerfile.api | 5 +- heroku_deploy/api/evaluation_code/README.md | 1 + .../evalCommentaireCpp.cpython-39.pyc | Bin 0 -> 618 bytes .../evalNbLigneFonctionCpp.cpython-39.pyc | Bin 0 -> 2592 bytes .../evalRedondanceCpp.cpython-39.pyc | Bin 0 -> 7972 bytes .../evalVariableNameCpp.cpython-39.pyc | Bin 0 -> 4552 bytes .../evaluation_code/cpp/evalCommentaireCpp.py | 43 ++ .../cpp/evalNbLigneFonctionCpp.py | 150 +++++ .../evaluation_code/cpp/evalRedondanceCpp.py | 549 ++++++++++++++++++ .../cpp/evalVariableNameCpp.py | 308 ++++++++++ heroku_deploy/api/evaluation_code/cpp/main.py | 24 + .../evalCommentairePy.cpython-39.pyc | Bin 0 -> 670 bytes .../evalNbLigneFonctionPy.cpython-39.pyc | Bin 0 -> 2160 bytes .../evalRedondancePy.cpython-39.pyc | Bin 0 -> 6787 bytes .../evalVariableNamePython.cpython-39.pyc | Bin 0 -> 3650 bytes .../python/evalCommentairePy.py | 46 ++ .../python/evalNbLigneFonctionPy.py | 125 ++++ .../python/evalRedondancePy.py | 485 ++++++++++++++++ .../python/evalVariableNamePython.py | 268 +++++++++ .../api/evaluation_code/python/main.py | 25 + .../api/src/attempts/attempts.service.ts | 8 + .../api/src/exec-server/godbox.repository.ts | 62 ++ 22 files changed, 2098 insertions(+), 1 deletion(-) create mode 100644 heroku_deploy/api/evaluation_code/README.md create mode 100644 heroku_deploy/api/evaluation_code/cpp/__pycache__/evalCommentaireCpp.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/cpp/__pycache__/evalNbLigneFonctionCpp.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/cpp/__pycache__/evalRedondanceCpp.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/cpp/__pycache__/evalVariableNameCpp.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py create mode 100644 heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py create mode 100644 heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py create mode 100644 heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py create mode 100644 heroku_deploy/api/evaluation_code/cpp/main.py create mode 100644 heroku_deploy/api/evaluation_code/python/__pycache__/evalCommentairePy.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/python/__pycache__/evalNbLigneFonctionPy.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/python/__pycache__/evalRedondancePy.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/python/__pycache__/evalVariableNamePython.cpython-39.pyc create mode 100644 heroku_deploy/api/evaluation_code/python/evalCommentairePy.py create mode 100644 heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py create mode 100644 heroku_deploy/api/evaluation_code/python/evalRedondancePy.py create mode 100644 heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py create mode 100644 heroku_deploy/api/evaluation_code/python/main.py diff --git a/heroku_deploy/api/Dockerfile.api b/heroku_deploy/api/Dockerfile.api index d3be497..29bae4c 100644 --- a/heroku_deploy/api/Dockerfile.api +++ b/heroku_deploy/api/Dockerfile.api @@ -38,8 +38,11 @@ WORKDIR /usr/src/app COPY --from=builder /usr/src/app/package*.json /usr/src/app/ COPY --from=builder /usr/src/app/dist/ /usr/src/app/ -ENV LIBS_DIR=/usr/src/app/libs +ENV LIBS_DIR=/usr/src/app/ +ENV ALGO_DIR=/usr/src/app/evaluation_code + COPY ./libs ${LIBS_DIR} +COPY ./evaluation_code ${ALGO_DIR} COPY ./conf /usr/src/app/conf diff --git a/heroku_deploy/api/evaluation_code/README.md b/heroku_deploy/api/evaluation_code/README.md new file mode 100644 index 0000000..3188577 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/README.md @@ -0,0 +1 @@ +"# Algo-valuation-code" diff --git a/heroku_deploy/api/evaluation_code/cpp/__pycache__/evalCommentaireCpp.cpython-39.pyc b/heroku_deploy/api/evaluation_code/cpp/__pycache__/evalCommentaireCpp.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..774ddc4a3ec35fe2d0b18c6054947d5b585168aa GIT binary patch literal 618 zcmYjNO>5LZ7@p5fHr;52-h|$_2N!w~M8p!ir&5X^mk@w%cPzuP{bnS+J4~2~4FcX1+M)=zS!!9VE9_ z+ypf7fW4QOWN)^Sz-+>gDv4fsu8h%U zN<6n+v+OOAD-7uSW=0ut5gi) z@Oo)f(RB~H3%{d22qpd&{?COg?LH_(GRz3W@R5|JI3*K68luQ&fujt#Z9F0)!ic#C cUB^=#ZG7o1wGBC+K3;42zEMxYmR|t$2PEQ>)c^nh literal 0 HcmV?d00001 diff --git a/heroku_deploy/api/evaluation_code/cpp/__pycache__/evalNbLigneFonctionCpp.cpython-39.pyc b/heroku_deploy/api/evaluation_code/cpp/__pycache__/evalNbLigneFonctionCpp.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dd3566ad25d7f16033c16e8d2cc8648d1c599cfb GIT binary patch literal 2592 zcmaJ@O>f&q5Zxsyijrwrae~waf`UK`v@&An0|nZ+sZqy`fdH;yBxw$;1A*qQ9NH8q zFDa*1mc69Epy)9NJE!^|^c-J{B0z6MPwgqcpny-ESxSm5C#A3-9KM-Za^Jj_H#u1) zaQ!*sd-WP2|KQE&rNPbD(2}drF~Vp_T(V7=_L91k>CE_vxEd=l6GoktnFXW4=mXNI zya5lg-Y|QO@0aIYZ@zbZ{#Ntxvl~~l%>?`N*16u&dE>L|SF_vW<|POL_HlFX9PoXq z-nD?<{CK?gdPD9nd$-QR=gutvRyubEr(C}}WBQ*@a&DdI?o<4<{mX<=hqeMOc@5n* z$ta_l22E#LW-vV~Ni8LkJg2)v{4R;qW(hNPHL)gjR{ES|x-<$a%nfEDUfDHxPIqG@DkT zS(-t?s#U>S)vB791fMe;v@i%X#lgQ}0^Fm(Lrs!z$m7?@L#gi*aZ~Dtu-8WvcN_Pf z>9Yj)f6r!yLiAXv7!?w@0bE3%63k3lLcBCnO`6XsGiS&w`G90)6{~zE&f(C1EE6kd z6tWdr{usvYqad;|h^%-C@3Ch~n%F9bUgVIPV&%W^q9d#XQYI;H?t3Eew!(3Gdc|W0 zw%-{*fQVhi+EJz=tp`+nx045~|21*E{WuVgw-a~MlVhhFIXvljK-~UgU~78N;gHY? zyA2PtiQA0zcqF)de~v&bMAF0tf^sBq*>93gC9%x}?^++S9IGQ|yPyTu+<3 zCJgu*4;y-3N;+YXiZa{^z&nxhj*Qvmswz7rY(s^S2QdEAjjyC7?MF*`ifi*Xqz$ z=?qdE#u_!%c$u0y(A^NzfIma>i(nX%{4cmcp+%BI)1iTc0#PYa7Uax?R)%JQ{8r#; z6~>8_%F=VBbP3AhN`|Dj_o-L{I;v4tqzw{W*;@i4RscB(VqBAxfZoZbIy)F6IVqziVUBto9YjoyNOI{Q|nrF^zjU^pbS#yj^($R_Ufd zF>@yqKkjf8LKIAQq7{fFy%)he6?FvE3L>t=ZK#wKP6#yG13^SbaRE*B(N&?@t$7)TcJAu#>FH_q{P0I4rPXRjvb@$%q--faUQ03~>JMP1VIes;L~CciyYR#9yUg>2!b3M!5)%JoI?%)76Ew5 z_g;4oIn+4G45quP-m6!y{=WA!t#a8j@cCJ}-8#2o82?6#r{xUZ zo)m8xjbqRz*%zKu0Gck0@Nw7IN1FbZC3#Ly>fRQ#wAp6{ zZx_EC_(dM}_mMFWQVdLK4lI;yX$=b6xM@6id*EnC+D}Y%Nn?*+HNfKxtgwdGB3iFg z>krVXEj5p_cw(z}xrc>!K|APC*qYb&o}mk$31N`rt$B=5#Lv|>#`u>(NtgD7bYCbm>oU)*y!EyA2NSWgSBzaLj?6X?-%;B#GRaw?m)^%4`_e@#F{A#)eO>57D^yiI&0sYFa8kTX@ z2tDSh5D#WGiP=r*$&9x!Z}7~%)>FEsCyyI*22ptile=Q;b7)$U6=~_I&(LpJ%f~|h z;|3_xT0qY!J-u$y%A)5xn(koruA-xIJ2Cdfxo@brx-T00VzF;7*89gkK7H+lvoF5$ z{e^Rl^A|oEoVk4ErSoU^#r{E!BRURPU{<-g@)y!?#!7d}HPMom=R%{a#}xvAdlx zNc?Umir;RjPV2pHkXY@_xaoDm+uI>aYgUPTqlW>)xD$5b=48hI#sNO2aAX6+E` zTclmen|0=vOU>$fCOKQ}6{c(gvT5GrBUbuGeY5Q?Y zZQN76_pxlz+Di9P@77MMd!r|Vwf5%bT7b%%f$W8{6}E#Lo0}IlpC-qkkIdJK7J%2N ziUA^thaqhGn)Gu`SGdBVC+aofS)On#rU+knX!k_L^s*i^Xmc!Tx6Ny2#d1OM#0e91 z$eIGxH!I?Vn6gwI6dD}-7<=Ze1MC4FSh&9__SmtZ4Zg#cn$d+_E1J=UwsA** zMZ2atDGLJ!zas7iP-IZTJ%J4wOh5{uL0Oli`NZC}l&2kj8oGqu4iMlI?gQ>8mik2d zdqR7ROoTWo7a`kEhSF2cpN!>n!TAetmb0EEXeU%9)gC%{a|X0P3(=_t9hfKLv9cE6 z67fJUXQ%;C2MC&Loz_a)CNx5O8JP60F5-DxyJ%TM-y-yI(;gZl4ZM)nGMDJ{7z!%c6o+k5Z_ zqyXI-m~mdKpjOeQuB@9t^$9I@z^%Rn5{VSwF~*nqcw29W{|T*V&nwU!J1K2#pa+%2 zpbDvutZD-`qpGWq2&ais(^Y96&-i%c3iRMMj1JDdqI4KpO&}}TJlgk3>==+3$ZD#8 z1UJqGml$EQ+Ar9?(dqlU6nO_`=w>BIkREKwYK^I+z{{g%iQyzMz+yzP`VJR~w^;-Ifa81tIz|9)<%56*fcfj9DQ-O(8mi-kRwHbOFbBqD0UQ=tUX7 zikK2-P1{WzK8-YtJpEr2`zN$&WOyNsj#boz@Z}uX!&rPclrD@MB;33%2pgS z%*2H~z25D$pCsOU^djpP9bG*?Wq-&Vzs9f;d9ntq*OXO(n~L&?y`j?yE0e1ED-=4p zuPYAO8#A{z>T65`_`yE!O>MDXWoaM}wc>``@E;50^#U6m(8-GY95>hGx1pV^ugd#| zWVxu7tjeEJE6~)^1@(E>?xN@CJOa3A1eR*5pT+{M;+YBG9Ci_2HTmDp)*TuhB{Rc` z(r^9}(>jC`mvPgN;sg+Y(4qd-UcD8zx=-O;97c)^C029@DoufmT z(+cByJCk-U2aNg$k2@G*y{GD(_4Gh@!YZUp` zsEfqT_jLk}-AcRH?Y3l~UO{tGYDu}m%Bb_iMt;(vOXbm}N)N@qgA!4n>@ML{(_Qg# zMCg{dChicRYxOEUj%*6U?8DrJp22Atw=aw}Hg@CWa9;?O2zl&u zUtWXk5$vH$J#->>Qzz2IzF6AAMHZRk_z956!g?W;!wO&x*m?LLZlXtRE<{&iai~ z&oC7d*r}Ejv3M8R)$4>mc6G#?ILuu+yr}P}gjTE9%9=f-WTD!cgk{oaySmxSE%j zRf)T2dBuM5YBoqFaFKoGesS^0*bP-k2RfG$6d9OY=;?iNx=}df`1&9o_`I2+Or{R| zp>GCZYa<|+Gm2N?sImoR54c&Owj0}uOgTKx)ImK0(p3=A{~;V*c5AN@Os`^CgWXHG ziR=)P;q*n#@=eb=BhHw!)(J%T{IyP5C(;ccZkN3=={2iBB`4-roR-oZ^~P+Y}N+Bk|LJBo$h z{5QlN@{iI$XgJ}~fNE@<1ea+0Tcay-n#KiJQN4vY?Qihf>2*}S^?q+V{^|=vZ1o`8 zL{cm#!*8Paf&w_m$+zJ`{T_mnAg1P_Ki2L96wF23A*%mDD^?u{0vGv8X-4g8*1CMi z1*4Oi#&5LLaJmZ!a>BS#NKeSY=BwkNCsxpn)f`Gq2QK+7RF0gPa@0a{tjA&1MQph3*Qbi;s~>Lyx8_M5!*q3QltRA|3ph)v$}Uy)C)Erb!5w3Y2U3^y5U z2~*DI*oV<2j=n6UZ{~zShcTx<$TP#77l>awv8f$oSRKlG&LQi}vWg>e_J;kBj3kRV zLw+{OKMZAOT##(%l1U!TW6Ref@_7s^9YdP{LszX}qPP3z%P+I1g~CGLTu4Lc)rQ3p zY#Qj+z}RpThvUZx>CRsG=wZ9Jv4I<$%#sWL@PkhL7)Oa((b!T?)j4!Z+_?1~wgWlR zQeL`vP`t#^71NJyW=#bfy`A7d-e1vvQbcDIIKX5VxdvyMvU~_6xnALHp(kcJPw3m~ z4){lQdL9kKot{CsNX|3uG=BUq1KcXC8toh68@OA@V3`9K8LAREJiI3m0TrInzLL`= z9xNlbXKQ~)sAcR5zmb&#MzCw<$CmcNUDjpJ1_^aWV=P2h{|sjsyT-c&shJKH(gV>P zaze!}X`Q4XLsSI9RJVQ{{=O~`Dnlt1c0GmK z(Un{dGF-E1jU;i6WHEh2)~~}={CDBd9B@+qFPZO;$b6smdrl_uX_s_K`_Q!nH+HxR zn0YNO>JnCKQcnVFYxobL2Cb$@BlP+dt3S=Ns)1S`%;@RZ)yPZHte%mfpU&3++&_&= zdK$8hp~tK~h8|}JbNZN`<6wpIpZ}rJp4R6n#+^kkw9(zTn+WfA>LR!=bi#IbTL%5= zcGL+U)yXh1R;B?8gO``y7CLT(^N5gf>M5tTDT8`Si&498Jl$%c`);lVS-w08T)oo&cxkZ95 zy3yMJzT-cRSE$j?;~(nCSG74qs7VQ>H-MtKI?Xw1MdNBORUs#^J#U`m*q3BPKLh}z zEV<4J|Cy0@Ag094hi!Uo)Kh+S0~&Fd-7F)*KKREVDWswG5uBe6K5PeV`lsQ5_3sHC z6y&gffPk8UG)gz|KM5RQdlX_*0G9=EIn@VxRFH-u&WbomWt);%d6^PTup3BIrHL=( zbT|;CBv(bunCee3YGWexho)&Nb$U>0iW5J)*@yO?j1S`ycRYl9JWWo7j&74EA3ot|GCFm_IpED4M;u#2Lw3xvP|mR8wVWO0aO>?O@q+YBCe&s4V! z4Ar@?M-D#Zw5MSYQMgB|93znS6s=Gq<;4p=AzQx38R93Qi5)KK0(6mB;VQWy=Y*-=xkC z-aUYL@lD#L(``n+j(&&n_V8TAlla(>H6vq!WnA#gMBfr-W-H^G zv2rVOlq0NlF3&1#$~gl(PG&|8P+d^pC+fSPDpO9Q&(m4-}sqV$aGK1YvbzVb2q$E>V8NS8@EHHH6#4J{fapNg_7 zZyDQ6HlVcv|Euu7rmCr}%1_uj&3LM|%@R+QRdvP?WqABA_+N`Es#4J4Uqw~*%BuZ8 zsfwr^HL`N*4BgZdY=-P|VXT|ba$`ib52Ql>m{)$P+_A^~Py0%_SjT5sUDQ-v`}-SJ zA97K{8XKwsZyQgTs7@QU0UvAU4AZ!1M84*!6AxB4ffY`wi4m_oZRpj#Qj@BoCT0xy zj9I;kiEY;ZEj%rWx-iw`Gsx|Z#}lzIXn@@sr1P*zEzoz4Drl)(*S0!*WEuDt)@bqHXK??m&PQK79)(^q2{ zh|*33ixVUM55DHHlg=76HTJOH)ZS^{k+7zm&FiZp%_DNo9_DVl(4YHJ_+U)u9g)wh z!enyq`omNPZE|v6#v6;;(aKgJgAQE25y&*RduWrKb#g0x)C+SDvwA_#4LM8uIDhs0 z@-Gr>(sDaU<7oNDqxQW(ZrqUZeQaB@e5JbZ*x83blOQ;FGy;9G2Z4YJCQfmIKvrrfL!V?WUnqN< zCohztESwS`5>EG*!p+ZlU*i+uPQgX^_W7>%g7fnOIX!TGq3w+&ffsUWq{kujz^J6GQLhR#nNn`@ zALU_Y5|S?Lcm==mahm;zcEA~FDCyOn08bU`V95)tk&o8K9I9L@)Hd6X2#R;sD@EZ)quuj#kRmHSAia^ zz-8!P9oy>Piv9tQ=qpv>H}+mw%76s*SXPHd2S{iD>+7n%M%YR-=nFnG;?q{E@IljH z8M8xII2sK((2#N!eW?jV2+$K~$mJ*C#@Ez6jf$huL!Fn%lU{+A8IQbC4;qAj&d4UV zdH+YdYu&$cANG-pc2`c(w7YU;X?d%ExIoX%0ixP(;&&bgJlJS<324qY0fO@7^8}C- zHaDZNAU8$WY~%PA{4z{8WkjrLyeXSqFa_XCAR)q}ImU-(u-Qz)PLwpoaniIJ7r3XD zNP^%3z<1b>7bP8YNe4|*zTaUh(!zUi^!5QbzH;)IbT!w7!70=hZy!{^98_Ce$eqIX zmM163R)v~6H4SR$u*)N8a+k0u=yqidqt;|@>)nw@iQxn>0N|5U9@kys&D|(Y=c!Yr z;mwdXHH~FH)eGfDCrOY#0Hf4`P2yfHMTCwAWAwq=h&SH zuq<0-dW!6M+85Arwy6=gXin1HAu>M3&}(748_4iuOeEWA3`gUk#>vCHM(9`I=?Etq zyh7Lt{Iqzbz**`8IW22$gr+sq0#;hwfy^`^r|GdKtKrYmm|Nk~m_f@YNmgr~#w-vQ znk&Q!?KJYa{0V&8hqe?HR1|BpRp=DBiu1t*OBreru27kwCeXD`d`Z)+)GYX(u%m{s zj{=MJJYbkg>{P`>%SoMPgy5Ki=M0H5H8Z0^67CutA% zZ4Mob-Bk2<3;-+)2?Sem%~*Lw=}4Jd1`1$vh+6_6$Wk1@2Y|+gp>*n30C2=H5O(p_ zoEA7Sh71Z{K)Fr)%1OC$Q0_TYf&rpkt;^k~XSgf>h9%)<4Au%OU+(H2aY3^+);vmO z;8rZDXd7l>L(wPjHvf%WE`K{nZ0Cx~}CCvaZ_&dC|;*M+v z_v6j<<#PaHGfaA@5y#WOK03dIkI*yr>U8r44tH42?;iXoDu{u6B+o)9_tN0*9bKoE#=Up)-R{}kL&d1)-wfJ@3^(Gf z@N0cvL0v+nlVKC0P<7_B21i|nKcIvj*L1z+vnjj@A>>cNzc0Y6qyUdT{TvlNPA`HS zLCH{Qanu=9aTRYXvk>}riWB<;^NQgJ{GRTBzz8NRao1ugAr=@Kj>ucn?VQ3jVeDkL9AgfzS=`daI& zU2S?E8eeIRqY*QdFX*1>_n#_D-#D%QY3MF18{Rc=zbmIDg&GIPt=#{oDr*eNnLn?C zK&Q;X%*9J5PtEShio2H^9ULvchz;6YNgJv`c2ADeDUZHYfnBuMt!i#jpvY?&FJM5`6ibv52V@Z&zD^B@IL0dMtj;EyuS(&6z<2hl9tqR+ zp=fmSIubr?hi$qlj58SB4qOC6avq$L_u9MUbf$nW$&1zqPCJ3||wLs2vBaY;L;{qinu#A34>UZP88LL2Crp6lK89(q;p G*#7{k)^$_> literal 0 HcmV?d00001 diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py new file mode 100644 index 0000000..376ec39 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py @@ -0,0 +1,43 @@ +def excecEvalCommentaire(code): + + lignes = code.split("\n") + scopeCodeUser = False + + nbLigne = 0 + nbComment = 0 + longComment = False + + for ligne in lignes: + + + if ligne != "": + nbLigne += 1 + + if '//' in ligne and not longComment: + nbComment +=1 + + if '/*' in ligne: + longComment = True + + if '*/' in ligne: + longComment = False + + if longComment: + nbComment += 1 + + + print(nbLigne) + print(nbComment) + + + res = "" + if nbLigne >0: + + if (nbComment/nbLigne)*100 >= 10: + res = "ok" + else: + res = "error" + else: + res = "ok" + + return res diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py new file mode 100644 index 0000000..e8472bd --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py @@ -0,0 +1,150 @@ +import re + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + +def find_function(line): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + + blockCodes = [] + i = 0 + cptAcollade = 0 + newBlock="" + addAblock = False + + while i < len(line): + + if line[i] == "{": + + cptAcollade += 1 + newBlock += line[i] + addAblock = True + i +=1 + + while cptAcollade != 0 and newBlock != "" and i < len(line): + + if line[i] == "{": + cptAcollade += 1 + + elif line[i] == "}": + cptAcollade -= 1 + + if addAblock: + newBlock += line[i] + + if cptAcollade == 0: + + blockCodes.append(newBlock) + newBlock = "" + i +=1 + + i +=1 + + return blockCodes + + + + + + + + + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "//" in ligne: + tab_line = ligne.split("//") + code_without_comentary.append(tab_line[0]) + + elif "/*" in ligne and "*/" in ligne: + tab_line1 = ligne.split("/*") + tab_line2 = ligne.split("*/") + new_line = tab_line1[0] + tab_line2[len(tab_line2)-1] + code_without_comentary.append(new_line) + + elif "/*" in ligne: + tab_line = ligne.split("/*") + code_without_comentary.append(tab_line[0]) + long_comment = True + + elif "*/" in ligne: + tab_line = ligne.split("*/") + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = False + + + elif not long_comment: + code_without_comentary.append(ligne) + + + + return code_without_comentary + + +def excecEvalNbLigneFonction(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + long_comment = False + + lignesCompacte = "" + newBlock = [] + functionCode = "" + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + if "#include" not in ligne and "using namespace" not in ligne: + lignesCompacte +=ligne + + + listFunctionCode = find_function(lignesCompacte) + + cpt_error = 0 + for function in listFunctionCode: + function = function.replace(" ","") + cpt_ligne = function.count('\n')-1 + + + table_rm = function.split('\n') + cpt_rm = 0 + + for ligne in table_rm: + ligne = ligne.replace(" ","") + if len(ligne) ==0: + cpt_rm +=1 + + if cpt_ligne-cpt_rm > 30: + cpt_error+=1 + + return cpt_error diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py new file mode 100644 index 0000000..cada91e --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py @@ -0,0 +1,549 @@ +import re + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + +def findVariableInFuction(line): + listVariable = [] + cpt = 0 + inFunction = False + + listContentinit = [] + listVarInFunction = "" + + for signe in line: + + if signe == "(": + cpt +=1 + inFunction = True + + elif signe == ")": + cpt -=1 + + if inFunction: + if True and cpt > 0 and signe != "(": + listVarInFunction += signe + + else: + listContentinit.append(listVarInFunction) + listVarInFunction = "" + + + listContentSplit = [] + listContentSplit2 = [] + + for functionContent in listContentinit: + functionContent = functionContent.replace(',', ', ') + x = functionContent.split(", ") + + for content in x: + listContentSplit2.append(content) + if not set('~!@#$%^&*()+.{}":;\'+$').intersection(content): + + if "[" in content: + newContent = "" + id=0 + finishExtractVarFromTable = False + + while id < len(content) and not finishExtractVarFromTable: + if content[id] == "[": + finishExtractVarFromTable = True + + else: + newContent += content[id] + id +=1 + + content = newContent + + if re.search(PATERN_VARIABLE[0], content) != None or re.search(PATERN_VARIABLE[1], content) != None or re.search(PATERN_VARIABLE[2], content) != None: + + listContentSplit.append(content) + + + for varaiblePart in listContentSplit: + + if ">" in varaiblePart: + parts = varaiblePart.split(">") + parts[len(parts)-2] +=">" + else: + parts = varaiblePart.split(" ") + + i = 0 + type="" + + while i < len(parts) -1: + type = type+parts[i] + i +=1 + + type = re.sub(' ', '', type) + variable = re.sub(' ', '', parts[len(parts)-1]) + listVariable.append((type, variable)) + + + return listVariable + + + +def findVariableDeclare(ligne): + """ + :param ligne: représente une ligne de code + :return: retour le la liste des variable au seins d'une fonction + """ + + listVariable = [] + type = "" + list = [] + + if True: + i = 0 + find = False + + while i < len(ligne) and not find: + + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + typeVar = "" + listVariableTransition = [] + inTab = False + + while k > 0 and notFind: + + if ligne[k] == " ": + + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + var = "" + + if ligne[k] == "]": + inTab= True + + if ligne[k] == "/": + if len(ligne) > k+1: + if ligne[k+1] == "/" or ligne[k+1] == "*": + + notFind = False + + #Si on trouve un signe arpès avoir trouvé un séparateur ou qu'on est en train de parcourir un mot + if ligne[k] != "," and ligne[k] != " " and k != i and not inTab: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + + if ligne[k] == "[": + inTab = False + + + if not notFind: + type = "" + while k > 0 and ligne[k] != " ": + type = ligne[k]+type + k -=1 + + + for variable in listVariableTransition: + if not set('[~!@#$%^&*()+.{}":;\']+$').intersection(type) and not set('[~!@#$%^&*()+.{}":;\']+$').intersection(variable) : + type = re.sub(' ', '', type) + variable = re.sub(' ', '', variable) + typeVar = (type, variable) + + if typeVar not in listVariable: + listVariable.append(typeVar) + + k -= 1 + + elif ligne[i] == ";" and "=" not in ligne: + line="" + line = re.findall(r'\s{0,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,};', ligne) + + if line != [] and "return" not in line[0]: + + line = re.sub(';', '', line[0]) + ligneTab = line.split(" ") + + u = 0 + type = "" + var = "" + while u + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', type+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', type+">", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+type+">", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+type+"<", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+type+"<", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+type+">", line) + + ###gestion du séparateur "," + line = re.sub(r'\s{0,}'+variable+r'\s{0,},', type+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+type+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+type+"=", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+type+")", line) + + ###gestion des symbole ( ) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', type+")", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+type+",", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+type+")", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', type+"!", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', type+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', type+">", line) + + i += 1 + + return line + + + + + + +def sanitize_list(liste_variable): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + + id = 0 + for elt in liste_variable: + cpt = elt[0].count('>') + + if cpt == 0: + newElt = (elt[0] + " ", elt[1]) + elt = newElt + liste_variable[id] = newElt + + id += 1 + + return liste_variable + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "//" in ligne: + tab_line = ligne.split("//") + code_without_comentary.append(tab_line[0]) + + elif "/*" in ligne and "*/" in ligne: + tab_line1 = ligne.split("/*") + tab_line2 = ligne.split("*/") + new_line = tab_line1[0] + tab_line2[len(tab_line2)-1] + code_without_comentary.append(new_line) + + elif "/*" in ligne: + tab_line = ligne.split("/*") + code_without_comentary.append(tab_line[0]) + long_comment = True + + elif "*/" in ligne: + tab_line = ligne.split("*/") + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = False + + + elif not long_comment: + code_without_comentary.append(ligne) + + + + return code_without_comentary + + +def excecEvalRedondance(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + long_comment = False + + lignesCompacte = "" + newBlock = [] + functionCode = "" + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + if "#include" not in ligne and "using namespace" not in ligne: + + ligne = ligne.replace('\n', '') + + listeVarInitFunction = findVariableInFuction(ligne) + + if listeVarInitFunction != []: + + if listVariableRename != []: + + listFunction.append(listVariableRename) + functionCode= "" + listVariableRename=[] + listVarToRenameFunction = [] + lastListVariableRename = [] + + i = 0 + while i < len(listeVarInitFunction): + if listeVarInitFunction[i] not in listVariableRename and listeVarInitFunction[i] != "": + listVariableRename.append(listeVarInitFunction[i]) + i += 1 + + else: + listVarToRenameFunction = listeVarInitFunction + + i = 0 + while i < len(listVarToRenameFunction): + if listVarToRenameFunction[i] not in listVariableRename and listVarToRenameFunction[i] != "": + listVariableRename.append(listVarToRenameFunction[i]) + i += 1 + + + else: + listVarToRenameFunction = listeVarInitFunction + findVariableDeclare(ligne) + + i = 0 + while i < len(listVarToRenameFunction): + if listVarToRenameFunction[i] not in listVariableRename and listVarToRenameFunction[i] != "": + listVariableRename.append(listVarToRenameFunction[i]) + i += 1 + + + + lignesCompacte +=ligne + + listFunction.append(listVariableRename) + + blockCodesWithRenameVariable = [] + listFunctionCode = find_function(lignesCompacte) + + + for function in listFunctionCode: + blockCodesWithRenameVariable.append(function) + + codeRename = "" + i=0 + for elt in blockCodesWithRenameVariable: + codeRename += rename_variable(elt, listFunction[i]) + i +=1 + + blockCodes = find_block(codeRename) + + cptRedondance = 0 + + for block in blockCodes: + if blockCodes[block] > 1: + cptRedondance += blockCodes[block]-1 + + return cptRedondance + diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py new file mode 100644 index 0000000..eabd8f9 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py @@ -0,0 +1,308 @@ +import re + + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', +] + + +def findVariableInFuction(line): + listVariable = [] + cpt = 0 + inFunction = False + + listContentinit = [] + listVarInFunction = "" + + for signe in line: + + if signe == "(": + cpt +=1 + inFunction = True + + elif signe == ")": + cpt -=1 + + if inFunction: + if True and cpt > 0 and signe != "(": + listVarInFunction += signe + + else: + listContentinit.append(listVarInFunction) + listVarInFunction = "" + + + listContentSplit = [] + listContentSplit2 = [] + + for functionContent in listContentinit: + functionContent = functionContent.replace(',', ', ') + x = functionContent.split(", ") + + for content in x: + + listContentSplit2.append(content) + if not set('~!@#$%^&*()+.{}":;\'+$').intersection(content): + + if "[" in content: + newContent = "" + id=0 + finishExtractVarFromTable = False + + while id < len(content) and not finishExtractVarFromTable: + if content[id] == "[": + finishExtractVarFromTable = True + + else: + newContent += content[id] + id +=1 + + content = newContent+"[]" + + if re.search(PATERN_VARIABLE[0], content) != None or re.search(PATERN_VARIABLE[1], content) != None or re.search(PATERN_VARIABLE[2], content) != None: + + listContentSplit.append(content) + + + for varaiblePart in listContentSplit: + + if ">" in varaiblePart: + parts = varaiblePart.split(">") + parts[len(parts)-2] +=">" + else: + parts = varaiblePart.split(" ") + + i = 0 + type="" + + while i < len(parts) -1: + type = type+parts[i] + i +=1 + + type = re.sub(' ', '', type) + variable = re.sub(' ', '', parts[len(parts)-1]) + + listVariable.append(variable) + + + return listVariable + + + +def findVariableDeclare(ligne): + """ + :param ligne: représente une ligne de code + :return: retour le la liste des variable au seins d'une fonction + """ + + listVariable = [] + type = "" + list = [] + + if True: + i = 0 + find = False + + while i < len(ligne) and not find: + + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + typeVar = "" + listVariableTransition = [] + inTab = False + + while k > 0 and notFind: + + if ligne[k] == " ": + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + + var = "" + + + if ligne[k] == "[": + inTab = False + + + #Si on trouve un signe arpès avoir trouvé un séparateur ou qu'on est en train de parcourir un mot + if ligne[k] != "," and ligne[k] != " " and k != i and not inTab: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + if ligne[k] == "]": + inTab= True + + if not notFind: + type = "" + while k > 0 and ligne[k] != " ": + type = ligne[k]+type + k -=1 + + + for variable in listVariableTransition: + if not set('[~!@#$%^&*()+.{}":;\']+$').intersection(type) and not set('~!@#$%^&*()+.{}":;\'+$').intersection(variable) : + type = re.sub(' ', '', type) + variable = re.sub(' ', '', variable) + typeVar = variable + + if typeVar not in listVariable: + listVariable.append(typeVar) + + k -= 1 + + elif ligne[i] == ";" and "=" not in ligne: + line="" + line = re.findall(r'\s{0,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,};', ligne) + + if line != [] and "return" not in line[0]: + + line = re.sub(';', '', line[0]) + ligneTab = line.split(" ") + + u = 0 + type = "" + var = "" + while u + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "//" in ligne: + tab_line = ligne.split("//") + code_without_comentary.append(tab_line[0]) + + elif "/*" in ligne and "*/" in ligne: + tab_line1 = ligne.split("/*") + tab_line2 = ligne.split("*/") + new_line = tab_line1[0] + tab_line2[len(tab_line2)-1] + code_without_comentary.append(new_line) + + elif "/*" in ligne: + tab_line = ligne.split("/*") + code_without_comentary.append(tab_line[0]) + long_comment = True + + elif "*/" in ligne: + tab_line = ligne.split("*/") + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = False + + elif not long_comment: + code_without_comentary.append(ligne) + + return code_without_comentary + + +def excecEvalVariableName(code): + + lignes = code.split("\n") + scopeCodeUser = False + cpt = 0 + scopeCodeUser = False + cpt = 0 + + lignesCompacte = "" + listVariable = [] + lignes = remove_comentary(lignes) + + for ligne in lignes: + + ligne = ligne.replace('\n', '') + + variable = "" + variableDeclare = findVariableDeclare(ligne) + + for variable in variableDeclare: + if variable != "" and variable not in listVariable: + if not set('<>+-*~!@#$%^&*().{}":;\'+$').intersection(variable): + listVariable.append(variable) + + variable = "" + functionListVariable = findVariableInFuction(ligne) + + i = 0 + while i < len(functionListVariable): + if functionListVariable[i] not in listVariable and functionListVariable[i] != "": + if not set('<>+-*~!@#$%^&*().{}":;\'+$').intersection(functionListVariable[i]): + listVariable.append(functionListVariable[i]) + i += 1 + + + lignesCompacte +=ligne + + + error = 0 + for var in listVariable: + error = error + switch(var) + + + ###RESULTAT + return error + diff --git a/heroku_deploy/api/evaluation_code/cpp/main.py b/heroku_deploy/api/evaluation_code/cpp/main.py new file mode 100644 index 0000000..7b49a7b --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/main.py @@ -0,0 +1,24 @@ + +from evalNbLigneFonctionCpp import excecEvalNbLigneFonction +from evalCommentaireCpp import excecEvalCommentaire +from evalRedondanceCpp import excecEvalRedondance +from evalVariableNameCpp import excecEvalVariableName + +if __name__ == '__main__': + code= "int main() {"\ + "//COUCOU"\ + "std::cout <<\"Hello World!\";"\ + "return 0;"\ + "}" + + payload = { + "eval variable name":excecEvalVariableName(code), + "eval redondance": excecEvalRedondance(code), + "eval nb ligne fonction": excecEvalNbLigneFonction(code), + "eval commentaire": excecEvalCommentaire(code) + } + + print(payload) + + + diff --git a/heroku_deploy/api/evaluation_code/python/__pycache__/evalCommentairePy.cpython-39.pyc b/heroku_deploy/api/evaluation_code/python/__pycache__/evalCommentairePy.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..851693b572f7b6b55901ff93a5bf65b451729e8c GIT binary patch literal 670 zcmYjNy>HV%6u(c~b(^T5E(ocL!jy%90VGr*Abf09Bw(=&l6!YbLmZ!b=T;;-Pw
!k?n@0KWjP=tO5aMK8Yr{H!6f zIxuI*Ja??aOvW9qU389Re1RpOGjp_2tG?r=4D%``6PU`){zg05Z-}FxF-DMC$da`& z?4dB>yJL>tMRIEo$#l-mH@V%$CqLy*8^a{1T@1JD9eSL;TEj(t4u`|H zYYAu_o-HGKzPeKvc2HQWRs*R9LN6AoYKoarc0@h5bvbK17y7hJ)i2MAGHlB0WpfNYs>9c3o-FUzOTVW+2_-IDuchz?_8|mB zQp^a$@R5Whc;kJX0vnN_r9AMU<6U3^XKurvha=qO?z}g`Ezo>&u+Z|fR8PXDKj7#; DJWHjF literal 0 HcmV?d00001 diff --git a/heroku_deploy/api/evaluation_code/python/__pycache__/evalNbLigneFonctionPy.cpython-39.pyc b/heroku_deploy/api/evaluation_code/python/__pycache__/evalNbLigneFonctionPy.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4e619b0634a125b354c9c6a55aff9538adcc95a5 GIT binary patch literal 2160 zcmZvdOK;mo5XX0yq(sZKtT?Id1VurlDNtQ}ZDANjQ?~|+riPI|4ul(l=B^yZ6e%w$ zyDF$l(o@l6KY)EH>T5qj{VjNGd-0{m6v(OnS;~&`ps7oNtk^Egip}&d*~#SJYfNoLRvqufJ<9C7=>)eCPqv0uUXfW68VjB}-H53P!kPGMVQ7|AgA zW!&#yoNGAd{(h20hxtsbFfIIO8tub=mPSRKrT)p|7+dr+?Zk0-A3im3G$$2cHhE_=M|4DH&rK}()$E+ zp_KQ{Vr7%*Iny^N)|XrBd*9-0`Cb$jS-Q77jvj}4u&c8tDk}25`^iD}`Ei&~$i3mX zcnli_d1wDYe2}W`>2Y?)Yr}E1(2rBu>yPRq(ise3tYLHW6D~$ibhyVm^n={uw(y|S zH(~t-T|}6n>p3Q%h=VX;sQL$liPAb|dZ)Bbapz}zVoR&ErG1+nbG=#5q_x6mw!umP zKFlgHa^%5FNau{pMokf7KmxPIrnC#hdd6jQ6(p{(2?&KhEXY?nX6HZ5&b8Mo(M#?j z6Rz$4dfjd|HbuO$FL~~neGJEVM?sl4`VWVnp%t*^h3XxLIu7@f*Rc)jWgi6iS0(^- zWN4lxm~g*B`0Y+1vf=mK50A50`{9#pR9u|y1PMzv!|hekql=7E=F=|L~b1_R_~uuK`mCj?p2^okhi&6 z;ma5)1@s+wyn;LNe~tT}5U7|E?r0VoiYXA~K-58jYoIlub!pLT z+n#u(dn!uLAiD|VT&yifd(ti!u>NSWhrJ(iKOqQiSSUR;Xnn;NthQ8 z-qagU*qVB%SFuH~kVn~2QE8(R7|i!$ofluEm={62CTJ@g0QN%ZMRM@2Y8&|ki__h| z$?C23Z4-3XCJ*MKVbN1sXF71NR%+!-=n~b_gP=i{dhj}OchnD&il_#^QF9++zx-o# z3{Vk%HsGtrS_X6i09v-et|d@yxr^%S8Aw}}HkV*mLaX}An~Naj%v;d^gf{fM8-q-a R617QxOF7Z%TJ8sK_kSMgEam_J literal 0 HcmV?d00001 diff --git a/heroku_deploy/api/evaluation_code/python/__pycache__/evalRedondancePy.cpython-39.pyc b/heroku_deploy/api/evaluation_code/python/__pycache__/evalRedondancePy.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..664c41502a76273786fbb63aa779d4f0c22ba2cd GIT binary patch literal 6787 zcmb7IO>7&-72erhE|))&Wl5G~)o~fwiA`G)lC(`4#}VQ`wJuV@aNM+@We97|%3(w; zrP-AdF+-z(dn$?`1#&1*ps))Ruz?MGuJ!=+O3iZ%B%y zl>jBNJ3sHuo7s7P-%Kzxl(+DElB))P`i^D&of^GA8;v*c#C5!+B}Lt;Shp-`|5j9l zbfo(;t76NH^iVo7D}9u%%*i~;j4a3^N>2{SVU$^UK#rjF{BqvZ7 zdUbB4t+*~D?YrZh|>dK7|UYu<$$Mk->_f&J?>CO*cm~EXM z>|THf^bdA7pJM!~srFkyb8b-HSB}QquQgwNn*G#M3&2WG_3`o0*ZaD@W=o!0Ck?L( z+S>NdL+RkTfG7SvUbn24kfLQvyX9!>t|gs&LfUJtx-Z?9izlO}XhvySBFP2?1+s zwJ9d0_)aaWwY_L!QxVs=-QcSWh}q?u}CD@szQ z9!9AbY;1&)EPJV2uSH>6tk>e??LgInoAogDw>vdaOEYm2C=3Jp151sP(8UX9mVXq7 zDqgMzNh4amvQvF0Q0rGz`D%*J@=qFKS!*WI~(cGDlzhk*$j0$niJfd+_~vo$q`* zQMF5N)1&h;KWVMG9|?6Ev*gWJc3KiMqNlKCcYBK5Gt|?A@q42%Yfk4NAI^at$+rr+ zK>J8NkY8X<2h#qay^lov8GT(eOLg@beHR{2^X^iQ_O;j+ToQRBWVToqf%`#z^!S5j);;F|5`D6@D9p_f|H7U~i#*Q+G;+8-7F{gg=b{)fMAn6dpIqf7kZ7KW`5UPk5$fkBdB{7G218 zRS9!fX>&S1s=IhNkj|n4oe22dv_`PZkY$Kh;GAbI4soDLQ4{1btQUKUx4$e>Z)-ya zNm#a1KMLPFUvE^`()>*-D6GVTyHhmmE6njrOdFFzE#Zq%XV_N9QSS>8q}gtW_z4<_ zvO0AM)fs5jb;j`aDT&(>$GzAL(2-Z&I+!9p>!% zbu*~H8opKmatfHEsEY``4*HAT`99SdT|hw0ARuND;&SZrxy=Zn*3lU%-&XDV_pD9t6JX2EPhI;rQh62J;JuFpWh^2>jOFca;L1LG1~Xxt+!h>}vZE$!rLBjPMrdheYYrdVyLQf;*~ zKVN3y#*)azj5$4r+T!E?;&;vXjhkk%$a+x4YKV*UZ-UiO>e6~EIZE~HP8_i+5I$(uc{Xbv@kb1fFXCloI2yHMl26gb9)^*_#BJ9hn(vI*6zPhdPrbr*VEit{ zvZ6DLp1h+d_Vk%PnSIyge}zWZ^a1fWhwdSQkK5T0u1?vIb0MJva(2p#w)8m5QEu;T z`vYwPY_|c{D2w0boDUcYNJpR&u#yl5f(o#R^ibOE?37o8fA*BU_?RMUDkLj86=5n? zjR71+e>uadVAZfr)eLdx0x8e&z7B3VXQh?ZEn{i_0dri!%ktX0ZWn29#R&Z=s34>i z5n9ws;OW~@f|%V{{{k8elmV0P*}^hTE-4huBFYmyrm%TZX5IpF!eg1>$cdLtn#8H+ z@w&EHM#QBS88Lz+MaRLfI6#KAQj1rrjrDby>NJMO#BXudqr9iSg;rm7qRA-9oA3u~ zK&V52NASYhDR`l6a9T#Y0QN6wPrA^Ir!z8xGP60Q#YJGM8=tna2_U-kG=M&VeP|iz zNIPidP+Iq#7WSaa0aVn(fk4&6QDhlFQe+bY41jxc3vAIdXKIl2$!n@lP7QJ&>hfFeu0 zihk-0Qz20vW$J!XkFnI_eNvy}aiGZKJZ?WK_M}bi-xo9X`7ZTDpJcNyphDmMl#|^# z%lph}s3g@;`^Oror&#LgedhcB_S8t5WodIAX`3%=^2zx&V0i|9(u0jDd^SCEW6;c- za{2V~X?2JQ_URY9opZ}`O?&P|X2zksnKjIFyJD{CcLwf?)7{3YRGjKImYcqowe6Y= zb!X)3AYO0J+!1hNS6tr}H@d^-Q!(FdTI=JKp_y&pc{HA+0DPsoYtduaD*l`>&B8$Lk; z*-ro!;kpUn{~tg_wsvrKTVk!^GK$XQ8kb*(t!<$eOid!=QSB_y3~oP|N*HIeh*3Bm z;o6LjML%a5Xc1s13EE8{3rC3T6i$Vc$gMn{f%;}q;))A1f6_CmPr4RGI*fJr9u4yK z$~LD>hLQIpgp(}#XC@kYItFrHR9>SuW3 zr5;}c#JEOlM7KJ4B%L6YDdwLE%lS&CPQXE-Wu>smup6`eBd8Z z;d)~`+#7kDv^oza#>edgA8?vIg7bM^OhLzl)(HPnIl++tdSAkbKD|$%qpSBBNF^jp zddK77aSe`xt}?(zbYql7ua74OoSa8lfNy7jmohp7OS#=D;wV+TBjN=d$cC`@sJDi} zcR=F}?Z2D2+;>2u2f8lco@YdlBsjA11?nfdphsX6Htg!YsRKDWsM~iv(`GG>FbW&l z+{RJV(?e`$3rUuaqOF6NZ&V+|dd6F0di1WB_oG?6F7A*(HLWSa=7%=X0~_&{*fJJPM#P@At)ieP^70-t+~nIxz7{bj zFuEz?vj_)O_Q5o>p=wc5o=~SjG?%Z7Z8Walpsoozl)c$=Cu?#>_ny|ofXl=>6jvJ? zA>E14m26sAttmRsp`N6}#x5^3){#q+(3}g39pF!6Qsf@K`MuU?rzNt^iq8YjAldvSvcwvOj0{WA_^u+nUyZ0M_r=sAzX3n-2)GXv9a*|YFMSa z<2|0=k=6eIV@-CWJE}ZoIL>lZ(y4Io+Jjnj9Wn(!z-iF+abBcLAe7+pouU}E6)gffSa_5tMfU70CO=t z-PKjq(_LSET};NtA_sr}t#^|DyzV$((ct8t#Ncf_`4u$EQKILpI7%w_kIsrvp7QaQ zDo{1NT@|W2-kyq718-k7)fnD^5;vT7>jgYGOC3S4;a`Bai{~1i{3)7sXCRaqNF@iZ zbsjm&JrGK6dgh7p1|A;Yx`nXLzSwlk6YE%a)=~bZG>a-2c-B?5X$O{`d1(Fo;c!0O zbj|OF{rZW1g#JS-tC^oT1DQ@?Bz6U);*qrSKnU!3Fw{_Wtn*i_gKtnZ=)2obIM z9;6<=IQ*$IsBK@jQiTM!?I~5~(~#yoH0r!h>=7pu+34t0FpE8+tt2*5(X_*R|1(yJ zs$JtGc%-l*Bn>{fO44M>*a->jkFBt3-PYm%44-Q>XxIjyEhO;YU`<5Dd|?B`=4;wr zI!}G`HSG&eVEMF3Qk@?6j!qo9(v0&S#w(B2xnLbSk;VhD{RwtOXA+@5&q>uVj&Y!LyTbvo`+uCP2(2?F!L=mFG!~pX_9`lZ<7e5{(+ z$n|S9Im)GXb*GmYO-Yo0ga(-;ku7K^kvVvyN9{Q0&v=zdB$3>AV`LZ2w_M6D{CGq* zlVSq-IKe+p1}u+cO9UdQMpz+&S7a-G<}B7em6vpSM|t@<2B0`lD##Xuhn(}wXNajp zoLxes6-R{o8KNhE2O``*S)qbyXE-N#T$`bs_0Wf&!U(z{>++aUM07`NAm&+zv*sVr_EOKv8|)P_vHe};f{2?-3>Y(oO)+K`D`zo`3`z*-wVV~ZOSuv#$`-_M~{N*$(9>%fX$n*ITa?tGeMs3#$TXQr9Y9PqHu`=(B`I_ z{kV{iTqO&yn%@`GxHYFScOaERx?PFzibtR&=vU{Zl)nT&9P2SfWEf#3h0I_Fd=p=YXHI?yh5gXx$2&0HXwr0}`_iQTcWgGXN@J zOOQ-i4C9_8|HB5O7=M?EY_?*$^z|K(3Saw|W25`#`Qu!tg^qhkH61IR$0L)y*dwq=s zY4OpLm*Qpcp)N?Qx@&9C9~+%^y4u7&d>9$z@h_9Ybm0hEovhbG4FdAKGL$axx1uC^ zg8_EWotvBE)MEs;Jrp?oUbkSjK2AkcMgjA7j@l?o*Y9+)tt}i(IYryQ1K@378zhA= zF?)tmw+xHqgF9SMg{i*Fy;re0ZuC~RtB)=J4#O%_eagm=OPX3*&eOl^>I-01i>RRz(g_?SU%AK2fazy1y9spfrCU2%!rVSVA8c zX@I%;LCprr0|_pmyzo$uE)>Y!edMsM9f*9vdXEC?0bL8Qt`#-54ndW;%8Ss3Tp#}v zmvMd8VGmD_Jg^L2p0bzW2*|$-i*H@{-S^&p{-~onRI-np9GB={LY4pZa)!l2g;7Ex zP>E8ZC7K@fflU0UFo;HS7jpc@J#!Ua+BI{Y*5yN>nt*Q{J_J5NRyy%%{E_^9;gzjS Z?ez2l{ZEtA^%#2Lx$rk(J8XvM{tpA#Nag?l literal 0 HcmV?d00001 diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py b/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py new file mode 100644 index 0000000..b97ae45 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py @@ -0,0 +1,46 @@ +def excecEvalCommentaire(code): + + lignes = code.split("\n") + scopeCodeUser = False + + nbligne = 0 + nbligneComment = 0 + longComment = False + + for ligne in lignes: + + if ligne != "": + nbligne += 1 + + if '#' in ligne: + nbligneComment +=1 + + if '"""' in ligne: + if ligne.count('"""') > 1: + nbligneComment +=1 + else: + if longComment: + longComment = False + else: + longComment = True + + if longComment: + nbligneComment +=1 + + + + + print(nbligne) + print(nbligneComment) + + res = "" + + if nbligne >0: + if (nbligneComment/nbligne)*100 >= 10: + res = "ok" + else: + res = "pas assez de commentaires" + else: + res = "ok" + + return res diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py new file mode 100644 index 0000000..2ea21e6 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py @@ -0,0 +1,125 @@ +import re + + +def find_function(lines): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + + blockCodes = [] + i = 0 + newBlock="" + addAblock = False + + for line in lines: + i = 0 + while i < len(line): + + if len(line)>i+4: + if line[i] == "d": + if line[i+1] == "e": + if line[i + 2] == "f": + if line[i + 3] == " ": + + if newBlock != "": + blockCodes.append(newBlock) + newBlock="" + + newBlock += line[i] + i +=1 + + return blockCodes + + + + + + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "#" in ligne: + tab_line = ligne.split("#") + + if "\n" not in tab_line[0]: + tab_line[0] = tab_line[0] + "\n" + + code_without_comentary.append(tab_line[0]) + + elif ligne.count("\"\"\"") == 2: + tab_line = ligne.split("\"\"\"") + new_line = tab_line[0] + tab_line[len(tab_line)-1] + code_without_comentary.append(new_line) + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[0]) + long_comment = not long_comment + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = not long_comment + + elif not long_comment: + code_without_comentary.append(ligne) + + return code_without_comentary + + + + +def excecEvalNbLigneFonctionPy(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + + lignesCompacte = [] + newBlock = [] + functionCode = "" + listVarToRename = [] + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + lignesCompacte.append(ligne) + + functionCodes = find_function(lignesCompacte) + + + cpt_error = 0 + for function in functionCodes: + + cpt_ligne = 0 + cpt_ligne = function.count("\n") + + table_rm = function.split('\n') + cpt_rm = 0 + for ligne in table_rm: + ligne = ligne.replace(" ", "") + if len(ligne) == 0: + cpt_rm += 1 + + if cpt_ligne-cpt_rm > 30: + cpt_error +=1 + + + return cpt_error diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py b/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py new file mode 100644 index 0000000..9ac9e1b --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py @@ -0,0 +1,485 @@ +import re + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + +def findVariableInFuction(line): + listVariable = [] + variable = "" + + i = 0 + if line.count('def') > 0: + start = False + end = False + + while i < len(line): + + if line[i] == "(": + start = True + i=i+1 + + + if start and not end: + + if line[i] != "," and line[i] != ")": + + if line[i] != " ": + variable += line[i] + + else: + listVariable.append(variable) + variable = "" + + if line[i] == ")": + end = True + + i +=1 + + return listVariable + + + + +def findVariableDeclare(ligne): + listVariable = [] + + if "=" in ligne: + i = 0 + find = False + + while i < len(ligne) and not find: + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + while k > 0 and notFind: + + if ligne[k] == " ": + permissionParcourtWord = False + + if var != "": + listVariable.append(var) + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "": + listVariable.append(var) + var = "" + + + if ligne[k] != "," and ligne[k] != " " and k != i: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + k -= 1 + + i += 1 + + if " in " in ligne: + findIn = False + notFind = True + permissionParcourtWord = False + + p = 0 + while p < len(ligne) and notFind: + if len(ligne) > p + 3: + if ligne[p] == " ": + if ligne[p+1] == "i": + if ligne[p + 2] == "n": + if ligne[p + 3] == " ": + findIn = True + + if findIn: + var = "" + m=p + while m > 0: + + if ligne[m] != " ": + if not permissionParcourtWord: + permissionParcourtWord = True + + elif permissionParcourtWord: + notFind = False + permissionParcourtWord = False + + if var != "" and var not in listVariable: + listVariable.append(var) + + if permissionParcourtWord and notFind: + var = ligne[m]+var + + + + m -=1 + + p +=1 + + + + return listVariable + + +def update_block(newBlock, blockCodes): + if newBlock in blockCodes: + blockCodes[newBlock] += 1 + + else: + blockCodes.update({newBlock: 1}) + + return blockCodes + + +def find_indentation(line): + + cpt = 0 + while cpt < len(line): + + symbole = line[cpt] + + if symbole == " ": + cpt +=1 + + elif symbole == "": + return 0 + + elif symbole == "\n": + return 0 + + elif symbole == "#": + return 0 + + else: + return cpt + + + return cpt + + +def find_block(code): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + listBlock = [] + i = 0 + lastIndentationValue=0 + currentIndentationValue = 0 + blockCodes = "" + save=0 + + for line in code: + + sanitize_line = line.replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") + + if len(sanitize_line) > 0: + + lastIndentationValue = save + currentIndentationValue = find_indentation(line) + + if currentIndentationValue > lastIndentationValue : + + k=i + + + blockCreate = False + blockCodes = "" + save = find_indentation(line) + # print("START") + + while not blockCreate and k < len(code): + + sanitize_line = code[k].replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") + + if len(sanitize_line) > 0: + # print(code[k]) + # print(len(sanitize_line)) + + # print("next") + + linebis = code[k] + newVal = find_indentation(linebis) + + if newVal != -1: + currentIndentationValue = newVal + + + if currentIndentationValue > lastIndentationValue: + blockCodes = blockCodes+linebis + + + else: + blockCreate = True + + k +=1 + + listBlock.append(blockCodes) + + else: + if find_indentation(line) != -1: + save = find_indentation(line) + + i +=1 + + + return listBlock + + + + +def find_function(line): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + + blockCodes = [] + i = 0 + newBlock="" + addAblock = False + + while i < len(line): + + if len(line)>i+4: + if line[i] == "d": + if line[i+1] == "e": + if line[i + 1] == "f": + if line[i + 1] == " ": + + if newBlock != "": + blockCodes.append(newBlock) + newBlock="" + + newBlock += line[i] + i +=1 + + return blockCodes + +def line_is_comment(line): + line.replace(" ","") + + if len(line)>0: + if line[0] == "#": + return True + else: + return False + + + + + +def rename_variable(line, listVariableRename): + + i = 0 + var = "var" + lineIndentation = find_indentation(line) + + a = 0 + espace = "" + while a < lineIndentation: + espace += " " + a +=1 + + for variable in listVariableRename: + + ###gestion var++ et var-- + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) + + line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) + + ###gestion de opérateur mathématique + line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) + + ###gestion des symbile [] + line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) + + ###gestion de symbole ; + # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) + + ###gestion de symbole . + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) + + ###gestion de symbole [ + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) + # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) + + ###gestion des symboles < > + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) + # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) + # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) + + ###gestion du séparateur "," + line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) + + ###gestion des symbole ( ) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) + + line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) + + + return line + + + +def sanitize_dict_(dict): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + + sanitize_dict = {} + + for block in dict: + # print(block) + sanitizeBlock = block.replace('\n', ';@;') + sanitizeBlock = sanitizeBlock.replace(' ', '') + sanitize_dict = update_block(sanitizeBlock, sanitize_dict) + + return sanitize_dict + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "#" in ligne: + tab_line = ligne.split("#") + + if "\n" not in tab_line[0]: + tab_line[0] = tab_line[0] + "\n" + + code_without_comentary.append(tab_line[0]) + + elif ligne.count("\"\"\"") == 2: + tab_line = ligne.split("\"\"\"") + new_line = tab_line[0] + tab_line[len(tab_line)-1] + code_without_comentary.append(new_line) + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[0]) + long_comment = not long_comment + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = not long_comment + + elif not long_comment: + code_without_comentary.append(ligne) + + return code_without_comentary + + +def excecEvalRedondance(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + + lignesCompacte = [] + newBlock = [] + functionCode = "" + listVarToRename = [] + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + if not line_is_comment(ligne): + ligneBis = ligne + + listeVarInitFunction = findVariableInFuction(ligne) + listeVarContentFunction = [] + + if listeVarInitFunction == []: + listeVarContentFunction = findVariableDeclare(ligne) + + listVarToRename = listeVarContentFunction + listeVarInitFunction + + i = 0 + while i < len(listVarToRename): + + if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": + listVariableRename.append(listVarToRename[i]) + i += 1 + + lignesCompacte.append(ligneBis) + + + + blockCodes = find_block(lignesCompacte) + + + renameBlock = [] + for block in blockCodes: + renameBlock.append(rename_variable(block, listVariableRename)) + + + sanitize_dict = sanitize_dict_(renameBlock) + + + cptRedondance = 0 + + for block in sanitize_dict: + print(block) + + + if sanitize_dict[block] > 1: + cptRedondance += sanitize_dict[block]-1 + + return cptRedondance + diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py b/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py new file mode 100644 index 0000000..16aab91 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py @@ -0,0 +1,268 @@ +import re + + + +def findVariableInFuction(line): + listVariable = [] + variable = "" + + i = 0 + if line.count('def') > 0: + start = False + end = False + + while i < len(line): + + if line[i] == "(": + start = True + i=i+1 + + + if start and not end: + + if line[i] != "," and line[i] != ")": + + if line[i] != " ": + variable += line[i] + + elif variable not in listVariable: + listVariable.append(variable) + variable = "" + + if line[i] == ")": + end = True + + i +=1 + + return listVariable + + + + +def findVariableDeclare(ligne): + listVariable = [] + + if "=" in ligne: + i = 0 + find = False + + while i < len(ligne) and not find: + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + while k > 0 and notFind: + + if ligne[k] == " ": + permissionParcourtWord = False + + if var != "" and var not in listVariable: + listVariable.append(var) + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "" and var not in listVariable: + listVariable.append(var) + var = "" + + + if ligne[k] != "," and ligne[k] != " " and k != i: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + k -= 1 + + i += 1 + + if " in " in ligne: + findIn = False + notFind = True + permissionParcourtWord = False + + p = 0 + while p < len(ligne) and notFind: + if len(ligne) > p + 3: + if ligne[p] == " ": + if ligne[p+1] == "i": + if ligne[p + 2] == "n": + if ligne[p + 3] == " ": + findIn = True + + if findIn: + var = "" + m=p + while m > 0: + + if ligne[m] != " ": + if not permissionParcourtWord: + permissionParcourtWord = True + + elif permissionParcourtWord: + notFind = False + permissionParcourtWord = False + + if var != "" and var not in listVariable: + listVariable.append(var) + + if permissionParcourtWord and notFind: + var = ligne[m]+var + + m -=1 + + p +=1 + + return listVariable + +def findVariableFromList(line): + + i = 0 + if line.count(' in ') > 0: + variable = "" + find = False + findSpace = False + + while i < len(line): + + if line[i] == "i" and i+4 <= len(line): + + if i-1 > 0: + + if line[i-1] == " ": + + if line[i+1] == "n" and line[i+2] == " ": + find = True + + if not find: + + if line[i] != " ": + + if findSpace: + findSpace = False + variable = "" + + variable += ligne[i] + + else: + findSpace = True + + else: + return variable + + i +=1 + + return "" + + + +def switch(variable): + switcher = { + len(variable) == 1: 1, #teste si une varaible contient plus d'une lettre + variable.lower() != variable and re.search(r'[A-Z]{' + str(len(variable)) + ',}',variable) == None : 1, #teste si une varaible commence par une majuscule + + } + + return switcher.get(True, 0) + + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "#" in ligne: + tab_line = ligne.split("#") + code_without_comentary.append(tab_line[0]) + + elif ligne.count("\"\"\"") == 2: + tab_line = ligne.split("\"\"\"") + new_line = tab_line[0] + tab_line[len(tab_line)-1] + code_without_comentary.append(new_line) + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[0]) + long_comment = not long_comment + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = not long_comment + + elif not long_comment: + code_without_comentary.append(ligne) + + return code_without_comentary + + + + +def excecEvalVariableNamePython(code): + + lignes = code.split("\n") + scopeCodeUser = False + cpt = 0 + + listVariable = [] + + lignes = remove_comentary(lignes) + + for ligne in lignes: + print(ligne) + + variables = "" + variables = findVariableDeclare(ligne) + + for variable in variables: + + if variables != "" and variable not in listVariable: + if not set('[=<>+-*~!@#$%^&*().{}":;\']+$').intersection(variable): + listVariable.append(variable) + + + + variable = "" + functionListVariable = findVariableInFuction(ligne) + + i = 0 + while i < len(functionListVariable): + if functionListVariable[i] not in listVariable: + if not set('[=<>+-*~!@#$%^&*().{}":;\']+$').intersection(functionListVariable[i]): + listVariable.append(functionListVariable[i]) + i +=1 + + variableFromList = findVariableFromList(ligne) + + if variableFromList != "" and variableFromList not in listVariable: + if not set('[=~!@#$%^&*()+.{}":;\']+$').intersection(variableFromList): + listVariable.append(variableFromList) + + + error = 0 + print(listVariable) + for var in listVariable: + error = error + switch(var) + + + ###RESULTAT + return error diff --git a/heroku_deploy/api/evaluation_code/python/main.py b/heroku_deploy/api/evaluation_code/python/main.py new file mode 100644 index 0000000..c5040ab --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/main.py @@ -0,0 +1,25 @@ + +from evalNbLigneFonctionPy import excecEvalNbLigneFonctionPy +from evalCommentairePy import excecEvalCommentaire +from evalRedondancePy import excecEvalRedondance +from evalVariableNamePython import excecEvalVariableNamePython + + + +if __name__ == '__main__': + code="def excecEvalRedondance(code)" \ + " Aa = 0" \ + "def excecEvalRedondance(code)" \ + " Aa = 0" + + payload = { + "eval variable name":excecEvalVariableNamePython(code), + "eval redondance": excecEvalRedondance(code), + "eval nb ligne fonction": excecEvalNbLigneFonctionPy(code), + "eval commentaire": excecEvalCommentaire(code) + } + + print(payload) + + + diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 91783b5..29a4be1 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -38,6 +38,14 @@ export class AttemptsService { execBootstrap, ); + + const execResultsAlgoEvaluation = await this.execServerService.executeAlgoEvaluation( + insertAttemptDTO.code, + execBootstrap, + ); + + console.log(execResultsAlgoEvaluation) + const attempt = ( await new this.attemptModel({ ...execResults, diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 1522906..e9f04be 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -10,6 +10,8 @@ import { ChallengesService } from 'src/challenges/challenges.service'; import { Language } from 'src/languages/language.schema'; const LIBS_DIR = process.env.LIBS_DIR || '/usr/src/app/libs'; +const ALGO_DIR = process.env.ALGO_DIR || '/usr/src/app/evaluation_code'; + @Injectable() export class GodBoxRepository { constructor( @@ -75,6 +77,40 @@ export class GodBoxRepository { return zip.toBuffer().toString('base64'); } + + + private async bundleExecEvaluationCode( + code: string, + language: Language + ) { + const zip = new AdmZip(); + + const main_algo = + "from evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ + "from evalCommentaireCpp import excecEvalCommentaire \n"+ + "from evalRedondanceCpp import excecEvalRedondance \n"+ + "from evalVariableNameCpp import excecEvalVariableName \n"+ + "if __name__ == '__main__': \n"+ + " code="+code+" \n"+ + " payload = { \n"+ + " \"eval_variable_name\":excecEvalVariableName(code), \n"+ + " \"eval_redondance\": excecEvalRedondance(code), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(code), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(code) \n"+ + " } \n"+ + " print(payload) \n" + + + zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); + + zip.addFile(`main.py`, Buffer.from(main_algo)); + + + return zip.toBuffer().toString('base64'); + } + + + formatPhasesResults(phases: GodboxPhaseOutputDTO[]): GodboxPhaseOutputDTO { const res = phases[phases.length - 1]; return { @@ -108,4 +144,30 @@ export class GodBoxRepository { ); } } + + + async executeAlgoEvaluation( + code: string, + bootstrap: ExecBootstrap, + ): Promise { + const language = await this.languagesService.findByName("python"); + + + const payload = { + phases: language.phases, + files: await this.bundleExecEvaluationCode(code, language), + }; + + try { + const { data }: { data: { phases: GodboxPhaseOutputDTO[] } } = + await axios.post(`${godboxConfig.baseUrl}/run`, payload); + return this.formatPhasesResults(data.phases); + } catch (err) { + throw new InternalServerErrorException( + err?.response?.data?.message || err?.message || 'Unkown reason.', + ); + } + } + + } From 634e76b375d4d2f83ea51c25327d71feacc0e220 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 19:39:17 +0200 Subject: [PATCH 083/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index e9f04be..83720b8 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -91,7 +91,7 @@ export class GodBoxRepository { "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " code="+code+" \n"+ + " code=\""+code+"\" \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(code), \n"+ " \"eval_redondance\": excecEvalRedondance(code), \n"+ From 0ae6e8c9aaa37dbb6a3cb60880b2c11e30643633 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 19:45:21 +0200 Subject: [PATCH 084/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 83720b8..3409de8 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -100,6 +100,7 @@ export class GodBoxRepository { " } \n"+ " print(payload) \n" + console.log(main_algo) zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); From cc7d414d9127dd8402cfdca8f41812feddbbe669 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 19:51:23 +0200 Subject: [PATCH 085/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 3409de8..2bb289d 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -91,12 +91,11 @@ export class GodBoxRepository { "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " code=\""+code+"\" \n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(code), \n"+ - " \"eval_redondance\": excecEvalRedondance(code), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(code), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(code) \n"+ + " \"eval_variable_name\":excecEvalVariableName("+code+"), \n"+ + " \"eval_redondance\": excecEvalRedondance("+code+"), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction("+code+"), \n"+ + " \"eval_commentaire\": excecEvalCommentaire("+code+") \n"+ " } \n"+ " print(payload) \n" From 796d92b9bc54b3df5f27bf888ade269b50dee0b6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 19:58:56 +0200 Subject: [PATCH 086/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 2bb289d..4360f1b 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -92,12 +92,12 @@ export class GodBoxRepository { "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName("+code+"), \n"+ - " \"eval_redondance\": excecEvalRedondance("+code+"), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction("+code+"), \n"+ - " \"eval_commentaire\": excecEvalCommentaire("+code+") \n"+ + " \"eval_variable_name\":excecEvalVariableName(\""+code+"\"), \n"+ + " \"eval_redondance\": excecEvalRedondance(\""+code+"\"), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\""+code+"\"), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(\""+code+"\") \n"+ " } \n"+ - " print(payload) \n" + " print(payload) \n" console.log(main_algo) From 03ad59198d61f55b5f89db0aa8c2f8a128d7be2c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 20:00:42 +0200 Subject: [PATCH 087/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 4360f1b..51ef122 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -99,7 +99,7 @@ export class GodBoxRepository { " } \n"+ " print(payload) \n" - console.log(main_algo) + console.log(main_algo) zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); From 90815936012c4fc307337019bb7b337e1ce2d1fa Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:13:56 +0200 Subject: [PATCH 088/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 51ef122..93e36bf 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -92,10 +92,10 @@ export class GodBoxRepository { "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(\""+code+"\"), \n"+ - " \"eval_redondance\": excecEvalRedondance(\""+code+"\"), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\""+code+"\"), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(\""+code+"\") \n"+ + " \"eval_variable_name\":excecEvalVariableName(\'"+code+"\'), \n"+ + " \"eval_redondance\": excecEvalRedondance(\'"+code+"\'), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\'"+code+"\'), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(\'"+code+"\') \n"+ " } \n"+ " print(payload) \n" From 3b594acc4d038e9773df79bf31fe54fdfbc034c0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:22:31 +0200 Subject: [PATCH 089/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 93e36bf..1b717a3 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -83,7 +83,7 @@ export class GodBoxRepository { code: string, language: Language ) { - const zip = new AdmZip(); + const zip = new AdmZip(); const main_algo = "from evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ @@ -92,10 +92,10 @@ export class GodBoxRepository { "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(\'"+code+"\'), \n"+ - " \"eval_redondance\": excecEvalRedondance(\'"+code+"\'), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\'"+code+"\'), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(\'"+code+"\') \n"+ + " \"eval_variable_name\":excecEvalVariableName(\`"+code+"\`), \n"+ + " \"eval_redondance\": excecEvalRedondance(\`"+code+"\`), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\`"+code+"\`), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(\`"+code+"\`) \n"+ " } \n"+ " print(payload) \n" From 5b24252a2ca8b8f0476f5e12469877ddb881bfdb Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:29:10 +0200 Subject: [PATCH 090/207] update algo eval code --- .../api/src/exec-server/godbox.repository.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 1b717a3..ea48f89 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -85,17 +85,17 @@ export class GodBoxRepository { ) { const zip = new AdmZip(); - const main_algo = - "from evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ + const main_algo ="from evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ "from evalCommentaireCpp import excecEvalCommentaire \n"+ "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ + " code=str("+code+")\n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(\`"+code+"\`), \n"+ - " \"eval_redondance\": excecEvalRedondance(\`"+code+"\`), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(\`"+code+"\`), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(\`"+code+"\`) \n"+ + " \"eval_variable_name\":excecEvalVariableName(code), \n"+ + " \"eval_redondance\": excecEvalRedondance(code), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(code), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(code) \n"+ " } \n"+ " print(payload) \n" From d9d15ca818381e6dec9c47984d32c93bde42706f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:33:35 +0200 Subject: [PATCH 091/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index ea48f89..156d274 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,7 +90,7 @@ export class GodBoxRepository { "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " code=str("+code+")\n"+ + " code=\'"+code+"\' \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(code), \n"+ " \"eval_redondance\": excecEvalRedondance(code), \n"+ From 1f8badf8bdc3ae0fe5214c00e7c8a6e4994f172d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:37:50 +0200 Subject: [PATCH 092/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 156d274..44eae03 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,7 +90,7 @@ export class GodBoxRepository { "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " code=\'"+code+"\' \n"+ + " code=\""+code+"\" \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(code), \n"+ " \"eval_redondance\": excecEvalRedondance(code), \n"+ From 500b43203a61d6a8f21c6e4a018dc06baf6c4e23 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 22:51:13 +0200 Subject: [PATCH 093/207] update algo eval code --- .../evaluation_code/cpp/evalCommentaireCpp.py | 11 +++----- .../cpp/evalNbLigneFonctionCpp.py | 9 ++++--- .../evaluation_code/cpp/evalRedondanceCpp.py | 9 ++++--- .../cpp/evalVariableNameCpp.py | 7 ++++-- heroku_deploy/api/evaluation_code/cpp/main.py | 24 ------------------ .../python/evalCommentairePy.py | 11 +++----- .../python/evalNbLigneFonctionPy.py | 7 +++--- .../python/evalRedondancePy.py | 8 +++--- .../python/evalVariableNamePython.py | 6 +++-- .../api/evaluation_code/python/main.py | 25 ------------------- .../api/src/exec-server/godbox.repository.ts | 10 ++++---- 11 files changed, 41 insertions(+), 86 deletions(-) delete mode 100644 heroku_deploy/api/evaluation_code/cpp/main.py delete mode 100644 heroku_deploy/api/evaluation_code/python/main.py diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py index 376ec39..a20e2a5 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py @@ -1,6 +1,7 @@ -def excecEvalCommentaire(code): +def excecEvalCommentaire(): - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False nbLigne = 0 @@ -26,10 +27,6 @@ def excecEvalCommentaire(code): nbComment += 1 - print(nbLigne) - print(nbComment) - - res = "" if nbLigne >0: @@ -39,5 +36,5 @@ def excecEvalCommentaire(code): res = "error" else: res = "ok" - + filin.close() return res diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py index e8472bd..006c750 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py @@ -103,15 +103,16 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalNbLigneFonction(code): +def excecEvalNbLigneFonction(): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") - + filin = open("userCode.py", "r") + lignes = filin.readlines() + scopeCodeUser = False firstInsert = False long_comment = False @@ -146,5 +147,5 @@ def excecEvalNbLigneFonction(code): if cpt_ligne-cpt_rm > 30: cpt_error+=1 - + filin.close() return cpt_error diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py index cada91e..0e963bb 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py @@ -456,15 +456,16 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(code): +def excecEvalRedondance(): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") - + filin = open("userCode.py", "r") + lignes = filin.readlines() + scopeCodeUser = False firstInsert = False long_comment = False @@ -544,6 +545,6 @@ def excecEvalRedondance(code): for block in blockCodes: if blockCodes[block] > 1: cptRedondance += blockCodes[block]-1 - + filin.close() return cptRedondance diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py index eabd8f9..fb86360 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py @@ -260,9 +260,11 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalVariableName(code): +def excecEvalVariableName(): - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() + scopeCodeUser = False cpt = 0 scopeCodeUser = False @@ -304,5 +306,6 @@ def excecEvalVariableName(code): ###RESULTAT + filin.close() return error diff --git a/heroku_deploy/api/evaluation_code/cpp/main.py b/heroku_deploy/api/evaluation_code/cpp/main.py deleted file mode 100644 index 7b49a7b..0000000 --- a/heroku_deploy/api/evaluation_code/cpp/main.py +++ /dev/null @@ -1,24 +0,0 @@ - -from evalNbLigneFonctionCpp import excecEvalNbLigneFonction -from evalCommentaireCpp import excecEvalCommentaire -from evalRedondanceCpp import excecEvalRedondance -from evalVariableNameCpp import excecEvalVariableName - -if __name__ == '__main__': - code= "int main() {"\ - "//COUCOU"\ - "std::cout <<\"Hello World!\";"\ - "return 0;"\ - "}" - - payload = { - "eval variable name":excecEvalVariableName(code), - "eval redondance": excecEvalRedondance(code), - "eval nb ligne fonction": excecEvalNbLigneFonction(code), - "eval commentaire": excecEvalCommentaire(code) - } - - print(payload) - - - diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py b/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py index b97ae45..8f39101 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py @@ -1,6 +1,7 @@ -def excecEvalCommentaire(code): +def excecEvalCommentaire(): - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False nbligne = 0 @@ -29,10 +30,6 @@ def excecEvalCommentaire(code): - - print(nbligne) - print(nbligneComment) - res = "" if nbligne >0: @@ -42,5 +39,5 @@ def excecEvalCommentaire(code): res = "pas assez de commentaires" else: res = "ok" - + filin.close() return res diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py index 2ea21e6..6a37be2 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py @@ -79,14 +79,15 @@ def remove_comentary(lignes): -def excecEvalNbLigneFonctionPy(code): +def excecEvalNbLigneFonctionPy(): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False firstInsert = False @@ -121,5 +122,5 @@ def excecEvalNbLigneFonctionPy(code): if cpt_ligne-cpt_rm > 30: cpt_error +=1 - + filin.close() return cpt_error diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py b/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py index 9ac9e1b..f84a179 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py @@ -418,14 +418,15 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(code): +def excecEvalRedondance(): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False firstInsert = False @@ -480,6 +481,7 @@ def excecEvalRedondance(code): if sanitize_dict[block] > 1: cptRedondance += sanitize_dict[block]-1 - + + filin.close() return cptRedondance diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py b/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py index 16aab91..f982322 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py @@ -217,9 +217,10 @@ def remove_comentary(lignes): -def excecEvalVariableNamePython(code): +def excecEvalVariableNamePython(): - lignes = code.split("\n") + filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False cpt = 0 @@ -265,4 +266,5 @@ def excecEvalVariableNamePython(code): ###RESULTAT + filin.close() return error diff --git a/heroku_deploy/api/evaluation_code/python/main.py b/heroku_deploy/api/evaluation_code/python/main.py deleted file mode 100644 index c5040ab..0000000 --- a/heroku_deploy/api/evaluation_code/python/main.py +++ /dev/null @@ -1,25 +0,0 @@ - -from evalNbLigneFonctionPy import excecEvalNbLigneFonctionPy -from evalCommentairePy import excecEvalCommentaire -from evalRedondancePy import excecEvalRedondance -from evalVariableNamePython import excecEvalVariableNamePython - - - -if __name__ == '__main__': - code="def excecEvalRedondance(code)" \ - " Aa = 0" \ - "def excecEvalRedondance(code)" \ - " Aa = 0" - - payload = { - "eval variable name":excecEvalVariableNamePython(code), - "eval redondance": excecEvalRedondance(code), - "eval nb ligne fonction": excecEvalNbLigneFonctionPy(code), - "eval commentaire": excecEvalCommentaire(code) - } - - print(payload) - - - diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 44eae03..b386ff6 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,12 +90,11 @@ export class GodBoxRepository { "from evalRedondanceCpp import excecEvalRedondance \n"+ "from evalVariableNameCpp import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " code=\""+code+"\" \n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(code), \n"+ - " \"eval_redondance\": excecEvalRedondance(code), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(code), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(code) \n"+ + " \"eval_variable_name\":excecEvalVariableName(), \n"+ + " \"eval_redondance\": excecEvalRedondance(), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ + " \"eval_commentaire\": excecEvalCommentaire() \n"+ " } \n"+ " print(payload) \n" @@ -104,6 +103,7 @@ export class GodBoxRepository { zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); zip.addFile(`main.py`, Buffer.from(main_algo)); + zip.addFile(`userCode.py`, Buffer.from(code)); return zip.toBuffer().toString('base64'); From 57ee72cfd640d634081310d6f39cc8c8b72670f3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:02:52 +0200 Subject: [PATCH 094/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/main.py | 13 +++++++ .../api/evaluation_code/python/main.py | 13 +++++++ .../api/src/exec-server/godbox.repository.ts | 36 +++++++++---------- 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 heroku_deploy/api/evaluation_code/cpp/main.py create mode 100644 heroku_deploy/api/evaluation_code/python/main.py diff --git a/heroku_deploy/api/evaluation_code/cpp/main.py b/heroku_deploy/api/evaluation_code/cpp/main.py new file mode 100644 index 0000000..2f58f08 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/main.py @@ -0,0 +1,13 @@ +from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction +from evaluation_code.evalCommentaireCpp import excecEvalCommentaire +from evaluation_code.evalRedondanceCpp import excecEvalRedondance +from evaluation_code.evalVariableNameCpp import excecEvalVariableName + +if __name__ == '__main__': + payload = { + "eval_variable_name\":excecEvalVariableName(), + "eval_redondance\": excecEvalRedondance(), + "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), + "eval_commentaire\": excecEvalCommentaire() + } + print(payload) \ No newline at end of file diff --git a/heroku_deploy/api/evaluation_code/python/main.py b/heroku_deploy/api/evaluation_code/python/main.py new file mode 100644 index 0000000..2f58f08 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/main.py @@ -0,0 +1,13 @@ +from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction +from evaluation_code.evalCommentaireCpp import excecEvalCommentaire +from evaluation_code.evalRedondanceCpp import excecEvalRedondance +from evaluation_code.evalVariableNameCpp import excecEvalVariableName + +if __name__ == '__main__': + payload = { + "eval_variable_name\":excecEvalVariableName(), + "eval_redondance\": excecEvalRedondance(), + "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), + "eval_commentaire\": excecEvalCommentaire() + } + print(payload) \ No newline at end of file diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index b386ff6..794818d 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -83,27 +83,27 @@ export class GodBoxRepository { code: string, language: Language ) { - const zip = new AdmZip(); - - const main_algo ="from evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ - "from evalCommentaireCpp import excecEvalCommentaire \n"+ - "from evalRedondanceCpp import excecEvalRedondance \n"+ - "from evalVariableNameCpp import excecEvalVariableName \n"+ - "if __name__ == '__main__': \n"+ - " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(), \n"+ - " \"eval_redondance\": excecEvalRedondance(), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ - " \"eval_commentaire\": excecEvalCommentaire() \n"+ - " } \n"+ - " print(payload) \n" - - console.log(main_algo) + const zip = new AdmZip(); + const exec_algo = + "from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ + "from evaluation_code.evalCommentaireCpp import excecEvalCommentaire \n"+ + "from evaluation_code.evalRedondanceCpp import excecEvalRedondance \n"+ + "from evaluation_code.evalVariableNameCpp import excecEvalVariableName \n"+ + "if __name__ == '__main__': \n"+ + " payload = { \n"+ + " \"eval_variable_name\":excecEvalVariableName(), \n"+ + " \"eval_redondance\": excecEvalRedondance(), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ + " \"eval_commentaire\": excecEvalCommentaire() \n"+ + " } \n"+ + " print(payload) \n"+ + + + zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); - - zip.addFile(`main.py`, Buffer.from(main_algo)); zip.addFile(`userCode.py`, Buffer.from(code)); + zip.addFile(`main.py`, Buffer.from(exec_algo)); return zip.toBuffer().toString('base64'); From 07b3f5877652360ba363d981c59275e255c0cff9 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:07:46 +0200 Subject: [PATCH 095/207] update algo eval code --- .../cpp/{evalCommentaireCpp.py => evalCommentaire.py} | 0 .../{evalNbLigneFonctionCpp.py => evalNbLigneFonction.py} | 0 .../cpp/{evalRedondanceCpp.py => evalRedondance.py} | 0 .../cpp/{evalVariableNameCpp.py => evalVariableName.py} | 0 .../python/{evalCommentairePy.py => evalCommentaire.py} | 0 .../{evalNbLigneFonctionPy.py => evalNbLigneFonction.py} | 0 .../python/{evalRedondancePy.py => evalRedondance.py} | 0 .../{evalVariableNamePython.py => evalVariableName.py} | 0 heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 9 files changed, 4 insertions(+), 4 deletions(-) rename heroku_deploy/api/evaluation_code/cpp/{evalCommentaireCpp.py => evalCommentaire.py} (100%) rename heroku_deploy/api/evaluation_code/cpp/{evalNbLigneFonctionCpp.py => evalNbLigneFonction.py} (100%) rename heroku_deploy/api/evaluation_code/cpp/{evalRedondanceCpp.py => evalRedondance.py} (100%) rename heroku_deploy/api/evaluation_code/cpp/{evalVariableNameCpp.py => evalVariableName.py} (100%) rename heroku_deploy/api/evaluation_code/python/{evalCommentairePy.py => evalCommentaire.py} (100%) rename heroku_deploy/api/evaluation_code/python/{evalNbLigneFonctionPy.py => evalNbLigneFonction.py} (100%) rename heroku_deploy/api/evaluation_code/python/{evalRedondancePy.py => evalRedondance.py} (100%) rename heroku_deploy/api/evaluation_code/python/{evalVariableNamePython.py => evalVariableName.py} (100%) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py similarity index 100% rename from heroku_deploy/api/evaluation_code/cpp/evalCommentaireCpp.py rename to heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py similarity index 100% rename from heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonctionCpp.py rename to heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py similarity index 100% rename from heroku_deploy/api/evaluation_code/cpp/evalRedondanceCpp.py rename to heroku_deploy/api/evaluation_code/cpp/evalRedondance.py diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py similarity index 100% rename from heroku_deploy/api/evaluation_code/cpp/evalVariableNameCpp.py rename to heroku_deploy/api/evaluation_code/cpp/evalVariableName.py diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentairePy.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py similarity index 100% rename from heroku_deploy/api/evaluation_code/python/evalCommentairePy.py rename to heroku_deploy/api/evaluation_code/python/evalCommentaire.py diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py similarity index 100% rename from heroku_deploy/api/evaluation_code/python/evalNbLigneFonctionPy.py rename to heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondancePy.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py similarity index 100% rename from heroku_deploy/api/evaluation_code/python/evalRedondancePy.py rename to heroku_deploy/api/evaluation_code/python/evalRedondance.py diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py similarity index 100% rename from heroku_deploy/api/evaluation_code/python/evalVariableNamePython.py rename to heroku_deploy/api/evaluation_code/python/evalVariableName.py diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 794818d..8321955 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction \n"+ - "from evaluation_code.evalCommentaireCpp import excecEvalCommentaire \n"+ - "from evaluation_code.evalRedondanceCpp import excecEvalRedondance \n"+ - "from evaluation_code.evalVariableNameCpp import excecEvalVariableName \n"+ + "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ + "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ + "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(), \n"+ From f8d7880d49e904995a3519ccfe0502d6065a534a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:11:56 +0200 Subject: [PATCH 096/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/main.py | 13 ------------- heroku_deploy/api/evaluation_code/python/main.py | 13 ------------- 2 files changed, 26 deletions(-) delete mode 100644 heroku_deploy/api/evaluation_code/cpp/main.py delete mode 100644 heroku_deploy/api/evaluation_code/python/main.py diff --git a/heroku_deploy/api/evaluation_code/cpp/main.py b/heroku_deploy/api/evaluation_code/cpp/main.py deleted file mode 100644 index 2f58f08..0000000 --- a/heroku_deploy/api/evaluation_code/cpp/main.py +++ /dev/null @@ -1,13 +0,0 @@ -from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction -from evaluation_code.evalCommentaireCpp import excecEvalCommentaire -from evaluation_code.evalRedondanceCpp import excecEvalRedondance -from evaluation_code.evalVariableNameCpp import excecEvalVariableName - -if __name__ == '__main__': - payload = { - "eval_variable_name\":excecEvalVariableName(), - "eval_redondance\": excecEvalRedondance(), - "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), - "eval_commentaire\": excecEvalCommentaire() - } - print(payload) \ No newline at end of file diff --git a/heroku_deploy/api/evaluation_code/python/main.py b/heroku_deploy/api/evaluation_code/python/main.py deleted file mode 100644 index 2f58f08..0000000 --- a/heroku_deploy/api/evaluation_code/python/main.py +++ /dev/null @@ -1,13 +0,0 @@ -from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction -from evaluation_code.evalCommentaireCpp import excecEvalCommentaire -from evaluation_code.evalRedondanceCpp import excecEvalRedondance -from evaluation_code.evalVariableNameCpp import excecEvalVariableName - -if __name__ == '__main__': - payload = { - "eval_variable_name\":excecEvalVariableName(), - "eval_redondance\": excecEvalRedondance(), - "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), - "eval_commentaire\": excecEvalCommentaire() - } - print(payload) \ No newline at end of file From d8cacbdba35094c99c1abdbf8e1c4a72f018b579 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:19:09 +0200 Subject: [PATCH 097/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 8321955..21dc295 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ - "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ - "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ - "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "from evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evalCommentaire import excecEvalCommentaire \n"+ + "from evalRedondance import excecEvalRedondance \n"+ + "from evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(), \n"+ From 5c2bb0e014616e5d1a1f61c73aed9ae4d510bcee Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:31:00 +0200 Subject: [PATCH 098/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 21dc295..101f06e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evalNbLigneFonction import excecEvalNbLigneFonction \n"+ - "from evalCommentaire import excecEvalCommentaire \n"+ - "from evalRedondance import excecEvalRedondance \n"+ - "from evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code."+language.name+".evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evaluation_code."+language.name+".evalCommentaire import excecEvalCommentaire \n"+ + "from evaluation_code."+language.name+".evalRedondance import excecEvalRedondance \n"+ + "from evaluation_code."+language.name+".evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(), \n"+ @@ -100,7 +100,6 @@ export class GodBoxRepository { " print(payload) \n"+ - zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); zip.addFile(`userCode.py`, Buffer.from(code)); zip.addFile(`main.py`, Buffer.from(exec_algo)); From e7e1485a6db62ca9ca4db3054dcee0f6576d854a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:37:40 +0200 Subject: [PATCH 099/207] update algo eval code --- .../api/src/exec-server/godbox.repository.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 101f06e..e517454 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,18 +86,21 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code."+language.name+".evalNbLigneFonction import excecEvalNbLigneFonction \n"+ - "from evaluation_code."+language.name+".evalCommentaire import excecEvalCommentaire \n"+ - "from evaluation_code."+language.name+".evalRedondance import excecEvalRedondance \n"+ - "from evaluation_code."+language.name+".evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ + "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ + "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ - " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(), \n"+ - " \"eval_redondance\": excecEvalRedondance(), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ - " \"eval_commentaire\": excecEvalCommentaire() \n"+ - " } \n"+ - " print(payload) \n"+ + + " import os \n"+ + " print(os.listdir('.')) \n"+ + " # payload = { \n"+ + " # \"eval_variable_name\":excecEvalVariableName(), \n"+ + " # \"eval_redondance\": excecEvalRedondance(), \n"+ + " # \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ + " # \"eval_commentaire\": excecEvalCommentaire() \n"+ + " # } \n"+ + " # print(payload) \n"+ zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); From e98cac7e0d787277817e58a575f07669ae56a122 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:41:07 +0200 Subject: [PATCH 100/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index e517454..ba214d5 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ - "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ - "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ - "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "#from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "#from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ + "#from evaluation_code.evalRedondance import excecEvalRedondance \n"+ + "#from evaluation_code.evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ From 10b42e77982f5d00c21147033d1ec1cc3ed356d1 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:44:57 +0200 Subject: [PATCH 101/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index ba214d5..090740d 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -93,7 +93,7 @@ export class GodBoxRepository { "if __name__ == '__main__': \n"+ " import os \n"+ - " print(os.listdir('.')) \n"+ + " print(os.listdir('./evaluation_code')) \n"+ " # payload = { \n"+ " # \"eval_variable_name\":excecEvalVariableName(), \n"+ " # \"eval_redondance\": excecEvalRedondance(), \n"+ From dd2d11b7267fbe8f8be37e5d24464c8d5b12a66d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:48:17 +0200 Subject: [PATCH 102/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 090740d..0deff04 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "#from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ - "#from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ - "#from evaluation_code.evalRedondance import excecEvalRedondance \n"+ - "#from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ + "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ + "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ From 1620ff619982a58eb0e54d465da8ccb248e15629 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:55:47 +0200 Subject: [PATCH 103/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 0deff04..8f2a35f 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,7 +86,7 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ + "from evaluation_code import evalNbLigneFonction \n"+ "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ From 68029f55185a181a863aca3da691b823c5db680d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 10 Oct 2021 23:59:23 +0200 Subject: [PATCH 104/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 8f2a35f..5588205 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -89,7 +89,7 @@ export class GodBoxRepository { "from evaluation_code import evalNbLigneFonction \n"+ "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ - "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code import evalVariableName \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ From eec25da0a0e782357cc3173b0fbbf5b059e0fd1a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:04:03 +0200 Subject: [PATCH 105/207] update algo eval code --- .../api/evaluation_code/cpp/evalCommentaire.py | 2 +- .../api/evaluation_code/cpp/evalNbLigneFonction.py | 2 +- .../api/evaluation_code/cpp/evalRedondance.py | 2 +- .../api/evaluation_code/cpp/evalVariableName.py | 2 +- .../api/evaluation_code/python/evalCommentaire.py | 2 +- .../evaluation_code/python/evalNbLigneFonction.py | 2 +- .../api/evaluation_code/python/evalRedondance.py | 2 +- .../api/evaluation_code/python/evalVariableName.py | 2 +- .../api/src/exec-server/godbox.repository.ts | 14 +++++++------- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py index a20e2a5..6c9ce52 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py @@ -1,6 +1,6 @@ def excecEvalCommentaire(): - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py index 006c750..3da20a6 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py @@ -110,7 +110,7 @@ def excecEvalNbLigneFonction(): lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py index 0e963bb..3deff95 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py @@ -463,7 +463,7 @@ def excecEvalRedondance(): lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index fb86360..6d621df 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -262,7 +262,7 @@ def remove_comentary(lignes): def excecEvalVariableName(): - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index 8f39101..8333372 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -1,6 +1,6 @@ def excecEvalCommentaire(): - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index 6a37be2..ca660d9 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -86,7 +86,7 @@ def excecEvalNbLigneFonctionPy(): lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index f84a179..53d2386 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -425,7 +425,7 @@ def excecEvalRedondance(): lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index f982322..d8ce472 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -219,7 +219,7 @@ def remove_comentary(lignes): def excecEvalVariableNamePython(): - filin = open("userCode.py", "r") + filin = open("../userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False cpt = 0 diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 5588205..716d86e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -94,13 +94,13 @@ export class GodBoxRepository { " import os \n"+ " print(os.listdir('./evaluation_code')) \n"+ - " # payload = { \n"+ - " # \"eval_variable_name\":excecEvalVariableName(), \n"+ - " # \"eval_redondance\": excecEvalRedondance(), \n"+ - " # \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ - " # \"eval_commentaire\": excecEvalCommentaire() \n"+ - " # } \n"+ - " # print(payload) \n"+ + " payload = { \n"+ + " \"eval_variable_name\":excecEvalVariableName(), \n"+ + " \"eval_redondance\": excecEvalRedondance(), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ + " \"eval_commentaire\": excecEvalCommentaire() \n"+ + " } \n"+ + " print(payload) \n"+ zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); From 0c2dd318073b4407e49f560f060602fda865f209 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:10:03 +0200 Subject: [PATCH 106/207] update algo eval code --- .../api/evaluation_code/python/evalNbLigneFonction.py | 2 +- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- heroku_deploy/api/src/exec-server/godbox.repository.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index ca660d9..4ded940 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -79,7 +79,7 @@ def remove_comentary(lignes): -def excecEvalNbLigneFonctionPy(): +def excecEvalNbLigneFonction(): listFunction = [] listVariableRename = [] diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index d8ce472..0037d1d 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -217,7 +217,7 @@ def remove_comentary(lignes): -def excecEvalVariableNamePython(): +def excecEvalVariableName(): filin = open("../userCode.py", "r") lignes = filin.readlines() diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 716d86e..4f72474 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -86,10 +86,10 @@ export class GodBoxRepository { const zip = new AdmZip(); const exec_algo = - "from evaluation_code import evalNbLigneFonction \n"+ + "from evaluation_code.evalNbLigneFonction import excecEvalNbLigneFonction \n"+ "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ - "from evaluation_code import evalVariableName \n"+ + "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ From 30ae0dcae13a2ec27a5d29abe5c22f35dd3ec098 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:15:59 +0200 Subject: [PATCH 107/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 4f72474..c822e86 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -93,7 +93,7 @@ export class GodBoxRepository { "if __name__ == '__main__': \n"+ " import os \n"+ - " print(os.listdir('./evaluation_code')) \n"+ + " print(os.listdir('./')) \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(), \n"+ " \"eval_redondance\": excecEvalRedondance(), \n"+ From cb95eeda0d61f662610c651d3139fb863e8be39b Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:22:40 +0200 Subject: [PATCH 108/207] update algo eval code --- heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py | 2 +- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index 4ded940..76b5406 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -86,7 +86,7 @@ def excecEvalNbLigneFonction(): lastListVariableRename = [] listVarBlock = [] - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index c822e86..7de1b87 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -104,7 +104,7 @@ export class GodBoxRepository { zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); - zip.addFile(`userCode.py`, Buffer.from(code)); + zip.addFile(`evaluation_code/userCode.py`, Buffer.from(code)); zip.addFile(`main.py`, Buffer.from(exec_algo)); From a7cd67a8c6171b1022ad624395158bad403d1c12 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:22:57 +0200 Subject: [PATCH 109/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 7de1b87..d981d65 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -94,6 +94,7 @@ export class GodBoxRepository { " import os \n"+ " print(os.listdir('./')) \n"+ + " print(os.listdir('./evaluation_code')) \n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(), \n"+ " \"eval_redondance\": excecEvalRedondance(), \n"+ From 624436ba486fc86bb7f215b7aaead0dd87218d05 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:27:00 +0200 Subject: [PATCH 110/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalRedondance.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 2 +- heroku_deploy/api/evaluation_code/python/evalCommentaire.py | 2 +- heroku_deploy/api/evaluation_code/python/evalRedondance.py | 2 +- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py index 6c9ce52..a20e2a5 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py @@ -1,6 +1,6 @@ def excecEvalCommentaire(): - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py index 3da20a6..006c750 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py @@ -110,7 +110,7 @@ def excecEvalNbLigneFonction(): lastListVariableRename = [] listVarBlock = [] - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py index 3deff95..0e963bb 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py @@ -463,7 +463,7 @@ def excecEvalRedondance(): lastListVariableRename = [] listVarBlock = [] - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 6d621df..fb86360 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -262,7 +262,7 @@ def remove_comentary(lignes): def excecEvalVariableName(): - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index 8333372..8f39101 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -1,6 +1,6 @@ def excecEvalCommentaire(): - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index 53d2386..f84a179 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -425,7 +425,7 @@ def excecEvalRedondance(): lastListVariableRename = [] listVarBlock = [] - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 0037d1d..243b349 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -219,7 +219,7 @@ def remove_comentary(lignes): def excecEvalVariableName(): - filin = open("../userCode.py", "r") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False cpt = 0 From a3b2d42a05d99e742111cda767cc78b93044245c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:36:05 +0200 Subject: [PATCH 111/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index fb86360..db695bb 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -262,7 +262,7 @@ def remove_comentary(lignes): def excecEvalVariableName(): - filin = open("userCode.py", "r") + filin = open("./userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False From 35df4d47a0ccb617f8d1fe8733aef530b3e45fa4 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:40:41 +0200 Subject: [PATCH 112/207] update algo eval code --- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 243b349..ebf3dd1 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -219,7 +219,7 @@ def remove_comentary(lignes): def excecEvalVariableName(): - filin = open("userCode.py", "r") + filin = open("./userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False cpt = 0 From 1ed6a0b56d42e5fbe7443a1a56eb11afb0e07176 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:48:39 +0200 Subject: [PATCH 113/207] update algo eval code --- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index ebf3dd1..138c846 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -218,8 +218,9 @@ def remove_comentary(lignes): def excecEvalVariableName(): - - filin = open("./userCode.py", "r") + import os + os.path.join(os.path.abspath(__file__), "userCode.py") + filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False cpt = 0 From 04974188cc1b825973988181894036b339c75462 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 00:56:14 +0200 Subject: [PATCH 114/207] update algo eval code --- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 138c846..a2067b2 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -1,4 +1,5 @@ import re +from userCode import * From add441957ffaf129ecc15f69b09b849741227dac Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:01:59 +0200 Subject: [PATCH 115/207] update algo eval code --- .../api/evaluation_code/python/evalVariableName.py | 8 ++------ heroku_deploy/api/src/exec-server/godbox.repository.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index a2067b2..4090a23 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -1,7 +1,4 @@ import re -from userCode import * - - def findVariableInFuction(line): listVariable = [] @@ -218,10 +215,9 @@ def remove_comentary(lignes): -def excecEvalVariableName(): +def excecEvalVariableName(filin): import os - os.path.join(os.path.abspath(__file__), "userCode.py") - filin = open("userCode.py", "r") + lignes = filin.readlines() scopeCodeUser = False cpt = 0 diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index d981d65..a0dcf50 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -93,10 +93,15 @@ export class GodBoxRepository { "if __name__ == '__main__': \n"+ " import os \n"+ + " import re \n"+ + " print(os.listdir('./')) \n"+ " print(os.listdir('./evaluation_code')) \n"+ + " filin = open(\"userCode.py\", \"r\") \n"+ + + " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(), \n"+ + " \"eval_variable_name\":excecEvalVariableName(filin), \n"+ " \"eval_redondance\": excecEvalRedondance(), \n"+ " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ " \"eval_commentaire\": excecEvalCommentaire() \n"+ @@ -105,7 +110,7 @@ export class GodBoxRepository { zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); - zip.addFile(`evaluation_code/userCode.py`, Buffer.from(code)); + zip.addFile(`userCode.py`, Buffer.from(code)); zip.addFile(`main.py`, Buffer.from(exec_algo)); From 4b5c045171c904240e50e5bd307a00cf431ac972 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:10:12 +0200 Subject: [PATCH 116/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index a0dcf50..5554f8e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -98,7 +98,7 @@ export class GodBoxRepository { " print(os.listdir('./')) \n"+ " print(os.listdir('./evaluation_code')) \n"+ " filin = open(\"userCode.py\", \"r\") \n"+ - + " print(filin)\n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(filin), \n"+ From 9668c8111363e4b6c691df8b2a3229d4add8a94e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:14:10 +0200 Subject: [PATCH 117/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py | 3 +-- .../api/evaluation_code/cpp/evalNbLigneFonction.py | 3 +-- heroku_deploy/api/evaluation_code/cpp/evalRedondance.py | 3 +-- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 3 +-- heroku_deploy/api/evaluation_code/python/evalCommentaire.py | 3 +-- .../api/evaluation_code/python/evalNbLigneFonction.py | 3 +-- heroku_deploy/api/evaluation_code/python/evalRedondance.py | 3 +-- .../api/evaluation_code/python/evalVariableName.py | 3 +-- heroku_deploy/api/src/exec-server/godbox.repository.ts | 6 +++--- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py index a20e2a5..513a718 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py @@ -1,6 +1,5 @@ -def excecEvalCommentaire(): +def excecEvalCommentaire(filin): - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py index 006c750..a29cc04 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py @@ -103,14 +103,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalNbLigneFonction(): +def excecEvalNbLigneFonction(filin): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py index 0e963bb..f1f0f61 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py @@ -456,14 +456,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(): +def excecEvalRedondance(filin): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index db695bb..75847b9 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -260,9 +260,8 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalVariableName(): +def excecEvalVariableName(filin): - filin = open("./userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index 8f39101..7d6d850 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -1,6 +1,5 @@ -def excecEvalCommentaire(): +def excecEvalCommentaire(filin): - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index 76b5406..69d768f 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -79,14 +79,13 @@ def remove_comentary(lignes): -def excecEvalNbLigneFonction(): +def excecEvalNbLigneFonction(filin): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index f84a179..7221914 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -418,14 +418,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(): +def excecEvalRedondance(filin): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - filin = open("userCode.py", "r") lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 4090a23..4aba41d 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -152,7 +152,7 @@ def findVariableFromList(line): findSpace = False variable = "" - variable += ligne[i] + variable += line[i] else: findSpace = True @@ -216,7 +216,6 @@ def remove_comentary(lignes): def excecEvalVariableName(filin): - import os lignes = filin.readlines() scopeCodeUser = False diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 5554f8e..22366ed 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -102,9 +102,9 @@ export class GodBoxRepository { " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(filin), \n"+ - " \"eval_redondance\": excecEvalRedondance(), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(), \n"+ - " \"eval_commentaire\": excecEvalCommentaire() \n"+ + " \"eval_redondance\": excecEvalRedondance(filin), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(filin), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(filin) \n"+ " } \n"+ " print(payload) \n"+ From 532d3a7f3ef3e63d10d2651643b77802f43dfa34 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:19:23 +0200 Subject: [PATCH 118/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalRedondance.py | 2 +- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 1 - heroku_deploy/api/evaluation_code/python/evalCommentaire.py | 2 +- heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py | 1 - heroku_deploy/api/evaluation_code/python/evalRedondance.py | 1 - heroku_deploy/api/evaluation_code/python/evalVariableName.py | 1 - heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 ++ 9 files changed, 6 insertions(+), 8 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py index 513a718..46bed1f 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py @@ -35,5 +35,5 @@ def excecEvalCommentaire(filin): res = "error" else: res = "ok" - filin.close() + return res diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py index a29cc04..3b99ae8 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py @@ -146,5 +146,5 @@ def excecEvalNbLigneFonction(filin): if cpt_ligne-cpt_rm > 30: cpt_error+=1 - filin.close() + return cpt_error diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py index f1f0f61..501e234 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py @@ -544,6 +544,6 @@ def excecEvalRedondance(filin): for block in blockCodes: if blockCodes[block] > 1: cptRedondance += blockCodes[block]-1 - filin.close() + return cptRedondance diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 75847b9..0e425ca 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -305,6 +305,5 @@ def excecEvalVariableName(filin): ###RESULTAT - filin.close() return error diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index 7d6d850..e472ed4 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -38,5 +38,5 @@ def excecEvalCommentaire(filin): res = "pas assez de commentaires" else: res = "ok" - filin.close() + return res diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index 69d768f..f9ccf9f 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -121,5 +121,4 @@ def excecEvalNbLigneFonction(filin): if cpt_ligne-cpt_rm > 30: cpt_error +=1 - filin.close() return cpt_error diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index 7221914..112467b 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -481,6 +481,5 @@ def excecEvalRedondance(filin): if sanitize_dict[block] > 1: cptRedondance += sanitize_dict[block]-1 - filin.close() return cptRedondance diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 4aba41d..6cf98c1 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -263,5 +263,4 @@ def excecEvalVariableName(filin): ###RESULTAT - filin.close() return error diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 22366ed..6a02c1e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -106,6 +106,8 @@ export class GodBoxRepository { " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(filin), \n"+ " \"eval_commentaire\": excecEvalCommentaire(filin) \n"+ " } \n"+ + " filin.close() \n"+ + " print(payload) \n"+ From 31c0fc99b94c0d961b9cf82a5f5c12963d6393e3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:22:54 +0200 Subject: [PATCH 119/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 6a02c1e..618acd6 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -107,8 +107,7 @@ export class GodBoxRepository { " \"eval_commentaire\": excecEvalCommentaire(filin) \n"+ " } \n"+ " filin.close() \n"+ - - " print(payload) \n"+ + " print(payload) \n" zip.addLocalFolder(`${ALGO_DIR}/${language.name}`, 'evaluation_code'); From d1c68b21658d8a2ced28e1a9ff2cfcd685c681f9 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:38:34 +0200 Subject: [PATCH 120/207] update algo eval code --- heroku_deploy/api/evaluation_code/python/evalRedondance.py | 7 ------- .../api/evaluation_code/python/evalVariableName.py | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index 112467b..6fe4639 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -208,7 +208,6 @@ def find_block(code): blockCreate = False blockCodes = "" save = find_indentation(line) - # print("START") while not blockCreate and k < len(code): @@ -216,10 +215,7 @@ def find_block(code): sanitize_line = sanitize_line.replace("\n", "") if len(sanitize_line) > 0: - # print(code[k]) - # print(len(sanitize_line)) - # print("next") linebis = code[k] newVal = find_indentation(linebis) @@ -370,7 +366,6 @@ def sanitize_dict_(dict): sanitize_dict = {} for block in dict: - # print(block) sanitizeBlock = block.replace('\n', ';@;') sanitizeBlock = sanitizeBlock.replace(' ', '') sanitize_dict = update_block(sanitizeBlock, sanitize_dict) @@ -475,8 +470,6 @@ def excecEvalRedondance(filin): cptRedondance = 0 for block in sanitize_dict: - print(block) - if sanitize_dict[block] > 1: cptRedondance += sanitize_dict[block]-1 diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 6cf98c1..b2c11c0 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -224,9 +224,9 @@ def excecEvalVariableName(filin): listVariable = [] lignes = remove_comentary(lignes) + print(lignes) for ligne in lignes: - print(ligne) variables = "" variables = findVariableDeclare(ligne) @@ -257,7 +257,6 @@ def excecEvalVariableName(filin): error = 0 - print(listVariable) for var in listVariable: error = error + switch(var) From 03474e10b3c248bb7f159d54ef52669745fd7ac7 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:44:59 +0200 Subject: [PATCH 121/207] update algo eval code --- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 3 ++- heroku_deploy/api/evaluation_code/python/evalCommentaire.py | 1 + .../api/evaluation_code/python/evalNbLigneFonction.py | 1 + heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 0e425ca..4f63d3e 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -274,8 +274,9 @@ def excecEvalVariableName(filin): lignes = remove_comentary(lignes) for ligne in lignes: + ligne.replace("\\n","") - ligne = ligne.replace('\n', '') + # ligne = ligne.replace('\n', '') variable = "" variableDeclare = findVariableDeclare(ligne) diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index e472ed4..98f134c 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -8,6 +8,7 @@ def excecEvalCommentaire(filin): longComment = False for ligne in lignes: + ligne.replace("\\n","") if ligne != "": nbligne += 1 diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index f9ccf9f..6fc1d75 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -99,6 +99,7 @@ def excecEvalNbLigneFonction(filin): lignes = remove_comentary(lignes) for ligne in lignes: + ligne.replace("\\n","") lignesCompacte.append(ligne) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index b2c11c0..a48a959 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -227,7 +227,7 @@ def excecEvalVariableName(filin): print(lignes) for ligne in lignes: - + ligne.replace("\\n","") variables = "" variables = findVariableDeclare(ligne) From d0e31e3fc63490665ae80782d49f502356dfc777 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:50:08 +0200 Subject: [PATCH 122/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 618acd6..3ad4d46 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -95,11 +95,12 @@ export class GodBoxRepository { " import os \n"+ " import re \n"+ - " print(os.listdir('./')) \n"+ - " print(os.listdir('./evaluation_code')) \n"+ " filin = open(\"userCode.py\", \"r\") \n"+ - " print(filin)\n"+ + " for ligne in filin:\n"+ + " ligne.replace(\"\\n\", \"\")\n"+ + " print(filin)\n"+ + " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(filin), \n"+ " \"eval_redondance\": excecEvalRedondance(filin), \n"+ From 381d5d2176e3250749c078cb9b3b0669f1480e61 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 01:54:47 +0200 Subject: [PATCH 123/207] update algo eval code --- .../api/evaluation_code/cpp/evalCommentaire.py | 3 +-- .../evaluation_code/cpp/evalNbLigneFonction.py | 3 +-- .../api/evaluation_code/cpp/evalRedondance.py | 3 +-- .../evaluation_code/cpp/evalVariableName.py | 5 +---- .../evaluation_code/python/evalCommentaire.py | 4 +--- .../python/evalNbLigneFonction.py | 4 +--- .../evaluation_code/python/evalRedondance.py | 3 +-- .../evaluation_code/python/evalVariableName.py | 5 +---- .../api/src/exec-server/godbox.repository.ts | 18 ++++++++++-------- 9 files changed, 18 insertions(+), 30 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py index 46bed1f..5f13b8d 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalCommentaire.py @@ -1,6 +1,5 @@ -def excecEvalCommentaire(filin): +def excecEvalCommentaire(lignes): - lignes = filin.readlines() scopeCodeUser = False nbLigne = 0 diff --git a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py index 3b99ae8..eb733a4 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalNbLigneFonction.py @@ -103,14 +103,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalNbLigneFonction(filin): +def excecEvalNbLigneFonction(lignes): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = filin.readlines() scopeCodeUser = False firstInsert = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py index 501e234..d4b4dcc 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalRedondance.py @@ -456,14 +456,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(filin): +def excecEvalRedondance(lignes): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = filin.readlines() scopeCodeUser = False firstInsert = False diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 4f63d3e..64ec680 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -260,9 +260,7 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalVariableName(filin): - - lignes = filin.readlines() +def excecEvalVariableName(lignes): scopeCodeUser = False cpt = 0 @@ -274,7 +272,6 @@ def excecEvalVariableName(filin): lignes = remove_comentary(lignes) for ligne in lignes: - ligne.replace("\\n","") # ligne = ligne.replace('\n', '') diff --git a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py index 98f134c..cd9244b 100644 --- a/heroku_deploy/api/evaluation_code/python/evalCommentaire.py +++ b/heroku_deploy/api/evaluation_code/python/evalCommentaire.py @@ -1,6 +1,5 @@ -def excecEvalCommentaire(filin): +def excecEvalCommentaire(lignes): - lignes = filin.readlines() scopeCodeUser = False nbligne = 0 @@ -8,7 +7,6 @@ def excecEvalCommentaire(filin): longComment = False for ligne in lignes: - ligne.replace("\\n","") if ligne != "": nbligne += 1 diff --git a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py index 6fc1d75..9722f01 100644 --- a/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py +++ b/heroku_deploy/api/evaluation_code/python/evalNbLigneFonction.py @@ -79,14 +79,13 @@ def remove_comentary(lignes): -def excecEvalNbLigneFonction(filin): +def excecEvalNbLigneFonction(lignes): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = filin.readlines() scopeCodeUser = False firstInsert = False @@ -99,7 +98,6 @@ def excecEvalNbLigneFonction(filin): lignes = remove_comentary(lignes) for ligne in lignes: - ligne.replace("\\n","") lignesCompacte.append(ligne) diff --git a/heroku_deploy/api/evaluation_code/python/evalRedondance.py b/heroku_deploy/api/evaluation_code/python/evalRedondance.py index 6fe4639..f5b531a 100644 --- a/heroku_deploy/api/evaluation_code/python/evalRedondance.py +++ b/heroku_deploy/api/evaluation_code/python/evalRedondance.py @@ -413,14 +413,13 @@ def remove_comentary(lignes): return code_without_comentary -def excecEvalRedondance(filin): +def excecEvalRedondance(lignes): listFunction = [] listVariableRename = [] lastListVariableRename = [] listVarBlock = [] - lignes = filin.readlines() scopeCodeUser = False firstInsert = False diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index a48a959..742db2a 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -215,19 +215,16 @@ def remove_comentary(lignes): -def excecEvalVariableName(filin): +def excecEvalVariableName(lignes): - lignes = filin.readlines() scopeCodeUser = False cpt = 0 listVariable = [] lignes = remove_comentary(lignes) - print(lignes) for ligne in lignes: - ligne.replace("\\n","") variables = "" variables = findVariableDeclare(ligne) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 3ad4d46..e4d0d42 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -96,16 +96,18 @@ export class GodBoxRepository { " import re \n"+ " filin = open(\"userCode.py\", \"r\") \n"+ - - " for ligne in filin:\n"+ - " ligne.replace(\"\\n\", \"\")\n"+ - " print(filin)\n"+ + " lignes = filin.readlines()\n"+ + + " for ligne in lignes:\n"+ + " ligne.replace(\"\\n\", \"\")\n"+ + + " print(lignes)\n"+ " payload = { \n"+ - " \"eval_variable_name\":excecEvalVariableName(filin), \n"+ - " \"eval_redondance\": excecEvalRedondance(filin), \n"+ - " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(filin), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(filin) \n"+ + " \"eval_variable_name\":excecEvalVariableName(lignes), \n"+ + " \"eval_redondance\": excecEvalRedondance(lignes), \n"+ + " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(lignes), \n"+ + " \"eval_commentaire\": excecEvalCommentaire(lignes) \n"+ " } \n"+ " filin.close() \n"+ " print(payload) \n" From 34b68a251797d3ed84a954323dabf4d43fb1c7e6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 02:00:07 +0200 Subject: [PATCH 124/207] update algo eval code --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index e4d0d42..f5ed950 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -98,9 +98,12 @@ export class GodBoxRepository { " filin = open(\"userCode.py\", \"r\") \n"+ " lignes = filin.readlines()\n"+ + " new_lignes = []\n"+ " for ligne in lignes:\n"+ " ligne.replace(\"\\n\", \"\")\n"+ + " new_lignes.append(ligne)\n"+ + " lignes = new_lignes\n"+ " print(lignes)\n"+ " payload = { \n"+ From 125ad9a2cdf24b6816dd094226af77eb6c55d9ab Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 02:06:46 +0200 Subject: [PATCH 125/207] update algo eval code --- .../api/evaluation_code/python/evalVariableName.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 742db2a..ae422cf 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -1,5 +1,7 @@ import re + + def findVariableInFuction(line): listVariable = [] variable = "" @@ -152,7 +154,7 @@ def findVariableFromList(line): findSpace = False variable = "" - variable += line[i] + variable += ligne[i] else: findSpace = True @@ -215,7 +217,7 @@ def remove_comentary(lignes): -def excecEvalVariableName(lignes): +def excecEvalVariableNamePython(lignes): scopeCodeUser = False cpt = 0 @@ -225,6 +227,8 @@ def excecEvalVariableName(lignes): lignes = remove_comentary(lignes) for ligne in lignes: + print(ligne) + variables = "" variables = findVariableDeclare(ligne) @@ -254,9 +258,8 @@ def excecEvalVariableName(lignes): error = 0 + print(listVariable) for var in listVariable: error = error + switch(var) - - ###RESULTAT - return error + return error \ No newline at end of file From 0082c1dfefe2a9e858ad1d449f9217dcf57510a3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 17:35:31 +0200 Subject: [PATCH 126/207] =?UTF-8?q?correction=20erreur=20d=C3=A9pendance?= =?UTF-8?q?=20python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index ae422cf..1fe0a40 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -217,7 +217,7 @@ def remove_comentary(lignes): -def excecEvalVariableNamePython(lignes): +def excecEvalVariableName(lignes): scopeCodeUser = False cpt = 0 From 8011182c379fbe51b1f9cff0c431788350e7f922 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 17:40:47 +0200 Subject: [PATCH 127/207] =?UTF-8?q?correction=20erreur=20d=C3=A9pendance?= =?UTF-8?q?=20python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 1fe0a40..4203988 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -154,7 +154,7 @@ def findVariableFromList(line): findSpace = False variable = "" - variable += ligne[i] + variable += line[i] else: findSpace = True From f4f2a1a651167b1221c815f68a4de7c02e9cd6e1 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:00:39 +0200 Subject: [PATCH 128/207] correction erreur algoNameVar --- .../api/evaluation_code/python/evalVariableName.py | 12 +++++++----- .../api/src/exec-server/godbox.repository.ts | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 4203988..bdfeed3 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -169,6 +169,7 @@ def findVariableFromList(line): def switch(variable): + print(variable) switcher = { len(variable) == 1: 1, #teste si une varaible contient plus d'une lettre variable.lower() != variable and re.search(r'[A-Z]{' + str(len(variable)) + ',}',variable) == None : 1, #teste si une varaible commence par une majuscule @@ -181,10 +182,8 @@ def switch(variable): def remove_comentary(lignes): - """ - :param liste_variable: représente la liste des variables du code - :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection - """ + + long_comment = False code_without_comentary = [] @@ -216,7 +215,6 @@ def remove_comentary(lignes): - def excecEvalVariableName(lignes): scopeCodeUser = False @@ -232,6 +230,7 @@ def excecEvalVariableName(lignes): variables = "" variables = findVariableDeclare(ligne) + for variable in variables: if variables != "" and variable not in listVariable: @@ -240,6 +239,9 @@ def excecEvalVariableName(lignes): + print("variables") + print(listVariable) + variable = "" functionListVariable = findVariableInFuction(ligne) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index f5ed950..849b932 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -104,7 +104,6 @@ export class GodBoxRepository { " new_lignes.append(ligne)\n"+ " lignes = new_lignes\n"+ - " print(lignes)\n"+ " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(lignes), \n"+ From 7c4fa84fb8d27e5fd2b68423e0030af7c9e8f2ba Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:05:40 +0200 Subject: [PATCH 129/207] correction erreur algoNameVar --- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 64ec680..973541c 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -273,7 +273,7 @@ def excecEvalVariableName(lignes): for ligne in lignes: - # ligne = ligne.replace('\n', '') + ligne = ligne.replace('\n', '') variable = "" variableDeclare = findVariableDeclare(ligne) From 8d67bebcb666380378f4120a7d63709b985bb23c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:09:01 +0200 Subject: [PATCH 130/207] correction erreur algoNameVar --- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 973541c..667f9cb 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -273,7 +273,7 @@ def excecEvalVariableName(lignes): for ligne in lignes: - ligne = ligne.replace('\n', '') + ligne = ligne.replace('\\n', '') variable = "" variableDeclare = findVariableDeclare(ligne) From e901d859b33cd59ac4fb50d33189a77ac6655c0d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:13:16 +0200 Subject: [PATCH 131/207] correction erreur algoNameVar --- heroku_deploy/api/evaluation_code/cpp/evalVariableName.py | 2 +- heroku_deploy/api/evaluation_code/python/evalVariableName.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py index 667f9cb..7afa079 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalVariableName.py @@ -273,7 +273,7 @@ def excecEvalVariableName(lignes): for ligne in lignes: - ligne = ligne.replace('\\n', '') + # ligne = ligne.replace('\\n', '') variable = "" variableDeclare = findVariableDeclare(ligne) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index bdfeed3..0612e6c 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -226,6 +226,7 @@ def excecEvalVariableName(lignes): for ligne in lignes: print(ligne) + ligne = ligne.replace('\\n', '') variables = "" variables = findVariableDeclare(ligne) From 0a64e0eee0c010dd17ea3594d9ec73ad80f2cda2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:25:20 +0200 Subject: [PATCH 132/207] correction erreur algoNameVar --- .../api/evaluation_code/python/evalVariableName.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalVariableName.py b/heroku_deploy/api/evaluation_code/python/evalVariableName.py index 0612e6c..00746c1 100644 --- a/heroku_deploy/api/evaluation_code/python/evalVariableName.py +++ b/heroku_deploy/api/evaluation_code/python/evalVariableName.py @@ -169,7 +169,7 @@ def findVariableFromList(line): def switch(variable): - print(variable) + switcher = { len(variable) == 1: 1, #teste si une varaible contient plus d'une lettre variable.lower() != variable and re.search(r'[A-Z]{' + str(len(variable)) + ',}',variable) == None : 1, #teste si une varaible commence par une majuscule @@ -225,8 +225,6 @@ def excecEvalVariableName(lignes): lignes = remove_comentary(lignes) for ligne in lignes: - print(ligne) - ligne = ligne.replace('\\n', '') variables = "" variables = findVariableDeclare(ligne) @@ -240,8 +238,6 @@ def excecEvalVariableName(lignes): - print("variables") - print(listVariable) variable = "" functionListVariable = findVariableInFuction(ligne) @@ -261,7 +257,6 @@ def excecEvalVariableName(lignes): error = 0 - print(listVariable) for var in listVariable: error = error + switch(var) From 19442d8b2ec7d1ebbdd15642844b2647ca67f532 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 11 Oct 2021 18:37:37 +0200 Subject: [PATCH 133/207] aff resule algo --- heroku_deploy/api/src/attempts/attempts.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 29a4be1..1c284fc 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -44,7 +44,8 @@ export class AttemptsService { execBootstrap, ); - console.log(execResultsAlgoEvaluation) + console.log(execResultsAlgoEvaluation["stdout"]) + execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] const attempt = ( await new this.attemptModel({ From 0a386f7d38cfe15d7902c73e57f86a4d9c6e68a2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 18:37:47 +0200 Subject: [PATCH 134/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/evaluation_code/cpp/evalPlagiat.py | 699 ++++++++++++++++++ .../api/evaluation_code/python/evalPlagiat.py | 592 +++++++++++++++ .../api/src/exec-server/godbox.repository.ts | 3 + 3 files changed, 1294 insertions(+) create mode 100644 heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py create mode 100644 heroku_deploy/api/evaluation_code/python/evalPlagiat.py diff --git a/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py new file mode 100644 index 0000000..73371d7 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py @@ -0,0 +1,699 @@ +import re + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + + + + +dico_stemming = { + "def": "d", + "while": "w", + "for": "f", + "elif": "ei", + "else": "e", + "<=": "c", + ">=": "c", + "<": "c", + ">": "c", + "!=": "!", + "==": "-", + "and": "&", + "or": "|", + "int": "i", + "bool": "bo", + "string": "s", + "long ": "l", + "char":"ch", + "float ": "fl", + "void": "v", + "double":"db", + "break":"b", + "case":"cs", + "try":"t", + "catch":"ct", + "class":"cl", + "continue":"cn", + "default":"df", + "const": "cst", + "delete": "dl" , + "enum":"en", + "private":"pri", + "protected":"pro", + "public":"pub", + "extern": "ex", + "friend": "fr", + "goto": "got", + "inline": "inl", + "new": "nw", + "operator": "op", + "register": "rg", + "return": "rt", + "short": "sh", + "signed": "sg", + "sizeof": "sz", + "static": "stc", + "struct": "str", + "switch": "sw", + "typedef": "td", + "template": "tmp", + "throw": "th", + "union": "un", + "unsigned": "uns", + "virtual": "vr", + "volatile": "vl", + + "alignas": "ag", + "alignof": "agn", + "and_eq": "&e", + "auto": "au", + "bitand": "btd", + "bitor": "bt", + "char16_t": "c16", + "char32_t": "c32", + + "constexpr": "cx", + "decltype": "dt", + "const_cast": "ca", + "export": "ep", + "thread_local": "tl", + "static_assert": "ss", + "reinterpret_cast": "ra", + "this": "ti", + "mutable": "mt", + "xor_eq": "xe", + "using,": "us", + "noexcept, ": "nx", + "not": "n", + "not_eq": "!p", + "nullptr": "nr", + "or_eq": "|p", + "true": "tr", + "false": "fs", + "typeid": "tp", + "xor": "xr", + +} + + +dico_supression = { + " ": "", + "{": "", + "}": "", + "(": "", + ")": "", + ";": "", + ":": "" +} + + +def delete_string(ligne): + delete = False + list_chain_to_remove = [] + + if ligne.count("\"") > 0: + + i = 0 + chain_to_remove = "" + + while i < len(ligne): + + if ligne[i] == '\"': + list_chain_to_remove.append(chain_to_remove) + chain_to_remove = "" + delete = not delete + + if delete and ligne[i] != '"': + chain_to_remove = chain_to_remove + ligne[i] + + i += 1 + + for chain in list_chain_to_remove: + ligne = ligne.replace(chain, "") + + ligne = ligne.replace("\"\"", "\"") + + return ligne + + +def replace_by_new_content(ligne): + for key in dico_stemming: + ligne = ligne.replace(key, dico_stemming[key]) + return ligne + + +def delete_unuse_content(ligne): + for key in dico_supression: + ligne = ligne.replace(key, dico_supression[key]) + + return ligne + + +def sanitize_content(ligne): + ligne = delete_string(ligne) + filtered_content =replace_by_new_content(ligne) + filtered_content = delete_unuse_content(filtered_content) + filtered_content = re.sub('[0-9]{1,}', '*', filtered_content) + + return filtered_content + + + +def findVariableInFuction(line): + listVariable = [] + cpt = 0 + inFunction = False + + listContentinit = [] + listVarInFunction = "" + + for signe in line: + + if signe == "(": + cpt +=1 + inFunction = True + + elif signe == ")": + cpt -=1 + + if inFunction: + if True and cpt > 0 and signe != "(": + listVarInFunction += signe + + else: + listContentinit.append(listVarInFunction) + listVarInFunction = "" + + + listContentSplit = [] + listContentSplit2 = [] + + for functionContent in listContentinit: + functionContent = functionContent.replace(',', ', ') + x = functionContent.split(", ") + + for content in x: + listContentSplit2.append(content) + if not set('~!@#$%^&*()+.{}":;\'+$').intersection(content): + + if "[" in content: + newContent = "" + id=0 + finishExtractVarFromTable = False + + while id < len(content) and not finishExtractVarFromTable: + if content[id] == "[": + finishExtractVarFromTable = True + + else: + newContent += content[id] + id +=1 + + content = newContent + + if re.search(PATERN_VARIABLE[0], content) != None or re.search(PATERN_VARIABLE[1], content) != None or re.search(PATERN_VARIABLE[2], content) != None: + + listContentSplit.append(content) + + + for varaiblePart in listContentSplit: + + if ">" in varaiblePart: + parts = varaiblePart.split(">") + parts[len(parts)-2] +=">" + else: + parts = varaiblePart.split(" ") + + i = 0 + type="" + + while i < len(parts) -1: + type = type+parts[i] + i +=1 + + type = re.sub(' ', '', type) + variable = re.sub(' ', '', parts[len(parts)-1]) + listVariable.append((type, variable)) + + + return listVariable + + +def findVariableDeclare(ligne): + """ + :param ligne: représente une ligne de code + :return: retour le la liste des variable au seins d'une fonction + """ + + listVariable = [] + type = "" + list = [] + + if True: + i = 0 + find = False + + while i < len(ligne) and not find: + + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + typeVar = "" + listVariableTransition = [] + inTab = False + + while k > 0 and notFind: + + if ligne[k] == " ": + + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "": + listVariableTransition.append(var) + var = "" + + if ligne[k] == "]": + inTab= True + + if ligne[k] == "/": + if len(ligne) > k+1: + if ligne[k+1] == "/" or ligne[k+1] == "*": + + notFind = False + + #Si on trouve un signe arpès avoir trouvé un séparateur ou qu'on est en train de parcourir un mot + if ligne[k] != "," and ligne[k] != " " and k != i and not inTab: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + + if ligne[k] == "[": + inTab = False + + + if not notFind: + type = "" + while k > 0 and ligne[k] != " ": + type = ligne[k]+type + k -=1 + + + for variable in listVariableTransition: + if not set('[~!@#$%^&*()+.{}":;\']+$').intersection(type) and not set('[~!@#$%^&*()+.{}":;\']+$').intersection(variable) : + type = re.sub(' ', '', type) + variable = re.sub(' ', '', variable) + typeVar = (type, variable) + + if typeVar not in listVariable: + listVariable.append(typeVar) + + k -= 1 + + elif ligne[i] == ";" and "=" not in ligne: + line="" + line = re.findall(r'\s{0,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,};', ligne) + + if line != [] and "return" not in line[0]: + + line = re.sub(';', '', line[0]) + ligneTab = line.split(" ") + + u = 0 + type = "" + var = "" + while u 75: + blockCodes.append(sanitize_code) + newBlock = "" + k +=1 + + i +=1 + + return blockCodes + + + + +def find_function(line): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + + blockCodes = [] + i = 0 + cptAcollade = 0 + newBlock="" + addAblock = False + + while i < len(line): + + if line[i] == "{": + + cptAcollade += 1 + newBlock += line[i] + addAblock = True + i +=1 + + while cptAcollade != 0 and newBlock != "" and i < len(line): + + if line[i] == "{": + cptAcollade += 1 + + elif line[i] == "}": + cptAcollade -= 1 + + if addAblock: + newBlock += line[i] + + if cptAcollade == 0: + + blockCodes.append(newBlock) + newBlock = "" + i +=1 + + i +=1 + + return blockCodes + + + +def rename_variable(line, listVariableRename): + + listType = [] + i = 0 + + while i < len(listVariableRename): + + type = listVariableRename[i][0] + if type not in listType: + listType.append(type) + + listCurrentVar = [] + + for variable in listVariableRename: + + if variable[0] == type: + listCurrentVar.append(variable[1]) + + + line = line.replace(type, "") + + for variable in listCurrentVar: + + ###gestion var++ et var-- + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', type+"="+type+"+1", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', type+"="+type+"-1", line) + + line = re.sub(r'\s{1,}'+variable+r'\s{1,}', type, line) + + ###gestion de opérateur mathématique + line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', type+"-", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', type+"+", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', type+"*", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', type+"|divide|", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', type+"=", line) + + ###gestion des symbile [] + line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+type+"]", line) + + ###gestion de symbole ; + line = re.sub(r'\s{0,}'+variable+r'\s{0,};', type+";", line) + + ###gestion de symbole . + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', type+".", line) + + ###gestion de symbole [ + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', type+"[", line) + + ###gestion des symboles < > + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', type+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', type+">", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+type+">", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+type+"<", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+type+"<", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+type+">", line) + + ###gestion du séparateur "," + line = re.sub(r'\s{0,}'+variable+r'\s{0,},', type+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+type+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+type+"=", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+type+")", line) + + ###gestion des symbole ( ) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', type+")", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+type+",", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+type+")", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', type+"!", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', type+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', type+">", line) + + i += 1 + + return line + + + + + + +def sanitize_list(liste_variable): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + + id = 0 + for elt in liste_variable: + cpt = elt[0].count('>') + + if cpt == 0: + newElt = (elt[0] + " ", elt[1]) + elt = newElt + liste_variable[id] = newElt + + id += 1 + + return liste_variable + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "//" in ligne: + tab_line = ligne.split("//") + code_without_comentary.append(tab_line[0]) + + elif "/*" in ligne and "*/" in ligne: + tab_line1 = ligne.split("/*") + tab_line2 = ligne.split("*/") + new_line = tab_line1[0] + tab_line2[len(tab_line2)-1] + code_without_comentary.append(new_line) + + elif "/*" in ligne: + tab_line = ligne.split("/*") + code_without_comentary.append(tab_line[0]) + long_comment = True + + elif "*/" in ligne: + tab_line = ligne.split("*/") + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = False + + + elif not long_comment: + code_without_comentary.append(ligne) + + + + return code_without_comentary + + +def excecEvalPlagiat(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + long_comment = False + + lignesCompacte = "" + newBlock = [] + functionCode = "" + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + if "#include" not in ligne and "using namespace" not in ligne: + + ligne = ligne.replace('\n', '') + + listeVarInitFunction = findVariableInFuction(ligne) + + if listeVarInitFunction != []: + + if listVariableRename != []: + + listFunction.append(listVariableRename) + functionCode= "" + listVariableRename=[] + listVarToRenameFunction = [] + lastListVariableRename = [] + + i = 0 + while i < len(listeVarInitFunction): + if listeVarInitFunction[i] not in listVariableRename and listeVarInitFunction[i] != "": + listVariableRename.append(listeVarInitFunction[i]) + i += 1 + + else: + listVarToRenameFunction = listeVarInitFunction + + i = 0 + while i < len(listVarToRenameFunction): + if listVarToRenameFunction[i] not in listVariableRename and listVarToRenameFunction[i] != "": + listVariableRename.append(listVarToRenameFunction[i]) + i += 1 + + + else: + listVarToRenameFunction = listeVarInitFunction + findVariableDeclare(ligne) + + i = 0 + while i < len(listVarToRenameFunction): + if listVarToRenameFunction[i] not in listVariableRename and listVarToRenameFunction[i] != "": + listVariableRename.append(listVarToRenameFunction[i]) + i += 1 + + + + lignesCompacte +=ligne + + listFunction.append(listVariableRename) + + blockCodesWithRenameVariable = [] + listFunctionCode = find_function(lignesCompacte) + + + for function in listFunctionCode: + blockCodesWithRenameVariable.append(function) + + codeRename = "" + i=0 + for elt in blockCodesWithRenameVariable: + codeRename += rename_variable(elt, listFunction[i]) + i +=1 + + blockCodes = find_block(codeRename) + + return blockCodes \ No newline at end of file diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py new file mode 100644 index 0000000..e674b8f --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -0,0 +1,592 @@ +import re + + + +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + + + + + + + + + + + + +dico_stemming = { + "def": "d", + "while": "w", + "for": "f", + "if": "i", + "elif": "ei", + "else": "e", + "<=": "c", + ">=": "c", + "<": "c", + ">": "c", + "def": "d", + "!=": "!", + "==": "-", + "and": "&", + "or": "|", + "var": "v", + "del": "d", + "from": "w", + "not": "n", + "while": "w", + "assert": "as", + "global": "gl", + "as": "as", + "break": "bk", + "continue": "ct", + "lambda": "lb", + "try": "t", + "with": "wh", + "except": "ex", + "pass": "ps", + "yield": "y", + "import": "ip", + "finally": "fn", + "class": "cl", + "raise": "rs", + "exec": "ex", + "is": "is", + "in": "in", + "print": "", + "True": "tr", + "False": "fl", +} + +dico_supression = { + " ": "", + "{": "", + "}": "", + "(": "", + ")": "", + ";": "", + ":": "" + +} + + +def delete_string(ligne): + delete = False + list_chain_to_remove = [] + + if ligne.count("\"") > 0: + + i = 0 + chain_to_remove = "" + + while i < len(ligne): + + if ligne[i] == '\"': + list_chain_to_remove.append(chain_to_remove) + chain_to_remove = "" + delete = not delete + + if delete and ligne[i] != '"': + chain_to_remove = chain_to_remove + ligne[i] + + i += 1 + + for chain in list_chain_to_remove: + ligne = ligne.replace(chain, "") + + ligne = ligne.replace("\"\"", "\"") + + return ligne + + +def replace_by_new_content(ligne): + for key in dico_stemming: + ligne = ligne.replace(key, dico_stemming[key]) + + return ligne + + +def delete_unuse_content(ligne): + for key in dico_supression: + ligne = ligne.replace(key, dico_supression[key]) + + return ligne + + +def sanitize_content(ligne): + filtered_content = "" + + ligne = delete_string(ligne) + filtered_content = filtered_content + (replace_by_new_content(ligne)) + filtered_content = delete_unuse_content(filtered_content) + + return filtered_content + + + +def findVariableInFuction(line): + listVariable = [] + variable = "" + + i = 0 + if line.count('def') > 0: + start = False + end = False + + while i < len(line): + + if line[i] == "(": + start = True + i=i+1 + + + if start and not end: + + if line[i] != "," and line[i] != ")": + + if line[i] != " ": + variable += line[i] + + else: + listVariable.append(variable) + variable = "" + + if line[i] == ")": + end = True + + i +=1 + + return listVariable + + + + +def findVariableDeclare(ligne): + listVariable = [] + + if "=" in ligne: + i = 0 + find = False + + while i < len(ligne) and not find: + if ligne[i] == "=": + + notFind = True + findSeparator = True + permissionParcourtWord = False + + k = i + var = "" + while k > 0 and notFind: + + if ligne[k] == " ": + permissionParcourtWord = False + + if var != "": + listVariable.append(var) + var = "" + + if ligne[k] == ",": + + findSeparator = True + permissionParcourtWord = False + + if var != "": + listVariable.append(var) + var = "" + + + if ligne[k] != "," and ligne[k] != " " and k != i: + + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var + + else: + notFind = False + + k -= 1 + + i += 1 + + if " in " in ligne: + findIn = False + notFind = True + permissionParcourtWord = False + + p = 0 + while p < len(ligne) and notFind: + if len(ligne) > p + 3: + if ligne[p] == " ": + if ligne[p+1] == "i": + if ligne[p + 2] == "n": + if ligne[p + 3] == " ": + findIn = True + + if findIn: + var = "" + m=p + while m > 0: + + if ligne[m] != " ": + if not permissionParcourtWord: + permissionParcourtWord = True + + elif permissionParcourtWord: + notFind = False + permissionParcourtWord = False + + if var != "" and var not in listVariable: + listVariable.append(var) + + if permissionParcourtWord and notFind: + var = ligne[m]+var + + + + m -=1 + + p +=1 + + + + return listVariable + + +def update_block(newBlock, blockCodes): + if newBlock in blockCodes: + blockCodes[newBlock] += 1 + + else: + blockCodes.update({newBlock: 1}) + + return blockCodes + + +def find_indentation(line): + + cpt = 0 + while cpt < len(line): + + symbole = line[cpt] + + if symbole == " ": + cpt +=1 + + elif symbole == "": + return 0 + + elif symbole == "\n": + return 0 + + elif symbole == "#": + return 0 + + else: + return cpt + + + return cpt + + +def find_block(code): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + listBlock = [] + i = 0 + lastIndentationValue=0 + currentIndentationValue = 0 + blockCodes = "" + save=0 + + for line in code: + + sanitize_line = line.replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") + + if len(sanitize_line) > 0: + + lastIndentationValue = save + currentIndentationValue = find_indentation(line) + + if currentIndentationValue > lastIndentationValue : + + k=i + + + blockCreate = False + blockCodes = "" + save = find_indentation(line) + + while not blockCreate and k < len(code): + + sanitize_line = code[k].replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") + + if len(sanitize_line) > 0: + + linebis = code[k] + newVal = find_indentation(linebis) + + if newVal != -1: + currentIndentationValue = newVal + + + if currentIndentationValue > lastIndentationValue: + blockCodes = blockCodes+linebis + + + else: + blockCreate = True + + k +=1 + + listBlock.append(blockCodes) + + else: + if find_indentation(line) != -1: + save = find_indentation(line) + + i +=1 + + + return listBlock + + + + +def find_function(line): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + + blockCodes = [] + i = 0 + newBlock="" + addAblock = False + + while i < len(line): + + if len(line)>i+4: + if line[i] == "d": + if line[i+1] == "e": + if line[i + 1] == "f": + if line[i + 1] == " ": + + if newBlock != "": + blockCodes.append(newBlock) + newBlock="" + + newBlock += line[i] + i +=1 + + return blockCodes + +def line_is_comment(line): + line.replace(" ","") + + if len(line)>0: + if line[0] == "#": + return True + else: + return False + + + + + +def rename_variable(line, listVariableRename): + + i = 0 + var = "var" + lineIndentation = find_indentation(line) + + a = 0 + espace = "" + while a < lineIndentation: + espace += " " + a +=1 + + for variable in listVariableRename: + + ###gestion var++ et var-- + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) + + line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) + + ###gestion de opérateur mathématique + line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) + + ###gestion des symbile [] + line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) + + ###gestion de symbole ; + # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) + + ###gestion de symbole . + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) + + ###gestion de symbole [ + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) + # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) + + ###gestion des symboles < > + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) + # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) + # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) + + ###gestion du séparateur "," + line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) + + ###gestion des symbole ( ) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) + + line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) + + + return line + + + +def sanitize_dict_(dict): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + + sanitize_dict = [] + + for block in dict: + sanitizeBlock = sanitize_content(block) + sanitizeBlock = re.sub('[0-9]{1,}', '*', sanitizeBlock) + + if len(sanitizeBlock) > 75: + sanitize_dict.append(sanitizeBlock) + + return sanitize_dict + + + +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] + + for ligne in lignes: + + if "#" in ligne: + tab_line = ligne.split("#") + + if "\n" not in tab_line[0]: + tab_line[0] = tab_line[0] + "\n" + + code_without_comentary.append(tab_line[0]) + + elif ligne.count("\"\"\"") == 2: + tab_line = ligne.split("\"\"\"") + new_line = tab_line[0] + tab_line[len(tab_line)-1] + code_without_comentary.append(new_line) + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[0]) + long_comment = not long_comment + + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = not long_comment + + elif not long_comment: + code_without_comentary.append(ligne) + + return code_without_comentary + + +def excecEvalPlagiat(code): + + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] + + listVarBlock = [] + lignes = code.split("\n") + + scopeCodeUser = False + firstInsert = False + + lignesCompacte = [] + newBlock = [] + functionCode = "" + listVarToRename = [] + + lignes = remove_comentary(lignes) + + for ligne in lignes: + + if not line_is_comment(ligne): + ligneBis = ligne + + listeVarInitFunction = findVariableInFuction(ligne) + listeVarContentFunction = [] + + if listeVarInitFunction == []: + listeVarContentFunction = findVariableDeclare(ligne) + + listVarToRename = listeVarContentFunction + listeVarInitFunction + + i = 0 + while i < len(listVarToRename): + + if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": + listVariableRename.append(listVarToRename[i]) + i += 1 + + lignesCompacte.append(ligneBis) + + + + blockCodes = find_block(lignesCompacte) + + + renameBlock = [] + for block in blockCodes: + renameBlock.append(rename_variable(block, listVariableRename)) + + sanitize_code_dict = sanitize_dict_(renameBlock) + + return sanitize_code_dict \ No newline at end of file diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 849b932..4b61212 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,6 +90,8 @@ export class GodBoxRepository { "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code.evalPlagiat import excecEvalPlagiat \n"+ + "if __name__ == '__main__': \n"+ " import os \n"+ @@ -110,6 +112,7 @@ export class GodBoxRepository { " \"eval_redondance\": excecEvalRedondance(lignes), \n"+ " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(lignes), \n"+ " \"eval_commentaire\": excecEvalCommentaire(lignes) \n"+ + " \"eval_plagiat\": excecEvalPlagiat(lignes) \n"+ " } \n"+ " filin.close() \n"+ " print(payload) \n" From 3a4160994c52deecb9774521504a322bc7966239 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 18:44:37 +0200 Subject: [PATCH 135/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 4b61212..c18209e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -175,6 +175,8 @@ export class GodBoxRepository { files: await this.bundleExecEvaluationCode(code, language), }; + console.log(payload) + try { const { data }: { data: { phases: GodboxPhaseOutputDTO[] } } = await axios.post(`${godboxConfig.baseUrl}/run`, payload); From ae1c6798f56d491fb19cef6c0976f64ae5f2647e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 18:50:36 +0200 Subject: [PATCH 136/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/attempts/attempts.service.ts | 4 +++- heroku_deploy/api/src/exec-server/godbox.repository.ts | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 1c284fc..8dd6321 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -43,9 +43,11 @@ export class AttemptsService { insertAttemptDTO.code, execBootstrap, ); + console.log("COUCOUTEST ALGO") console.log(execResultsAlgoEvaluation["stdout"]) - execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] + + // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] const attempt = ( await new this.attemptModel({ diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index c18209e..ef843db 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -175,7 +175,6 @@ export class GodBoxRepository { files: await this.bundleExecEvaluationCode(code, language), }; - console.log(payload) try { const { data }: { data: { phases: GodboxPhaseOutputDTO[] } } = From 8f17b699344b92c640c2555e4f6d6af4326e3bae Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 18:54:44 +0200 Subject: [PATCH 137/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index ef843db..fba2d8e 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,29 +90,21 @@ export class GodBoxRepository { "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ - "from evaluation_code.evalPlagiat import excecEvalPlagiat \n"+ - "if __name__ == '__main__': \n"+ - " import os \n"+ " import re \n"+ - " filin = open(\"userCode.py\", \"r\") \n"+ " lignes = filin.readlines()\n"+ - " new_lignes = []\n"+ " for ligne in lignes:\n"+ " ligne.replace(\"\\n\", \"\")\n"+ " new_lignes.append(ligne)\n"+ - " lignes = new_lignes\n"+ - " payload = { \n"+ " \"eval_variable_name\":excecEvalVariableName(lignes), \n"+ " \"eval_redondance\": excecEvalRedondance(lignes), \n"+ " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(lignes), \n"+ " \"eval_commentaire\": excecEvalCommentaire(lignes) \n"+ - " \"eval_plagiat\": excecEvalPlagiat(lignes) \n"+ " } \n"+ " filin.close() \n"+ " print(payload) \n" From c8311c19d594df5657ee835f06c2bd1f6db6d3ca Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:10:33 +0200 Subject: [PATCH 138/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index fba2d8e..87d0c7c 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,6 +90,7 @@ export class GodBoxRepository { "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ + "from evaluation_code.excecEvalPlagiat import evalPlagiat \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ " import re \n"+ From c45ed80930d8fbec13f7bb12facc2818e33f6f8c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:14:00 +0200 Subject: [PATCH 139/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 87d0c7c..a35d5cd 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -90,7 +90,7 @@ export class GodBoxRepository { "from evaluation_code.evalCommentaire import excecEvalCommentaire \n"+ "from evaluation_code.evalRedondance import excecEvalRedondance \n"+ "from evaluation_code.evalVariableName import excecEvalVariableName \n"+ - "from evaluation_code.excecEvalPlagiat import evalPlagiat \n"+ + "from evaluation_code.evalPlagiat import excecEvalPlagiat \n"+ "if __name__ == '__main__': \n"+ " import os \n"+ " import re \n"+ From 99f62298b15eb68a4fa432064ce89cb13e3e140d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:21:39 +0200 Subject: [PATCH 140/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index a35d5cd..8d0f155 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -106,6 +106,8 @@ export class GodBoxRepository { " \"eval_redondance\": excecEvalRedondance(lignes), \n"+ " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(lignes), \n"+ " \"eval_commentaire\": excecEvalCommentaire(lignes) \n"+ + " \"eval_plagiat\": excecEvalPlagiat(lignes) \n"+ + " } \n"+ " filin.close() \n"+ " print(payload) \n" From e120d5f5cf7e40ba89a681604054452abe71239e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:28:07 +0200 Subject: [PATCH 141/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/evaluation_code/python/evalPlagiat.py | 777 +++++++++--------- 1 file changed, 389 insertions(+), 388 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index e674b8f..34065eb 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -2,15 +2,15 @@ -PATERN_VARIABLE = [ - r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', - r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', - r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', +# PATERN_VARIABLE = [ +# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', +# r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', +# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', - r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', - r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', - r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', -] +# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', +# r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', +# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +# ] @@ -25,568 +25,569 @@ -dico_stemming = { - "def": "d", - "while": "w", - "for": "f", - "if": "i", - "elif": "ei", - "else": "e", - "<=": "c", - ">=": "c", - "<": "c", - ">": "c", - "def": "d", - "!=": "!", - "==": "-", - "and": "&", - "or": "|", - "var": "v", - "del": "d", - "from": "w", - "not": "n", - "while": "w", - "assert": "as", - "global": "gl", - "as": "as", - "break": "bk", - "continue": "ct", - "lambda": "lb", - "try": "t", - "with": "wh", - "except": "ex", - "pass": "ps", - "yield": "y", - "import": "ip", - "finally": "fn", - "class": "cl", - "raise": "rs", - "exec": "ex", - "is": "is", - "in": "in", - "print": "", - "True": "tr", - "False": "fl", -} +# dico_stemming = { +# "def": "d", +# "while": "w", +# "for": "f", +# "if": "i", +# "elif": "ei", +# "else": "e", +# "<=": "c", +# ">=": "c", +# "<": "c", +# ">": "c", +# "def": "d", +# "!=": "!", +# "==": "-", +# "and": "&", +# "or": "|", +# "var": "v", +# "del": "d", +# "from": "w", +# "not": "n", +# "while": "w", +# "assert": "as", +# "global": "gl", +# "as": "as", +# "break": "bk", +# "continue": "ct", +# "lambda": "lb", +# "try": "t", +# "with": "wh", +# "except": "ex", +# "pass": "ps", +# "yield": "y", +# "import": "ip", +# "finally": "fn", +# "class": "cl", +# "raise": "rs", +# "exec": "ex", +# "is": "is", +# "in": "in", +# "print": "", +# "True": "tr", +# "False": "fl", +# } -dico_supression = { - " ": "", - "{": "", - "}": "", - "(": "", - ")": "", - ";": "", - ":": "" +# dico_supression = { +# " ": "", +# "{": "", +# "}": "", +# "(": "", +# ")": "", +# ";": "", +# ":": "" -} +# } -def delete_string(ligne): - delete = False - list_chain_to_remove = [] +# def delete_string(ligne): +# delete = False +# list_chain_to_remove = [] - if ligne.count("\"") > 0: +# if ligne.count("\"") > 0: - i = 0 - chain_to_remove = "" +# i = 0 +# chain_to_remove = "" - while i < len(ligne): +# while i < len(ligne): - if ligne[i] == '\"': - list_chain_to_remove.append(chain_to_remove) - chain_to_remove = "" - delete = not delete +# if ligne[i] == '\"': +# list_chain_to_remove.append(chain_to_remove) +# chain_to_remove = "" +# delete = not delete - if delete and ligne[i] != '"': - chain_to_remove = chain_to_remove + ligne[i] +# if delete and ligne[i] != '"': +# chain_to_remove = chain_to_remove + ligne[i] - i += 1 +# i += 1 - for chain in list_chain_to_remove: - ligne = ligne.replace(chain, "") +# for chain in list_chain_to_remove: +# ligne = ligne.replace(chain, "") - ligne = ligne.replace("\"\"", "\"") +# ligne = ligne.replace("\"\"", "\"") - return ligne +# return ligne -def replace_by_new_content(ligne): - for key in dico_stemming: - ligne = ligne.replace(key, dico_stemming[key]) +# def replace_by_new_content(ligne): +# for key in dico_stemming: +# ligne = ligne.replace(key, dico_stemming[key]) - return ligne +# return ligne -def delete_unuse_content(ligne): - for key in dico_supression: - ligne = ligne.replace(key, dico_supression[key]) +# def delete_unuse_content(ligne): +# for key in dico_supression: +# ligne = ligne.replace(key, dico_supression[key]) - return ligne +# return ligne -def sanitize_content(ligne): - filtered_content = "" +# def sanitize_content(ligne): +# filtered_content = "" - ligne = delete_string(ligne) - filtered_content = filtered_content + (replace_by_new_content(ligne)) - filtered_content = delete_unuse_content(filtered_content) +# ligne = delete_string(ligne) +# filtered_content = filtered_content + (replace_by_new_content(ligne)) +# filtered_content = delete_unuse_content(filtered_content) - return filtered_content +# return filtered_content -def findVariableInFuction(line): - listVariable = [] - variable = "" +# def findVariableInFuction(line): +# listVariable = [] +# variable = "" - i = 0 - if line.count('def') > 0: - start = False - end = False +# i = 0 +# if line.count('def') > 0: +# start = False +# end = False - while i < len(line): +# while i < len(line): - if line[i] == "(": - start = True - i=i+1 +# if line[i] == "(": +# start = True +# i=i+1 - if start and not end: +# if start and not end: - if line[i] != "," and line[i] != ")": +# if line[i] != "," and line[i] != ")": - if line[i] != " ": - variable += line[i] +# if line[i] != " ": +# variable += line[i] - else: - listVariable.append(variable) - variable = "" +# else: +# listVariable.append(variable) +# variable = "" - if line[i] == ")": - end = True +# if line[i] == ")": +# end = True - i +=1 +# i +=1 - return listVariable +# return listVariable -def findVariableDeclare(ligne): - listVariable = [] +# def findVariableDeclare(ligne): +# listVariable = [] - if "=" in ligne: - i = 0 - find = False +# if "=" in ligne: +# i = 0 +# find = False - while i < len(ligne) and not find: - if ligne[i] == "=": +# while i < len(ligne) and not find: +# if ligne[i] == "=": - notFind = True - findSeparator = True - permissionParcourtWord = False +# notFind = True +# findSeparator = True +# permissionParcourtWord = False - k = i - var = "" - while k > 0 and notFind: +# k = i +# var = "" +# while k > 0 and notFind: - if ligne[k] == " ": - permissionParcourtWord = False +# if ligne[k] == " ": +# permissionParcourtWord = False - if var != "": - listVariable.append(var) - var = "" +# if var != "": +# listVariable.append(var) +# var = "" - if ligne[k] == ",": +# if ligne[k] == ",": - findSeparator = True - permissionParcourtWord = False +# findSeparator = True +# permissionParcourtWord = False - if var != "": - listVariable.append(var) - var = "" +# if var != "": +# listVariable.append(var) +# var = "" - if ligne[k] != "," and ligne[k] != " " and k != i: +# if ligne[k] != "," and ligne[k] != " " and k != i: - if findSeparator or permissionParcourtWord: - findSeparator = False - permissionParcourtWord = True - var = ligne[k]+var +# if findSeparator or permissionParcourtWord: +# findSeparator = False +# permissionParcourtWord = True +# var = ligne[k]+var - else: - notFind = False +# else: +# notFind = False - k -= 1 +# k -= 1 - i += 1 +# i += 1 - if " in " in ligne: - findIn = False - notFind = True - permissionParcourtWord = False +# if " in " in ligne: +# findIn = False +# notFind = True +# permissionParcourtWord = False - p = 0 - while p < len(ligne) and notFind: - if len(ligne) > p + 3: - if ligne[p] == " ": - if ligne[p+1] == "i": - if ligne[p + 2] == "n": - if ligne[p + 3] == " ": - findIn = True +# p = 0 +# while p < len(ligne) and notFind: +# if len(ligne) > p + 3: +# if ligne[p] == " ": +# if ligne[p+1] == "i": +# if ligne[p + 2] == "n": +# if ligne[p + 3] == " ": +# findIn = True - if findIn: - var = "" - m=p - while m > 0: +# if findIn: +# var = "" +# m=p +# while m > 0: - if ligne[m] != " ": - if not permissionParcourtWord: - permissionParcourtWord = True +# if ligne[m] != " ": +# if not permissionParcourtWord: +# permissionParcourtWord = True - elif permissionParcourtWord: - notFind = False - permissionParcourtWord = False +# elif permissionParcourtWord: +# notFind = False +# permissionParcourtWord = False - if var != "" and var not in listVariable: - listVariable.append(var) +# if var != "" and var not in listVariable: +# listVariable.append(var) - if permissionParcourtWord and notFind: - var = ligne[m]+var +# if permissionParcourtWord and notFind: +# var = ligne[m]+var - m -=1 +# m -=1 - p +=1 +# p +=1 - return listVariable +# return listVariable -def update_block(newBlock, blockCodes): - if newBlock in blockCodes: - blockCodes[newBlock] += 1 +# def update_block(newBlock, blockCodes): +# if newBlock in blockCodes: +# blockCodes[newBlock] += 1 - else: - blockCodes.update({newBlock: 1}) +# else: +# blockCodes.update({newBlock: 1}) - return blockCodes +# return blockCodes -def find_indentation(line): +# def find_indentation(line): - cpt = 0 - while cpt < len(line): +# cpt = 0 +# while cpt < len(line): - symbole = line[cpt] +# symbole = line[cpt] - if symbole == " ": - cpt +=1 +# if symbole == " ": +# cpt +=1 - elif symbole == "": - return 0 +# elif symbole == "": +# return 0 - elif symbole == "\n": - return 0 +# elif symbole == "\n": +# return 0 - elif symbole == "#": - return 0 +# elif symbole == "#": +# return 0 - else: - return cpt +# else: +# return cpt - return cpt +# return cpt -def find_block(code): - """ - :param: line: représente le code à analyser - :return retourne les différents blocks représentant ce code (fonction while for if ..) - """ - listBlock = [] - i = 0 - lastIndentationValue=0 - currentIndentationValue = 0 - blockCodes = "" - save=0 +# def find_block(code): +# """ +# :param: line: représente le code à analyser +# :return retourne les différents blocks représentant ce code (fonction while for if ..) +# """ +# listBlock = [] +# i = 0 +# lastIndentationValue=0 +# currentIndentationValue = 0 +# blockCodes = "" +# save=0 - for line in code: +# for line in code: - sanitize_line = line.replace(" ", "") - sanitize_line = sanitize_line.replace("\n", "") +# sanitize_line = line.replace(" ", "") +# sanitize_line = sanitize_line.replace("\n", "") - if len(sanitize_line) > 0: +# if len(sanitize_line) > 0: - lastIndentationValue = save - currentIndentationValue = find_indentation(line) +# lastIndentationValue = save +# currentIndentationValue = find_indentation(line) - if currentIndentationValue > lastIndentationValue : +# if currentIndentationValue > lastIndentationValue : - k=i +# k=i - blockCreate = False - blockCodes = "" - save = find_indentation(line) +# blockCreate = False +# blockCodes = "" +# save = find_indentation(line) - while not blockCreate and k < len(code): +# while not blockCreate and k < len(code): - sanitize_line = code[k].replace(" ", "") - sanitize_line = sanitize_line.replace("\n", "") +# sanitize_line = code[k].replace(" ", "") +# sanitize_line = sanitize_line.replace("\n", "") - if len(sanitize_line) > 0: +# if len(sanitize_line) > 0: - linebis = code[k] - newVal = find_indentation(linebis) +# linebis = code[k] +# newVal = find_indentation(linebis) - if newVal != -1: - currentIndentationValue = newVal +# if newVal != -1: +# currentIndentationValue = newVal - if currentIndentationValue > lastIndentationValue: - blockCodes = blockCodes+linebis +# if currentIndentationValue > lastIndentationValue: +# blockCodes = blockCodes+linebis - else: - blockCreate = True +# else: +# blockCreate = True - k +=1 +# k +=1 - listBlock.append(blockCodes) +# listBlock.append(blockCodes) - else: - if find_indentation(line) != -1: - save = find_indentation(line) +# else: +# if find_indentation(line) != -1: +# save = find_indentation(line) - i +=1 +# i +=1 - return listBlock +# return listBlock -def find_function(line): - """ - :param: line: représente le code à analyser - :return retourne les différents blocks représentant ce code (fonction while for if ..) - """ +# def find_function(line): +# """ +# :param: line: représente le code à analyser +# :return retourne les différents blocks représentant ce code (fonction while for if ..) +# """ - blockCodes = [] - i = 0 - newBlock="" - addAblock = False +# blockCodes = [] +# i = 0 +# newBlock="" +# addAblock = False - while i < len(line): +# while i < len(line): - if len(line)>i+4: - if line[i] == "d": - if line[i+1] == "e": - if line[i + 1] == "f": - if line[i + 1] == " ": +# if len(line)>i+4: +# if line[i] == "d": +# if line[i+1] == "e": +# if line[i + 1] == "f": +# if line[i + 1] == " ": - if newBlock != "": - blockCodes.append(newBlock) - newBlock="" +# if newBlock != "": +# blockCodes.append(newBlock) +# newBlock="" - newBlock += line[i] - i +=1 +# newBlock += line[i] +# i +=1 - return blockCodes +# return blockCodes -def line_is_comment(line): - line.replace(" ","") +# def line_is_comment(line): +# line.replace(" ","") - if len(line)>0: - if line[0] == "#": - return True - else: - return False +# if len(line)>0: +# if line[0] == "#": +# return True +# else: +# return False -def rename_variable(line, listVariableRename): +# def rename_variable(line, listVariableRename): - i = 0 - var = "var" - lineIndentation = find_indentation(line) +# i = 0 +# var = "var" +# lineIndentation = find_indentation(line) - a = 0 - espace = "" - while a < lineIndentation: - espace += " " - a +=1 +# a = 0 +# espace = "" +# while a < lineIndentation: +# espace += " " +# a +=1 - for variable in listVariableRename: +# for variable in listVariableRename: - ###gestion var++ et var-- - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) +# ###gestion var++ et var-- +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) - line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) +# line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) - ###gestion de opérateur mathématique - line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) +# ###gestion de opérateur mathématique +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) - ###gestion des symbile [] - line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) +# ###gestion des symbile [] +# line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) - ###gestion de symbole ; - # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) +# ###gestion de symbole ; +# # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) - ###gestion de symbole . - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) +# ###gestion de symbole . +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) - ###gestion de symbole [ - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) - # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) +# ###gestion de symbole [ +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) +# # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) - ###gestion des symboles < > - line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) - line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) - line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) - # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) - # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) +# ###gestion des symboles < > +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) +# line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) +# line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) +# # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) +# # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) - ###gestion du séparateur "," - line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) - line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) - line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) - line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) +# ###gestion du séparateur "," +# line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) +# line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) +# line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) +# line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) - ###gestion des symbole ( ) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) - line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) - line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) +# ###gestion des symbole ( ) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) +# line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) +# line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) - line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) +# line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) - return line +# return line -def sanitize_dict_(dict): - """ - :param liste_variable: représente la liste des variables du code - :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection - """ +# def sanitize_dict_(dict): +# """ +# :param liste_variable: représente la liste des variables du code +# :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection +# """ - sanitize_dict = [] +# sanitize_dict = [] - for block in dict: - sanitizeBlock = sanitize_content(block) - sanitizeBlock = re.sub('[0-9]{1,}', '*', sanitizeBlock) +# for block in dict: +# sanitizeBlock = sanitize_content(block) +# sanitizeBlock = re.sub('[0-9]{1,}', '*', sanitizeBlock) - if len(sanitizeBlock) > 75: - sanitize_dict.append(sanitizeBlock) +# if len(sanitizeBlock) > 75: +# sanitize_dict.append(sanitizeBlock) - return sanitize_dict +# return sanitize_dict -def remove_comentary(lignes): - """ - :param liste_variable: représente la liste des variables du code - :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection - """ - long_comment = False - code_without_comentary = [] +# def remove_comentary(lignes): +# """ +# :param liste_variable: représente la liste des variables du code +# :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection +# """ +# long_comment = False +# code_without_comentary = [] - for ligne in lignes: +# for ligne in lignes: - if "#" in ligne: - tab_line = ligne.split("#") +# if "#" in ligne: +# tab_line = ligne.split("#") - if "\n" not in tab_line[0]: - tab_line[0] = tab_line[0] + "\n" +# if "\n" not in tab_line[0]: +# tab_line[0] = tab_line[0] + "\n" - code_without_comentary.append(tab_line[0]) +# code_without_comentary.append(tab_line[0]) - elif ligne.count("\"\"\"") == 2: - tab_line = ligne.split("\"\"\"") - new_line = tab_line[0] + tab_line[len(tab_line)-1] - code_without_comentary.append(new_line) +# elif ligne.count("\"\"\"") == 2: +# tab_line = ligne.split("\"\"\"") +# new_line = tab_line[0] + tab_line[len(tab_line)-1] +# code_without_comentary.append(new_line) - elif "\"\"\"" in ligne: - tab_line = ligne.split("\"\"\"" ) - code_without_comentary.append(tab_line[0]) - long_comment = not long_comment +# elif "\"\"\"" in ligne: +# tab_line = ligne.split("\"\"\"" ) +# code_without_comentary.append(tab_line[0]) +# long_comment = not long_comment - elif "\"\"\"" in ligne: - tab_line = ligne.split("\"\"\"" ) - code_without_comentary.append(tab_line[len(tab_line)-1]) - long_comment = not long_comment +# elif "\"\"\"" in ligne: +# tab_line = ligne.split("\"\"\"" ) +# code_without_comentary.append(tab_line[len(tab_line)-1]) +# long_comment = not long_comment - elif not long_comment: - code_without_comentary.append(ligne) +# elif not long_comment: +# code_without_comentary.append(ligne) - return code_without_comentary +# return code_without_comentary def excecEvalPlagiat(code): + return 0 - listFunction = [] - listVariableRename = [] - lastListVariableRename = [] + # listFunction = [] + # listVariableRename = [] + # lastListVariableRename = [] - listVarBlock = [] - lignes = code.split("\n") + # listVarBlock = [] + # lignes = code.split("\n") - scopeCodeUser = False - firstInsert = False + # scopeCodeUser = False + # firstInsert = False - lignesCompacte = [] - newBlock = [] - functionCode = "" - listVarToRename = [] + # lignesCompacte = [] + # newBlock = [] + # functionCode = "" + # listVarToRename = [] - lignes = remove_comentary(lignes) + # lignes = remove_comentary(lignes) - for ligne in lignes: + # for ligne in lignes: - if not line_is_comment(ligne): - ligneBis = ligne + # if not line_is_comment(ligne): + # ligneBis = ligne - listeVarInitFunction = findVariableInFuction(ligne) - listeVarContentFunction = [] + # listeVarInitFunction = findVariableInFuction(ligne) + # listeVarContentFunction = [] - if listeVarInitFunction == []: - listeVarContentFunction = findVariableDeclare(ligne) + # if listeVarInitFunction == []: + # listeVarContentFunction = findVariableDeclare(ligne) - listVarToRename = listeVarContentFunction + listeVarInitFunction + # listVarToRename = listeVarContentFunction + listeVarInitFunction - i = 0 - while i < len(listVarToRename): + # i = 0 + # while i < len(listVarToRename): - if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": - listVariableRename.append(listVarToRename[i]) - i += 1 + # if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": + # listVariableRename.append(listVarToRename[i]) + # i += 1 - lignesCompacte.append(ligneBis) + # lignesCompacte.append(ligneBis) - blockCodes = find_block(lignesCompacte) + # blockCodes = find_block(lignesCompacte) - renameBlock = [] - for block in blockCodes: - renameBlock.append(rename_variable(block, listVariableRename)) + # renameBlock = [] + # for block in blockCodes: + # renameBlock.append(rename_variable(block, listVariableRename)) - sanitize_code_dict = sanitize_dict_(renameBlock) + # sanitize_code_dict = sanitize_dict_(renameBlock) - return sanitize_code_dict \ No newline at end of file + # return sanitize_code_dict \ No newline at end of file From 2a3d42268f997a3798c9dfbafc4a2096bc31e7b8 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:41:33 +0200 Subject: [PATCH 142/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/evaluation_code/python/evalPlagiat.py | 2 -- heroku_deploy/api/src/exec-server/godbox.repository.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index 34065eb..453a3dc 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -1,7 +1,5 @@ import re - - # PATERN_VARIABLE = [ # r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', # r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', diff --git a/heroku_deploy/api/src/exec-server/godbox.repository.ts b/heroku_deploy/api/src/exec-server/godbox.repository.ts index 8d0f155..f6e28b3 100644 --- a/heroku_deploy/api/src/exec-server/godbox.repository.ts +++ b/heroku_deploy/api/src/exec-server/godbox.repository.ts @@ -105,7 +105,7 @@ export class GodBoxRepository { " \"eval_variable_name\":excecEvalVariableName(lignes), \n"+ " \"eval_redondance\": excecEvalRedondance(lignes), \n"+ " \"eval_nb ligne_fonction\": excecEvalNbLigneFonction(lignes), \n"+ - " \"eval_commentaire\": excecEvalCommentaire(lignes) \n"+ + " \"eval_commentaire\": excecEvalCommentaire(lignes), \n"+ " \"eval_plagiat\": excecEvalPlagiat(lignes) \n"+ " } \n"+ From 02ac0b1cb6b06ed00d3103ca7cd04be50d6bfe4a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:47:21 +0200 Subject: [PATCH 143/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/evaluation_code/python/evalPlagiat.py | 795 +++++++++--------- 1 file changed, 393 insertions(+), 402 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index 453a3dc..8498df4 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -1,591 +1,582 @@ import re -# PATERN_VARIABLE = [ -# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', -# r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', -# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', +PATERN_VARIABLE = [ + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s*', + r'[A-Za-z0-9_]{1,}\s{0,}<[A-Za-z0-9_]{1,}>\s{0,}[A-Za-z0-9_]{1,}', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}', + + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', + r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', + r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', +] + + + + -# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{0,};', -# r'[A-Za-z0-9_]{1,}\s*<[A-Za-z0-9_]{1,}>\s*[A-Za-z0-9_]{0,};', -# r'[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{1,}\s{1,}[A-Za-z0-9_]{0,};', -# ] +dico_stemming = { + "def": "d", + "while": "w", + "for": "f", + "if": "i", + "elif": "ei", + "else": "e", + "<=": "c", + ">=": "c", + "<": "c", + ">": "c", + "def": "d", + "!=": "!", + "==": "-", + "and": "&", + "or": "|", + "var": "v", + "del": "d", + "from": "w", + "not": "n", + "while": "w", + "assert": "as", + "global": "gl", + "as": "as", + "break": "bk", + "continue": "ct", + "lambda": "lb", + "try": "t", + "with": "wh", + "except": "ex", + "pass": "ps", + "yield": "y", + "import": "ip", + "finally": "fn", + "class": "cl", + "raise": "rs", + "exec": "ex", + "is": "is", + "in": "in", + "print": "", + "True": "tr", + "False": "fl", +} +dico_supression = { + " ": "", + "{": "", + "}": "", + "(": "", + ")": "", + ";": "", + ":": "" +} +def delete_string(ligne): + delete = False + list_chain_to_remove = [] + if ligne.count("\"") > 0: + i = 0 + chain_to_remove = "" + while i < len(ligne): + if ligne[i] == '\"': + list_chain_to_remove.append(chain_to_remove) + chain_to_remove = "" + delete = not delete + if delete and ligne[i] != '"': + chain_to_remove = chain_to_remove + ligne[i] + i += 1 + for chain in list_chain_to_remove: + ligne = ligne.replace(chain, "") + ligne = ligne.replace("\"\"", "\"") -# dico_stemming = { -# "def": "d", -# "while": "w", -# "for": "f", -# "if": "i", -# "elif": "ei", -# "else": "e", -# "<=": "c", -# ">=": "c", -# "<": "c", -# ">": "c", -# "def": "d", -# "!=": "!", -# "==": "-", -# "and": "&", -# "or": "|", -# "var": "v", -# "del": "d", -# "from": "w", -# "not": "n", -# "while": "w", -# "assert": "as", -# "global": "gl", -# "as": "as", -# "break": "bk", -# "continue": "ct", -# "lambda": "lb", -# "try": "t", -# "with": "wh", -# "except": "ex", -# "pass": "ps", -# "yield": "y", -# "import": "ip", -# "finally": "fn", -# "class": "cl", -# "raise": "rs", -# "exec": "ex", -# "is": "is", -# "in": "in", -# "print": "", -# "True": "tr", -# "False": "fl", -# } + return ligne -# dico_supression = { -# " ": "", -# "{": "", -# "}": "", -# "(": "", -# ")": "", -# ";": "", -# ":": "" -# } +def replace_by_new_content(ligne): + for key in dico_stemming: + ligne = ligne.replace(key, dico_stemming[key]) + return ligne -# def delete_string(ligne): -# delete = False -# list_chain_to_remove = [] -# if ligne.count("\"") > 0: +def delete_unuse_content(ligne): + for key in dico_supression: + ligne = ligne.replace(key, dico_supression[key]) -# i = 0 -# chain_to_remove = "" + return ligne -# while i < len(ligne): -# if ligne[i] == '\"': -# list_chain_to_remove.append(chain_to_remove) -# chain_to_remove = "" -# delete = not delete +def sanitize_content(ligne): + filtered_content = "" -# if delete and ligne[i] != '"': -# chain_to_remove = chain_to_remove + ligne[i] + ligne = delete_string(ligne) + filtered_content = filtered_content + (replace_by_new_content(ligne)) + filtered_content = delete_unuse_content(filtered_content) -# i += 1 + return filtered_content -# for chain in list_chain_to_remove: -# ligne = ligne.replace(chain, "") -# ligne = ligne.replace("\"\"", "\"") -# return ligne +def findVariableInFuction(line): + listVariable = [] + variable = "" + i = 0 + if line.count('def') > 0: + start = False + end = False -# def replace_by_new_content(ligne): -# for key in dico_stemming: -# ligne = ligne.replace(key, dico_stemming[key]) + while i < len(line): -# return ligne + if line[i] == "(": + start = True + i=i+1 -# def delete_unuse_content(ligne): -# for key in dico_supression: -# ligne = ligne.replace(key, dico_supression[key]) + if start and not end: -# return ligne + if line[i] != "," and line[i] != ")": + if line[i] != " ": + variable += line[i] -# def sanitize_content(ligne): -# filtered_content = "" + else: + listVariable.append(variable) + variable = "" -# ligne = delete_string(ligne) -# filtered_content = filtered_content + (replace_by_new_content(ligne)) -# filtered_content = delete_unuse_content(filtered_content) + if line[i] == ")": + end = True -# return filtered_content + i +=1 + return listVariable -# def findVariableInFuction(line): -# listVariable = [] -# variable = "" -# i = 0 -# if line.count('def') > 0: -# start = False -# end = False -# while i < len(line): +def findVariableDeclare(ligne): + listVariable = [] -# if line[i] == "(": -# start = True -# i=i+1 + if "=" in ligne: + i = 0 + find = False + while i < len(ligne) and not find: + if ligne[i] == "=": -# if start and not end: + notFind = True + findSeparator = True + permissionParcourtWord = False -# if line[i] != "," and line[i] != ")": + k = i + var = "" + while k > 0 and notFind: -# if line[i] != " ": -# variable += line[i] + if ligne[k] == " ": + permissionParcourtWord = False -# else: -# listVariable.append(variable) -# variable = "" + if var != "": + listVariable.append(var) + var = "" -# if line[i] == ")": -# end = True + if ligne[k] == ",": -# i +=1 + findSeparator = True + permissionParcourtWord = False -# return listVariable + if var != "": + listVariable.append(var) + var = "" + if ligne[k] != "," and ligne[k] != " " and k != i: + if findSeparator or permissionParcourtWord: + findSeparator = False + permissionParcourtWord = True + var = ligne[k]+var -# def findVariableDeclare(ligne): -# listVariable = [] + else: + notFind = False -# if "=" in ligne: -# i = 0 -# find = False + k -= 1 -# while i < len(ligne) and not find: -# if ligne[i] == "=": + i += 1 -# notFind = True -# findSeparator = True -# permissionParcourtWord = False + if " in " in ligne: + findIn = False + notFind = True + permissionParcourtWord = False -# k = i -# var = "" -# while k > 0 and notFind: + p = 0 + while p < len(ligne) and notFind: + if len(ligne) > p + 3: + if ligne[p] == " ": + if ligne[p+1] == "i": + if ligne[p + 2] == "n": + if ligne[p + 3] == " ": + findIn = True -# if ligne[k] == " ": -# permissionParcourtWord = False + if findIn: + var = "" + m=p + while m > 0: -# if var != "": -# listVariable.append(var) -# var = "" + if ligne[m] != " ": + if not permissionParcourtWord: + permissionParcourtWord = True -# if ligne[k] == ",": + elif permissionParcourtWord: + notFind = False + permissionParcourtWord = False -# findSeparator = True -# permissionParcourtWord = False + if var != "" and var not in listVariable: + listVariable.append(var) -# if var != "": -# listVariable.append(var) -# var = "" + if permissionParcourtWord and notFind: + var = ligne[m]+var -# if ligne[k] != "," and ligne[k] != " " and k != i: -# if findSeparator or permissionParcourtWord: -# findSeparator = False -# permissionParcourtWord = True -# var = ligne[k]+var + m -=1 -# else: -# notFind = False + p +=1 -# k -= 1 -# i += 1 -# if " in " in ligne: -# findIn = False -# notFind = True -# permissionParcourtWord = False + return listVariable -# p = 0 -# while p < len(ligne) and notFind: -# if len(ligne) > p + 3: -# if ligne[p] == " ": -# if ligne[p+1] == "i": -# if ligne[p + 2] == "n": -# if ligne[p + 3] == " ": -# findIn = True -# if findIn: -# var = "" -# m=p -# while m > 0: +def update_block(newBlock, blockCodes): + if newBlock in blockCodes: + blockCodes[newBlock] += 1 -# if ligne[m] != " ": -# if not permissionParcourtWord: -# permissionParcourtWord = True + else: + blockCodes.update({newBlock: 1}) -# elif permissionParcourtWord: -# notFind = False -# permissionParcourtWord = False + return blockCodes -# if var != "" and var not in listVariable: -# listVariable.append(var) -# if permissionParcourtWord and notFind: -# var = ligne[m]+var +def find_indentation(line): + cpt = 0 + while cpt < len(line): + symbole = line[cpt] -# m -=1 + if symbole == " ": + cpt +=1 -# p +=1 + elif symbole == "": + return 0 + elif symbole == "\n": + return 0 + elif symbole == "#": + return 0 -# return listVariable + else: + return cpt -# def update_block(newBlock, blockCodes): -# if newBlock in blockCodes: -# blockCodes[newBlock] += 1 + return cpt -# else: -# blockCodes.update({newBlock: 1}) -# return blockCodes +def find_block(code): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ + listBlock = [] + i = 0 + lastIndentationValue=0 + currentIndentationValue = 0 + blockCodes = "" + save=0 + for line in code: -# def find_indentation(line): + sanitize_line = line.replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") -# cpt = 0 -# while cpt < len(line): + if len(sanitize_line) > 0: -# symbole = line[cpt] + lastIndentationValue = save + currentIndentationValue = find_indentation(line) -# if symbole == " ": -# cpt +=1 + if currentIndentationValue > lastIndentationValue : -# elif symbole == "": -# return 0 + k=i -# elif symbole == "\n": -# return 0 -# elif symbole == "#": -# return 0 + blockCreate = False + blockCodes = "" + save = find_indentation(line) -# else: -# return cpt + while not blockCreate and k < len(code): + sanitize_line = code[k].replace(" ", "") + sanitize_line = sanitize_line.replace("\n", "") -# return cpt + if len(sanitize_line) > 0: + linebis = code[k] + newVal = find_indentation(linebis) -# def find_block(code): -# """ -# :param: line: représente le code à analyser -# :return retourne les différents blocks représentant ce code (fonction while for if ..) -# """ -# listBlock = [] -# i = 0 -# lastIndentationValue=0 -# currentIndentationValue = 0 -# blockCodes = "" -# save=0 + if newVal != -1: + currentIndentationValue = newVal -# for line in code: -# sanitize_line = line.replace(" ", "") -# sanitize_line = sanitize_line.replace("\n", "") + if currentIndentationValue > lastIndentationValue: + blockCodes = blockCodes+linebis -# if len(sanitize_line) > 0: -# lastIndentationValue = save -# currentIndentationValue = find_indentation(line) + else: + blockCreate = True -# if currentIndentationValue > lastIndentationValue : + k +=1 -# k=i + listBlock.append(blockCodes) + else: + if find_indentation(line) != -1: + save = find_indentation(line) -# blockCreate = False -# blockCodes = "" -# save = find_indentation(line) + i +=1 -# while not blockCreate and k < len(code): -# sanitize_line = code[k].replace(" ", "") -# sanitize_line = sanitize_line.replace("\n", "") + return listBlock -# if len(sanitize_line) > 0: -# linebis = code[k] -# newVal = find_indentation(linebis) -# if newVal != -1: -# currentIndentationValue = newVal +def find_function(line): + """ + :param: line: représente le code à analyser + :return retourne les différents blocks représentant ce code (fonction while for if ..) + """ -# if currentIndentationValue > lastIndentationValue: -# blockCodes = blockCodes+linebis + blockCodes = [] + i = 0 + newBlock="" + addAblock = False + while i < len(line): -# else: -# blockCreate = True + if len(line)>i+4: + if line[i] == "d": + if line[i+1] == "e": + if line[i + 1] == "f": + if line[i + 1] == " ": -# k +=1 + if newBlock != "": + blockCodes.append(newBlock) + newBlock="" -# listBlock.append(blockCodes) + newBlock += line[i] + i +=1 -# else: -# if find_indentation(line) != -1: -# save = find_indentation(line) + return blockCodes -# i +=1 +def line_is_comment(line): + line.replace(" ","") + if len(line)>0: + if line[0] == "#": + return True + else: + return False -# return listBlock -# def find_function(line): -# """ -# :param: line: représente le code à analyser -# :return retourne les différents blocks représentant ce code (fonction while for if ..) -# """ +def rename_variable(line, listVariableRename): -# blockCodes = [] -# i = 0 -# newBlock="" -# addAblock = False + i = 0 + var = "var" + lineIndentation = find_indentation(line) -# while i < len(line): + a = 0 + espace = "" + while a < lineIndentation: + espace += " " + a +=1 -# if len(line)>i+4: -# if line[i] == "d": -# if line[i+1] == "e": -# if line[i + 1] == "f": -# if line[i + 1] == " ": + for variable in listVariableRename: -# if newBlock != "": -# blockCodes.append(newBlock) -# newBlock="" + ###gestion var++ et var-- + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) -# newBlock += line[i] -# i +=1 + line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) -# return blockCodes + ###gestion de opérateur mathématique + line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) -# def line_is_comment(line): -# line.replace(" ","") + ###gestion des symbile [] + line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) -# if len(line)>0: -# if line[0] == "#": -# return True -# else: -# return False + ###gestion de symbole ; + # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) + ###gestion de symbole . + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) + ###gestion de symbole [ + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) + # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) + ###gestion des symboles < > + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) + line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) + line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) + # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) + # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) + ###gestion du séparateur "," + line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) + line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) -# def rename_variable(line, listVariableRename): + ###gestion des symbole ( ) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) + line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) -# i = 0 -# var = "var" -# lineIndentation = find_indentation(line) + line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) -# a = 0 -# espace = "" -# while a < lineIndentation: -# espace += " " -# a +=1 -# for variable in listVariableRename: + return line -# ###gestion var++ et var-- -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+\+', var+"="+var+"+1", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\-\-', var+"="+var+"-1", line) -# line = re.sub(r'\s{1,}'+variable+r'\s{1,}', var, line) -# ###gestion de opérateur mathématique -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}-', var+"-", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\+', var+"+", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\*', var+"*", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\\', var+"|divide|", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}=', var+"=", line) +def sanitize_dict_(dict): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ -# ###gestion des symbile [] -# line = re.sub(r'\[\s{0,}'+variable+r'\s{0,}\]', "["+var+"]", line) + sanitize_dict = [] -# ###gestion de symbole ; -# # line = re.sub(r'\s{0,}'+variable+r'\s{0,};', var+";", line) + for block in dict: + sanitizeBlock = sanitize_content(block) + sanitizeBlock = re.sub('[0-9]{1,}', '*', sanitizeBlock) -# ###gestion de symbole . -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\.', var+".", line) + if len(sanitizeBlock) > 75: + sanitize_dict.append(sanitizeBlock) -# ###gestion de symbole [ -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\[', var+"[", line) -# # line = re.sub(r'=\s{0,}'+variable+r'\s{0,}\[int\]', type+"[", line) + return sanitize_dict -# ###gestion des symboles < > -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) -# line = re.sub(r'>\s{0,}'+variable+r'\s{0,}>', ">"+var+">", line) -# line = re.sub(r'<\s{0,}'+variable+r'\s{0,}<', "<"+var+"<", line) -# # line = re.sub(r'>\s{0,}'+variable+r'\s{0,}<', ">"+var+"<", line) -# # line = re.sub(r'<\s{0,}'+variable+r'\s{0,}>', "<"+var+">", line) -# ###gestion du séparateur "," -# line = re.sub(r'\s{0,}'+variable+r'\s{0,},', var+",", line) -# line = re.sub(r',\s{0,}'+variable+r'\s{0,},', ","+var+",", line) -# line = re.sub(r',\s{0,}'+variable+r'\s{0,}=', ","+var+"=", line) -# line = re.sub(r',\s{0,}'+variable+r'\s{0,}\)', ","+var+")", line) -# ###gestion des symbole ( ) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}\)', var+")", line) -# line = re.sub(r'\(\s{0,}'+variable+r'\s{0,},', "("+var+",", line) -# line = re.sub(r'\(\s{0,}'+variable+r'\s{0,}\)', "("+var+")", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}!', var+"!", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}<', var+"<", line) -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}>', var+">", line) +def remove_comentary(lignes): + """ + :param liste_variable: représente la liste des variables du code + :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection + """ + long_comment = False + code_without_comentary = [] -# line = re.sub(r'\s{0,}'+variable+r'\s{0,}:', var+":", line) + for ligne in lignes: + if "#" in ligne: + tab_line = ligne.split("#") -# return line + if "\n" not in tab_line[0]: + tab_line[0] = tab_line[0] + "\n" + code_without_comentary.append(tab_line[0]) + elif ligne.count("\"\"\"") == 2: + tab_line = ligne.split("\"\"\"") + new_line = tab_line[0] + tab_line[len(tab_line)-1] + code_without_comentary.append(new_line) -# def sanitize_dict_(dict): -# """ -# :param liste_variable: représente la liste des variables du code -# :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection -# """ + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[0]) + long_comment = not long_comment -# sanitize_dict = [] + elif "\"\"\"" in ligne: + tab_line = ligne.split("\"\"\"" ) + code_without_comentary.append(tab_line[len(tab_line)-1]) + long_comment = not long_comment -# for block in dict: -# sanitizeBlock = sanitize_content(block) -# sanitizeBlock = re.sub('[0-9]{1,}', '*', sanitizeBlock) + elif not long_comment: + code_without_comentary.append(ligne) -# if len(sanitizeBlock) > 75: -# sanitize_dict.append(sanitizeBlock) - -# return sanitize_dict - - - -# def remove_comentary(lignes): -# """ -# :param liste_variable: représente la liste des variables du code -# :return: retourne la liste des variables après avoir ajouté un espace après le type de la variable. Permet de différencier les types Matrice et collection -# """ -# long_comment = False -# code_without_comentary = [] - -# for ligne in lignes: - -# if "#" in ligne: -# tab_line = ligne.split("#") - -# if "\n" not in tab_line[0]: -# tab_line[0] = tab_line[0] + "\n" - -# code_without_comentary.append(tab_line[0]) - -# elif ligne.count("\"\"\"") == 2: -# tab_line = ligne.split("\"\"\"") -# new_line = tab_line[0] + tab_line[len(tab_line)-1] -# code_without_comentary.append(new_line) - -# elif "\"\"\"" in ligne: -# tab_line = ligne.split("\"\"\"" ) -# code_without_comentary.append(tab_line[0]) -# long_comment = not long_comment - -# elif "\"\"\"" in ligne: -# tab_line = ligne.split("\"\"\"" ) -# code_without_comentary.append(tab_line[len(tab_line)-1]) -# long_comment = not long_comment - -# elif not long_comment: -# code_without_comentary.append(ligne) - -# return code_without_comentary + return code_without_comentary def excecEvalPlagiat(code): - return 0 - # listFunction = [] - # listVariableRename = [] - # lastListVariableRename = [] + listFunction = [] + listVariableRename = [] + lastListVariableRename = [] - # listVarBlock = [] - # lignes = code.split("\n") + listVarBlock = [] + lignes = code.split("\n") - # scopeCodeUser = False - # firstInsert = False + scopeCodeUser = False + firstInsert = False - # lignesCompacte = [] - # newBlock = [] - # functionCode = "" - # listVarToRename = [] + lignesCompacte = [] + newBlock = [] + functionCode = "" + listVarToRename = [] - # lignes = remove_comentary(lignes) + lignes = remove_comentary(lignes) - # for ligne in lignes: + for ligne in lignes: - # if not line_is_comment(ligne): - # ligneBis = ligne + if not line_is_comment(ligne): + ligneBis = ligne - # listeVarInitFunction = findVariableInFuction(ligne) - # listeVarContentFunction = [] + listeVarInitFunction = findVariableInFuction(ligne) + listeVarContentFunction = [] - # if listeVarInitFunction == []: - # listeVarContentFunction = findVariableDeclare(ligne) + if listeVarInitFunction == []: + listeVarContentFunction = findVariableDeclare(ligne) - # listVarToRename = listeVarContentFunction + listeVarInitFunction + listVarToRename = listeVarContentFunction + listeVarInitFunction - # i = 0 - # while i < len(listVarToRename): + i = 0 + while i < len(listVarToRename): - # if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": - # listVariableRename.append(listVarToRename[i]) - # i += 1 + if listVarToRename[i] not in listVariableRename and listVarToRename[i] != "": + listVariableRename.append(listVarToRename[i]) + i += 1 - # lignesCompacte.append(ligneBis) + lignesCompacte.append(ligneBis) - # blockCodes = find_block(lignesCompacte) + blockCodes = find_block(lignesCompacte) - # renameBlock = [] - # for block in blockCodes: - # renameBlock.append(rename_variable(block, listVariableRename)) + renameBlock = [] + for block in blockCodes: + renameBlock.append(rename_variable(block, listVariableRename)) - # sanitize_code_dict = sanitize_dict_(renameBlock) + sanitize_code_dict = sanitize_dict_(renameBlock) - # return sanitize_code_dict \ No newline at end of file + return sanitize_code_dict \ No newline at end of file From 7346efc2844fb3dcda26bea13ecb7a8b505e0841 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:52:32 +0200 Subject: [PATCH 144/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/src/attempts/attempts.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 8dd6321..2bbc426 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -43,9 +43,8 @@ export class AttemptsService { insertAttemptDTO.code, execBootstrap, ); - console.log("COUCOUTEST ALGO") - console.log(execResultsAlgoEvaluation["stdout"]) + console.log(execResultsAlgoEvaluation) // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] From 487cf518c55009455a5d1768c61d53bed54687a8 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 19:56:22 +0200 Subject: [PATCH 145/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/evaluation_code/python/evalPlagiat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index 8498df4..7a73499 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -534,8 +534,7 @@ def excecEvalPlagiat(code): lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") - + scopeCodeUser = False firstInsert = False From 9e675017ce72837eab333442b2292e8efe5d8048 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:02:07 +0200 Subject: [PATCH 146/207] =?UTF-8?q?test=20imt=C3=A9gration=20plagiat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heroku_deploy/api/evaluation_code/python/evalPlagiat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index 7a73499..b735860 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -534,7 +534,7 @@ def excecEvalPlagiat(code): lastListVariableRename = [] listVarBlock = [] - + scopeCodeUser = False firstInsert = False @@ -543,7 +543,7 @@ def excecEvalPlagiat(code): functionCode = "" listVarToRename = [] - lignes = remove_comentary(lignes) + lignes = remove_comentary(code) for ligne in lignes: From 12dd65368a37464b56fff1838e39db3c43b5524f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:12:48 +0200 Subject: [PATCH 147/207] ajout schema plagiat --- .../api/evaluation_code/cpp/evalPlagiat.py | 1 - .../src/attempts/dto/evaluate-plagia.dto.ts | 13 ++++++++ .../api/src/challenges/code_plagiat.schema.ts | 33 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 heroku_deploy/api/src/attempts/dto/evaluate-plagia.dto.ts create mode 100644 heroku_deploy/api/src/challenges/code_plagiat.schema.ts diff --git a/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py index 73371d7..f000652 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py @@ -620,7 +620,6 @@ def excecEvalPlagiat(code): lastListVariableRename = [] listVarBlock = [] - lignes = code.split("\n") scopeCodeUser = False firstInsert = False diff --git a/heroku_deploy/api/src/attempts/dto/evaluate-plagia.dto.ts b/heroku_deploy/api/src/attempts/dto/evaluate-plagia.dto.ts new file mode 100644 index 0000000..d565711 --- /dev/null +++ b/heroku_deploy/api/src/attempts/dto/evaluate-plagia.dto.ts @@ -0,0 +1,13 @@ +import { IsMongoId, IsNotEmpty, IsString } from 'class-validator'; + +export class EvaluatePlagiaDTO { + + @IsNotEmpty() + codeToken: string; + + @IsNotEmpty() + user: string; + + @IsNotEmpty() + exoName: string; +} diff --git a/heroku_deploy/api/src/challenges/code_plagiat.schema.ts b/heroku_deploy/api/src/challenges/code_plagiat.schema.ts new file mode 100644 index 0000000..e88df1c --- /dev/null +++ b/heroku_deploy/api/src/challenges/code_plagiat.schema.ts @@ -0,0 +1,33 @@ +import { Prop, SchemaFactory, Schema } from '@nestjs/mongoose'; +import { Document, Types } from 'mongoose'; +import { User } from 'src/users/user.schema'; + +export type ChallengeDocument = Challenge & Document; + +@Schema() +export class Challenge { + _id?: string; + + @Prop({ required: true, unique: true }) + name: string; + + @Prop({ required: true }) + instructions: string; + + @Prop({ type: Types.ObjectId, ref: User.name }) + owner: string; + + @Prop({ default: false }) + isCourse: boolean; + + @Prop() + editedAt?: Date; + + @Prop({ required: true }) + createdAt: Date; + + @Prop() + deletedAt?: Date; +} + +export const ChallengeSchema = SchemaFactory.createForClass(Challenge); From da5da344d6193e32a53915475c4906eaefc0076f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:13:18 +0200 Subject: [PATCH 148/207] ajout schema plagiat --- .../api/src/challenges/code_plagiat.schema.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/heroku_deploy/api/src/challenges/code_plagiat.schema.ts b/heroku_deploy/api/src/challenges/code_plagiat.schema.ts index e88df1c..784e48b 100644 --- a/heroku_deploy/api/src/challenges/code_plagiat.schema.ts +++ b/heroku_deploy/api/src/challenges/code_plagiat.schema.ts @@ -2,23 +2,18 @@ import { Prop, SchemaFactory, Schema } from '@nestjs/mongoose'; import { Document, Types } from 'mongoose'; import { User } from 'src/users/user.schema'; -export type ChallengeDocument = Challenge & Document; - @Schema() -export class Challenge { +export class EvalPlagiat { _id?: string; @Prop({ required: true, unique: true }) - name: string; + toke: string; @Prop({ required: true }) - instructions: string; - - @Prop({ type: Types.ObjectId, ref: User.name }) - owner: string; + exercice: string; - @Prop({ default: false }) - isCourse: boolean; + @Prop({ required: true }) + langage: string; @Prop() editedAt?: Date; @@ -30,4 +25,4 @@ export class Challenge { deletedAt?: Date; } -export const ChallengeSchema = SchemaFactory.createForClass(Challenge); +export const EvalPlagiatCst = SchemaFactory.createForClass(EvalPlagiat); From c038a4be04594172735f83128c62504e2887d56f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:52:14 +0200 Subject: [PATCH 149/207] log stat user --- heroku_deploy/api/src/user-stats/user-stats.controller.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/user-stats/user-stats.controller.ts b/heroku_deploy/api/src/user-stats/user-stats.controller.ts index 31f9000..f467cfb 100644 --- a/heroku_deploy/api/src/user-stats/user-stats.controller.ts +++ b/heroku_deploy/api/src/user-stats/user-stats.controller.ts @@ -8,6 +8,8 @@ export class UserStatsController { @Get('default_series/:id') async completion(@Param() userIdObject: FindByIdDTO) { + console.log("userIdObject") + console.log(userIdObject) return await this.userStatsService.getCompletion(userIdObject); } From cbe3ce4366d5b5d4b2defb23ea47d8bdc96d3321 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:55:12 +0200 Subject: [PATCH 150/207] log stat user --- heroku_deploy/api/src/user-stats/user-stats.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/heroku_deploy/api/src/user-stats/user-stats.service.ts b/heroku_deploy/api/src/user-stats/user-stats.service.ts index 9763e29..2f9173f 100644 --- a/heroku_deploy/api/src/user-stats/user-stats.service.ts +++ b/heroku_deploy/api/src/user-stats/user-stats.service.ts @@ -22,6 +22,8 @@ export class UserStatsService { userIdDTO: FindByIdDTO, ): Promise { const defaultSeries = await this.seriesService.findDefaultSeries(); + console.log("defaultSeries") + console.log(defaultSeries) const attemptsToStats = async ( challengeId: string, @@ -37,6 +39,10 @@ export class UserStatsService { challengeId, ); + console.log("challenge") + console.log(challenge) + console.log("attempts") + console.log(attempts) let bestTime: number; if (attempts.length > 0) { bestTime = attempts.reduce((prev, next) => From a144e425190a7dfb055e6c07292db3b14cc6465d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 20:59:44 +0200 Subject: [PATCH 151/207] log stat user --- heroku_deploy/api/src/user-stats/user-stats.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/user-stats/user-stats.service.ts b/heroku_deploy/api/src/user-stats/user-stats.service.ts index 2f9173f..b9aa845 100644 --- a/heroku_deploy/api/src/user-stats/user-stats.service.ts +++ b/heroku_deploy/api/src/user-stats/user-stats.service.ts @@ -41,8 +41,10 @@ export class UserStatsService { console.log("challenge") console.log(challenge) + console.log("attempts") console.log(attempts) + let bestTime: number; if (attempts.length > 0) { bestTime = attempts.reduce((prev, next) => From a365c339234a0126f4f4a12450a8b6f0aca0c88c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 21:10:50 +0200 Subject: [PATCH 152/207] log stat user --- heroku_deploy/api/src/series/series.service.ts | 4 ++++ heroku_deploy/api/src/user-stats/user-stats.service.ts | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/series/series.service.ts b/heroku_deploy/api/src/series/series.service.ts index 0adb0b7..f4415d5 100644 --- a/heroku_deploy/api/src/series/series.service.ts +++ b/heroku_deploy/api/src/series/series.service.ts @@ -56,6 +56,10 @@ export class SeriesService { async create(createSerieDTO: InsertSerieDTO): Promise { if (await this.findByName(createSerieDTO.name)) { + + console.log("createSerieDTO") + console.log(createSerieDTO) + throw new UnprocessableEntityException( `Serie name ${createSerieDTO.name} has already been taken.`, ); diff --git a/heroku_deploy/api/src/user-stats/user-stats.service.ts b/heroku_deploy/api/src/user-stats/user-stats.service.ts index b9aa845..a0f0a47 100644 --- a/heroku_deploy/api/src/user-stats/user-stats.service.ts +++ b/heroku_deploy/api/src/user-stats/user-stats.service.ts @@ -22,8 +22,7 @@ export class UserStatsService { userIdDTO: FindByIdDTO, ): Promise { const defaultSeries = await this.seriesService.findDefaultSeries(); - console.log("defaultSeries") - console.log(defaultSeries) + const attemptsToStats = async ( challengeId: string, @@ -41,7 +40,7 @@ export class UserStatsService { console.log("challenge") console.log(challenge) - + console.log("attempts") console.log(attempts) From 38b10ad5e39e5ba9a37f56797f418ab0542a3b5b Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 21:26:38 +0200 Subject: [PATCH 153/207] log stat user --- heroku_deploy/api/src/series/series.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/series/series.service.ts b/heroku_deploy/api/src/series/series.service.ts index f4415d5..d3a7265 100644 --- a/heroku_deploy/api/src/series/series.service.ts +++ b/heroku_deploy/api/src/series/series.service.ts @@ -55,10 +55,11 @@ export class SeriesService { } async create(createSerieDTO: InsertSerieDTO): Promise { - if (await this.findByName(createSerieDTO.name)) { - console.log("createSerieDTO") - console.log(createSerieDTO) + console.log("createSerieDTO") + console.log(createSerieDTO) + + if (await this.findByName(createSerieDTO.name)) { throw new UnprocessableEntityException( `Serie name ${createSerieDTO.name} has already been taken.`, From adfd8b353947440b6a2346910f698ea2710137e9 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 21:38:14 +0200 Subject: [PATCH 154/207] log stat user --- heroku_deploy/api/src/attempts/attempt.schema.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heroku_deploy/api/src/attempts/attempt.schema.ts b/heroku_deploy/api/src/attempts/attempt.schema.ts index 4964d03..4a220de 100644 --- a/heroku_deploy/api/src/attempts/attempt.schema.ts +++ b/heroku_deploy/api/src/attempts/attempt.schema.ts @@ -21,6 +21,9 @@ export class Attempt { @Prop() phase: string; + @Prop() + result: boolean; + @Prop() status: number; From f666eb23fb917f1bdfd7b27fefe123e6de6662ea Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 21:53:09 +0200 Subject: [PATCH 155/207] log stat user --- heroku_deploy/api/src/user-stats/user-stats.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/user-stats/user-stats.service.ts b/heroku_deploy/api/src/user-stats/user-stats.service.ts index a0f0a47..a68d254 100644 --- a/heroku_deploy/api/src/user-stats/user-stats.service.ts +++ b/heroku_deploy/api/src/user-stats/user-stats.service.ts @@ -23,6 +23,10 @@ export class UserStatsService { ): Promise { const defaultSeries = await this.seriesService.findDefaultSeries(); + console.log("defaultSeries") + console.log(defaultSeries) + console.log("userIdDTO") + console.log(userIdDTO) const attemptsToStats = async ( challengeId: string, @@ -32,14 +36,14 @@ export class UserStatsService { id: challengeId, }); + const attempts = await this.attemptsService.findValidatedByUserAndChallenge( userId, challengeId, ); - console.log("challenge") - console.log(challenge) + console.log("attempts") console.log(attempts) From b300d4961576d1a33971b95ac82124e93a959670 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 22:00:15 +0200 Subject: [PATCH 156/207] log stat user --- heroku_deploy/api/src/series/series.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/series/series.service.ts b/heroku_deploy/api/src/series/series.service.ts index d3a7265..b7cdc21 100644 --- a/heroku_deploy/api/src/series/series.service.ts +++ b/heroku_deploy/api/src/series/series.service.ts @@ -49,7 +49,7 @@ export class SeriesService { } async findDefaultSeries(): Promise { - return (await this.seriesModel.find({ isCourse: true }).exec()).map((a) => + return (await this.seriesModel.find({ name: "default" }).exec()).map((a) => a.toObject(), ); } @@ -58,7 +58,7 @@ export class SeriesService { console.log("createSerieDTO") console.log(createSerieDTO) - + if (await this.findByName(createSerieDTO.name)) { throw new UnprocessableEntityException( From f4f2d8e7cc47c0170796238f1814b16d0eac68d3 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 22:20:17 +0200 Subject: [PATCH 157/207] ajout CodePlagiat table --- .../api/src/attempts/evalPlagiat.schema.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 heroku_deploy/api/src/attempts/evalPlagiat.schema.ts diff --git a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts new file mode 100644 index 0000000..fbe2562 --- /dev/null +++ b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts @@ -0,0 +1,28 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { User } from 'src/users/user.schema'; +import { Document, Types } from 'mongoose'; +import { ExecBootstrap } from 'src/exec-bootstrap/exec-bootstrap.schema'; + +export type AttemptDocument = CodePlagiat & Document; + +@Schema() +export class CodePlagiat { + _id?: string; + + @Prop({ required: true }) + userId: string; + + @Prop({ required: true }) + exercice: string; + + @Prop({ required: true }) + code: string; + + @Prop() + createdAt: Date; + + @Prop() + deletedAt?: Date; +} + +export const CodePlagiatSchema = SchemaFactory.createForClass(CodePlagiat); From 64530d4a245f7c254b117cc5b3315e3868928d2e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 22:35:51 +0200 Subject: [PATCH 158/207] ajout CodePlagiat table --- heroku_deploy/api/src/attempts/attempts.module.ts | 2 ++ heroku_deploy/api/src/attempts/evalPlagiat.schema.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.module.ts b/heroku_deploy/api/src/attempts/attempts.module.ts index 4219849..c3d52cf 100644 --- a/heroku_deploy/api/src/attempts/attempts.module.ts +++ b/heroku_deploy/api/src/attempts/attempts.module.ts @@ -2,6 +2,7 @@ import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { AttemptsController } from './attempts.controller'; import { Attempt, AttemptSchema } from './attempt.schema'; +import { CodePlagiat, CodePlagiatSchema } from './evalPlagiat.schema'; import { AttemptsService } from './attempts.service'; import { ChallengesModule } from 'src/challenges/challenges.module'; import { ExecServerModule } from 'src/exec-server/exec-server.module'; @@ -11,6 +12,7 @@ import { ExecBootstrapsModule } from 'src/exec-bootstrap/exec-bootstraps.module' @Module({ imports: [ MongooseModule.forFeature([{ name: Attempt.name, schema: AttemptSchema }]), + MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), ChallengesModule, ExecServerModule, LanguagesModule, diff --git a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts index fbe2562..e3df3ae 100644 --- a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts +++ b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts @@ -3,7 +3,7 @@ import { User } from 'src/users/user.schema'; import { Document, Types } from 'mongoose'; import { ExecBootstrap } from 'src/exec-bootstrap/exec-bootstrap.schema'; -export type AttemptDocument = CodePlagiat & Document; +export type CodePlagiatDocument = CodePlagiat & Document; @Schema() export class CodePlagiat { From 213afb729ac436e6064e082e8aaea7041608bcb5 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 22:54:47 +0200 Subject: [PATCH 159/207] ajout CodePlagiat table --- heroku_deploy/api/src/attempts/evalPlagiat.schema.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts index e3df3ae..710c4ce 100644 --- a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts +++ b/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts @@ -1,7 +1,5 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; -import { User } from 'src/users/user.schema'; -import { Document, Types } from 'mongoose'; -import { ExecBootstrap } from 'src/exec-bootstrap/exec-bootstrap.schema'; +import { Document} from 'mongoose'; export type CodePlagiatDocument = CodePlagiat & Document; From 15af92b296d8ee974a067faaa33c8250df144178 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:20:22 +0200 Subject: [PATCH 160/207] ajout CodePlagiat table --- .../api/src/challenges/code_plagiat.schema.ts | 28 ------------------- .../src/eval_plagiat/evalplagiat.module.ts | 12 ++++++++ .../evalplagiat.schema.ts} | 0 3 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 heroku_deploy/api/src/challenges/code_plagiat.schema.ts create mode 100644 heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts rename heroku_deploy/api/src/{attempts/evalPlagiat.schema.ts => eval_plagiat/evalplagiat.schema.ts} (100%) diff --git a/heroku_deploy/api/src/challenges/code_plagiat.schema.ts b/heroku_deploy/api/src/challenges/code_plagiat.schema.ts deleted file mode 100644 index 784e48b..0000000 --- a/heroku_deploy/api/src/challenges/code_plagiat.schema.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Prop, SchemaFactory, Schema } from '@nestjs/mongoose'; -import { Document, Types } from 'mongoose'; -import { User } from 'src/users/user.schema'; - -@Schema() -export class EvalPlagiat { - _id?: string; - - @Prop({ required: true, unique: true }) - toke: string; - - @Prop({ required: true }) - exercice: string; - - @Prop({ required: true }) - langage: string; - - @Prop() - editedAt?: Date; - - @Prop({ required: true }) - createdAt: Date; - - @Prop() - deletedAt?: Date; -} - -export const EvalPlagiatCst = SchemaFactory.createForClass(EvalPlagiat); diff --git a/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts b/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts new file mode 100644 index 0000000..0a0eb43 --- /dev/null +++ b/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { ObjectStorageModule } from 'src/object-storage/object-storage.module'; +import { CodePlagiat, CodePlagiatSchema } from './evalplagiat.schema'; + +@Module({ + imports: [ + MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), + ObjectStorageModule, + ], +}) +export class CodePlagiatModule {} diff --git a/heroku_deploy/api/src/attempts/evalPlagiat.schema.ts b/heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts similarity index 100% rename from heroku_deploy/api/src/attempts/evalPlagiat.schema.ts rename to heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts From bf870b32a8759a312f75279ceebd6715102238ae Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:26:35 +0200 Subject: [PATCH 161/207] ajout CodePlagiat table --- heroku_deploy/api/evaluation_code/cpp/main.py | 13 ++ .../api/evaluation_code/python/main.py | 13 ++ .../api/src/attempts/attempts.module.ts | 1 - .../eval_plagiat/dto/sanitized-user.dto.ts | 25 ++++ .../src/eval_plagiat/dto/update-user.dto.ts | 19 +++ .../api/src/eval_plagiat/users.controller.ts | 80 +++++++++++ .../api/src/eval_plagiat/users.service.ts | 133 ++++++++++++++++++ 7 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 heroku_deploy/api/evaluation_code/cpp/main.py create mode 100644 heroku_deploy/api/evaluation_code/python/main.py create mode 100644 heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts create mode 100644 heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts create mode 100644 heroku_deploy/api/src/eval_plagiat/users.controller.ts create mode 100644 heroku_deploy/api/src/eval_plagiat/users.service.ts diff --git a/heroku_deploy/api/evaluation_code/cpp/main.py b/heroku_deploy/api/evaluation_code/cpp/main.py new file mode 100644 index 0000000..2f58f08 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/cpp/main.py @@ -0,0 +1,13 @@ +from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction +from evaluation_code.evalCommentaireCpp import excecEvalCommentaire +from evaluation_code.evalRedondanceCpp import excecEvalRedondance +from evaluation_code.evalVariableNameCpp import excecEvalVariableName + +if __name__ == '__main__': + payload = { + "eval_variable_name\":excecEvalVariableName(), + "eval_redondance\": excecEvalRedondance(), + "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), + "eval_commentaire\": excecEvalCommentaire() + } + print(payload) \ No newline at end of file diff --git a/heroku_deploy/api/evaluation_code/python/main.py b/heroku_deploy/api/evaluation_code/python/main.py new file mode 100644 index 0000000..2f58f08 --- /dev/null +++ b/heroku_deploy/api/evaluation_code/python/main.py @@ -0,0 +1,13 @@ +from evaluation_code.evalNbLigneFonctionCpp import excecEvalNbLigneFonction +from evaluation_code.evalCommentaireCpp import excecEvalCommentaire +from evaluation_code.evalRedondanceCpp import excecEvalRedondance +from evaluation_code.evalVariableNameCpp import excecEvalVariableName + +if __name__ == '__main__': + payload = { + "eval_variable_name\":excecEvalVariableName(), + "eval_redondance\": excecEvalRedondance(), + "eval_nb ligne_fonction\": excecEvalNbLigneFonction(), + "eval_commentaire\": excecEvalCommentaire() + } + print(payload) \ No newline at end of file diff --git a/heroku_deploy/api/src/attempts/attempts.module.ts b/heroku_deploy/api/src/attempts/attempts.module.ts index c3d52cf..9727a84 100644 --- a/heroku_deploy/api/src/attempts/attempts.module.ts +++ b/heroku_deploy/api/src/attempts/attempts.module.ts @@ -12,7 +12,6 @@ import { ExecBootstrapsModule } from 'src/exec-bootstrap/exec-bootstraps.module' @Module({ imports: [ MongooseModule.forFeature([{ name: Attempt.name, schema: AttemptSchema }]), - MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), ChallengesModule, ExecServerModule, LanguagesModule, diff --git a/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts b/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts new file mode 100644 index 0000000..1bb1c9e --- /dev/null +++ b/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts @@ -0,0 +1,25 @@ +export class SanitizedUserDTO { + _id?: string; + + username: string; + + avatarUrl?: string; + + email: string; + + editedAt?: Date; + + createdAt: Date; + + deletedAt?: Date; +} + +export const sanitizedUserTemplate: SanitizedUserDTO = { + _id: '', + username: '', + avatarUrl: '', + email: '', + editedAt: new Date(), + createdAt: new Date(), + deletedAt: new Date(), +}; diff --git a/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts b/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts new file mode 100644 index 0000000..918d27f --- /dev/null +++ b/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts @@ -0,0 +1,19 @@ +import { IsEmail, IsNotEmpty, IsOptional, Matches } from 'class-validator'; + +export class UpdateUserDTO { + @IsOptional() + @IsNotEmpty() + @Matches( + /^(?=.{8,})(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$ %^&*-])([a-zA-Z#?!@$ %^&*-]*\d){3,}/, + { + message: + 'Password must contain at least 8 character with lower and uppercase characters, special characters, and at least 3 digits.', + }, + ) + password?: string; + + @IsOptional() + @IsNotEmpty() + @IsEmail() + email?: string; +} diff --git a/heroku_deploy/api/src/eval_plagiat/users.controller.ts b/heroku_deploy/api/src/eval_plagiat/users.controller.ts new file mode 100644 index 0000000..38ca717 --- /dev/null +++ b/heroku_deploy/api/src/eval_plagiat/users.controller.ts @@ -0,0 +1,80 @@ +import { + BadRequestException, + Body, + Controller, + Get, + NotFoundException, + Param, + Post, + Put, + Request, + UploadedFile, + UseGuards, + UseInterceptors, +} from '@nestjs/common'; +import { SessionUserDTO } from 'src/auth/dto/session-user.dto'; +import { JwtAuthGuard } from '../auth/jwt-auth.guard'; +import { CreateUserDTO } from './dto/create-user.dto'; +import { FindByIdDTO } from '../common/dto/find-by-id.dto'; +import { + SanitizedUserDTO, + sanitizedUserTemplate, +} from './dto/sanitized-user.dto'; +import { UpdateUserDTO } from './dto/update-user.dto'; +import { UsersService } from './users.service'; +import { FileInterceptor } from '@nestjs/platform-express'; +import { BufferedFile } from 'src/common/dto/buffered-file.dto'; +import { sanitize } from 'src/common/responses/generic_sanitizer'; +@Controller('users') +export class UsersController { + constructor(private readonly usersService: UsersService) {} + + @Get(':id') + async getUser(@Param() idObject: FindByIdDTO): Promise { + const user = await this.usersService.findOne(idObject.id); + + + if (!user) { + throw new NotFoundException('User with specified ID does not exist.'); + } + + return sanitize(user, sanitizedUserTemplate); + } + + @UseInterceptors(FileInterceptor('avatar')) + @Post() + async createUser( + @Body() userDTO: CreateUserDTO, + @UploadedFile() avatarPicture?: BufferedFile, + ): Promise { + return await this.usersService.create(userDTO, avatarPicture); + } + + @UseInterceptors(FileInterceptor('avatar')) + @UseGuards(JwtAuthGuard) + @Put() + async updateUser( + @Request() req: { user: SessionUserDTO }, + @Body() updateUserDTO: UpdateUserDTO, + @UploadedFile() avatarPicture: BufferedFile, + ): Promise { + if (Object.keys(updateUserDTO).length === 0 && !avatarPicture) { + throw new BadRequestException('No changes were specified.'); + } + + const user = this.usersService.update( + req.user.userId, + updateUserDTO, + avatarPicture, + ); + + return user; + } + + @Get() + async getUsers(): Promise { + return (await this.usersService.findAll()).map((user) => + sanitize(user, sanitizedUserTemplate), + ); + } +} diff --git a/heroku_deploy/api/src/eval_plagiat/users.service.ts b/heroku_deploy/api/src/eval_plagiat/users.service.ts new file mode 100644 index 0000000..ca7f994 --- /dev/null +++ b/heroku_deploy/api/src/eval_plagiat/users.service.ts @@ -0,0 +1,133 @@ +import { + Injectable, + NotFoundException, + UnprocessableEntityException, +} from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Model } from 'mongoose'; +import { BufferedFile } from 'src/common/dto/buffered-file.dto'; +import { encrypt } from 'src/common/crypt.handler'; +import ObjectStorageService, { + PicspyBucket, +} from 'src/object-storage/object-storage.service'; +import { CreateUserDTO } from './dto/create-user.dto'; +import { UpdateUserDTO } from './dto/update-user.dto'; +import { User, UserDocument } from './user.schema'; + +@Injectable() +export class UsersService { + constructor( + @InjectModel(User.name) private readonly userModel: Model, + private readonly objectStorageService: ObjectStorageService, + ) {} + + async findAll(): Promise { + return (await this.userModel.find().exec()).map((user) => { + const userObject = user.toObject(); + return { + ...userObject, + avatarUrl: + userObject.avatarUrl && + this.objectStorageService.generateExternalServerAddress( + userObject.avatarUrl, + ), + }; + }); + } + + async findOne(id: string): Promise { + const userObject = (await this.userModel.findById(id).exec())?.toObject(); + + if (!userObject) { + throw new NotFoundException(`User: ${id} does not exist.`); + } + + if (!userObject) { + throw new NotFoundException(`User: ${id} does not exist.`); + } + + return { + ...userObject, + avatarUrl: + userObject.avatarUrl && + this.objectStorageService.generateExternalServerAddress( + userObject.avatarUrl, + ), + }; + } + + async findByUsername(username: string): Promise { + return await (await this.userModel.findOne({ username }))?.toObject(); + } + + async create( + createUserDTO: CreateUserDTO, + file?: BufferedFile, + ): Promise { + if (await this.findByUsername(createUserDTO.username)) { + throw new UnprocessableEntityException( + `Username ${createUserDTO.username} already taken.`, + ); + } + + let avatarUrl = undefined; + if (await this.findByUsername(createUserDTO.username)) { + throw new UnprocessableEntityException( + `Username ${createUserDTO.username} already taken.`, + ); + } + + if (file) { + avatarUrl = await this.objectStorageService.upload( + file, + 'raw', + PicspyBucket.PROFILE, + ); + } + + + return ( + await new this.userModel({ + ...createUserDTO, + createdAt: new Date(), + password: await encrypt(createUserDTO.password), + avatarUrl, + }).save() + ).toObject(); + } + + async update( + id: string, + updateUserDTO: UpdateUserDTO, + file?: BufferedFile, + ): Promise { + const userObject: { + password?: string; + avatarUrl?: string; + editedAt: Date; + } = { + ...updateUserDTO, + editedAt: new Date(), + }; + + if (updateUserDTO.password) { + userObject.password = await encrypt(updateUserDTO.password); + } + + if (file) { + userObject.avatarUrl = await this.objectStorageService.upload( + file, + 'raw', + PicspyBucket.PROFILE, + ); + } + + return ( + await this.userModel.findByIdAndUpdate(id, userObject).exec() + )?.toObject(); + } + + async delete(id: string): Promise { + await this.userModel.findByIdAndDelete(id).exec(); + } +} From 3384aa0cc57d67fafd41bc5e3a178942b12c73e0 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:30:26 +0200 Subject: [PATCH 162/207] ajout CodePlagiat table --- .../api/src/attempts/attempts.module.ts | 1 - .../eval_plagiat/dto/sanitized-user.dto.ts | 25 ---- .../src/eval_plagiat/dto/update-user.dto.ts | 19 --- .../src/eval_plagiat/evalplagiat.module.ts | 12 -- .../src/eval_plagiat/evalplagiat.schema.ts | 26 ---- .../api/src/eval_plagiat/users.controller.ts | 80 ----------- .../api/src/eval_plagiat/users.service.ts | 133 ------------------ 7 files changed, 296 deletions(-) delete mode 100644 heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts delete mode 100644 heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts delete mode 100644 heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts delete mode 100644 heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts delete mode 100644 heroku_deploy/api/src/eval_plagiat/users.controller.ts delete mode 100644 heroku_deploy/api/src/eval_plagiat/users.service.ts diff --git a/heroku_deploy/api/src/attempts/attempts.module.ts b/heroku_deploy/api/src/attempts/attempts.module.ts index 9727a84..4219849 100644 --- a/heroku_deploy/api/src/attempts/attempts.module.ts +++ b/heroku_deploy/api/src/attempts/attempts.module.ts @@ -2,7 +2,6 @@ import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { AttemptsController } from './attempts.controller'; import { Attempt, AttemptSchema } from './attempt.schema'; -import { CodePlagiat, CodePlagiatSchema } from './evalPlagiat.schema'; import { AttemptsService } from './attempts.service'; import { ChallengesModule } from 'src/challenges/challenges.module'; import { ExecServerModule } from 'src/exec-server/exec-server.module'; diff --git a/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts b/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts deleted file mode 100644 index 1bb1c9e..0000000 --- a/heroku_deploy/api/src/eval_plagiat/dto/sanitized-user.dto.ts +++ /dev/null @@ -1,25 +0,0 @@ -export class SanitizedUserDTO { - _id?: string; - - username: string; - - avatarUrl?: string; - - email: string; - - editedAt?: Date; - - createdAt: Date; - - deletedAt?: Date; -} - -export const sanitizedUserTemplate: SanitizedUserDTO = { - _id: '', - username: '', - avatarUrl: '', - email: '', - editedAt: new Date(), - createdAt: new Date(), - deletedAt: new Date(), -}; diff --git a/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts b/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts deleted file mode 100644 index 918d27f..0000000 --- a/heroku_deploy/api/src/eval_plagiat/dto/update-user.dto.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { IsEmail, IsNotEmpty, IsOptional, Matches } from 'class-validator'; - -export class UpdateUserDTO { - @IsOptional() - @IsNotEmpty() - @Matches( - /^(?=.{8,})(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$ %^&*-])([a-zA-Z#?!@$ %^&*-]*\d){3,}/, - { - message: - 'Password must contain at least 8 character with lower and uppercase characters, special characters, and at least 3 digits.', - }, - ) - password?: string; - - @IsOptional() - @IsNotEmpty() - @IsEmail() - email?: string; -} diff --git a/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts b/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts deleted file mode 100644 index 0a0eb43..0000000 --- a/heroku_deploy/api/src/eval_plagiat/evalplagiat.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Module } from '@nestjs/common'; -import { MongooseModule } from '@nestjs/mongoose'; -import { ObjectStorageModule } from 'src/object-storage/object-storage.module'; -import { CodePlagiat, CodePlagiatSchema } from './evalplagiat.schema'; - -@Module({ - imports: [ - MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), - ObjectStorageModule, - ], -}) -export class CodePlagiatModule {} diff --git a/heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts b/heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts deleted file mode 100644 index 710c4ce..0000000 --- a/heroku_deploy/api/src/eval_plagiat/evalplagiat.schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; -import { Document} from 'mongoose'; - -export type CodePlagiatDocument = CodePlagiat & Document; - -@Schema() -export class CodePlagiat { - _id?: string; - - @Prop({ required: true }) - userId: string; - - @Prop({ required: true }) - exercice: string; - - @Prop({ required: true }) - code: string; - - @Prop() - createdAt: Date; - - @Prop() - deletedAt?: Date; -} - -export const CodePlagiatSchema = SchemaFactory.createForClass(CodePlagiat); diff --git a/heroku_deploy/api/src/eval_plagiat/users.controller.ts b/heroku_deploy/api/src/eval_plagiat/users.controller.ts deleted file mode 100644 index 38ca717..0000000 --- a/heroku_deploy/api/src/eval_plagiat/users.controller.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { - BadRequestException, - Body, - Controller, - Get, - NotFoundException, - Param, - Post, - Put, - Request, - UploadedFile, - UseGuards, - UseInterceptors, -} from '@nestjs/common'; -import { SessionUserDTO } from 'src/auth/dto/session-user.dto'; -import { JwtAuthGuard } from '../auth/jwt-auth.guard'; -import { CreateUserDTO } from './dto/create-user.dto'; -import { FindByIdDTO } from '../common/dto/find-by-id.dto'; -import { - SanitizedUserDTO, - sanitizedUserTemplate, -} from './dto/sanitized-user.dto'; -import { UpdateUserDTO } from './dto/update-user.dto'; -import { UsersService } from './users.service'; -import { FileInterceptor } from '@nestjs/platform-express'; -import { BufferedFile } from 'src/common/dto/buffered-file.dto'; -import { sanitize } from 'src/common/responses/generic_sanitizer'; -@Controller('users') -export class UsersController { - constructor(private readonly usersService: UsersService) {} - - @Get(':id') - async getUser(@Param() idObject: FindByIdDTO): Promise { - const user = await this.usersService.findOne(idObject.id); - - - if (!user) { - throw new NotFoundException('User with specified ID does not exist.'); - } - - return sanitize(user, sanitizedUserTemplate); - } - - @UseInterceptors(FileInterceptor('avatar')) - @Post() - async createUser( - @Body() userDTO: CreateUserDTO, - @UploadedFile() avatarPicture?: BufferedFile, - ): Promise { - return await this.usersService.create(userDTO, avatarPicture); - } - - @UseInterceptors(FileInterceptor('avatar')) - @UseGuards(JwtAuthGuard) - @Put() - async updateUser( - @Request() req: { user: SessionUserDTO }, - @Body() updateUserDTO: UpdateUserDTO, - @UploadedFile() avatarPicture: BufferedFile, - ): Promise { - if (Object.keys(updateUserDTO).length === 0 && !avatarPicture) { - throw new BadRequestException('No changes were specified.'); - } - - const user = this.usersService.update( - req.user.userId, - updateUserDTO, - avatarPicture, - ); - - return user; - } - - @Get() - async getUsers(): Promise { - return (await this.usersService.findAll()).map((user) => - sanitize(user, sanitizedUserTemplate), - ); - } -} diff --git a/heroku_deploy/api/src/eval_plagiat/users.service.ts b/heroku_deploy/api/src/eval_plagiat/users.service.ts deleted file mode 100644 index ca7f994..0000000 --- a/heroku_deploy/api/src/eval_plagiat/users.service.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { - Injectable, - NotFoundException, - UnprocessableEntityException, -} from '@nestjs/common'; -import { InjectModel } from '@nestjs/mongoose'; -import { Model } from 'mongoose'; -import { BufferedFile } from 'src/common/dto/buffered-file.dto'; -import { encrypt } from 'src/common/crypt.handler'; -import ObjectStorageService, { - PicspyBucket, -} from 'src/object-storage/object-storage.service'; -import { CreateUserDTO } from './dto/create-user.dto'; -import { UpdateUserDTO } from './dto/update-user.dto'; -import { User, UserDocument } from './user.schema'; - -@Injectable() -export class UsersService { - constructor( - @InjectModel(User.name) private readonly userModel: Model, - private readonly objectStorageService: ObjectStorageService, - ) {} - - async findAll(): Promise { - return (await this.userModel.find().exec()).map((user) => { - const userObject = user.toObject(); - return { - ...userObject, - avatarUrl: - userObject.avatarUrl && - this.objectStorageService.generateExternalServerAddress( - userObject.avatarUrl, - ), - }; - }); - } - - async findOne(id: string): Promise { - const userObject = (await this.userModel.findById(id).exec())?.toObject(); - - if (!userObject) { - throw new NotFoundException(`User: ${id} does not exist.`); - } - - if (!userObject) { - throw new NotFoundException(`User: ${id} does not exist.`); - } - - return { - ...userObject, - avatarUrl: - userObject.avatarUrl && - this.objectStorageService.generateExternalServerAddress( - userObject.avatarUrl, - ), - }; - } - - async findByUsername(username: string): Promise { - return await (await this.userModel.findOne({ username }))?.toObject(); - } - - async create( - createUserDTO: CreateUserDTO, - file?: BufferedFile, - ): Promise { - if (await this.findByUsername(createUserDTO.username)) { - throw new UnprocessableEntityException( - `Username ${createUserDTO.username} already taken.`, - ); - } - - let avatarUrl = undefined; - if (await this.findByUsername(createUserDTO.username)) { - throw new UnprocessableEntityException( - `Username ${createUserDTO.username} already taken.`, - ); - } - - if (file) { - avatarUrl = await this.objectStorageService.upload( - file, - 'raw', - PicspyBucket.PROFILE, - ); - } - - - return ( - await new this.userModel({ - ...createUserDTO, - createdAt: new Date(), - password: await encrypt(createUserDTO.password), - avatarUrl, - }).save() - ).toObject(); - } - - async update( - id: string, - updateUserDTO: UpdateUserDTO, - file?: BufferedFile, - ): Promise { - const userObject: { - password?: string; - avatarUrl?: string; - editedAt: Date; - } = { - ...updateUserDTO, - editedAt: new Date(), - }; - - if (updateUserDTO.password) { - userObject.password = await encrypt(updateUserDTO.password); - } - - if (file) { - userObject.avatarUrl = await this.objectStorageService.upload( - file, - 'raw', - PicspyBucket.PROFILE, - ); - } - - return ( - await this.userModel.findByIdAndUpdate(id, userObject).exec() - )?.toObject(); - } - - async delete(id: string): Promise { - await this.userModel.findByIdAndDelete(id).exec(); - } -} From 95baccfc3e8255c15328bb6c4ea1f3576ebaf415 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:36:00 +0200 Subject: [PATCH 163/207] ajout CodePlagiat table --- .../api/src/codeplagiat/codeplagiat.schema.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts new file mode 100644 index 0000000..5f289ca --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts @@ -0,0 +1,26 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { Document} from 'mongoose'; + +export type CodePlagiatDocument = CodePlagiat & Document; + +@Schema() +export class CodePlagiat { + _id?: string; + + @Prop({ required: true }) + userId: string; + + @Prop({ required: true }) + exercice: string; + + @Prop({ required: true }) + code: string; + + @Prop() + createdAt: Date; + + @Prop() + deletedAt?: Date; +} + +export const CodePlagiatSchema = SchemaFactory.createForClass(CodePlagiat); \ No newline at end of file From 01cc6d2fe42686e4dbc3f2bfed32e1613167dc86 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:43:16 +0200 Subject: [PATCH 164/207] ajout CodePlagiat table --- .../api/src/codeplagiat/codeplagiat.module.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts new file mode 100644 index 0000000..0ab766b --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { CodePlagiat, CodePlagiatSchema } from './codeplagiat.schema'; + + +@Module({ + imports: [ + MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), + ], + +}) +export class CodePlagiatModule {} From adad233e648807dc4dd4f0c5d91c558526efb6cb Mon Sep 17 00:00:00 2001 From: tcatonet Date: Fri, 15 Oct 2021 23:54:26 +0200 Subject: [PATCH 165/207] ajout CodePlagiat table --- .../api/src/codeplagiat/codeplagiat.module.ts | 5 ++++- .../src/codeplagiat/codeplagiat.service.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts index 0ab766b..1a5a405 100644 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts @@ -1,12 +1,15 @@ import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; import { CodePlagiat, CodePlagiatSchema } from './codeplagiat.schema'; +import { CodePlagiatService } from './codeplagiat.service'; @Module({ imports: [ MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), ], - + providers: [CodePlagiatService], + exports: [CodePlagiatService], }) + export class CodePlagiatModule {} diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts new file mode 100644 index 0000000..3d2300d --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts @@ -0,0 +1,19 @@ +import { Injectable, UnprocessableEntityException } from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Model } from 'mongoose'; +import { CodePlagiat, CodePlagiatDocument } from './codeplagiat.schema'; + +@Injectable() +export class CodePlagiatService { + constructor( + @InjectModel(CodePlagiat.name) + private readonly codePlagiatModel: Model, + ) {} + + + async findAll(): Promise { + return (await this.codePlagiatModel.find().exec()).map((language) => + language.toObject(), + ); + } +} From 385e8f03348f10b8e68118610209639edc3103d6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 00:07:18 +0200 Subject: [PATCH 166/207] ajout CodePlagiat table --- .../api/src/codeplagiat/codeplagiat.schema.ts | 24 +++++++------------ .../src/codeplagiat/codeplagiat.service.ts | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts index 5f289ca..2cd7b90 100644 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts @@ -1,26 +1,18 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; -import { Document} from 'mongoose'; +import { Document } from 'mongoose'; -export type CodePlagiatDocument = CodePlagiat & Document; +export type CatDocument = Cat & Document; @Schema() -export class CodePlagiat { - _id?: string; - - @Prop({ required: true }) - userId: string; - - @Prop({ required: true }) - exercice: string; - - @Prop({ required: true }) - code: string; +export class Cat { + @Prop() + name: string; @Prop() - createdAt: Date; + age: number; @Prop() - deletedAt?: Date; + breed: string; } -export const CodePlagiatSchema = SchemaFactory.createForClass(CodePlagiat); \ No newline at end of file +export const CatSchema = SchemaFactory.createForClass(Cat); diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts index 3d2300d..fa6e2c4 100644 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts @@ -1,4 +1,4 @@ -import { Injectable, UnprocessableEntityException } from '@nestjs/common'; +import { Injectable} from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { CodePlagiat, CodePlagiatDocument } from './codeplagiat.schema'; From 45e4dac5a065363fb1889d15164a10f473257800 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 19:01:16 +0200 Subject: [PATCH 167/207] try add codeplagiat table --- .../api/src/codeplagiat/codeplagiat.module.ts | 15 --------------- .../src/codeplagiat/codeplagiat.service.ts | 19 ------------------- 2 files changed, 34 deletions(-) delete mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts delete mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts deleted file mode 100644 index 1a5a405..0000000 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Module } from '@nestjs/common'; -import { MongooseModule } from '@nestjs/mongoose'; -import { CodePlagiat, CodePlagiatSchema } from './codeplagiat.schema'; -import { CodePlagiatService } from './codeplagiat.service'; - - -@Module({ - imports: [ - MongooseModule.forFeature([{ name: CodePlagiat.name, schema: CodePlagiatSchema }]), - ], - providers: [CodePlagiatService], - exports: [CodePlagiatService], -}) - -export class CodePlagiatModule {} diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts deleted file mode 100644 index fa6e2c4..0000000 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Injectable} from '@nestjs/common'; -import { InjectModel } from '@nestjs/mongoose'; -import { Model } from 'mongoose'; -import { CodePlagiat, CodePlagiatDocument } from './codeplagiat.schema'; - -@Injectable() -export class CodePlagiatService { - constructor( - @InjectModel(CodePlagiat.name) - private readonly codePlagiatModel: Model, - ) {} - - - async findAll(): Promise { - return (await this.codePlagiatModel.find().exec()).map((language) => - language.toObject(), - ); - } -} From 94e5d32d824138b710a1a262c0992027b0a1e99d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 19:15:45 +0200 Subject: [PATCH 168/207] try add codeplagiat table --- .../api/src/codeplagiat/codeplagiat.module.ts | 11 ++++++++++ .../src/codeplagiat/codeplagiat.service.ts | 21 +++++++++++++++++++ .../api/src/codeplagiat/dot/create-cat.dto.ts | 8 +++++++ 3 files changed, 40 insertions(+) create mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts create mode 100644 heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts create mode 100644 heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts new file mode 100644 index 0000000..07f7642 --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts @@ -0,0 +1,11 @@ + +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { CatsService } from './codeplagiat.service'; +import { Cat, CatSchema } from './codeplagiat.schema'; + +@Module({ + imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])], + providers: [CatsService], +}) +export class CatsModule {} diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts new file mode 100644 index 0000000..834d310 --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts @@ -0,0 +1,21 @@ + +import { Model } from 'mongoose'; +import { Injectable } from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Cat, CatDocument } from './codeplagiat.schema'; +import { CreateCatDto } from './dto/create-cat.dto'; + +@Injectable() +export class CatsService { + constructor(@InjectModel(Cat.name) private catModel: Model) {} + + async create(createCatDto: CreateCatDto): Promise { + const createdCat = new this.catModel(createCatDto); + return createdCat.save(); + } + + async findAll(): Promise { + return this.catModel.find().exec(); + } +} + diff --git a/heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts b/heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts new file mode 100644 index 0000000..d86f353 --- /dev/null +++ b/heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts @@ -0,0 +1,8 @@ + +export class CreateCatDto { + name: string; + + age: number; + + breed: string; +} From 1ec7f2897bb44741de3d0a7ed43d79656e1086d8 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 19:17:43 +0200 Subject: [PATCH 169/207] try add codeplagiat table --- heroku_deploy/api/src/codeplagiat/{dot => dto}/create-cat.dto.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename heroku_deploy/api/src/codeplagiat/{dot => dto}/create-cat.dto.ts (100%) diff --git a/heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts b/heroku_deploy/api/src/codeplagiat/dto/create-cat.dto.ts similarity index 100% rename from heroku_deploy/api/src/codeplagiat/dot/create-cat.dto.ts rename to heroku_deploy/api/src/codeplagiat/dto/create-cat.dto.ts From d6223c41e6b4f9da9b7779b82d0bcfa1aebbb214 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 19:28:41 +0200 Subject: [PATCH 170/207] try add codeplagiat table --- heroku_deploy/api/src/app.module.ts | 3 +++ heroku_deploy/api/src/seed/seeds.module.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/heroku_deploy/api/src/app.module.ts b/heroku_deploy/api/src/app.module.ts index 4093a9a..e35376c 100644 --- a/heroku_deploy/api/src/app.module.ts +++ b/heroku_deploy/api/src/app.module.ts @@ -12,6 +12,8 @@ import { LanguagesModule } from './languages/languages.module'; import { ExecBootstrapsModule } from './exec-bootstrap/exec-bootstraps.module'; import { PicturesModule } from './pictures/pictures.module'; import { UserStatsModule } from './user-stats/user-stats.module'; +import { CatsModule } from 'src/codeplagiat/codeplagiat.module'; + @Module({ imports: [ MongooseModule.forRoot(dbConfig.url), @@ -24,6 +26,7 @@ import { UserStatsModule } from './user-stats/user-stats.module'; ExecBootstrapsModule, PicturesModule, UserStatsModule, + CatsModule, ], controllers: [AppController], providers: [AppService], diff --git a/heroku_deploy/api/src/seed/seeds.module.ts b/heroku_deploy/api/src/seed/seeds.module.ts index b13f1ee..b354594 100644 --- a/heroku_deploy/api/src/seed/seeds.module.ts +++ b/heroku_deploy/api/src/seed/seeds.module.ts @@ -20,6 +20,7 @@ import { LanguagesCommand } from './languages.command'; forwardRef(() => ExecBootstrapsModule), forwardRef(() => SeriesModule), forwardRef(() => UsersModule), + ], providers: [LanguagesCommand], exports: [LanguagesCommand], From b52d21b1482f0d88ad1db990c39840f62f391ed6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 20:36:06 +0200 Subject: [PATCH 171/207] try add codeplagiat table --- heroku_deploy/api/src/app.module.ts | 2 +- .../{codeplagiat/codeplagiat.module.ts => cat/cat.module.ts} | 4 ++-- .../{codeplagiat/codeplagiat.schema.ts => cat/cat.schema.ts} | 0 .../codeplagiat.service.ts => cat/cat.service.ts} | 2 +- .../api/src/{codeplagiat => cat}/dto/create-cat.dto.ts | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename heroku_deploy/api/src/{codeplagiat/codeplagiat.module.ts => cat/cat.module.ts} (69%) rename heroku_deploy/api/src/{codeplagiat/codeplagiat.schema.ts => cat/cat.schema.ts} (100%) rename heroku_deploy/api/src/{codeplagiat/codeplagiat.service.ts => cat/cat.service.ts} (90%) rename heroku_deploy/api/src/{codeplagiat => cat}/dto/create-cat.dto.ts (100%) diff --git a/heroku_deploy/api/src/app.module.ts b/heroku_deploy/api/src/app.module.ts index e35376c..290ce9e 100644 --- a/heroku_deploy/api/src/app.module.ts +++ b/heroku_deploy/api/src/app.module.ts @@ -12,7 +12,7 @@ import { LanguagesModule } from './languages/languages.module'; import { ExecBootstrapsModule } from './exec-bootstrap/exec-bootstraps.module'; import { PicturesModule } from './pictures/pictures.module'; import { UserStatsModule } from './user-stats/user-stats.module'; -import { CatsModule } from 'src/codeplagiat/codeplagiat.module'; +import { CatsModule } from 'src/cat/cat.module'; @Module({ imports: [ diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts b/heroku_deploy/api/src/cat/cat.module.ts similarity index 69% rename from heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts rename to heroku_deploy/api/src/cat/cat.module.ts index 07f7642..6432269 100644 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.module.ts +++ b/heroku_deploy/api/src/cat/cat.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { MongooseModule } from '@nestjs/mongoose'; -import { CatsService } from './codeplagiat.service'; -import { Cat, CatSchema } from './codeplagiat.schema'; +import { CatsService } from './cat.service'; +import { Cat, CatSchema } from './cat.schema'; @Module({ imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])], diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts b/heroku_deploy/api/src/cat/cat.schema.ts similarity index 100% rename from heroku_deploy/api/src/codeplagiat/codeplagiat.schema.ts rename to heroku_deploy/api/src/cat/cat.schema.ts diff --git a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts b/heroku_deploy/api/src/cat/cat.service.ts similarity index 90% rename from heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts rename to heroku_deploy/api/src/cat/cat.service.ts index 834d310..fd92bc7 100644 --- a/heroku_deploy/api/src/codeplagiat/codeplagiat.service.ts +++ b/heroku_deploy/api/src/cat/cat.service.ts @@ -2,7 +2,7 @@ import { Model } from 'mongoose'; import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { Cat, CatDocument } from './codeplagiat.schema'; +import { Cat, CatDocument } from './cat.schema'; import { CreateCatDto } from './dto/create-cat.dto'; @Injectable() diff --git a/heroku_deploy/api/src/codeplagiat/dto/create-cat.dto.ts b/heroku_deploy/api/src/cat/dto/create-cat.dto.ts similarity index 100% rename from heroku_deploy/api/src/codeplagiat/dto/create-cat.dto.ts rename to heroku_deploy/api/src/cat/dto/create-cat.dto.ts From ad8049bf8a21d06da8da4a41a9553c7af73655c2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 21:06:55 +0200 Subject: [PATCH 172/207] try add codeplagiat table --- .../api/src/challenges/challenges.service.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index 4e2eefc..e1796eb 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -15,6 +15,8 @@ import { DetailedChallengeDTO } from './dto/detailed-challenge.dto'; import { FindAndUpdateChallengeDTO } from './dto/find-and-update-challenge.dto'; import { InsertChallengeDTO } from './dto/insert-challenge.dto'; import { ListChallengeDTO } from './dto/list-challenge.dto'; +import { CatsService } from 'src/cat/cat.service'; +import { CreateCatDto } from 'src/cat/dto/create-cat.dto'; @Injectable() export class ChallengesService { @@ -105,6 +107,18 @@ export class ChallengesService { createChallengeDTO: InsertChallengeDTO, files: BufferedFile[], ): Promise { + + + + const createCatDto: CreateCatDto = { + name: 'test', + age: 0, + breed: 'test' + } + + await CatsService.create(createCatDto); + + if (await this.findByName(createChallengeDTO.name)) { throw new UnprocessableEntityException( `Challenge name ${createChallengeDTO.name} already taken.`, From 7363dd6a8d03c85c27c43ac092b6c7da9e92566d Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 21:13:26 +0200 Subject: [PATCH 173/207] try add codeplagiat table --- heroku_deploy/api/src/cat/cat.service.ts | 1 + heroku_deploy/api/src/challenges/challenges.service.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/cat/cat.service.ts b/heroku_deploy/api/src/cat/cat.service.ts index fd92bc7..9672ca5 100644 --- a/heroku_deploy/api/src/cat/cat.service.ts +++ b/heroku_deploy/api/src/cat/cat.service.ts @@ -7,6 +7,7 @@ import { CreateCatDto } from './dto/create-cat.dto'; @Injectable() export class CatsService { + constructor(@InjectModel(Cat.name) private catModel: Model) {} async create(createCatDto: CreateCatDto): Promise { diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index e1796eb..ed6b502 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -25,6 +25,8 @@ export class ChallengesService { private readonly challengeModel: Model, private readonly picturesService: PicturesService, private readonly execBootstrapService: ExecBootstrapsService, + private readonly catsService: CatsService, + ) {} async findAll(): Promise { @@ -115,9 +117,12 @@ export class ChallengesService { age: 0, breed: 'test' } + - await CatsService.create(createCatDto); - + const cat = ( + await this.catsService.create(createCatDto) + ); + if (await this.findByName(createChallengeDTO.name)) { throw new UnprocessableEntityException( From 5f3ba3e0214d8a057025f57955bfdf96ffa0188f Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 21:18:11 +0200 Subject: [PATCH 174/207] try add codeplagiat table --- heroku_deploy/api/src/challenges/challenges.service.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index ed6b502..a2d9b84 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -112,17 +112,7 @@ export class ChallengesService { - const createCatDto: CreateCatDto = { - name: 'test', - age: 0, - breed: 'test' - } - - const cat = ( - await this.catsService.create(createCatDto) - ); - if (await this.findByName(createChallengeDTO.name)) { throw new UnprocessableEntityException( From f3d8411afc9b0abedf5281c645f9c7e55f7a2e3a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 21:21:06 +0200 Subject: [PATCH 175/207] try add codeplagiat table --- heroku_deploy/api/src/challenges/challenges.service.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/heroku_deploy/api/src/challenges/challenges.service.ts b/heroku_deploy/api/src/challenges/challenges.service.ts index a2d9b84..4e2eefc 100644 --- a/heroku_deploy/api/src/challenges/challenges.service.ts +++ b/heroku_deploy/api/src/challenges/challenges.service.ts @@ -15,8 +15,6 @@ import { DetailedChallengeDTO } from './dto/detailed-challenge.dto'; import { FindAndUpdateChallengeDTO } from './dto/find-and-update-challenge.dto'; import { InsertChallengeDTO } from './dto/insert-challenge.dto'; import { ListChallengeDTO } from './dto/list-challenge.dto'; -import { CatsService } from 'src/cat/cat.service'; -import { CreateCatDto } from 'src/cat/dto/create-cat.dto'; @Injectable() export class ChallengesService { @@ -25,8 +23,6 @@ export class ChallengesService { private readonly challengeModel: Model, private readonly picturesService: PicturesService, private readonly execBootstrapService: ExecBootstrapsService, - private readonly catsService: CatsService, - ) {} async findAll(): Promise { @@ -109,11 +105,6 @@ export class ChallengesService { createChallengeDTO: InsertChallengeDTO, files: BufferedFile[], ): Promise { - - - - - if (await this.findByName(createChallengeDTO.name)) { throw new UnprocessableEntityException( `Challenge name ${createChallengeDTO.name} already taken.`, From b65844207bd2a69975cbb5ba10a8ab24ce8055f6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 22:14:01 +0200 Subject: [PATCH 176/207] try add codeplagiat table --- heroku_deploy/api/src/attempts/attempts.service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 2bbc426..d7b0641 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -2,6 +2,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { ChallengesService } from 'src/challenges/challenges.service'; +import { CatsService } from 'src/cat/cat.service'; import { FindByIdDTO } from 'src/common/dto/find-by-id.dto'; import { ExecBootstrapsService } from 'src/exec-bootstrap/exec-bootstraps.service'; import { GodBoxRepository } from 'src/exec-server/godbox.repository'; @@ -18,6 +19,8 @@ export class AttemptsService { private readonly execServerService: GodBoxRepository, private readonly execBootstrapService: ExecBootstrapsService, private readonly challengesService: ChallengesService, + private readonly catsService: CatsService, + ) {} async create( @@ -46,6 +49,10 @@ export class AttemptsService { console.log(execResultsAlgoEvaluation) + + const res = await this.catsService.findAll(); + console.log(res) + // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] const attempt = ( From d7e7a41eccbec8680736e51b4bbbcb55f763b800 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 22:21:20 +0200 Subject: [PATCH 177/207] try add codeplagiat table --- heroku_deploy/api/src/attempts/attempts.module.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heroku_deploy/api/src/attempts/attempts.module.ts b/heroku_deploy/api/src/attempts/attempts.module.ts index 4219849..b26ab3e 100644 --- a/heroku_deploy/api/src/attempts/attempts.module.ts +++ b/heroku_deploy/api/src/attempts/attempts.module.ts @@ -4,6 +4,7 @@ import { AttemptsController } from './attempts.controller'; import { Attempt, AttemptSchema } from './attempt.schema'; import { AttemptsService } from './attempts.service'; import { ChallengesModule } from 'src/challenges/challenges.module'; +import { CatsModule } from 'src/cat/cat.module'; import { ExecServerModule } from 'src/exec-server/exec-server.module'; import { LanguagesModule } from 'src/languages/languages.module'; import { ExecBootstrapsModule } from 'src/exec-bootstrap/exec-bootstraps.module'; @@ -15,6 +16,7 @@ import { ExecBootstrapsModule } from 'src/exec-bootstrap/exec-bootstraps.module' ExecServerModule, LanguagesModule, ExecBootstrapsModule, + CatsModule, ], providers: [AttemptsService], exports: [AttemptsService], From 672c09e01ce3c4fa0c3e7efe88fffd35113e24ea Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 22:31:42 +0200 Subject: [PATCH 178/207] try add codeplagiat table --- heroku_deploy/api/src/cat/cat.module.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/cat/cat.module.ts b/heroku_deploy/api/src/cat/cat.module.ts index 6432269..4333aa8 100644 --- a/heroku_deploy/api/src/cat/cat.module.ts +++ b/heroku_deploy/api/src/cat/cat.module.ts @@ -7,5 +7,6 @@ import { Cat, CatSchema } from './cat.schema'; @Module({ imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])], providers: [CatsService], + exports: [CatsService], }) export class CatsModule {} From c5daa390fca79a4789655042eeb26c98780d2b14 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sat, 16 Oct 2021 22:50:00 +0200 Subject: [PATCH 179/207] try add codeplagiat table --- heroku_deploy/api/src/attempts/attempts.service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index d7b0641..edeb460 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -10,6 +10,7 @@ import { Attempt, AttemptDocument } from './attempt.schema'; import { ExecutionResultsDTO } from './dto/execution-results.dto'; import { FindByUserAndBootstrapDTO } from './dto/find-by-user-and-bootstrap.dto'; import { InsertAttemptDTO } from './dto/insert-attempt.dto'; +import { CreateCatDto } from 'src/cat/dto/create-cat.dto'; @Injectable() export class AttemptsService { @@ -49,6 +50,12 @@ export class AttemptsService { console.log(execResultsAlgoEvaluation) + const catDto : CreateCatDto = { + name: 'test', + age: 1, + breed: 'test' + } + const res1 = await this.catsService.create(catDto); const res = await this.catsService.findAll(); console.log(res) From 2deaac07c451ff7dcca9e199815d253afec474b2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 02:43:21 +0200 Subject: [PATCH 180/207] add evalPlagiat table --- .../api/src/attempts/attempts.module.ts | 2 +- .../api/src/attempts/attempts.service.ts | 10 +++++----- heroku_deploy/api/src/cat/cat.module.ts | 12 ------------ heroku_deploy/api/src/cat/cat.schema.ts | 18 ------------------ .../{cat => evalPlagiat}/dto/create-cat.dto.ts | 0 .../api/src/evalPlagiat/evalPlagiat.module.ts | 12 ++++++++++++ .../api/src/evalPlagiat/evalPlagiat.schema.ts | 18 ++++++++++++++++++ .../evalPlagiat.service.ts} | 10 +++++----- 8 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 heroku_deploy/api/src/cat/cat.module.ts delete mode 100644 heroku_deploy/api/src/cat/cat.schema.ts rename heroku_deploy/api/src/{cat => evalPlagiat}/dto/create-cat.dto.ts (100%) create mode 100644 heroku_deploy/api/src/evalPlagiat/evalPlagiat.module.ts create mode 100644 heroku_deploy/api/src/evalPlagiat/evalPlagiat.schema.ts rename heroku_deploy/api/src/{cat/cat.service.ts => evalPlagiat/evalPlagiat.service.ts} (52%) diff --git a/heroku_deploy/api/src/attempts/attempts.module.ts b/heroku_deploy/api/src/attempts/attempts.module.ts index b26ab3e..f476396 100644 --- a/heroku_deploy/api/src/attempts/attempts.module.ts +++ b/heroku_deploy/api/src/attempts/attempts.module.ts @@ -4,7 +4,7 @@ import { AttemptsController } from './attempts.controller'; import { Attempt, AttemptSchema } from './attempt.schema'; import { AttemptsService } from './attempts.service'; import { ChallengesModule } from 'src/challenges/challenges.module'; -import { CatsModule } from 'src/cat/cat.module'; +import { CatsModule } from 'src/evalPlagiat/evalPlagiat.module'; import { ExecServerModule } from 'src/exec-server/exec-server.module'; import { LanguagesModule } from 'src/languages/languages.module'; import { ExecBootstrapsModule } from 'src/exec-bootstrap/exec-bootstraps.module'; diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index edeb460..739c20a 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -2,7 +2,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { ChallengesService } from 'src/challenges/challenges.service'; -import { CatsService } from 'src/cat/cat.service'; +import { EvalPlagiatService } from 'src/evalPlagiat/evalPlagiat.service'; import { FindByIdDTO } from 'src/common/dto/find-by-id.dto'; import { ExecBootstrapsService } from 'src/exec-bootstrap/exec-bootstraps.service'; import { GodBoxRepository } from 'src/exec-server/godbox.repository'; @@ -10,7 +10,7 @@ import { Attempt, AttemptDocument } from './attempt.schema'; import { ExecutionResultsDTO } from './dto/execution-results.dto'; import { FindByUserAndBootstrapDTO } from './dto/find-by-user-and-bootstrap.dto'; import { InsertAttemptDTO } from './dto/insert-attempt.dto'; -import { CreateCatDto } from 'src/cat/dto/create-cat.dto'; +import { CreateCatDto } from 'src/evalPlagiat/dto/create-cat.dto'; @Injectable() export class AttemptsService { @@ -20,7 +20,7 @@ export class AttemptsService { private readonly execServerService: GodBoxRepository, private readonly execBootstrapService: ExecBootstrapsService, private readonly challengesService: ChallengesService, - private readonly catsService: CatsService, + private readonly evalPlagiatService: EvalPlagiatService, ) {} @@ -55,9 +55,9 @@ export class AttemptsService { age: 1, breed: 'test' } - const res1 = await this.catsService.create(catDto); + const res1 = await this.evalPlagiatService.create(catDto); - const res = await this.catsService.findAll(); + const res = await this.evalPlagiatService.findAll(); console.log(res) // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] diff --git a/heroku_deploy/api/src/cat/cat.module.ts b/heroku_deploy/api/src/cat/cat.module.ts deleted file mode 100644 index 4333aa8..0000000 --- a/heroku_deploy/api/src/cat/cat.module.ts +++ /dev/null @@ -1,12 +0,0 @@ - -import { Module } from '@nestjs/common'; -import { MongooseModule } from '@nestjs/mongoose'; -import { CatsService } from './cat.service'; -import { Cat, CatSchema } from './cat.schema'; - -@Module({ - imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])], - providers: [CatsService], - exports: [CatsService], -}) -export class CatsModule {} diff --git a/heroku_deploy/api/src/cat/cat.schema.ts b/heroku_deploy/api/src/cat/cat.schema.ts deleted file mode 100644 index 2cd7b90..0000000 --- a/heroku_deploy/api/src/cat/cat.schema.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; -import { Document } from 'mongoose'; - -export type CatDocument = Cat & Document; - -@Schema() -export class Cat { - @Prop() - name: string; - - @Prop() - age: number; - - @Prop() - breed: string; -} - -export const CatSchema = SchemaFactory.createForClass(Cat); diff --git a/heroku_deploy/api/src/cat/dto/create-cat.dto.ts b/heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts similarity index 100% rename from heroku_deploy/api/src/cat/dto/create-cat.dto.ts rename to heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts diff --git a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.module.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.module.ts new file mode 100644 index 0000000..ec6d677 --- /dev/null +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.module.ts @@ -0,0 +1,12 @@ + +import { Module } from '@nestjs/common'; +import { MongooseModule } from '@nestjs/mongoose'; +import { EvalPlagiatService } from './evalPlagiat.service'; +import { EvalPlagiat, EvalPlagiatSchema } from './evalPlagiat.schema'; + +@Module({ + imports: [MongooseModule.forFeature([{ name: EvalPlagiat.name, schema: EvalPlagiatSchema }])], + providers: [EvalPlagiatService], + exports: [EvalPlagiatService], +}) +export class CatsModule {} diff --git a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.schema.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.schema.ts new file mode 100644 index 0000000..48e3acb --- /dev/null +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.schema.ts @@ -0,0 +1,18 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { Document } from 'mongoose'; + +export type EvalPlagiatDocument = EvalPlagiat & Document; + +@Schema() +export class EvalPlagiat { + @Prop() + tokenCode: string; + + @Prop() + nameExo: string; + + @Prop() + userId: string; +} + +export const EvalPlagiatSchema = SchemaFactory.createForClass(EvalPlagiat); diff --git a/heroku_deploy/api/src/cat/cat.service.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts similarity index 52% rename from heroku_deploy/api/src/cat/cat.service.ts rename to heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts index 9672ca5..06639d8 100644 --- a/heroku_deploy/api/src/cat/cat.service.ts +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts @@ -2,20 +2,20 @@ import { Model } from 'mongoose'; import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { Cat, CatDocument } from './cat.schema'; +import { EvalPlagiat, EvalPlagiatDocument } from './evalPlagiat.schema'; import { CreateCatDto } from './dto/create-cat.dto'; @Injectable() -export class CatsService { +export class EvalPlagiatService { - constructor(@InjectModel(Cat.name) private catModel: Model) {} + constructor(@InjectModel(EvalPlagiat.name) private catModel: Model) {} - async create(createCatDto: CreateCatDto): Promise { + async create(createCatDto: CreateCatDto): Promise { const createdCat = new this.catModel(createCatDto); return createdCat.save(); } - async findAll(): Promise { + async findAll(): Promise { return this.catModel.find().exec(); } } From efce4ee40525cc38e2b2c15ed3944ae13a04aced Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 02:47:38 +0200 Subject: [PATCH 181/207] add evalPlagiat table --- heroku_deploy/api/src/attempts/attempts.service.ts | 12 ++++++------ .../api/src/evalPlagiat/dto/create-cat.dto.ts | 8 -------- .../src/evalPlagiat/dto/create-evalPlagiat.dto.ts | 8 ++++++++ .../api/src/evalPlagiat/evalPlagiat.service.ts | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts create mode 100644 heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 739c20a..c963a2f 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -10,7 +10,7 @@ import { Attempt, AttemptDocument } from './attempt.schema'; import { ExecutionResultsDTO } from './dto/execution-results.dto'; import { FindByUserAndBootstrapDTO } from './dto/find-by-user-and-bootstrap.dto'; import { InsertAttemptDTO } from './dto/insert-attempt.dto'; -import { CreateCatDto } from 'src/evalPlagiat/dto/create-cat.dto'; +import { CreateCatDto } from 'src/evalPlagiat/dto/create-evalPlagiat.dto'; @Injectable() export class AttemptsService { @@ -50,12 +50,12 @@ export class AttemptsService { console.log(execResultsAlgoEvaluation) - const catDto : CreateCatDto = { - name: 'test', - age: 1, - breed: 'test' + const plagiatCodeDto : CreateCatDto = { + tokenCode: 'test', + nameExo: 'test', + userId: 'test' } - const res1 = await this.evalPlagiatService.create(catDto); + const res1 = await this.evalPlagiatService.create(plagiatCodeDto); const res = await this.evalPlagiatService.findAll(); console.log(res) diff --git a/heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts b/heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts deleted file mode 100644 index d86f353..0000000 --- a/heroku_deploy/api/src/evalPlagiat/dto/create-cat.dto.ts +++ /dev/null @@ -1,8 +0,0 @@ - -export class CreateCatDto { - name: string; - - age: number; - - breed: string; -} diff --git a/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts b/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts new file mode 100644 index 0000000..c3b67ce --- /dev/null +++ b/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts @@ -0,0 +1,8 @@ + +export class CreateCatDto { + tokenCode: string; + + nameExo: string; + + userId: string; +} diff --git a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts index 06639d8..feccc5a 100644 --- a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts @@ -3,7 +3,7 @@ import { Model } from 'mongoose'; import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { EvalPlagiat, EvalPlagiatDocument } from './evalPlagiat.schema'; -import { CreateCatDto } from './dto/create-cat.dto'; +import { CreateCatDto } from './dto/create-evalPlagiat.dto'; @Injectable() export class EvalPlagiatService { From d2b4f92407a84574b1f0d96fad795ea7dbf76219 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 02:48:08 +0200 Subject: [PATCH 182/207] add evalPlagiat table --- heroku_deploy/api/src/app.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/app.module.ts b/heroku_deploy/api/src/app.module.ts index 290ce9e..781b64f 100644 --- a/heroku_deploy/api/src/app.module.ts +++ b/heroku_deploy/api/src/app.module.ts @@ -12,7 +12,7 @@ import { LanguagesModule } from './languages/languages.module'; import { ExecBootstrapsModule } from './exec-bootstrap/exec-bootstraps.module'; import { PicturesModule } from './pictures/pictures.module'; import { UserStatsModule } from './user-stats/user-stats.module'; -import { CatsModule } from 'src/cat/cat.module'; +import { CatsModule } from 'src/evalPlagiat/evalPlagiat.module'; @Module({ imports: [ From 9c0a5f1baef2356688132d5c5dfbb87415b7d196 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:03:25 +0200 Subject: [PATCH 183/207] add evalPlagiat table --- .../api/src/attempts/attempts.service.ts | 4 ++-- .../api/src/evalPlagiat/evalPlagiat.service.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index c963a2f..87bdbb3 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -57,10 +57,10 @@ export class AttemptsService { } const res1 = await this.evalPlagiatService.create(plagiatCodeDto); - const res = await this.evalPlagiatService.findAll(); + const res = await this.evalPlagiatService.find(plagiatCodeDto); console.log(res) - // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] + // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] const attempt = ( await new this.attemptModel({ diff --git a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts index feccc5a..b63b20a 100644 --- a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts @@ -8,15 +8,24 @@ import { CreateCatDto } from './dto/create-evalPlagiat.dto'; @Injectable() export class EvalPlagiatService { - constructor(@InjectModel(EvalPlagiat.name) private catModel: Model) {} + constructor(@InjectModel(EvalPlagiat.name) private evalPlagiatModel: Model) {} async create(createCatDto: CreateCatDto): Promise { - const createdCat = new this.catModel(createCatDto); + const createdCat = new this.evalPlagiatModel(createCatDto); return createdCat.save(); } async findAll(): Promise { - return this.catModel.find().exec(); + return this.evalPlagiatModel.find().exec(); + } + + async find(plagiatCodeDto : CreateCatDto): Promise { + return this.evalPlagiatModel.find({ + userId: {$in: [plagiatCodeDto.userId], + tokenCode:plagiatCodeDto.tokenCode, + nameExo:plagiatCodeDto.nameExo, + + }}) } } From f1cc74242705c6e3ee955306f1a4d6ad5c24baa5 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:09:41 +0200 Subject: [PATCH 184/207] add evalPlagiat table --- heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts index b63b20a..3e51fc8 100644 --- a/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts +++ b/heroku_deploy/api/src/evalPlagiat/evalPlagiat.service.ts @@ -21,11 +21,11 @@ export class EvalPlagiatService { async find(plagiatCodeDto : CreateCatDto): Promise { return this.evalPlagiatModel.find({ - userId: {$in: [plagiatCodeDto.userId], + userId: {$ne: plagiatCodeDto.userId}, tokenCode:plagiatCodeDto.tokenCode, nameExo:plagiatCodeDto.nameExo, - }}) + }) } } From 10419b2f763d3214908dc6bc5b425da5453d20cd Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:10:23 +0200 Subject: [PATCH 185/207] update attemp service for eval code --- heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts b/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts index c3b67ce..b04162f 100644 --- a/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts +++ b/heroku_deploy/api/src/evalPlagiat/dto/create-evalPlagiat.dto.ts @@ -6,3 +6,4 @@ export class CreateCatDto { userId: string; } + \ No newline at end of file From 87b2ac78653c7248c12a90a3a82b046caa8ca20a Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:19:33 +0200 Subject: [PATCH 186/207] update attemp service for eval code --- .../api/src/attempts/attempts.service.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 87bdbb3..d711f5f 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -55,12 +55,19 @@ export class AttemptsService { nameExo: 'test', userId: 'test' } - const res1 = await this.evalPlagiatService.create(plagiatCodeDto); - const res = await this.evalPlagiatService.find(plagiatCodeDto); - console.log(res) + const affList = await this.evalPlagiatService.find(plagiatCodeDto); + console.log(affList) + + + if(affList.length > 0){ + execResults["stdout"] = "PALGIAT" + }else{ + const res = await this.evalPlagiatService.create(plagiatCodeDto); + execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] + + } - // execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] const attempt = ( await new this.attemptModel({ From 9ae5ebe7b1e28578f7d5ddeebe75cbb4b89a9cb2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:32:46 +0200 Subject: [PATCH 187/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index d711f5f..6d11acc 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -50,14 +50,19 @@ export class AttemptsService { console.log(execResultsAlgoEvaluation) + const challenge = await this.challengesService.findOne({ + id: execBootstrap.challenge, + }); + const plagiatCodeDto : CreateCatDto = { tokenCode: 'test', - nameExo: 'test', - userId: 'test' + nameExo: challenge.name, + userId: insertAttemptDTO.user } const affList = await this.evalPlagiatService.find(plagiatCodeDto); console.log(affList) + console.log(insertAttemptDTO.user) if(affList.length > 0){ From 7e81c5f953afcac55fc4233b331ba0b4e7661a90 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 03:36:30 +0200 Subject: [PATCH 188/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 6d11acc..bf8163f 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -63,6 +63,7 @@ export class AttemptsService { const affList = await this.evalPlagiatService.find(plagiatCodeDto); console.log(affList) console.log(insertAttemptDTO.user) + console.log("testtest") if(affList.length > 0){ From da79742fea84dedb4522c210e882436e688a120c Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 15:48:01 +0200 Subject: [PATCH 189/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index bf8163f..3fbdacb 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -48,7 +48,11 @@ export class AttemptsService { execBootstrap, ); - console.log(execResultsAlgoEvaluation) + + const evaluation = execResultsAlgoEvaluation['stdout'] + const obj = JSON.parse(evaluation); + console.log(execResultsAlgoEvaluation['stdout']) + console.log(obj) const challenge = await this.challengesService.findOne({ id: execBootstrap.challenge, @@ -61,9 +65,6 @@ export class AttemptsService { } const affList = await this.evalPlagiatService.find(plagiatCodeDto); - console.log(affList) - console.log(insertAttemptDTO.user) - console.log("testtest") if(affList.length > 0){ From 097400cd13bd296f194049b63593d6e3660307a2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 15:55:00 +0200 Subject: [PATCH 190/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 3fbdacb..93766f1 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -50,7 +50,8 @@ export class AttemptsService { const evaluation = execResultsAlgoEvaluation['stdout'] - const obj = JSON.parse(evaluation); + const string = JSON.stringify(evaluation) + const obj = JSON.parse(string); console.log(execResultsAlgoEvaluation['stdout']) console.log(obj) From e802d7893c51ac50c39d14fb2c73017f782707d7 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 15:58:50 +0200 Subject: [PATCH 191/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 93766f1..b9ea430 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -52,8 +52,9 @@ export class AttemptsService { const evaluation = execResultsAlgoEvaluation['stdout'] const string = JSON.stringify(evaluation) const obj = JSON.parse(string); - console.log(execResultsAlgoEvaluation['stdout']) - console.log(obj) + const listToken = obj['eval_plagiat'] + + console.log(listToken) const challenge = await this.challengesService.findOne({ id: execBootstrap.challenge, From f8adf5ea1e1c167ff1f78e3a9affe331e0991b4e Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:03:39 +0200 Subject: [PATCH 192/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index b9ea430..4f9184c 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -53,7 +53,8 @@ export class AttemptsService { const string = JSON.stringify(evaluation) const obj = JSON.parse(string); const listToken = obj['eval_plagiat'] - + + console.log(obj) console.log(listToken) const challenge = await this.challengesService.findOne({ From 6ceab79286ea7f100e0fc01a570eee073fe7aad2 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:13:11 +0200 Subject: [PATCH 193/207] update attemp service for eval code --- .../api/src/attempts/attempts.service.ts | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 4f9184c..681ebc7 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -52,8 +52,9 @@ export class AttemptsService { const evaluation = execResultsAlgoEvaluation['stdout'] const string = JSON.stringify(evaluation) const obj = JSON.parse(string); - const listToken = obj['eval_plagiat'] + const listToken = obj['eval_variable_name'] + console.log(string) console.log(obj) console.log(listToken) @@ -61,22 +62,46 @@ export class AttemptsService { id: execBootstrap.challenge, }); - const plagiatCodeDto : CreateCatDto = { - tokenCode: 'test', - nameExo: challenge.name, - userId: insertAttemptDTO.user - } - const affList = await this.evalPlagiatService.find(plagiatCodeDto); + let plagiaStringSize = 0 + let stringSize = 0 + + + /* + listToken.forEach(async element => { + const plagiatCodeDto : CreateCatDto = { + tokenCode: element, + nameExo: challenge.name, + userId: insertAttemptDTO.user + }; + + const affList = await this.evalPlagiatService.find(plagiatCodeDto); + + stringSize = stringSize + affList.length + + if(affList.length > 0){ + plagiaStringSize = plagiaStringSize + affList.length + }else{ + const res = await this.evalPlagiatService.create(plagiatCodeDto); + + } + + if ((plagiaStringSize*100)/(plagiaStringSize+stringSize) >= 80){ + execResults["stdout"] = "PALGIAT" + }else{ + execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] + } + + } + + ); + + */ + + - if(affList.length > 0){ - execResults["stdout"] = "PALGIAT" - }else{ - const res = await this.evalPlagiatService.create(plagiatCodeDto); - execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] - } const attempt = ( From cacc1088eae1ab10daafbe0ecbaeb253730d1761 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:13:43 +0200 Subject: [PATCH 194/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 681ebc7..fb51eea 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -53,10 +53,12 @@ export class AttemptsService { const string = JSON.stringify(evaluation) const obj = JSON.parse(string); const listToken = obj['eval_variable_name'] - + const listToken2 = obj["eval_variable_name"] + console.log(string) console.log(obj) console.log(listToken) + console.log(listToken2) const challenge = await this.challengesService.findOne({ id: execBootstrap.challenge, From d08064f7279654b15e9ebd9ea788c60a2876b867 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:22:50 +0200 Subject: [PATCH 195/207] update attemp service for eval code --- .../api/evaluation_code/cpp/evalPlagiat.py | 1 + .../api/evaluation_code/python/evalPlagiat.py | 2 ++ .../api/src/attempts/attempts.service.ts | 15 +++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py index f000652..7192f37 100644 --- a/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/cpp/evalPlagiat.py @@ -101,6 +101,7 @@ "false": "fs", "typeid": "tp", "xor": "xr", + ",": "", } diff --git a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py index b735860..1fdb0d7 100644 --- a/heroku_deploy/api/evaluation_code/python/evalPlagiat.py +++ b/heroku_deploy/api/evaluation_code/python/evalPlagiat.py @@ -57,6 +57,8 @@ "print": "", "True": "tr", "False": "fl", + ",": "", + } dico_supression = { diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index fb51eea..2b41cbc 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -51,14 +51,13 @@ export class AttemptsService { const evaluation = execResultsAlgoEvaluation['stdout'] const string = JSON.stringify(evaluation) - const obj = JSON.parse(string); - const listToken = obj['eval_variable_name'] - const listToken2 = obj["eval_variable_name"] - - console.log(string) - console.log(obj) - console.log(listToken) - console.log(listToken2) + const list_content_start = string.split('['); + const list_content_stop = list_content_start[0].split(']'); + const list_content = list_content_stop[0]; + const elt = list_content.split(",") + + + console.log(elt) const challenge = await this.challengesService.findOne({ id: execBootstrap.challenge, From b138d6066310723e4cb53660a53bfc65484118fc Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:23:10 +0200 Subject: [PATCH 196/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 2b41cbc..b3621ea 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -56,6 +56,7 @@ export class AttemptsService { const list_content = list_content_stop[0]; const elt = list_content.split(",") + console.log("elt") console.log(elt) From 497ded7689e0bf19d4adfcaec626c90a49b17585 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:27:51 +0200 Subject: [PATCH 197/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index b3621ea..0e3291c 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -52,12 +52,14 @@ export class AttemptsService { const evaluation = execResultsAlgoEvaluation['stdout'] const string = JSON.stringify(evaluation) const list_content_start = string.split('['); - const list_content_stop = list_content_start[0].split(']'); + const list_content_stop = list_content_start[1].split(']'); const list_content = list_content_stop[0]; const elt = list_content.split(",") - console.log("elt") - + console.log(string) + console.log(list_content_start) + console.log(list_content_stop) + console.log(list_content) console.log(elt) const challenge = await this.challengesService.findOne({ From 40f04372cfbdf1c1e7c730db749fd34af4830885 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:32:19 +0200 Subject: [PATCH 198/207] update attemp service for eval code --- .../api/src/attempts/attempts.service.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 0e3291c..9c2ed1b 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -56,11 +56,7 @@ export class AttemptsService { const list_content = list_content_stop[0]; const elt = list_content.split(",") - console.log(string) - console.log(list_content_start) - console.log(list_content_stop) - console.log(list_content) - console.log(elt) + const challenge = await this.challengesService.findOne({ id: execBootstrap.challenge, @@ -71,8 +67,8 @@ export class AttemptsService { let stringSize = 0 - /* - listToken.forEach(async element => { + + elt.forEach(async element => { const plagiatCodeDto : CreateCatDto = { tokenCode: element, nameExo: challenge.name, @@ -100,13 +96,8 @@ export class AttemptsService { ); - */ - - - - - - + + console.log((plagiaStringSize*100)/(plagiaStringSize+stringSize)) const attempt = ( await new this.attemptModel({ From 3c1082ff617fed070140e280c914594723610a83 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:39:23 +0200 Subject: [PATCH 199/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 9c2ed1b..5e6c523 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -74,10 +74,12 @@ export class AttemptsService { nameExo: challenge.name, userId: insertAttemptDTO.user }; - + console.log("stringSize") + const affList = await this.evalPlagiatService.find(plagiatCodeDto); stringSize = stringSize + affList.length + console.log(stringSize) if(affList.length > 0){ plagiaStringSize = plagiaStringSize + affList.length From 3c908d0e40e1e072f98203a9407a18b990021e12 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:43:34 +0200 Subject: [PATCH 200/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 5e6c523..62dd4f9 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -78,11 +78,11 @@ export class AttemptsService { const affList = await this.evalPlagiatService.find(plagiatCodeDto); - stringSize = stringSize + affList.length + stringSize = stringSize + element.length console.log(stringSize) if(affList.length > 0){ - plagiaStringSize = plagiaStringSize + affList.length + plagiaStringSize = plagiaStringSize + element.length }else{ const res = await this.evalPlagiatService.create(plagiatCodeDto); From 25182bac52722d958428f78cf756f2cd1fcc4372 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 16:54:14 +0200 Subject: [PATCH 201/207] update attemp service for eval code --- .../api/src/attempts/attempts.service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 62dd4f9..19c0f86 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -67,8 +67,9 @@ export class AttemptsService { let stringSize = 0 - - elt.forEach(async element => { + let n = 0; + while(n= 80){ execResults["stdout"] = "PALGIAT" }else{ execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] } + - } - - ); - - console.log((plagiaStringSize*100)/(plagiaStringSize+stringSize)) - + console.log("aaaa") const attempt = ( await new this.attemptModel({ ...execResults, @@ -113,6 +113,8 @@ export class AttemptsService { return { ...execResults, id: attempt.id }; } + + async findOne(findAttemptDTO: FindByIdDTO): Promise { const attempt: Attempt = ( await this.attemptModel.findById(findAttemptDTO.id).exec() From 1567154201838d5de96cc2917f6b78e110ef03c6 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 17:01:39 +0200 Subject: [PATCH 202/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 19c0f86..93af9e6 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -75,7 +75,6 @@ export class AttemptsService { nameExo: challenge.name, userId: insertAttemptDTO.user }; - console.log("stringSize") const affList = await this.evalPlagiatService.find(plagiatCodeDto); @@ -92,7 +91,7 @@ export class AttemptsService { } - if ((plagiaStringSize*100)/(plagiaStringSize+stringSize) >= 80){ + if ((plagiaStringSize*100)/(stringSize) >= 80){ execResults["stdout"] = "PALGIAT" }else{ execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] From dbe085f0e4f5cca49d71e93f61c1f33b90748a99 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 17:07:15 +0200 Subject: [PATCH 203/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 4 +++- .../api/src/object-storage/object-storage.service.ts | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 93af9e6..97b2833 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -97,9 +97,11 @@ export class AttemptsService { execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] } - + console.log("aaaa") + console.log("aaaa") console.log((plagiaStringSize*100)/(plagiaStringSize+stringSize)) console.log("aaaa") + const attempt = ( await new this.attemptModel({ ...execResults, diff --git a/heroku_deploy/api/src/object-storage/object-storage.service.ts b/heroku_deploy/api/src/object-storage/object-storage.service.ts index a7b5ab0..aefb233 100644 --- a/heroku_deploy/api/src/object-storage/object-storage.service.ts +++ b/heroku_deploy/api/src/object-storage/object-storage.service.ts @@ -16,7 +16,6 @@ export default class ObjectStorageService { constructor(private readonly minioService: MinioService) {} public generateInternalServerAddress(endOfLink: string) { - console.log("COUCOUTUTUINT") return `http${config.MINIO_USESSL ? 's' : ''}://${ config.MINIO_INTERNAL_ENDPOINT @@ -24,7 +23,6 @@ export default class ObjectStorageService { } public generateExternalServerAddress(endOfLink: string) { - console.log("COUCOUTUTUEXT") // https://minio.picspy.vagahbond.com/minio/picspy-challenges/AyoubTest/c5b3f69c-5222-4623-9993-792f7d8487491627296856152.PNG return `http${config.MINIO_USESSL ? 's' : ''}://${ From 188c3c77fbe28ea1ec400af80b21626570b81a39 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 17:16:19 +0200 Subject: [PATCH 204/207] update attemp service for eval code --- heroku_deploy/api/src/attempts/attempts.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/heroku_deploy/api/src/attempts/attempts.service.ts b/heroku_deploy/api/src/attempts/attempts.service.ts index 97b2833..f7c1897 100644 --- a/heroku_deploy/api/src/attempts/attempts.service.ts +++ b/heroku_deploy/api/src/attempts/attempts.service.ts @@ -79,7 +79,6 @@ export class AttemptsService { const affList = await this.evalPlagiatService.find(plagiatCodeDto); stringSize = stringSize + element.length - console.log(stringSize) if(affList.length > 0){ plagiaStringSize = plagiaStringSize + element.length @@ -97,9 +96,9 @@ export class AttemptsService { execResults["stdout"]=execResults["stdout"]+execResultsAlgoEvaluation["stdout"] } + console.log("aaaa") - console.log("aaaa") - console.log((plagiaStringSize*100)/(plagiaStringSize+stringSize)) + console.log((plagiaStringSize*100)/(stringSize)) console.log("aaaa") const attempt = ( From 57f8f8dd01fb6fbbfe3d7b8abb935f9cfdada642 Mon Sep 17 00:00:00 2001 From: tcatonet Date: Sun, 17 Oct 2021 17:27:50 +0200 Subject: [PATCH 205/207] update lib.cpp --- heroku_deploy/api/libs/cpp/bib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/libs/cpp/bib.cpp b/heroku_deploy/api/libs/cpp/bib.cpp index 9024afc..45cae77 100644 --- a/heroku_deploy/api/libs/cpp/bib.cpp +++ b/heroku_deploy/api/libs/cpp/bib.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include #include "Matrice.h" #include "Opencv.h" #include "Exercice.h" From 9d9faf175dd0af5bbaa8dc4ce7cbef8be1959eef Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 18 Oct 2021 17:10:28 +0200 Subject: [PATCH 206/207] update lib.cpp --- heroku_deploy/api/libs/cpp/bib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heroku_deploy/api/libs/cpp/bib.cpp b/heroku_deploy/api/libs/cpp/bib.cpp index 45cae77..96f0d33 100644 --- a/heroku_deploy/api/libs/cpp/bib.cpp +++ b/heroku_deploy/api/libs/cpp/bib.cpp @@ -104,13 +104,13 @@ std::string Exercice::assertResMult(std::vector solution_user, std::vect } } -std::string Exercice::assertResMultDict(const map solution_user,const map resultat){ +std::string Exercice::assertResMultDict(const map solution_user,const map resultat){ if(solution_user.size() != resultat.size()) return "ERROR"; - typename map::const_iterator i, j; + typename map::const_iterator i, j; for(i = solution_user.begin(), j = resultat.begin(); i != solution_user.end(); ++i, ++j) { if(*i != *j) From 48f6b7697f1f84eaf15bb8a12e209f5cb62862bf Mon Sep 17 00:00:00 2001 From: tcatonet Date: Mon, 18 Oct 2021 17:20:25 +0200 Subject: [PATCH 207/207] update lib.cpp --- heroku_deploy/api/libs/cpp/Exercice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heroku_deploy/api/libs/cpp/Exercice.h b/heroku_deploy/api/libs/cpp/Exercice.h index bfa7356..9171fb0 100644 --- a/heroku_deploy/api/libs/cpp/Exercice.h +++ b/heroku_deploy/api/libs/cpp/Exercice.h @@ -13,7 +13,7 @@ class Exercice std::string assertRes(int solution_user, int resultat); std::string assertResMult(std::vector solution_user, std::vector resultat); std::string assertResMultInt(std::vector solution_user, std::vector resultat); - std::string assertResMultDict(const std::map solution_user, const std::map resultat); + std::string assertResMultDict(const std::map solution_user, const std::map resultat); }; #endif /* MY_CLASS_H */