frumbert / wp2moodle--wordpress-

Wordpress to Moodle pass through authentication plugin (wordpress end)
27 stars 23 forks source link

Error 500 - Internal Server Error #24

Closed jmj5g closed 8 years ago

jmj5g commented 8 years ago

I've setup a test environment with Moodle 3.0.3 to WordPress 4.4.2 running Avada Child theme, to see if I can get WP to Moodle enrollment working. I got both plugins installed and can see the settings fine. (BTW, even through I renamed the zip files as you instruct, when they decompressed the uncompressed directory reverted to the old name, but I just renamed.) I created a GUID and put in the settings on both sides. I added in the URL to the moodle dev site in the settings: https://the3doors.org/moodledev/

I've created 3 demo courses on the moodle dev site, which have course IDs of 2, 3, 4. I have activated the WP2Moodle enrollment plugin for the site. BUT, when I go into the course settings, I cannot add that enrollment method to the course. It does not appear in the list of enrollment plugin options.

I will note that whenever I did the Moodle install for an unknown reason the CAS plugin didn't install automatically. I did manually install that after seeing the error on the plugins page, but the CAS enrollment plugin is not activated. Are other enrollment plugins needed to support the WP2Moodle enrollment method?

My PHP environment seems to have all that is needed: https://the3doors.org/phpinfo.php

I created a test page with a hyperlink to a demo course. Here's the code in the WP page: [wp2moodle course='2']Enroll in Demo Course 1[/wp2moodle]

I created a new user on the WP site, with "author" as the WP role and logged in. Then I viewed my test page with the hyperlink to enroll in the demo course. However I then get a Apache Error 500, which doesn't give much to go on.

I've double checked the GUI to make sure it matches. I've tried multiple course IDs. I've made sure the Moodle URL is correct. I've tried both settings for "Whether Moodle will update the profile fields in Moodle for existing users." All still results in Error 500.

What suggestions do you have? Your plugin seems to do exactly what I need, so I'd really like to get this operational?

BTW, is it recommended to only have the Manual Enrollments method active for a paid course? My general plan is to use WooCommerce as you document on your site, and collect funds using multiple currencies using WooCommerce currency selector extension. Any known incompatibilities with this approach?

Many thanks for your generous sharing of these plugins.

John

frumbert commented 8 years ago

It sounds, intially, like you're using the course numbers rather than the course identifiers. image

so you need to add a value to the IDNUMBER field of whatever type of container object you are enrolling to (cohort, course, or group). This is usually text, and is not the same thing has the course id that you see in the URL for a course.

image

The error should be appearing in your websites' error log. However, you can also go to Site Administration > Development > Debugging and tick "Display debug messages" and set the "Debug messages" dropdown to "Developer". This should then show you what the 500 actually means.

jmj5g commented 8 years ago

Tim,

Thanks for the tip. I was referencing the wrong course ID. But when I fixed that I’m still getting the same error. Here’s the apache log error:

[Mon Mar 14 18:29:26 2016] [error] [client 76.5.66.201] SoftException in Application.cpp:262: File "/home/the3do5/public_html/moodledev/auth/wp2moodle/login.php" is writeable by others, referer: https://the3doors.org/dev/wp-to-moodle-test/

Looks like a permissions error. What do you suggest?

thanks!

John Jackson

On Mar 14, 2016, at 5:42 PM, TIm St.Clair notifications@github.com wrote:

It sounds, intially, like you're using the course numbers rather than the course identifiers. https://cloud.githubusercontent.com/assets/592257/13760845/469bf842-ea89-11e5-879f-50916c25d4b2.png so you need to add a value to the IDNUMBER field of whatever type of container object you are enrolling to (cohort, course, or group). This is usually text, and is not the same thing has the course id that you see in the URL for a course.

https://cloud.githubusercontent.com/assets/592257/13760872/653a8d72-ea89-11e5-808b-d65f3353f4b6.png The error should be appearing in your websites' error log. However, you can also go to Site Administration > Development > Debugging and tick "Display debug messages" and set the "Debug messages" dropdown to "Developer". This should then show you what the 500 actually means.

— Reply to this email directly or view it on GitHub https://github.com/frumbert/wp2moodle--wordpress-/issues/24#issuecomment-196533571.

frumbert commented 8 years ago

