To add two language button on quiz block: reg.

To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Number of replies: 35
This is my moodle quiz.
 

I want to add two language buttons like the below screenshot. because in my Moodle quiz, there is no language button is given. Can anyone help me with this kind of work?




Average of ratings: -
In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
It is easy to do. I will show you how next week.
In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Kumar -
🙏 thans for your reply.

 appreciate you Sir,

God bless you.

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Dear sir,
I'm waiting your reply, I believe that you will be find the solution of the aforesaid query.
Have a good 😊 day sir.
In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Virendra,

You will find two examples of language selector, one with multiple buttons and one with a single button, at https://dynamiccourseware.org/course/view.php?id=119&section=3➚. Click on "HTML code for the language selector above" to see the codes.

Essentially, it's simply adding the language to the URL, for example &lang=en for English, &lang=fr for French, &lang=es for Spanish, etc. Once the language is added, it does not change until changed again.

You can format the buttons as you wish. To place the buttons in the menu, you will need a line of JavaScript that I haven't included because I don't know exactly where you want them. Feel free to ask me for help if you have no one to assist you.

If you have access to the site administration, you can put the script in Site administration / Appearance / Additional HTML. If you don't have access, you can put it in a Text block, which you can display on all pages of your site, your course or your quiz, or only on certain pages as needed.

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
dear sir, 
First I appreciate you for this kind work.
Just I have added this code in Additional HTML block and for quiz pages, i have added this code in text block separately but does not work . please see screenshot. If I am doing wrong, then suggest me please .I want to add this button in specially for quiz block, where anyone can simply change the language as per need.

 

I have added this code in text block look like this:


Dear sir , please see screenshot also. I am seeing any button 

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
dear sir,
I  have added your code systematically, please see screenshot. It is good. thank you again.
But when we attempt the quiz it is not showing there. Would be added this code for every question?



It is not showing on quiz attempt page, please see screenshot.


In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Virendra,

I will assume that you are using the Boost theme, but it's not important if you're using another theme because we can make adjustments.

As I mentioned earlier, you can place the script in either Site Administration / etc. or within a block. Let's first place the script in a quiz Text block, i.e. a text block that appears on the various pages of a given quiz. We can explore other placement options later.

  1. In the quiz settings and under 'Appearance / Show more...', set 'Show blocks during quiz attempts' to 'Yes'.
  2. In your Preferences, set the editor to 'Plain text area' (recommended).
  3. Click on the quiz icon to get to the 'Quiz' tab page.
  4. Add a text block. Place the code below in the 'Content' field of the block. There is no need to give a 'Text block title'. Save changes.
  5. Click on the cog icon of the block and select 'Configure text block'.
  6. Under 'Where this block appears', set 'Display on page types' to 'Any quiz module page'. Save changes.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() {

  $("#page-mod-quiz-attempt #usernavigation").prepend('<div style="position: relative; padding-top: 5px; left: -30px;"><button class="btn-danger" id="DCen">English</button><button class="btn-danger" id="DChi">हिंदी</button></div>');

  $("#DCen, #DChi").css({"display":"inline-block", "cursor":"pointer", "padding":"5px 16px 8px", "background-color":"red", "color":"#FFF", "border-radius":"20px", "margin-left":"20px", "box-shadow":"-8px 15px 15px #aaa"});

  $("#DCen").mousedown(function(){
    // Format the button.
    $(this).css({"box-shadow":"-3px 3px 6px #aaa", "padding":"6px 16px 7px"});
    $("#DChi").css({"position":"relative", "top":"-1px"});
  });
  $("#DCen").mouseup(function(){
    // Format the button.
    $(this).css({"box-shadow":"-8px 15px 15px #aaa", "padding":"5px 16px 8px"});
    $("#DChi").css({"position":"relative", "top":"0px"});
  });

  $("#DChi").mousedown(function(){
    $(this).css({"box-shadow":"-3px 3px 6px #aaa", "padding":"6px 16px 7px"});
    $("#DCen").css({"position":"relative", "top":"-1px"});
  });
  $("#DChi").mouseup(function(){
    $(this).css({"box-shadow":"-5px 10px 10px #aaa", "padding":"5px 16px 8px"});
    $("#DCen").css({"position":"relative", "top":"0px"});
  });

  $("#DCen").click(function(){
    // Get the current URL.
    let url = window.location.href;
    // Remove any occurrence of &lang=en and &lang=hi in the current URL.
    url = url.replaceAll("&lang=en","");
    url = url.replaceAll("&lang=hi","");
    // Add &lang=en to the current URL.
    window.location.href = url + "&lang=en"
  });

  $("#DChi").click(function(){
    let url = window.location.href;
    url = url.replaceAll("&lang=en","");
    url = url.replaceAll("&lang=hi","");
    window.location.href = url + "&lang=hi"
  });
});
</script>

