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

Re: local plugin lib.php page doesn't run on every page (3.1)

$
0
0

by Tim Hunt.  

Its a feature. (A performance improvement.)


Re: local plugin lib.php page doesn't run on every page (3.1)

$
0
0

by David North.  

Thanks Tim

How would you suggest I add javascript from a local plugin onto a page going forwards?

I can add it to the theme lib.php but that will be creating unecessary dependancies. Or is there no other option?

Re: local plugin lib.php page doesn't run on every page (3.1)

$
0
0

by Tim Hunt.  

At the OU, we tend to put something like this in our theme.

Would be nice to have a better solution.

What is this JavaScript anyway?

Actually doing it as a block can work. Set the block to appear on every page on the site. The block will then get called on every page. You can then add the JavaScript, and generate no output, so the block does not actually appear.

Re: local plugin lib.php page doesn't run on every page (3.1)

$
0
0

by David North.  

Thanks Tim

It's javascript to add like and thanks buttons to the forum and advanced forum pages. And all the code exists is in the local plugin so it's not ideal decoupling the code that injects the javascript onto the page by putting it in the theme.

I will search for another possible solution but will probably have to end up putting it in the theme if I can't figure anything else out.

Moodle permission setting has no effect

$
0
0

by Duro Mandinic.  

I configured REST webservice on Moodle 3.0.5 to use function `core_course_get_courses` which is supposed to return a response containing basic info about all available courses.

This is the URL I've been using:

    https://example.com/webservice/rest/server.php?wstoken=713898e3fcaf9ead2218eb7565993230&wsfunction=core_course_get_courses&moodlewsrestformat=json

And, this is what I get:

    {
      "exception": "required_capability_exception",
      "errorcode": "nopermissions",
      "message": "Sorry, but you do not currently have permissions to do that (View courses without participation)"
    }

The permission in question has been set from the start, that is:

    moodle/course:view



It does not have any effect. I even allowed everything, some few hundred permissions just to see if it would work, but still no effect.

I used another function with the same service, it does work!:

    core_enrol_get_enrolled_users

Another important fact is that the `core_course_get_courses` function works on a local, development machine with fresh installation of Moodle. The production environment has 50 additional plugins installed.
The debugging, "extra Moodle debug messages for developers" has been enabled but there are no errors shown.

What could be the cause for this?

P.S. Dev. machine is Ubuntu 14.04



Re: local plugin lib.php page doesn't run on every page (3.1)

$
0
0

by Tim Hunt.  

Then the block solution sounds idea. The way blocks work, you can say the block should only affect mod-forum-* pages (and whatever the advanced forum equivalent is).

Redirect function by POST

$
0
0

by Iban Cardona i Subiela.  

Hello,

Is there any method to call Moodle redirect function and create a POST redirect action? I'm using Moodle 2.6.

Best regards!

Re: File URL - Moodle 3.1

$
0
0

by Dave Emsley.  

Having implemented the file system in the way I thought it was meant to work I find it still doesn't.  The URL of the file is:

http://192.168.1.36/~testmoodle/pluginfile.php/2/block_enrolmentcompletion/block_enrolmentcompletion/1/Emsley-Dave03041985.pdf

Does that look about right?


I have the call-back function - which is called - but the file doesn't exist:

Sorry, the requested file could not be found

More information about this error

Debug info:
Error code: filenotfound
Stack trace:
  • line 495 of /lib/setuplib.php: moodle_exception thrown
  • line 1803 of /lib/filelib.php: call to print_error()
  • line 4567 of /lib/filelib.php: call to send_file_not_found()
  • line 37 of /pluginfile.php: call to file_pluginfile()
Output buffer: I'm here.  (NB I added this to function my block: block_enrolmentcompletion_pluginfile to see if it was called)
I do have full debugging on and the above is all I get.

I would appreciate any advice on this.

Cheers

Dave


Add a Login & a Self- Registration Modal Window

$
0
0

by Shashank Kouloorkar.  

Hello Moodle Forum,

                      I am currently setting up an eLearning Portal using the Moodle theme- “Klass”. I learn, that the theme uses the "Base" theme for most of the visual functionalities. However, I would like to make few modifications to the design. I would like to have a modal open up on the same page, as soon as the user clicks on the “Log in” link that is present on the top-right corner of the top-most nav-bar. Also, would like to have a modal window that opens up on the same page that requires user registration. Is this something that could be achievable? If so, how? Please assist.

Regards,

Shashank Kouloorkar

Re: Moodle permission setting has no effect

$
0
0

by Darko Miletić.  

Rest web services in moodle require admin users or tokens generated for admin user.

Re: Moodle permission setting has no effect

$
0
0

by Duro Mandinic.  

I created a token for Admin user and used it. Never would have thought of that.

However, I get "500 Internal Server Error" now.

I think the error happens because of a too large result set (assuming so, because of no access to apache or php logs).

Is there any way of paginating the result? I don't see there is, according to docs.

Darko, thank you

Re: Moodle permission setting has no effect

$
0
0

by Darko Miletić.  

There is no pagination. You either need to fix your setup of Moodle or write your own web service that will support pagination if you have huge amount of courses. However I doubt there should be more than few thousand courses on the site.


