Add a logo quiz questions

Add a logo quiz questions

by Aditya Joshi -
Number of replies: 24

Is there a way to add logo to quiz question? I can see that we can add image to any question content but that does not appear something like watermark (in background of question). 

Any way to add watermark/logo on quiz questions?


Regards,

Aditya Joshi

Average of ratings: Useful (1)
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Hello Aditya,

Something like this?

Formulas_20201211_2029.png


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $(".formulation").css("background-image", "url('https://qa.moodledemo.net/draftfile.php/26/user/draft/637730801/Moodle%20is%20the%20worlds%20best%20LMS.png')");
    });
</script>
    
Reference: https://www.w3schools.com/html/html_images_background.asp ↗
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -
Hi Dominique Bauer,

Exactly, this is what I am looking for. Instead of text, it might be image (like logo). But what you have shown is exactly what I was asking for.
I also want the same background image or text to continue during quiz review (post submission of the test). So, on questions and same should be there on review part.

Could you please let me know where to add the script you have provided. I have tried to add this in HTML block of a quiz but did not work.

Regards,
Aditya Joshi
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

The text I showed was actually an image (https:// your domain name /draftfile.php/... your image.png) which I uploaded to the "Private files". You can use any image you want.

Putting the code in the HTML code of a block is a good idea. Here's how to do it:
  • Turn editing on.
  • Click on the quiz name.
  • In Boost theme, display the main menu on the left side of the page and, at the bottom of the menu, select "Add a block".
  • You can select any type of block, but "HTML" is a good choice.
  • Configure the block:
    • Add the code to the HTML of the Content of the block.
    • Set "Display on page types" to "Any quiz module page". <-- Important
Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -

Hi Dominique,

Thanks for providing further steps. I tried to replicate them as it is but still not working for me. Not sure what is the issue.

Please see the attached image (added screen shots of two separate UI screen of Moodle- quiz and html block is the upper one and lower right side is showing file uploaded in private files). 

I have tried to show the html block, image url and where I have uploaded the logo file under Private files. 

  • Set "Display on page types" to "Any quiz module page". <-- Important
Yes did this exactly.

Is there any issue in the url formed for image. 

I also tried an image located on internet by giving its url-
https://curizent.com/wp-content/uploads/2020/12/HL7-Logo.png

In the URL you have shown, you have used - draftfile.php/
I tried with that also but not working-
'https://exams.curizent.com/draftfile.php/user/files.php/curizentlogo.png'

Please help!!

Regards,

Aditya Joshi

Attachment Quiz logo issue.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Hello Aditya,

It looks like the code is not in the HTML of the HTML block. To put the code in the HTML using the Atto editor, say, follow these steps:

  • Configure the block.
  • In the editor menu, if the </> button is not displayed, click the ↴ button.
  • Click the </> button to edit the HTML code.
  • Paste the code.
  • Click on the </> button to return to preview mode. The field should appear empty.
  • Save the changes.

Note that this procedure is not specific to the HTML block. The same goes for any text field in any activity, using the Atto editor.

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

Re: Add a logo quiz questions

by Aditya Joshi -

Thanks a Dominique. You caught it. I followed your steps and now able to show logo on quiz question.

Issue 1:

But it not coming as background image and covering whole question. Please see attached image.

Issue 2; Using image in private file

Also, I am still not able to figure out how to use the logo or image available in moodle private files. 

'https://qa.moodledemo.net/draftfile.php/26/user/draft/637730801/Moodle%20is%20the%20worlds%20best%20LMS.png')

I am not able to understand what is draftfile.php/,  26 and draft/637730801 ? 

I can see the url of my private file- https://exams.curizent.com/user/files.php

So, I tried-


or 

https://exams.curizent.com/draftfile.php/user/files.php/curizentlogo,png

Not sure what to use.

Thanks for all your help, I feel I am almost there. Please help to achieve this. 

Regards,

Aditya Joshi

Attachment Quiz logo issue1.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Aditya,