You should get something like this:

MoodleForum_20240312_0246.png

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Thank you so much sir,

I appreciate your knowledge and helpful attitude also.

I have few questions, I want to add this language button in the menu. Please help for this kind work.

Please look this example link:
Embed multiple questions - sequential navigation, yes
In this demo quiz, when click on next button we move on without delay and I am seeing a fun javascript that it is not browsing like other quizzes.

I humble request that provide javascript as above please.

best regards.

In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello Virendra,

Let me know if you have resolved the issue with the language selection buttons to your satisfaction.

Regarding the sequence of embedded questions, the code is provided on the page you mentioned.

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Dear sir,

I am satisfied with your language button code. I have added the code as per your direction. It has been successfully implemented on quiz pages. I shall be grateful to you for this kind work.

Thank you so much sir.

In reply of Second question, I know that you have provided the code on website I have added that code in our end but the code is not working for the Moodle quiz.  I have added the code but not worked in my case. Will that code work for Moodle quiz, because that code is specially coded for embedded type question, is'nt?


Sir, if not sure with my query that what am I asking.. I am providing a quiz link. You can dig it your end. I want to make like this which is telling with you. When you click the next button this is not browsing and move on next question page. Please look at this quiz link.

https://testbook.com/TS-ssc-gk-previous-year-questions/tests/637c95b0f7c4bfd1c0a550cb?attemptNo=1#/lt-test

Sir, Please resolve the issue.


In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Dear sir,
You are great person. You have good knowledge and have a positive attitude.
You are helpful person.
Thank you so much thousands time.
In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Virendra,

Thank you for your kind words.

Will that code work for Moodle quiz, because that code is specially coded for embedded type question, is'nt?

You are correct, the code is only intended for embedded questions.

For regular quizzes, in the quiz settings you can choose various question behaviours, such as interactive with multiple tries, immediate feedback, deferred feedback, etc., and choose between free or sequential navigation methods. Additionally, on the question page, you can apply restrictions to questions using locks, preventing students from moving on to the next question until the previous one has been completed.

I suggest carefully exploring all these standard options first to see if any combination of them suits your needs. If not, then custom-made snippets may be useful.

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Thank you sir,.

I like your suggestion 

Please look at this plugin:

https://moodle.org/plugins/quizaccess_honestycheck

It is not working, I installed it on website but it is not working.

I want to do like this if any student want to start quiz, then it should be mandate.

Quiz screenshot is here;

Screenshot

In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Virendra,

It is working but the plugin does not have default settings so you must set the acknowledgment in each and every quiz as follows:

In the quiz settings, set 'Extra restrictions on attempts/ Students cognisance of plagiarism policy' to 'must be acknowledged before starting an attempt'.

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Dear sir,

When I click on quiz setting page, only 4 option is given here. 

Please see this screenshot

Here , I am not able to find that restriction which is said by you.

Screenshot

In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Virendra Yadav yadav -
Dear sir,

Please add the same language button in menu as of you added on quiz block pages.

Please made up some js code.

Please look at this screenshot:

Screenshot

In reply to Dominique Bauer

Embedded question regarding

by Virendra Yadav yadav -
Dear sir, 

How to find this code for embedded question ❓

Q{category_20210429_0003/question_20210429_0020|6c60cdeb8288b7072cebde62a1d607175ff2d4c83cc9eb23c619d3543406a697}Q
Please look at this screenshot, this code is made by you.