Moodle ignores try/catch

$
0
0

by Alex Black.  

I have the following PHP script, test.php in my Moodle plugin:

    <?php
    include('lib/httpful/httpful.phar');
   
        try{
            $response = \Httpful\Request::post($uri)                
                ->body($requestbody)            
                ->send();       
        }catch (Exception $e) {
            echo "Exception occurred";
        }
    ?>
Whenever an exception occurs the text "Exception Occurred" is displayed as expected.
Then I moved the code to a function in a class classes\http_client.php. Thus:

    class http_client{
      public function doPost($uri, $requestbody){
      
        try{
            $response = \Httpful\Request::post($uri)                
                ->body($requestbody)            
                ->send();       
        }catch (Exception $e) {
            echo "Exception occurred";
        }
      }
    }
Now I try to invoke from test.php:

    $client = new http_client();
    $client->doPost($uri, $requestbody);
The exceptions are no longer caught and the stack trace is displayed in the browser.

I have to mention that it only happens within Moodle. Outside Moodle the class http_client works fine, the catch block is executed.

My settings are: Moodle 3.0.1+ (Build: 20151223), PHP 5.5.12, Apache 2.4.9.

Thanks in advance

Help finding the right spot to modify

$
0
0

by M. Ferrell.  

Good afternoon all.
I am new to the platform and I am having some issues figuring out where is the best place to make the needed modifications.

For our school we need to limit the amount of classes that a user can self enroll to a specific number. We can use 5 for argument sake.


I have checked out the available authentication methods but there is not one that currently has this feature or I missed it.


I found one that was close and that was the enroll by profile fields plugin. It uses a custom userfield as its indicator so I figured I could use that as a bases for my first attempt at building a plugin.

Maybe I am just out of date but I cant make head nor tails of that way of doing a sql call. I also cant figure out how exactly this plugin actually gets called.



Any help in getting started would be most appreciated.


Re: File URL - Moodle 3.1

$
0
0

by Tim Hunt.  

block_enrolmentcompletion twice looks wrong to me.

Is the code of your block somewhere like github where we could see it?

Can you add some debugging to show what arguments are passed to your callback?


Re: Redirect function by POST

$
0
0

by Tim Hunt.  

The answer is No, not just in Moodle, but in the HTTP protocol which all web sites use.

The only work-around it to use javascript: Make the first HTTP request return the HTML of a form with hidden form fields for all the POST data, and some java-script to auto-submit the form onload.

Moodle PHPBB Integration

$
0
0

by Jason Leng.  

How do I integrate PHPBB with Moodle?


Thanks.

Re: Moodle ignores try/catch

$
0
0

by Alex Black.  

Greetings,

I found the solution on this Moodle forum. https://moodle.org/mod/forum/discuss.php?d=207445. Since the class http_client was within a namespace (a fact I have stupidly omitted)  I had to escape the Exception.

Thus:

}catch (\Exception $e) {
            echo "Exception occurred";
 }



Re: Moodle PHPBB Integration

$
0
0

by Olumuyiwa Taiwo.  

It may be helpfule if you're provide specifics of what the integration is supposed to achieve.

Changing Overview Graph

$
0
0

by Josh K..  

Hey Guys,

I am trying to change the Overview Graph so that it shows me all Courses of a single User on the X-Axis (Course1, Course2...) and the Points of each Course on the Y-Axis (1...100 Points).

I had no problem changing the X-Axis, but have no idea how to change the Y-Axis because there are parts of the code that i didn't find in graphlib.php and don't even now what they are doing...

I have to change the following code parts:


$line->y_format['allusers'] =array(
'colour'=>'red',
'bar'=>'fill',
'shadow_offset'=>1,
'legend'=> get_string('allparticipants')
);
$line->y_data['allusers'] = quiz_report_grade_bands($bandwidth, $bands, $quizid, $groupusers);

$line->y_order=array('allusers');

$ymax=max($line->y_data['allusers']);
$line->parameter['y_min_left'] =0;
$line->parameter['y_max_left'] =$ymax;
$line->parameter['y_decimal_left'] =0;

// Pick a sensible number of gridlines depending on max value on graph.
$gridlines=$ymax;
while ($gridlines>=10) {
if ($gridlines>=50) {
$gridlines/=5;
} else {
$gridlines/=2;
}
}


When I change the slightest here, the graph image isn't showing anymore..

I think it has to do with ['allusers'].

Can someone explain to me what I have to do with y_data to change the Y-Axis?


What I did was simply like I have done in the X-Axis before:

X-Axis

        for ($i=0; $i<=($SESSION['coursecount'] -1); $i++) {

            $bandlabels[] = $_SESSION['coursename'][$i];

        }

        $line->x_data = $bandlabels;


Y-Axis

      $bandlabels_y = array ();

        for($j=0; $j<=100; $j+=10) {

            bandlabels_y [] = $j;    //to show the points like: "0, 10, 20, 30,...,100"

        }

in the moodle overviewgraph this line looks like that:

        $line->y_data['allusers'] = quiz_report_grade_bands($bandwidth, $bands,    $quizid, $groupusers);


I just have no idea what to do with ['allusers'] ???

Could need some help heresad

Viewing all 37669 articles
Browse latest View live


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