@@ -95,13 +95,25 @@ export async function getCourseActivityTypes(
9595 } ,
9696 select : {
9797 isGamificationEnabled : true ,
98+ permissions : {
99+ where : { userId : account . userId } ,
100+ select : { permissionLevel : true } ,
101+ } ,
98102 liveQuizzes : { where : { isDeleted : false } } ,
99103 practiceQuizzes : { where : { isDeleted : false } } ,
100104 microLearnings : { where : { isDeleted : false } } ,
105+ chatbots : { select : { id : true } } ,
101106 } ,
102107 } )
103108 if ( ! course ) return null
104109
110+ const isManager = course . permissions . some (
111+ ( permission ) =>
112+ permission . permissionLevel === 'OWNER' ||
113+ permission . permissionLevel === 'ADMIN'
114+ )
115+ const hasChatbots = course . chatbots . length > 0
116+
105117 const mapSubselection : Record <
106118 string ,
107119 LiveQuiz [ ] | PracticeQuiz [ ] | MicroLearning [ ]
@@ -122,6 +134,20 @@ export async function getCourseActivityTypes(
122134 olatConfigurationKey,
123135 isSubselectionRequired,
124136 } ) => {
137+ if ( olatConfigurationKey === 'chatbot' ) {
138+ return isManager && hasChatbots
139+ ? {
140+ id,
141+ title_de : titleDE ,
142+ title_en : titleEN ,
143+ title_fr : titleFR ,
144+ title_it : titleIT ,
145+ olatConfigurationKey,
146+ isSubselectionRequired,
147+ }
148+ : [ ]
149+ }
150+
125151 // Subselection activities: only include if they have items
126152 if ( olatConfigurationKey in mapSubselection ) {
127153 return {
@@ -183,6 +209,35 @@ export async function getActivities(
183209 } )
184210 if ( ! account ) return null
185211
212+ if ( activityTypeKey === 'chatbot' ) {
213+ const course = await prisma . course . findUnique ( {
214+ where : {
215+ id : courseID ,
216+ permissions : {
217+ some : {
218+ userId : account . userId ,
219+ permissionLevel : { in : [ 'OWNER' , 'ADMIN' ] } ,
220+ } ,
221+ } ,
222+ } ,
223+ select : {
224+ chatbots : {
225+ select : { id : true , name : true } ,
226+ orderBy : { name : 'asc' } ,
227+ } ,
228+ } ,
229+ } )
230+ if ( ! course ) return null
231+
232+ return course . chatbots . map ( ( chatbot ) => ( {
233+ id : chatbot . id ,
234+ title_de : chatbot . name ,
235+ title_en : chatbot . name ,
236+ title_fr : chatbot . name ,
237+ title_it : chatbot . name ,
238+ } ) )
239+ }
240+
186241 const course = await prisma . course . findUnique ( {
187242 where : {
188243 id : courseID ,
0 commit comments