Skip to content

Commit 47834c6

Browse files
committed
WIP
1 parent cc4e9c3 commit 47834c6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

block_iagora.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,16 @@ public function get_content() {
7474
* @return string The generated HTML content for the chat.
7575
*/
7676
private function generate_chat_content($directlineurl, $token) {
77-
global $OUTPUT;
77+
global $OUTPUT, $USER, $COURSE, $PAGE;
7878
// Generate a unique identifier for the chat container.
79+
// die(var_dump($PAGE));
7980
$chatid = uniqid('iagora_chat_');
8081
$context = [
8182
'chatId' => $chatid,
8283
'directLineURL' => $directlineurl,
8384
'token' => $token,
85+
'moodleUserName' => $USER->firstname,
86+
'moodleCourseName' => $COURSE->fullname,
8487
];
8588
return $OUTPUT->render_from_template('block_iagora/chat', $context);
8689
}

templates/chat.mustache

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@
3737
"token": "RCurR_XV9ZA.cwA.BKA.iaJrC8xpy8qbOF5xnR..."
3838
}
3939
}}
40-
{{#pix}} t/message, core {{/pix}}
41-
<div id="{{chatId}}" role="main"></div>
40+
<div id="{{chatId}}" role="main" style="height: 500px;"></div>
4241

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

45-
{{#js}}
44+
{{js}}
4645
/* global WebChat */
4746
/* eslint-disable promise/no-native */
4847
(async function() {
@@ -60,7 +59,11 @@
6059
localTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
6160
locale,
6261
name: 'startConversation',
63-
type: 'event'
62+
type: 'event',
63+
value: {
64+
'MoodleUserName': '{{moodleUserName}}',
65+
'MoodleCourseName': '{{moodleCourseName}}'
66+
}
6467
})
6568
.subscribe();
6669
subscription.unsubscribe();

0 commit comments

Comments
 (0)