PageSourceSearch

https://formation.ch-alpes-isere.fr/lib/javascript.php/1789977024/…/boosticeo/javascript/boosticeo_utils.js

js ch-alpes-isere.fr collected 2026-10-02 19:10:01 UTC 11,402 bytes, 48 lines download raw bytes

1function addButtonRedirection(Y,urlToRedirect,containerSelector){let container=document.querySelector(containerSelector);if(container){let newNavitem=document.createElement('div');newNavitem.classList.add('navitem');let lien=document.createElement('a');lien.href=urlToRedirect;lien.textContent=M.util.get_string('course_home','theme_boosticeo');lien.classList.add('btn');lien.classList.add('btn-primary');newNavitem.appendChild(lien);let rowDiv=container.querySelector('.row');if(rowDiv){rowDiv.appendChild(newNavitem)}}}
2function changeHomeTitle(Y,homeNewTitle){let homeTitle=document.querySelector('#page-site-index .page-context-header h1');if(homeTitle){homeTitle.innerHTML=homeNewTitle}}
3function changeLoginTitle(Y,loginNewTitle){let loginTitle=document.querySelector('#page-login-index .page-context-header h1');if(loginTitle){loginTitle.innerHTML=loginNewTitle}}
4document.addEventListener("DOMContentLoaded",function(){if(window.self!==window.top&&document.querySelector('.hide-theme-layout')){document.documentElement.classList.add('is-embedded')}
5let blocksIconsData=document.getElementById('blocks_icons');if(blocksIconsData){let blockIcons={};try{blockIcons=JSON.parse(blocksIconsData.textContent)}catch(error){console.error("Erreur lors de la récupération des icônes des blocs :",error)}
6document.querySelectorAll(".block").forEach(block=>{const blockName=block.dataset.block;const icon=block.querySelector(".card-title i, h2 i");if(blockIcons[blockName]&&!icon){const newIcon=document.createElement("i");newIcon.className=blockIcons[blockName];const cardTitle=block.querySelector(".card-title");if(cardTitle){cardTitle.prepend(newIcon)}else{const alternativeTitle=block.querySelector(`h2`);if(alternativeTitle){alternativeTitle.prepend(newIcon)}}}})}
7const topOfScroll=document.getElementById("topofscroll");const scrollToTop=document.getElementById("scrolltotop");if(scrollToTop){function checkScroll(){if(topOfScroll.getBoundingClientRect().top>=0){scrollToTop.style.opacity="0"}else{scrollToTop.style.opacity="0.8"}}
8window.addEventListener("scroll",checkScroll);checkScroll()}
9let questions=document.querySelectorAll("#page-mod-quiz-review .multichoice, #page-mod-quiz-review .multichoiceset");for(let question of questions){let propositions=question.querySelectorAll(".answer p");let feedback=question.querySelector(".feedback .rightanswer");if(feedback&&propositions.length>0){let finalFeedback=feedback.textContent.split(":")[0]+":";let ul=document.createElement("ul");for(let proposition of propositions){let propositionText=proposition.textContent.trim();if(feedback.textContent.includes(propositionText)){let li=document.createElement("li");li.textContent=propositionText;ul.appendChild(li)}}
10feedback.textContent=finalFeedback;feedback.appendChild(ul)}}
11let questionsmatch=document.querySelectorAll("#page-mod-quiz-review .match");for(let question of questionsmatch){let texts=question.querySelectorAll("td.text");let feedback=question.querySelector(".feedback .rightanswer");for(let text of texts){let cleanedText=text.innerHTML.replace(/^<p>/i,'').replace(/<\/p>$/i,'');if(feedback.innerHTML.includes(cleanedText)){feedback.innerHTML=feedback.innerHTML.replace(cleanedText,'<br><br>'+cleanedText)}}
12question.innerHTML=question.innerHTML.replaceAll('→','<br>→')}
13let testcontainer=document.querySelector("#page-mod-quiz-attempt .focus-course-main-content");if(testcontainer){let activity_footer=document.querySelector(".activity_footer > .row");let activity_footer_content_left=document.querySelectorAll(".tertiary-navigation .btn-secondary");let activity_footer_content_right=document.querySelectorAll(".othernav .endtestlink");if(activity_footer){for(let element of activity_footer_content_left){activity_footer.appendChild(element)}
14for(let element of activity_footer_content_right){activity_footer.appendChild(element)}}
15if(document.querySelectorAll(".que").length===1){let submitbtns=document.querySelector(".submitbtns");let submitbtns_content_left=document.querySelectorAll(".que .state, .que .grade");let submitbtns_content_right=document.querySelectorAll(".que .questionflag, .que .editquestion, .submitbtns input");if(submitbtns&&!submitbtns.querySelector('.submitbtns-left')&&!submitbtns.querySelector('.submitbtns-right')){let submitbtns_left=document.createElement("div");let submitbtns_right=document.createElement("div");submitbtns_left.classList.add("submitbtns-left");submitbtns_right.classList.add("submitbtns-right");for(let element of submitbtns_content_left){submitbtns_left.appendChild(element)}
16for(let element of submitbtns_content_right){submitbtns_right.appendChild(element)}
17submitbtns.appendChild(submitbtns_left);
17submitbtns.appendChild(submitbtns_right)}}
18let testheader=document.querySelector(".activity-header");let activity_navigation=document.querySelector(".activity_navigation");if(activity_navigation){testheader.appendChild(activity_navigation)}
19let testheader_content=document.querySelectorAll(".boosticeo_customize_blocks");for(let element of testheader_content){testheader.appendChild(element)}}
20let testcontainer2=document.querySelector("#page-mod-quiz-summary .focus-course-main-content");if(testcontainer2){let activity_footer=document.querySelector(".activity_footer > .row");let activity_footer_content=document.querySelectorAll(".submitbtns form");if(activity_footer){for(let element of activity_footer_content){activity_footer.appendChild(element)}}
21if(!document.querySelector(".result-container")){let first_container=document.createElement("div");first_container.classList.add("result-container");let activity_navigation=document.querySelector(".activity_navigation");if(activity_navigation){first_container.appendChild(activity_navigation)}
22let first_container_content=document.querySelectorAll(".activity-header, div[role='main'] > h3, div[role='main'] > .table-responsive");for(let element of first_container_content){first_container.appendChild(element)}
23testcontainer2.appendChild(first_container);let submitbtn=document.querySelector(".submitbtns:has(.btn-finishattempt)");if(submitbtn){testcontainer2.appendChild(submitbtn)}}}
24let testcontainer3=document.querySelector("#page-mod-quiz-review .focus-course-main-content");if(testcontainer3){let testheader=document.querySelector(".activity-header");let testheader_content=document.querySelectorAll(".activity_navigation, .boosticeo_customize_blocks");for(let element of testheader_content){testheader.appendChild(element)}
25let container=document.querySelector("div[role='main'] > .submitbtns");let activity_nav_bottom=document.querySelector(".activity_navigation.bottom");if(container&&activity_nav_bottom){container.prepend(activity_nav_bottom)}}
26let testcontainer4=document.querySelector("#page-mod-quiz-view .focus-course-main-content");if(testcontainer4){let main=document.querySelector("div[role='main']");let description_container=document.createElement("div");description_container.classList.add("description-container");let description=document.querySelectorAll(".activity-description:not(.activity-altcontent), .tertiary-navigation");if(!document.querySelector(".description-container")){for(let element of description){description_container.appendChild(element)}
27main.append(description_container)}
28let quizinfo=document.querySelector(".quizinfo");let tertiary_navigation=document.querySelector(".tertiary-navigation");if(quizinfo&&tertiary_navigation){tertiary_navigation.prepend(quizinfo)}
29if(!document.querySelector(".tentative-table")){let contents=document.querySelectorAll("div[role='main'] > h3, div[role='main'] ul.list-unstyled");for(let content of contents){main.append(content)}
30let tentatives=document.querySelectorAll("div[role='main'] ul.list-unstyled li");if(tentatives.length>0){let new_table=document.createElement("table");new_table.classList.add("tentative-table","generaltable");let th1=document.querySelector('.quizreviewsummary tr:nth-child(1) th')?.textContent||"";let th2=document.querySelector('.quizreviewsummary tr:has(b) th')?.textContent||"";let feedback=document.querySelector('#feedback h3')?.textContent.split('/')?.pop()?.trim().replace(/\.$/,'')||"";if(th2&&feedback){th2+=` / ${feedback}`}
31let table_content=`<thead>
32                                            <tr>
33                                                <th></th>
34                                                ${th1 ? `<th>${th1}</th>` : ""}
35                                                ${th2 ? `<th>${th2}</th>` : ""}
36                                                <th></th>
37                                            </tr>
38                                        </thead>
39                                        <tbody>`;for(let tentative of tentatives){let name=tentative.querySelector("h4").textContent;let state=tentative.querySelector(".quizreviewsummary tr:nth-child(1) td")?.textContent+" <br> <span> "+tentative.querySelector(".quizreviewsummary tr:nth-child(2) td")?.textContent+"</span>";let grade=tentative.querySelector(".quizreviewsummary tr td b:first-child")?.textContent;let preview=tentative.querySelector(".card-body a")?.outerHTML||"";table_content+=`<tr>
40                                        <td>${name}</td>
41                                        ${th1 ? `<td>${state}</td>` : ""}
42                                        ${th2 ? `<td>${grade}</td>` : ""}
43                                        <td>${preview}</td>
44                                    </tr>`}
45table_content+="</tbody>";new_table.innerHTML=table_content;let table_container=document.createElement("div");table_container.classList.add("table-container");table_container.appendChild(new_table);main.append(table_container)}
46let best_grade=document.querySelector("#feedback");if(best_grade){main.append(best_grade)}}}
47if(document.querySelector('#page-enrol-index')){let blocks=document.querySelectorAll('#page-enrol-index .layout-block');for(let block of blocks){let totalContentHeight=block.querySelector('.layout-block-content-body').scrollHeight;let blockHeight=block.clientHeight;if(totalContentHeight>blockHeight){let button=document.createElement('div');button.classList.add('layout-block-expand-btn');button.setAttribute('title',M.util.get_string('expand_block','theme_boosticeo'));button.innerHTML='<i class="ph ph-caret-down"></i>';button.addEventListener('click',()=>toggleBlock(block));block.appendChild(button);function toggleBlock(block){block.classList.toggle('expanded');button.innerHTML=block.classList.contains('expanded')?'<i class="ph ph-caret-up"></i>':'<i class="ph ph-caret-down"></i>'}}}}
48let expandActivities=document.querySelector('#page-enrol-index .course-plan-section.expand-activity');let expandActDesc=document.querySelector('#page-enrol-index .course-plan-section.expand-actdesc');if(expandActivities||expandActDesc){let sections=document.querySelectorAll('#page-enrol-index .course-plan-section');sections.forEach(section=>{section.addEventListener('click',()=>{section.classList.toggle('expanded');section.querySelector('.expand-btn').innerHTML=section.classList.contains('expanded')?'<i class="ph ph-caret-up"></i>':'<i class="ph ph-caret-down"></i>'})})}});function toggleLeftMenu(show=!1){const container=document.getElementById("left_menu-container");const button=document.getElementById("left_menu-container-button");if(!container||!button)return;container.classList.toggle("shown",show);button.classList.toggle("shown",show)}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.