feat: add dynamic activity name to content button

Modified script.js to dynamically include the activity name in the content button text using a data attribute. Updated view.php to pass the activity name to the script for better contextual display of the content button.

This enhancement improves the user experience by making the button's label more meaningful and relevant.
This commit is contained in:
Kumi 2024-09-23 08:43:57 +02:00
parent 476606f22f
commit 17e8bc0c18
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 7 additions and 1 deletions

View file

@ -185,12 +185,16 @@
window.top.closeQuizModal = closeQuizModal; window.top.closeQuizModal = closeQuizModal;
window.top.goToQuiz = window.top.nextContent; window.top.goToQuiz = window.top.nextContent;
var contentName = $(currentScript).attr("data-activity-name");
$(currentScript) $(currentScript)
.parent() .parent()
.append( .append(
`<button id="contentButton-` + `<button id="contentButton-` +
scriptId + scriptId +
`" class="btn btn-primary" type="button">360° Content</button>` `" class="btn btn-primary" type="button">` +
contentName +
`</button>`
); );
var button = $("#contentButton-" + scriptId); var button = $("#contentButton-" + scriptId);

View file

@ -27,9 +27,11 @@ $PAGE->set_heading(format_string($course->fullname));
echo $OUTPUT->header(); echo $OUTPUT->header();
$content_id = $exp360->content_id; $content_id = $exp360->content_id;
$activity_name = $exp360->name;
echo "<script echo "<script
data-activity-id='$content_id' data-activity-id='$content_id'
data-activity-name='$activity_name'
src='/mod/exp360/script.js'> src='/mod/exp360/script.js'>
</script>"; </script>";