Quantcast
Channel: General developer forum
Viewing all 37665 articles
Browse latest View live

Re: How can I ensure output goes through active filters?

$
0
0

by Marcus Green.  

Thank for the feedback Tim. Am I right in thinking that base64 encoded images that you paste in would work without that code but a link to a Moodle file system image would not. The reason I ask is that the jiggery pokery I do to the content  of the question text (rather than the introduction text)  breaks links to moodle image files, but pasted in images work fine.

I realised my "a great advert for using an IDE" comment might be a bit obscure, I meant it made searching through the code easy to find that solution.


Re: What plugin type modifies every page?

$
0
0

by Richard Oelmann.  

Blocks and other plugins can have their own style.css file and if you prefix all of the styles with one id or class that wraps your entire content, then it would only be overridden by a theme if the theme designer specifically targets it.

The problem comes if you are trying to get your block/plugin to override theme css after the theme has been added, simply because that's not how the css inheritance works (core -> plugins -> themes).

It sounds like you might need a local plugin - and you may want to look at adminer. That has a kind of floating UI for database management and has its own self contained css, so may be a useful starting point.

Richard

Re: What plugin type modifies every page?

$
0
0

by David Mudrák.  

I meant that the block's get_content() method can return empty content so the block is not displayed at all. Even if it exists on the page. And it still has a chance to inject and execute the javascript via $this->page->requires which in turn can modify HTML etc. Such a block can be configured to appear across the whole site. As a result, you can embed your JS into almost every page in Moodle.

Re: What plugin type modifies every page?

$
0
0

by David Mudrák.  

See my other post where I describe how to use the block get_content() and simply use the block as a widget to execute your JS.

Re: What plugin type modifies every page?

$
0
0

by Miles Fletcher.  

Interesting!

