-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨(projet) get user completionrecover the student's progress #9
base: main
Are you sure you want to change the base?
Conversation
6940969
to
4402d19
Compare
block_iagora.php
Outdated
@@ -55,9 +55,49 @@ public function get_content() { | |||
} else { | |||
$this->content->text = $this->generate_chat_content($copilotendpointurl); | |||
} | |||
|
|||
// Marquer l'activité comme vue pour la complétion si le suivi est activé |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Marquer l'activité comme vue pour la complétion si le suivi est activé | |
// Mark activity as viewed if tracking is enabled. |
As most of our comments are in English, could we keep it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite right
block_iagora.php
Outdated
// Generate a unique identifier for the chat container. | ||
$chatid = uniqid('iagora_chat_'); | ||
|
||
// Si la complétion est activée et que l'utilisateur visualise l'activité | ||
if ($completion->is_enabled($cm) && $completion->is_tracked_user($USER->id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is $completion
defined? (I got an exception here saying that it's null
)
block_iagora.php
Outdated
$completion = new completion_info($COURSE); | ||
if ($completion->is_enabled($this->context) && $completion->is_tracked_user($USER->id)) { | ||
// Marquer l'activité comme vue dans le système de complétion | ||
$completion->set_module_viewed($this->context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we set the module as viewed? Isn't this managed by the completion plugin?
Maybe we could retrieve all completed activities and pass this information the the copilot? For example:
global $COURSE, $USER;
$completed_activities = array();
$completion = new completion_info($COURSE);
$modinfo = get_fast_modinfo($COURSE, $USER->id);
$cms = $modinfo->get_cms();
foreach ($cms as $cm) {
if ($cm->completion == COMPLETION_TRACKING_NONE) {
continue;
}
if (!$cm->uservisible) {
continue;
}
$completiondata = $completion->get_data($cm, true, $USER->id);
if ($completiondata->completionstate == COMPLETION_COMPLETE ||
$completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
$completed_activities[] = $cm->name;
}
}
Maybe passing a list of incomplete activities might be useful, too? What do you think?
block_iagora.php
Outdated
// Appeler l'API Moodle | ||
$completionstatus = call_external_api('core_completion_get_activities_completion_status', [ | ||
'courseid' => $courseid, | ||
'userid' => $userid | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin runs inside Moodle; thus, I guess we should avoid calling the external API.
We could check out the source code of the get_activities_completion_status function, which gives an excellent example of how to use the completion_info
class to retrieve information about course completion.
The Moodle block_selfcompletion plugin might serve as a great example too)
block_iagora.php
Outdated
$context = [ | ||
'chatId' => $chatid, | ||
'tokenEndpointURL' => $copilotendpointurl, | ||
'progress' => $progressPercentage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'progress' => $progressPercentage | |
'progressPercentage' => $progressPercentage |
The key should match the one used in the Mustache template.
5aacf45
to
9e3f576
Compare
dfcae7f
to
6b5b399
Compare
use moodle's completion tracker to track student progress
6b5b399
to
0c56826
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better 👍
Maybe we could also add a second variable to provide a list of incomplete activities? What do you think?
block_iagora.php
Outdated
// Generate a unique identifier for the chat container. | ||
$chatid = uniqid('iagora_chat_'); | ||
$context = [ | ||
'chatId' => $chatid, | ||
'tokenEndpointURL' => $copilotendpointurl, | ||
'completedactivities' => json_encode($this->get_student_progress()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'completedactivities' => json_encode($this->get_student_progress()), | |
'completedActivities' => json_encode($this->get_student_progress()), |
Aren't JavaScript variables using camelCase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but moodle has not accepted this naming.Here's the error he made Variable "completedActivities" must be all lower-case
block_iagora.php
Outdated
@@ -66,12 +100,13 @@ public function get_content() { | |||
* @return string The generated HTML content for the chat. | |||
*/ | |||
private function generate_chat_content($copilotendpointurl) { | |||
global $OUTPUT; | |||
global $OUTPUT, $USER, $COURSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global $OUTPUT, $USER, $COURSE; | |
global $OUTPUT; |
Where are $USER
and $COURSE
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In get_student_progress()
I used $COURSE
and $USER
to retrieve the user's activity progress information get_fast_modinfo($COURSE, $USER->id)
and also in $completion->get_data($cm, true, $USER->id)
to retrieve whether or not the user has completed the activity.
templates/chat.mustache
Outdated
@@ -45,8 +45,21 @@ | |||
/* eslint-disable promise/no-native */ | |||
(async function() { | |||
const styleOptions = { | |||
hideUploadButton: true | |||
hideUploadButton: true, | |||
botAvatarImage: "/image/iagora.jpg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a 404 - image not found. Where is this image defined?
Setting a fixed image for the bot should be fine in the first iteration; however, we should probably make this configurable in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed, the method I had originally used required providing a link to the image, which had to be available online. I now wanted to try and create a sub-folder in the IAgora folder to store the image in, and then provide the local path to that image.
templates/chat.mustache
Outdated
botAvatarInitials: 'BF', | ||
userAvatarImage: 'https://github.com/compulim.png?size=64', | ||
userAvatarInitials: 'WC' | ||
}; | ||
const styleSet = window.WebChat.createStyleSet({ | ||
bubbleBackground: 'rgba(0, 0, 255, .1)', | ||
bubbleFromUserBackground: 'rgba(0, 255, 0, .1)' | ||
}); | ||
|
||
styleSet.textContent = Object.assign({}, styleSet.textContent, { | ||
fontFamily: "'Comic Sans MS', 'Arial', sans-serif", | ||
fontWeight: 'bold' | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thoughts here; these values should be configurable.
For the userAvatarImage,
we could use the Moodle user profile image, and for the userAvatarInitials
- the first letter of the Moodle user's first name and last name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's a good idea, I'm going to follow this approach.
templates/chat.mustache
Outdated
type: 'event' | ||
type: 'event', | ||
value: { | ||
completedactivities: completedactivities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completedactivities: completedactivities | |
completedActivities: '{{completedActivities}}' |
templates/chat.mustache
Outdated
@@ -69,7 +82,7 @@ | |||
}) | |||
.then(({token}) => token) | |||
]); | |||
|
|||
const completedactivities = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const completedactivities = []; |
Isn't the completedActivities
variable already defined in the Mustache template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completedactivities
is defined in the mustache template, but as an empty array. I'll fix that using the data passed from the block. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing doc string for the completedActivities
context variable (line 29)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll add it
8b5b855
to
e5495b9
Compare
block_iagora.php
Outdated
$uncompletedactivities[] = $cm->name; | ||
} | ||
} | ||
// Return the array of completed activities and uncompleted activities . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Return the array of completed activities and uncompleted activities . |
Isn't this information is already present in the function docstring?
@@ -28,11 +28,14 @@ | |||
Context variables required for this template: | |||
* chatId: The ID of the chat div element where to render the chat block. | |||
* tokenEndpointURL: The Copilot Token Endpoint URL for native apps. | |||
* completedActivities: A JSON string containing the list of activities the user has already completed. | |||
* uncompletedActivities: A JSON string containing the list of activities the user has not yet completed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstrings for userAvatarImage
and userAvatarInitials
templates/chat.mustache
Outdated
|
||
Example context (json): | ||
{ | ||
"chatId": "iagora_chat_55a6cad25a0f6", | ||
"tokenEndpointURL": "https://insert/your/copilot/endpoint/url" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing example values for completedActivities
, uncompletedActivities
, userAvatarImage
and userAvatarInitials
c479f42
to
cdaaa50
Compare
7f59af2
to
517e618
Compare
Update the block_iagora to include customisable avatar initials and profil image.
517e618
to
03e8f46
Compare
use moodle's completion tracker to track student progress
Purpose
Proposal