@@ -33,7 +33,10 @@ export class GroupsService {
3333
3434 //TODO: Waiting for the trello part
3535 const retro = createRetroGroup ( course , user ) ;
36- course . groups . forEach ( async ( groups , index ) => {
36+ await this . deleteCourseRetro ( courseId ) ;
37+ await this . emptyCourseProjects ( courseId ) ;
38+ for ( const groups of course . groups ) {
39+ const index = course . groups . indexOf ( groups ) ;
3740 const projectDocument : CanvasRoom = {
3841 owner : userId ,
3942 meta : {
@@ -57,12 +60,24 @@ export class GroupsService {
5760 { _id : new ObjectId ( courseId ) } ,
5861 { $push : { projects : canvas . insertedId } } ,
5962 ) ;
60- } ) ;
63+ }
6164
6265 const newRetro = await this . retrospectiveRepository . createRetrospective ( retro ) ;
6366 await this . coursesRepository . updateOneCourse (
6467 { _id : new ObjectId ( courseId ) } ,
6568 { $set : { retro : newRetro . insertedId , isLocked : true } } ,
6669 ) ;
6770 }
71+ async emptyCourseProjects ( courseId : string ) {
72+ await this . coursesRepository . updateOneCourse (
73+ { _id : new ObjectId ( courseId ) } ,
74+ { $set : { projects : [ ] } } ,
75+ ) ;
76+ }
77+ async deleteCourseRetro ( courseId : string ) {
78+ await this . coursesRepository . updateOneCourse (
79+ { _id : new ObjectId ( courseId ) } ,
80+ { $set : { retro : null } } ,
81+ ) ;
82+ }
6883}
0 commit comments