You can place the image anywhere you want. If you put it in the "body", you will get something like what is shown below.

<script>
    $(document).ready(function() {
        $("body").css("background-image", ...
To get the URL of an image from the Private files, simply insert the image using the "Insert or edit image" button in the Atto editor menu. Then you can copy the URL into the script.

You could also consider using a theme which you can customize to suit your needs. See for example https://moodle.org/plugins/browse.php?list=category&id=3 ↗



In reply to Dominique Bauer

Re: Add a logo quiz questions

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

To get pretty much the same result as in my previous post, if you are using the Boost theme you can also just add a background image in Site administration / Appearance / Themes / Boost / Background image.
In reply to Dominique Bauer

Re: Add a logo quiz questions

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

In fact, I didn't quite understand what exactly you want to achieve. Anyway, here's another suggestion:

...
$(document).ready(function() {
    $("body").css("background-image", "url('https://... png')");
    $("body").css("opacity", "0.75");
...

In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -
Hi Dominique,

Thanks for your responses. I am trying to replicate what you have done in your very first reply-

https://moodle.org/mod/forum/discuss.php?d=415277#p1673842

This is exactly I want. Image comes as background image but not disturbing reading of the question. The way you have shown is perfect, Image crossing the quiz questions only and opacity seems to be perfect.

I tried the same and posted the outcome here-
https://moodle.org/mod/forum/discuss.php?d=415277#p1674025

In this image is not really in background but it is on top of the quiz question and the image is covering whole quiz question. There are many times image is coming instead of just once. Does it cover whole quiz question area, any way to restrict it it just in center and really in background.
Like we add a background image in pdf, image comes once on center as background image.

The intent is that if somebody copies the question by taking picture, still logo image goes with that.

The body function you have shown is adding up image everywhere, that is not what I am trying.

Certainly trying what you have shown as your first reply but not able to achieve that.

Regards,
Aditya Joshi
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Hello Aditya,

If you look closely for example at "c. football" in you screenshot, you will see that the logo is indeed in the background.

Use a logo that is a little lighter than normal so that the question text remains readable when it covers the logo.

If you use the Boost theme, place the following CSS in Site administration / Appearance - Themes / Boost / Advanced settings - Raw SCSS:

.formulation {
    background-image: url('http... Private files...png');
    background-repeat: no-repeat;
    background-position:center center;
}

Formulas_20201215_0147.png

In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -

Hi Dominique,

Thanks again for your inputs. I am able to add file and get url for image. I followed your instruction- insert or edit image in HTML box and then actually I have uploaded the logo image there. Somehow, it was not able to see any file in Private Files folder. When I uploaded new file through insert method, it gave me url also.

latest code you have provided is the best thing, now I have only one image on each question.

I guess, I have to use much lighter image. Please see the screenshot attached. current image is covering question text, not sure if it is really going in background or maybe image is like that.

How your last post image is showing logo really in background?

I don't want to use body function as it is giving logo image everywhere on the page. 

Is there way to use opacity with .formulation. I actually tried also but it is then applied to whole question text-

.formulation {

    background-repeat: no-repeat;

    background-position:center center;

    opacity: 0.5;

}

This impacts whole question text and image, not just logo image. I have modified the opacity to 1.0 (for the example attached with this post).

This is my HTML block code in use-

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>

    $(document).ready(function() {

        $(".formulation").css("background-image", "url('https://exams.curizent.com/draftfile.php/5/user/draft/947842291/Curizent%20Logo%20file.png')");

    });

</script>

Any help please on making the image really in background or adding opacity with current code (using .formulation). I have tried opacity with body and it worked but as I said earlier using body function added logo images on entire page which is not desired.

Regards,

Aditya Joshi

Attachment Quiz logo issue2.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

If you want the logo to appear in all quizzes on your moodle site, you don't need the HTML blocks. Instead, place the CSS in Site administration... like I mentioned in my last post.

You can add the following line to the CSS so that the logo is always displayed in full: 
background-size: contain;
Use a light-colored (high brightness) image like the one attached below.

To get the image URL, follow these steps:
  1. Upload the image to your Private files.
  2. Insert the image in a label just to get the URL.
  3. Copy the address in the CSS.



Attachment High_Res5.png
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -

Hi Dominique,

Finally, I am able to achieve what I initially thought. 

See the attached screenshot. I am now using very light image. I don't want students taking quiz to distract due to background image but at the same time, it is ensuring if someone takes picture of question, at least my branding goes with that. 

Let me know your thoughts as how it is looking now. 

Question: font color and size for quiz question and options:

how I can change font of quiz question and answer options. Thinking to make them little black so that student will be able to see them more clearly and background image will not distract at all. 

Thanks for all your help, it would have impossible for me to get it done without your help.

Regards,

Aditya Joshi


Attachment Quiz logo issue resolved.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Hello Aditya,

If you want the characters to be darker not only in the quizzes but also throughout your site, you can redefine the color of the characters in Site administration / Appearance / Themes - Boost / Advanced settings / Raw SCSS. Just add the following code to get black characters (#000):

span,p,div,th,td,li {
    color: #000;
}
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -
This is great. Thanks a lot Dominique.

Regards,
Aditya Joshi
In reply to Aditya Joshi

Re: Add a logo quiz questions

by Aditya Joshi -

Hi Dominique,

I found a strange issue. the logo behind quiz appearing when I try the quiz as admin but when I tried with some student login, there is no logo image behind quiz questions. 

Please see the screen shot. 

Please help. I am not able to get that how come background image is gone for student login.

Regards,

Aditya Joshi

Attachment Quiz logo issue3.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Clear the browser cache and make sure it is the same quiz. Otherwise, I don't know what might be causing this problem.
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -

Hi Dominique,

I cleared the browser cache, tried on another browser as student but still not working. 

There is something missing for sure. I tried the whole process with one small quiz of 3 questions and strangely both admin and student login can see the background image. 

But with another quiz with 50 questions, only admin able to see the image. 

One thing I noticed with comparison to small quiz is that HTML block was visible to both admin and student attempt. But the same is not with the bigger quiz. 

Please see attached screenshot. I can see HTML block with script to have background image when admin attempting the quiz but the same is not visible when student attempt the quiz.

Regards,

Aditya Joshi


Attachment Quiz logo issue4.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

by Aditya Joshi -

adding screenshot of another small quiz. both admin and student attempt can see HTML block and background image

Regards,

Aditya Joshi

Attachment Quiz logo issue5.png
In reply to Aditya Joshi

Re: Add a logo quiz questions

by Aditya Joshi -
Hi Dominique,

Please help. I have tried with all my other quizzes, in fact created one simple quiz with one question only and added same HTML block with exact same code.
Except for one quiz for which I have shown images in my previous post, none other quizzes showing logo image in background.

One thing common in all the quizzes where student not able to see background image is that HTML block is also not visible. I have checked block permissions and student is part of it.

Regards,
Aditya Joshi
In reply to Aditya Joshi

Re: Add a logo quiz questions

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

Putting code in a block is only useful if you want only certain quizzes to have access to the code and not the others. Do you want the logo to appear in all your quizzes? If this is the case, it is easier to put the code in Site administration / Appearance - Themes / Boost / Advanced settings - Raw SCSS as I indicated to you earlier.
In reply to Dominique Bauer

Re: Add a logo quiz questions

by Aditya Joshi -
thanks a lot Dominique, this has resolved the issue.

By the way, I had added separate HTML block for all individual quizzes. But still, background image surprisingly was coming only for one quiz.

I have removed individual html blocks now and added the code in Site administration / Appearance - Themes / Boost / Advanced settings - Raw SCSS and it is working fine for all quizzes. I tested and with student login also, I can see background image.

Thank you so much for your help.

Regards,
Aditya Joshi