';// Function to check if the URL contains any of the strings in the arrayfunction containsAny(url, substrings) { for (var i = 0; i !== substrings.length; i++) { if (url.indexOf(substrings[i]) !== -1) { return true; } } return false;}// Check if the URL contains any of the strings in the arrayif (containsAny(currentURL, URLstoFind)) { // Get the div element with the class user-report-container var userReportContainer = document.querySelector('#maincontent'); // Check if the userReportContainer exists if (userReportContainer) { // Insert the HTML content before the userReportContainer element userReportContainer.insertAdjacentHTML('afterend', htmlContent); } else { // Get the element with id overview-grades var overviewGrade = document.querySelector('#maincontent'); // Check if the overviewGrade element exists if (overviewGrade) { // Insert the HTML content before the overviewGrade element overviewGrade.insertAdjacentHTML('afterend', htmlContent); } }}document.addEventListener("DOMContentLoaded", function() { document.querySelectorAll('.themeboostunionadvtile').forEach(tile => { const btn = tile.querySelector('.card-footer a.btn'); const header = tile.querySelector('h5.card-header'); if (btn && header) { const href = btn.getAttribute('href'); const headerText = header.textContent; if (href && headerText) { // Create new anchor element const anchor = document.createElement('a'); anchor.setAttribute('href', href); anchor.textContent = headerText; // Clear existing text and append anchor header.textContent = ''; header.appendChild(anchor); } } });});//// make Panopto embeds responsive// Select all iframes with src starting with 'https://soas.hosted.panopto.com'document.addEventListener("DOMContentLoaded", function() { var matchingIframes = document.querySelectorAll('iframe[src^="https://soas.hosted.panopto.com"]'); // Loop through each matching iframe matchingIframes.forEach(function(iframe) { // Check if the iframe has a parent div if (iframe.parentNode && iframe.parentNode.tagName === 'DIV') { // Add the class 'panopto-embed-container' to the parent div iframe.parentNode.classList.add('panopto-embed-container'); } });});// END make Panopto embeds responsive// Module template notesfunction replaceDivContent(divId, newContent) { var div = document.getElementById(divId); if (div && div.innerHTML !== newContent) { div.innerHTML = newContent; }}function removeTabIndexFromTemplateDelete() { const templateDeleteElements = document.querySelectorAll('.template-delete'); templateDeleteElements.forEach(element => { if (element.hasAttribute('tabindex')) { element.removeAttribute('tabindex'); } });}// Function to update elements by adding class and duplicating the .editing_delete elementfunction updateElements() { if (document.body.classList.contains('pagelayout-course')) { const modtypeLabels = document.querySelectorAll('li.modtype_label'); modtypeLabels.forEach(li => { const moduleTemplate = li.querySelector('div[id^="module_template--"]'); if (moduleTemplate && !li.classList.contains('module-template-note')) { li.classList.add('module-template-note'); const editingDelete = li.querySelector('a.editing_delete'); if (editingDelete) { const editingDeleteClone = editingDelete.cloneNode(true); editingDeleteClone.classList.add('template-delete'); const activityBasis = li.querySelector('.activity-basis'); if (activityBasis && !activityBasis.querySelector('.template-delete')) { activityBasis.appendChild(editingDeleteClone); } } } }); removeTabIndexFromTemplateDelete(); }}// Function to apply initial changesfunction applyInitialChanges() { if (document.querySelector('[data-key="siteadminnode"]')) { document.body.classList.add('role-site-admin'); } if (document.body.classList.contains('pagelayout-course')) { replaceDivContent('module_template--guide', '
Guidance for staff
New module pages now include guidance for staff with instructions about what information should be included in the relevant sections. This is designed to improve the consistency across modules and allow students to locate important information easily.
These notes are hidden from students; please delete them when they are no longer required (enable edit mode to do this).
'); replaceDivContent('module_template--welcome', '
Guidance for staff
The Welcome topic
Please use this topic to introduces the module, this might include:
- a short description of the module
- a banner image and/or an introductory video
It is recommended that this topic is kept as short as possible and additional information and activities are located in the topics below.
'); replaceDivContent('module_template--overview', '
Guidance for staff
The Module overview topic
Please use this topic for general resources and information about the module, including:
- contact information for teaching staff
- module overview information (including intended learning outcomes)
- information about how the module will be delivered (including dates, times and locations of activities, such as lectures or seminars)
'); replaceDivContent('module_template--assessment', '
Guidance for staff
The Assessment topic
Please use this topic for information about how the module is assessed, including:
- a list of assessments – showing their due dates, format, and weighting
- links to submission portals or other assessment activities (e.g. Turnitin, Quizzes, etc.)
- past papers and other resources
'); replaceDivContent('module_template--readings', '
Guidance for staff
The Readings topic
The readings section should include details of all the module readings.
It is your responsibility to ensure that all items on your module reading list are available, accessible, and have been copyright cleared. Please contact the relevant subject librarian who will be able to help you with this.
'); replaceDivContent('module_template--topics', '
Guidance for staff
Topics
Please use additional topics sections to structure your module, including:
- a summary of what will be covered
- any resources or activities relevant to this stage of the module
Remember to use meaningful topic titles to help students locate information easily.
'); } updateElements();}// MutationObserver to monitor changes to the order of children in all ul.section elementsfunction observeSectionsOrder() { const sectionLists = document.querySelectorAll('ul.section'); sectionLists.forEach((sectionList) => { const observer = new MutationObserver((mutationsList) => { let shouldRunUpdates = false; for (let mutation of mutationsList) { if (mutation.type === 'childList') { shouldRunUpdates = true; break; } } if (shouldRunUpdates) { observer.disconnect(); // Temporarily disconnect to prevent infinite loops applyInitialChanges(); observer.observe(sectionList, { childList: true, }); } }); // Start observing the ul.section for changes in its child order observer.observe(sectionList, { childList: true, }); // Initial run to apply changes immediately applyInitialChanges(); });}// Start observing the section order for all ul.section elementsobserveSectionsOrder();// END Module template notesdocument.addEventListener("DOMContentLoaded", function() { // Disable Tii checkboxes let allTiiCheckboxes = document.querySelectorAll( '#page-backup-import [id^="id_setting_activity_turnitintooltwo_"], ' + '#page-backup-backup [id^="id_setting_activity_turnitintooltwo_"], ' + '#page-backup-import [id^="id_setting_activity_lti_"], ' + '#page-backup-backup [id^="id_setting_activity_lti_"], ' + '#page-backup-import [id^="id_setting_activity_attendance_"], ' + '#page-backup-backup [id^="id_setting_activity_attendance_"]' ); allTiiCheckboxes.forEach(checkbox => { checkbox.checked = false; checkbox.disabled = true; }); // Disable Announcements forum checkbox let announcementsForum = document.querySelectorAll('#page-backup-import label[for^="id_setting_activity_forum_"], #page-backup-backup label[for^="id_setting_activity_forum_"]'); announcementsForum.forEach(label => { if (label.innerHTML.includes("Announcements")) { let checkbox = label.previousElementSibling; if (checkbox) { checkbox.checked = false; checkbox.disabled = true; } } });});document.addEventListener('DOMContentLoaded', (event) => { // Function to set the active tab function setActiveTab() { // Check if the 'Favourite' tab is available and active const favouriteTab = document.querySelector('.nav-item.nav-link[data-region="favourite-tab-nav"]'); const favouritePane = document.querySelector('.tab-pane[data-region="favourites"]'); const isFavouriteActive = favouriteTab && favouriteTab.classList.contains('active'); if (isFavouriteActive) { // If 'Favourite' tab is active, do nothing return; } // Remove 'active' class from all .nav-link and .tab-pane elements const navLinks = document.querySelectorAll('.nav-item.nav-link'); const tabPanes = document.querySelectorAll('.tab-pane'); navLinks.forEach(link => { link.classList.remove('active'); link.setAttribute('aria-selected', 'false'); link.setAttribute('tabindex', '-1'); }); tabPanes.forEach(pane => { pane.classList.remove('active'); }); // Set 'Recommended' tab as active const recommendedTab = document.querySelector('.nav-item.nav-link[data-region="recommended-tab-nav"]'); const recommendedPane = document.querySelector('.tab-pane[data-region="recommended"]'); if (recommendedTab && recommendedPane) { recommendedTab.classList.add('active'); recommendedTab.setAttribute('aria-selected', 'true'); recommendedTab.setAttribute('tabindex', '0'); recommendedPane.classList.add('active'); } } // MutationObserver to detect when the content is loaded via AJAX const observer = new MutationObserver((mutationsList, observer) => { for (const mutation of mutationsList) { if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { // Check if the 'Recommended' tab is available const recommendedTab = document.querySelector('.nav-item.nav-link[data-region="recommended-tab-nav"]'); const recommendedPane = document.querySelector('.tab-pane[data-region="recommended"]'); if (recommendedTab && recommendedPane) { setActiveTab(); } } } }); // Observe the body for changes observer.observe(document.body, { childList: true, subtree: true });});// Check if body has the 'notloggedin' classif (document.body.classList.contains('notloggedin')) { // Find the h1 element with the class 'h2' and content 'SOAS Moodle' var h1Element = document.querySelector('h1.h2'); if (h1Element && h1Element.textContent.trim() === 'SOAS Moodle') { // Replace the inner HTML with the new structure h1Element.innerHTML = 'SOAS Moodle'; }}////// Hide Turnitin due date setting for non-Admins and show selected valuesdocument.addEventListener("DOMContentLoaded", function() { // Check if the body has the specific ID and does not have the 'role-site-admin' class if (document.body.id === 'page-mod-turnitintooltwo-mod' && !document.body.classList.contains('role-site-admin')) { // Get the select elements const day = document.getElementById('id_dtdue1_day'); const month = document.getElementById('id_dtdue1_month'); const year = document.getElementById('id_dtdue1_year'); const hour = document.getElementById('id_dtdue1_hour'); const minute = document.getElementById('id_dtdue1_minute'); // Get the selected values const selectedDay = day.options[day.selectedIndex].text; const selectedMonth = month.options[month.selectedIndex].text; const selectedYear = year.options[year.selectedIndex].text; const selectedHour = hour.options[hour.selectedIndex].text; const selectedMinute = minute.options[minute.selectedIndex].text; // Create a string in the required format const formattedDateTime = `${selectedDay} ${selectedMonth} ${selectedYear}, ${selectedHour}:${selectedMinute}`; // Create a span element to display the formatted string const displaySpan = document.createElement('span'); displaySpan.className = 'selected-date-time'; displaySpan.textContent = formattedDateTime; // Insert the span into the DOM (for example, before the fieldset) const fieldset = document.getElementById('id_dtdue1'); fieldset.parentNode.insertBefore(displaySpan, fieldset); // Hide the select fields [day, month, year, hour, minute].forEach(selectElement => { selectElement.style.display = 'none'; }); }});// Check if the page contains the #page-mod-book-view elementif (document.querySelector('#page-mod-book-view')) { // Select the source and target elements const sourceElement = document.querySelector('.block_book_toc'); const targetElement = document.querySelector('#book_toc'); // Check if both elements exist if (sourceElement && targetElement) { // Clone the contents of the source element const clonedContent = sourceElement.cloneNode(true); // Append the cloned content to the target element targetElement.appendChild(clonedContent); } else { console.error("Source or target element not found."); }} else { console.log("The #page-mod-book-view element is not present.");}