Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placing an image in the HTML block #2

Open
gemguardian opened this issue Feb 24, 2017 · 7 comments · May be fixed by #7
Open

Placing an image in the HTML block #2

gemguardian opened this issue Feb 24, 2017 · 7 comments · May be fixed by #7

Comments

@gemguardian
Copy link

Hello Valery,

I am not sure if it's not possible or if it's a bug.
I am using Moodle 2.9 on this.

We placed an image in the HTML block, and we do see it in the editing mode. But when we save the changes the image doesn't appear on the course page.

Is this a bug? Or is this something that is part of the functionality of the block.

Thank you very much.
Gemma

@vfremaux
Copy link
Owner

vfremaux commented Feb 24, 2017 via email

@gemguardian
Copy link
Author

Thank you for your responds, I will do a check and give you feedback as soon as possible.

@gemguardian
Copy link
Author

Hi Valery,

We tried it with branch 2.9 but the technical department reported these issues back to me:

  1. The version branch on github had a lower version number then the one on Moodle.org (?)
  2. When placing the block in a course it actually “crashed” the course with :
    Error in programmingcode. Get _context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.

Since I have no local 2.9 moodle I couldn’t test it myself, so this is the information I can give.
Any thoughts? Feedback?

And while mailing you now, do you have any plans to upgrade the block for Moodle 3.2?

@1JackBlack1
Copy link

1JackBlack1 commented Oct 30, 2020

I know this issue is old, but in the current version (of both the rolespecific html block and Moodle) files do not work.

There are 3 issues that I can see.
1 - In 65eb98e
in the command to move embedded files, 'block_rolespecifichtml' was changed into 'block_rolespecificthtml' with an extra t between specific and html.
This occurs on line 119 and 133 of block_rolespecifichtml.php
This appears to prevent moving the draft file to a permanent file (and even if the file was moved, it wouldn't match the URL that is produced in get_content.

2 - On line 63 of lib.php, you have:
session_get_instance()->write_close();
This has been depreciated since Moodle 2.6
Instead it should be:
\core\session\manager::write_close();

3 - Currently all files are placed in /content.
This means all roles share the same file area. This has 2 related issues.
3a - Only the files saved in the last role listed will actually be saved. Any files added to prior file areas, not also in the third one are lost.
3b - There is no requirement for someone to have a particular role to access a file, so a file present only meant to be available to teachers is technically accessible by everyone, including students.

To fix 3a, it would require changing edit_form.php and block_rolespecifichtml.php to change the file area to something more unique, such as content_all and content_roleid. Then also changing the block_rolespecifichtml_pluginfile to allow more files, either by checking for all possible fileareas, or just checking the first part of the string.

To fix 3b, as well as the change for 3a, it also requires adding a check for the role into the above function.

I have submitted a pull request to fix all bar 3b.
#7

@kiratskitizing
Copy link

Good day. This issue is still happening in latest version from master branch.

Environment
Moodle - 3.9.3+ (Build: 20201127)
block_rolespecifichtml - 2016083100 (latest available from Plugin Developer Master branch at https://github.com/vfremaux/moodle-block_rolespecifichtml)

Steps:

  1. Create a course and turn editing on.
  2. Add an HTML (per role) block.
  3. Configure the HTML (per role) block.
  4. In the Block content for all roles, type a message/text and embed an image file.
  5. Just to include in here the actual HTML generated for typing the message/text and embedding the image for reference.
<p dir="ltr" style="text-align: left;">Testing embed image.</p>
<p dir="ltr" style="text-align: left;"><img src="http://[moodle_url]/draftfile.php/5/user/draft/429109665/Screenshot_20200707_104941.png" alt="" role="presentation" class="img-responsive atto_image_button_text-bottom" width="610" height="503"><br></p>
<p dir="ltr" style="text-align: left;">The image should be above this text.<br></p>
  1. Click the "Save changes" button. The page will redirect to the Course contents page.

Result: You will see that the text is displayed, but the image is not. See screenshot attached.
Screenshot_20201203_095456

@1JackBlack1
Copy link

Good day. This issue is still happening in latest version from master branch.

Yes, the pull request I submitted to solve this issue has not yet been accepted.

You can try using my master branch which fixes this and has a few other issues fixed, or you can use my branch specifically for this fix:
https://github.com/1JackBlack1/moodle-block_rolespecifichtml/tree/FixFiles

Note that the branch to just fix uploading of files doesn't check if people can access the section of the block the file is in to be able to access the file. So if someone knows the URL to a file, and has access to the block, they can access any file in the block.

My master version includes that checking as well as some other functionality to make blocks work in other locations.

@kiratskitizing
Copy link

Good day. This issue is still happening in latest version from master branch.

Yes, the pull request I submitted to solve this issue has not yet been accepted.

You can try using my master branch which fixes this and has a few other issues fixed, or you can use my branch specifically for this fix:
https://github.com/1JackBlack1/moodle-block_rolespecifichtml/tree/FixFiles

Note that the branch to just fix uploading of files doesn't check if people can access the section of the block the file is in to be able to access the file. So if someone knows the URL to a file, and has access to the block, they can access any file in the block.

My master version includes that checking as well as some other functionality to make blocks work in other locations.

Thanks. We will have a look and review. Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants