Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioSim committed Sep 13, 2024
1 parent cc4e9c3 commit 47834c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion block_iagora.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ public function get_content() {
* @return string The generated HTML content for the chat.
*/
private function generate_chat_content($directlineurl, $token) {
global $OUTPUT;
global $OUTPUT, $USER, $COURSE, $PAGE;
// Generate a unique identifier for the chat container.
// die(var_dump($PAGE));
$chatid = uniqid('iagora_chat_');
$context = [
'chatId' => $chatid,
'directLineURL' => $directlineurl,
'token' => $token,
'moodleUserName' => $USER->firstname,
'moodleCourseName' => $COURSE->fullname,
];
return $OUTPUT->render_from_template('block_iagora/chat', $context);
}
Expand Down
11 changes: 7 additions & 4 deletions templates/chat.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@
"token": "RCurR_XV9ZA.cwA.BKA.iaJrC8xpy8qbOF5xnR..."
}
}}
{{#pix}} t/message, core {{/pix}}
<div id="{{chatId}}" role="main"></div>
<div id="{{chatId}}" role="main" style="height: 500px;"></div>

<script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>

{{#js}}
{{js}}
/* global WebChat */
/* eslint-disable promise/no-native */
(async function() {
Expand All @@ -60,7 +59,11 @@
localTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
locale,
name: 'startConversation',
type: 'event'
type: 'event',
value: {
'MoodleUserName': '{{moodleUserName}}',
'MoodleCourseName': '{{moodleCourseName}}'
}
})
.subscribe();
subscription.unsubscribe();
Expand Down

0 comments on commit 47834c6

Please sign in to comment.