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:
parent
476606f22f
commit
17e8bc0c18
2 changed files with 7 additions and 1 deletions
|
@ -185,12 +185,16 @@
|
|||
window.top.closeQuizModal = closeQuizModal;
|
||||
window.top.goToQuiz = window.top.nextContent;
|
||||
|
||||
var contentName = $(currentScript).attr("data-activity-name");
|
||||
|
||||
$(currentScript)
|
||||
.parent()
|
||||
.append(
|
||||
`<button id="contentButton-` +
|
||||
scriptId +
|
||||
`" class="btn btn-primary" type="button">360° Content</button>`
|
||||
`" class="btn btn-primary" type="button">` +
|
||||
contentName +
|
||||
`</button>`
|
||||
);
|
||||
|
||||
var button = $("#contentButton-" + scriptId);
|
||||
|
|
2
view.php
2
view.php
|
@ -27,9 +27,11 @@ $PAGE->set_heading(format_string($course->fullname));
|
|||
echo $OUTPUT->header();
|
||||
|
||||
$content_id = $exp360->content_id;
|
||||
$activity_name = $exp360->name;
|
||||
|
||||
echo "<script
|
||||
data-activity-id='$content_id'
|
||||
data-activity-name='$activity_name'
|
||||
src='/mod/exp360/script.js'>
|
||||
</script>";
|
||||
|
||||
|
|
Loading…
Reference in a new issue