In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Virendra,

Did you forget to include the screen shot?

Where does this embed question code come from? Could you be more specific?

In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -
Image


This code has come from your website.

I have already installed plugin as per your general guidelines. 

But I am unable to embedded question filters.

The code which is mentioned the above between

{Q{...…….....}Q}. How to find that embedded code.

For example:

Q{category_20210429_0003/question_20210429_0020|6c60cdeb8288b7072cebde62a1d607175ff2d4c83cc9eb23c619d3543406a697}Q

In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Virendra,

These codes are generated by the Moodle Embed Question plugin, which must be installed on your Moodle site in order to use it: https://moodle.org/plugins/filter_embedquestion➚. Please read all the instructions carefully at https://github.com/moodleou/moodle-filter_embedquestion/blob/main/internaldoc/functionality.txt➚.

It is an excellent plugin, very user-friendly and easy to use.

In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -
Dear sir,

As per your guidelines, I have installed the plugins and their dependencies plugins also. And I have added 'ambedquestion' word in the list of Toolbar_config but insert question option is not being show in toolbar editor. Therefore,  I am unable to add embedded question in anywhere.

Please look at this screenshot:

Image_2

Image _1


In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
You have to use the 'Atto' editor, not 'TinyMCE'. You can change it by clicking on your user photo or avatar in the upper right corner of the page, then selecting 'Preferences', and then 'Editor preferences'.
In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -
You are a very good and intelligent person, no matter how many times thank you, it will be less. Thank you very much.
In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -
You are a very good and intelligent person, no matter how many times thank you, it will be less. Thank you very much.


Sir,

Can I give any numbers or words for course ID and questions ID? That means a different ID would be different for each question. Right sir?

In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Virendra,

You have to give a question bank 'category' id and a 'question' id. The question id's must be unique within the same quiz. Id's can be numbers or words or a combination of numbers and letters.

One way to make sure that an id is unique is to name it with the date and time at which it is created, for example "question_20240401_1429" which could be used for a question id created on the 1st of April 2024 at 14:29.
In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -
Dear sir, I have two questions;

1. Can I use any numbers or word for Course iD and Questions iD ?

2. In question bank, each question has different question ID, but course ID would be separate from question iD. Is it right?


In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
1) Yes, 2) Yes. At least, I think so. It is not difficult for you to just check by yourself. smile
In reply to Dominique Bauer

Re: Embedded question regarding

by Virendra Yadav yadav -

Dear sir,

I have added ID in the question category and also added ID in some questions which is in associated category. But I could not solve it.

Please look at this screenshot:



I have ID in the question bank for each question.



after completing the process, I insert a page, in which I click on insert embedded question, but embedded category is not being shown. Please look at this screenshot:



Please see, what am I doing wrong?

guide me, please.

Best regards.

In reply to Virendra Yadav yadav

Re: Embedded question regarding

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Virendra,

Not a 'course' category, but rather a 'question' category in the question bank! smile

See https://docs.moodle.org/en/Question_categories
In reply to Dominique Bauer

Change time per question

by Shruti Singh -
Dear sir,

It may be possible or not that when we start any quiz, we see that a time start in total time as per by given time for the quiz 

But I want here, that when we start the quiz the time should be  start for particular question

That means for question -1, time start should be from 1 second

And for question-2 , again time should be start from 1 second.

Here you can see time spend for each question generally.

In reply to Virendra Yadav yadav

Re: To add two language button on quiz block: reg.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Why not the prescribed way as documented in Language_settings#Display_language_menu?
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: To add two language button on quiz block: reg.

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello Visvanath,

Because it is more fun. Also, it is more direct and faster. Also, it is something that Virendra wants to have, whatever his reasons may be. Moodle is not a high security jail guarded by developers. smile
In reply to Dominique Bauer

Re: To add two language button on quiz block: reg.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Watching those JS magic alone is fun. My consideration was whether the OP is fully aware of the plus- and downsides. It is possible that since the site admin doesn't activate the language selection menu our OP is going in an adventure without knowing the risks. 
big grin

And on top of that, is he going to add this JS to every question in the question bank?