Richard, how do you expect coding this as a block instead of a local plugin would affect the behaviour and usability?

 (I've written a block before, so the temptation to go with what I know is high! Local plugins look like they have a lot more files associated with them that I would have to learn how to create)

Re: What plugin type modifies every page?

$
0
0

by Richard Oelmann.  

Blocks need to be put on the page, or someone to add them as a 'sticky' block across the site.

Adding the functionality to a local plugin should remove that requirement as it would always be available in the same way as something like adminer. That said, it may be that you want this to float over the current page (adminer does open its own in the background) in which case maybe a block is better.

To be perfectly honest, where you have written blocks before, I have written quite a few themes, so I would have been tempted to build this functionality into a theme - but again, if your institution needs to use multiple themes, that may not be appropriate either smile

As far as I can tell, the need to add the block to the page(s) is the only way it would affect behaviour/usability that I can think of and that could be an advantage in terms of controlling where it appears (or doesn't). But the suggestion really came from having just been using adminer this morning and knowing that that has a kind of 'floating UI' and is installed as a local plugin smile


R

How to determine the type of resource when adding new activity

$
0
0

by John Lu.  

How do I determine if a resource is a .pdf or is it a .xlsl file? 

When adding a new activity as a resource, new entries will be added to '`mdl_resource' table regardless of the resource type. One of the columns in `mdl_resource` table called `display`. I believe this is the primary key of the table the determine the type of resource, however, I'm unable to locate that... any help would be appreciated. smile

Thanks.

Re: How can I ensure output goes through active filters?

$
0
0

by Tim Hunt.  

You are thinking right there, I think.


Displaying the feedback on all answers , not only in which they answered

$
0
0

by Paolo Moriero.  

Displaying the feedback on all answers , not only in which they answered

Re: Parameters in AJAX Call

$
0
0

by Damyon Wiese.  

You are free to do what you think makes sense it your own plugins.

Yes it is OK to call lib functions from externallib (in fact this is good separation and re-use). The extra things an external lib function needs to take care of are: validating parameters, calling external_format_text / external_format_string on strings that are returned, ensure permission checks are correct.

However - IMO an API function returning a HTML table is not a clear separating of logic and presentation. A better alternative would be to return the data for the table from the API function and render the table with a template.

https://docs.moodle.org/dev/Templates

This also means a themer can override the template to format the table differently for their theme (e.g. bootstrap has classes to make nice looking tables).


Create Custom filter on Report

$
0
0

by Shalini Vashist.  

Hi,

I am creating User report using Totara Report Builder API. In which I have to create on select type filter which will contain three values:

1. Any Values

2. Non- Confirmed Users only 

3. Confirmed Users


To achieve this I am writing following code in my Source file but Unfortunately it is not working sad

protected function 


 protected function define_filteroptions() {
    $filteroptions = array(
    new rb_filter_option(
    'user',
    'confirm',
    'User Confirm Status',//get_string('goalscopecolumn', 'rb_source_goal_status_history'),
    'select',
    array('selectfunc' => 'user_confirm_status',
    'attributes' => rb_filter_option::select_width_limiter(),
    )
    ));
    }
    
    
    function rb_filter_user_confirm_status() {
    //global $DB;
   
    //$return = 
        return array('0' => 'Confirmed users only', '1' =>'Non-confirmed users only');
    }


I am attaching the screenshot of the filter that I have to create. 

Please Help....

Thanks In Advance !



Re: Behat stuck after a failed install

$
0
0

by Jessica Gramp.  

Hi Davo,


I'm having the same issue. Where do I comment out is_test_site? I can't find this.


Thanks,


Jess

Re: Create Custom filter on Report

$
0
0

by Richard Oelmann.  

If you are using Totara then you probably need to be asking in their support forums as most Moodle forum members will not have access to that report builder.

Re: Behat stuck after a failed install

$
0
0

by Davo Smith.  

Usually your IDE can find functions very quickly (for example, in PHPStorm I hit Ctrl+Alt+Shift+N and type 'is_test_site' and it takes me to the definition, holding Ctrl and clicking on the name of the function takes me to everywhere it is used).

In this case, lib/behat/classes/util.php - function test_environment_problem(), approx line 214, comment out the 'This is not a behat test site!' error (but be very certain you are doing the right thing - this will allow you to drop a real site, if you call 'drop' on the wrong site).

Re: Behat stuck after a failed install

$
0
0

by Mark Johnson.  

I usually find the solution to this case (without messing with code) is to manually drop all the database tables with the behat prefix and delete the contents of the behat dataroot folder.  After that, the behat init.php script should work again.

(Perhaps util.php should have a --fix-broken option which does this).


Re: Behat stuck after a failed install

$
0
0

by Jessica Gramp.  

Thanks Mark. 

I think I managed to find the code I need to comment out in my version (Moodle 3.1).

Thanks Davo for pointing me in the right direction. I don't have the 'is_test_site()' function in my util.php, but I have commented out the following on line 110 and it's now dropping my behat tables for me when I run admin/tool/behat/cli/util.php --drop:

if ($status) {

    exit ($status);

}

Thanks both for getting back to me so quickly.

Re: How can I ensure output goes through active filters?

$
0
0

by Marcus Green.  

Since I added that code the multi language filter is working nicely but pluginfile style images are not (they never have done and I don't do any jiggery pokery mangling in the introduction area I should say) . At runtime it is generating code like

BLA BLA brokenfile.php#/5/user/draft/834031054/handsome.png" 

Instead of 

BLA BLA pluginfile.php/795/question/questiontext/742/1/23872/handsome.png

The image shows in the edit mode before saving and I am wondering what is the most likely cause.

In the call to 

 $output=$question->format_text($question->introduction, $question->questiontextformat, $qa, 'question', 'introduction', $question->id);

I have tried messing with some of the parameters and I am wondering if it is more likely to be in the way the image was saved into the files table.

 UPDATE: The source to brokenfile.php gives some clues...

 * Sometimes developer forgets to postprocess files when saving

 * submitted form data or forget to replace the file placeholders

 * with the current area information.

 *

 

mod_assign Grader overriding in a theme.

$
0
0

by Gareth J Barnard.  

Hello,

As the new Grader in M3.1 is lacking in navigation bar obscure course link I want to improve it by overriding grading_app.php in /mod/assign/classes/output - I've managed to have the template overridden in the theme, but for the life of me cannot get the autoloading to pick up and use my replacement 'grading_app' class:

namespace theme_essential\output;
use renderer_base;
class grading_app extends \mod_assign\output\grading_app {
    /**
     * Export this class data as a flat list for rendering in a template.
     *
     * @param renderer_base $output The current page renderer.
     * @return stdClass - Flat list of exported data.
     */
    public function export_for_template(renderer_base $output) {
error_log('Overridden');
        $export = parent::export_for_template($output);
        return $export;
    }
}

Which is in /theme/essential/classes/output/grading_app.php.  The 'error_log' statement is just there as proof that its being used before I spend time writing code.

I've already read:

And https://docs.moodle.org/dev/Templates#How_to_I_override_a_template_in_my_theme.3F says nothing about the 'data' side of the template overriding process.

Does anybody have any idea what I'm doing wrong please?

Thanks,

Gareth

Re: How can I ensure output goes through active filters?

$
0
0

by Tim Hunt.  

Well, it works for other question types. I think you need to pick another qtype, then play spot the difference with your code.

Re: mod_assign Grader overriding in a theme.

$
0
0

by Richard Oelmann.  

If its any help Gareth, the user profile renderer class that you helped me solve a while back ended up as

namespace theme_themename\output\core_user\myprofile;
use \core_user\output\myprofile\category;

defined('MOODLE_INTERNAL') || die();
class renderer extends \core_user\output\myprofile\renderer {

which sits in themename\classes\output\core_user\myprofile\renderer.php

I think from the reading you've done (and I did back then) there are several ways to accomplish this, but that is what worked for me

Richard

Viewing all 37665 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>