This appears unrelated to the functionality of the plugin - it doesn't need permission to write anything. It may be that an error is occurring before the plugin can execute? Some installations (I think cpanel-based ones) have permission checking built into the web server and don't like to see permissions set in a particular way. I don't know what particular web server setup you have of what your particular skill level with it is, so I can only suggest some ideas.

Try setting permissions on the folder that contains the wp2moodle plugin so that it has owner read/write, group read, other read (remove any write permissions). Compare and match the permissions on the wp2moodle folder to another folder in the auth folder, then see if that helps.

/edit: seems to be an issue that comes up for other people, not neccesarily Moodle related. https://delboy1978uk.wordpress.com/2014/01/31/fixing-the-cpanel-softexception-writable-by-group/

jmj5g commented 8 years ago

Tim,

I had to tighten permissions on the folder so that only the owner could write, and that fixed it.

Thanks for your leads on fixing this. This issue is resolved.

BTW, is it recommended to only have the Manual Enrollments method active for a paid course? My plan is to use WooCommerce as you document on your site, and collect funds using multiple currencies using WooCommerce currency selector extension. Any known incompatibilities with this approach? My understanding is that I would not configure the course in moodle to have a PayPal enrollment cost, and the payment would be strictly handled in WooCommerce. Am I on the right track?

Any advice on how to avoid duplicating user accounts within Moodle, or is that managed automatically by checking email addresses when WP2Moodle sends the account information?

Thanks a million!

John

On Mar 14, 2016, at 6:46 PM, TIm St.Clair notifications@github.com wrote:

This appears unrelated to the functionality of the plugin - it doesn't need permission to write anything. It may be that an error is occurring before the plugin can execute? Some installations (I think cpanel-based ones) have permission checking built into the web server and don't like to see permissions set in a particular way. I don't know what particular web server setup you have of what your particular skill level with it is, so I can only suggest some ideas.

Try setting permissions on the folder that contains the wp2moodle plugin so that it has owner read/write, group read, other read (remove any write permissions). Compare and match the permissions on the wp2moodle folder to another folder in the auth folder, then see if that helps.

— Reply to this email directly or view it on GitHub https://github.com/frumbert/wp2moodle--wordpress-/issues/24#issuecomment-196553348.

frumbert commented 8 years ago

When a user is authenticated through Wordpress, it sends over the id of the user in the wordpress database and stores that in Moodle (but the Moodle user id and Wordpress user id aren't the same thing). If the user passed through a second time, it matches on that identifier and tries to update the user record in Moodle (in case the user has updated something in their Wordpress profile). So you would also normally use Moodle's permissions and capabilities to prevent users from changing their own profile fields within Moodle, and direct them to do that via Wordpress.

The typical usage scenario [that other users have] is they use WooCommerce or MarketPress inside Wordpress to handle the transaction stuff - payment for services/courses - and then configure moodle with manual enrolments for the course so that users can buy one course and get enrolled to that course via this plugin. You shouldn't need anything beyond the standard Moodle setup.

As far as enrolling into courses is concerned, if your sole source of users coming into courses is from this plugin, then just having the manual enrolments is fine. But there's no reason you can't have multiple types or sources for enrolment via multiple active enrolment methods for a course; most people I know use this plugin just have the one. Are you selling access forever, or for a particular access period (e.g. a year), or do you need to enrol users into multiple courses at the same time (e.g. selling bulk access)? These sorts of scenarios can be supported by using groups or cohorts as enrolment providers.

jmj5g commented 8 years ago

Tim,

I got the WooCommerce integration working. The only gotcha I have run across is the email receipt that WooCommerce sends to the customer, which I attach. The link for the WP2Moodle file opens a browser and then downloads the WP2Moodle file, rather than redirecting to moodle. Any ideas on ways to avoid that?

I also wonder if there is any way to revise the phrasing in WooCommerce's message so it doesn't sound like a download, and instead is a link.

Your The 3 Doors Dev order from March 15 2016 is complete download your files.pdf

Many thanks! John

frumbert commented 8 years ago

I don't really know WooCommerce that well. The way my plugin works is a hack really, since WooCommerce isn't designed for authenticated integration work (that is, it is meant to download a file only). I capture the download hook and process a file so that it redirects - but perhaps the download via email works differently.

there seems to be a settings page for Customer Completed Order Email, which may have the ability to customise the "Subject (downloadable)" and "Email Heading (downloadable)" settings - or turn off notifications. There may be more information in the woocommerce knowledgebase https://support.woothemes.com/hc/en-us/categories/200146917-WooCommerce