Quantcast
Channel: Web services
Viewing all 2361 articles
Browse latest View live

Re: Myddleware and Magento

$
0
0

by Stéphane Faure.  

Hi Eric,

Thanks for using Myddleware.

Unfortunately the error returned by Moodle hasn't much detail. So could you try to create the user manually with the same data that you have in your transfer. Moodle should give you an error too with more detail, for example, the password is too short, or username has space, a user is alreday existing with the same email address...
When you have the error, you could change your data transfer and your rule.

The good news is, if Moodle returns this error, it means that your connection is working. It is better to get an erro than nothng ;).

Could you tell us if your problem is solved ? Thanks.

If you still have the error, could you show us the detail of a data transfert (but don't share client real data). Then we will test these data in our Moodle. Thanks

Best regards,
Stéphane



Re: Myddleware and Magento

$
0
0

by Eric Messick.  

Hi. That error was actually from Myddleware. I deleted my rule and made a very simple one. 

When I make the rule, it shows that both connectors connect (light bulb lights up).

I only have only one test customer in my Magento.

In the rule, modules are Magento customers to Moodle users. I then mapped email, firstname, lastname from Magento to Moodle. The simulation works. I set synchronisation type to "create data only" and confirmed the rule.

I then run it and check the transfer and it says "no transfer found." When I check the tasks it has an entry. Status is "end" and Open, Closed, Cancelled, and Error are all "0." Start and end date are the same.

Are there specific error logs that I should look at?

Thanks for your help.





Re: Myddleware and Magento

$
0
0

by Stéphane Faure.  

Hi Eric,

For information, Myddleware tried to create the user into Moodle, and the error displayed was just the message returned by Moodle.

So you tried to create a simple rule but Myddleware can't read any data. I guess it is just because of you reference date in your rule. This date is probably later than the creation date of your client in Magento. You can have more information about this reference date here : http://community.myddleware.com/index.php/tutorial/#parameters

If you change this date to a date before the creation of a customer in Magento, Myddleware will read it.

Then, if your data transfer is stopped to "error_sending" status again. Maybe you will have to change your rule again. But this time, don't delete it, here what you can do : 1) cancel your data  transfert, 2) change your rule, 3) change the rule reference date and 4) run the rule again.

About your rule, you will maybe need to set a password, it depends on your settings in Moodle. You can find in attachment a picture of a rule we have set up between Prestashop and Moodle.

Hope it will help.

Stéphane


Re: Myddleware and Magento

$
0
0

by Eric Messick.  

OK changing the date parameter has made a difference, but still not transferring data.

In the transfers list I'm getting two rows with "Error_sendingX" and type "C." It looks like each row is for a customer...which makes sense because I have 2 customers in Magento. I noticed the date/time in Myddleware is 13 hours behind my server time (NZ). I did set timezone in both php.ini files in etc/php/7.0:

 

Here is what one of the transfers looks like:



Tasks list has 2 rows, one for the manual running of the rule and one for the auto sync.  So it looks like when I change the date to 2010 and run it manually it is trying to send data...and that when the auto sync runs it it is not trying because the data parameter changes back to today:



Apache error log...one of my customers in Magento has no middle name so looks like that is reason for PHP notice:

[Wed Feb 14 12:00:39.054910 2018] [:error] [pid 5814] [client MYHOMEIPADDRESS:6412] PHP Warning:  Invalid argument supplied for foreach() in /var/www/myddleware/src/Myddleware/RegleBundle/Solutions/magento.php on line 268, referer: https://www.MYWEBSITE.COM/myddleware/rule/view/5a82462ba606d

[Wed Feb 14 12:00:39.460000 2018] [:error] [pid 5814] [client MYHOMEIPADDRESS:6412] PHP Warning:  Invalid argument supplied for foreach() in /var/www/myddleware/src/Myddleware/RegleBundle/Solutions/magento.php on line 268, referer: https://www. MYWEBSITE.COM/myddleware/rule/view/5a82462ba606d

[Wed Feb 14 12:02:02.267397 2018] [:error] [pid 5964] [client MYHOMEIPADDRESS:6411] PHP Notice:  Undefined index: middlename in /var/www/myddleware/src/Myddleware/RegleBundle/Classes/document.php on line 1239, referer: https://www. MYWEBSITE.COM/myddleware/rule/create/step3/5a82462ba606d

 PHP Notice:  Undefined index: middlename in /var/www/myddleware/src/Myddleware/RegleBundle/Classes/document.php on line 1021

Thanks for your help.

Re: Myddleware and Magento

$
0
0

by Eric Messick.  

I ran the rule later and had a look at the Apache access log right after:

MYSERVERIPADDRESS- - [14/Feb/2018:13:13:07 +1300] "POST /webservice/rest/server.php?wstoken=36effd29c7b6a56e743b9b7e77ca827a&wsfunction=core_webservice_get_site_info HTTP/1.1" 200 4266 "-""MoodleBot/1.0"

MYSERVERIPADDRESS- - [14/Feb/2018:13:13:07 +1300] "POST /webservice/rest/server.php?wstoken=36effd29c7b6a56e743b9b7e77ca827a&wsfunction=core_webservice_get_site_info HTTP/1.1" 200 4266 "-""MoodleBot/1.0"

MYSERVERIPADDRESS- - [14/Feb/2018:13:13:07 +1300] "POST /webservice/rest/server.php?wstoken=36effd29c7b6a56e743b9b7e77ca827a&wsfunction=core_user_create_users HTTP/1.1" 200 3747 "-""MoodleBot/1.0"

MYSERVERIPADDRESS- - [14/Feb/2018:13:13:07 +1300] "POST /webservice/rest/server.php?wstoken=36effd29c7b6a56e743b9b7e77ca827a&wsfunction=core_user_create_users HTTP/1.1" 200 3747 "-""MoodleBot/1.0"

MYSERVERIPADDRESS - - [14/Feb/2018:13:13:06 +1300] "GET /myddleware/rule/exec/5a82462ba606d HTTP/1.1" 302 4002 "https://www.MYWEBSITE.COM/myddleware/rule/view/5a82462ba606d""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36"

MYSERVERIPADDRESS - - [14/Feb/2018:13:13:07 +1300] "GET /myddleware/rule/view/5a82462ba606d HTTP/1.1" 200 5149 "https://www.MYWEBSITE.COM/myddleware/rule/view/5a82462ba606d""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36"

MYSERVERIPADDRESS - - [14/Feb/2018:13:13:08 +1300] "GET /myddleware/js/routing?callback=fos.Router.setData HTTP/1.1" 200 649"https://www.MYWEBSITE.COM/myddleware/rule/view/5a82462ba606d""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36"


Re: Myddleware and Magento

$
0
0

by Eric Messick.  

Hi, I have had some success!  I needed to make sure that Myddleware was sending all of the required fields to Moodle in order to create a user: username, firstname, lastname, password. I didn't have all of these in the rule so it did not work.

I was able to create a user. I changed the rule to update data and this worked too.

I came across a new problem...I deleted the user in Moodle, re-ran the rule (with date set to 2010), and it did not re-create the user. When I look in "transfers" in Myddleware, the status for the customer is "send" and type is "U"...I think that means "update." So Myddleware thinks it is updating, but moodle user list doesn't change.

If I create a new customer with the same info, in Magento, it works.

I tried going into the moodle database and deleting the users but that didn't have any effect (as described here https://stackoverflow.com/questions/33547376/moodle-clean-up-database).

Re: Myddleware and Magento

$
0
0

by Stéphane Faure.  

Hi Eric,

Good news about the user creation ;).

When you put a reference date in the past, or update a customer in Magento, Myddleware will read again the customer in Magento. Then Myddleware will check if this customer has already been sent to Moodle via the current rule.

 - If no, Myddleware will create the user in Moodle.

 - If yes, Myddleware will try to update the user in Moodle except if the rule's mode is "create_only". In this case, Myddleware will cancel the data transfer. But if the rule allows the data modification, Myddleware will find the Moodle user ID by searching with the Magento customer ID in a previous data transfer in the current rule. Then Myddleware will update the user in Moodle with the user ID found in Myddleware.

In your case, you have deleted the user in Moodle but Myddleware still have the user ID and try to update it even if it is deleted. Moodle doesn't seem to return an error when we try to update a deleted user. This is weird.

So if you delete a user in Moodle, you have 2 methods to handle it :

 - First method : delete the customer in Magento too, you will be sur that it won't be read again by Myddleware

 - Second method : you have to cancel every data transfert in you rule with the Moodle user ID. It isn't possible to cancel a data transfer already sent in Myddleware UI yet. We think about allow it for super ADMIN user. But for now, you have to update directly the database.

Here is a query for that : UPDATE `Document` SET status = 'Cancel', global_status = 'Cancel' WHERE `rule_id` = '<your_rule_id>' AND `target_id`  = '<Moodle_user_id>'

Then when you will update the customer in Magento or put the reference date in the past, Myddleware will try to create the user in Moodle.

Please let me know if it solves your problem. Thanks.

Stéphane


Re: Myddleware and Magento

$
0
0

by Eric Messick.  

Cheers for your help Stéphane. I had to remove the quotation marks from the query and it worked.

The only other small problem I have is that Myddleware's date/time seems to be set to Europe/France timezone. In Myddleware "Europe/France" seems to be default.

I set my timezone in both php.ini files (in cli and apache2 directories) as it says in your installation instructions. I checked phpinfo and my default timezone is working. 

Thanks heaps.

Eric


Re: Myddleware and Magento

$
0
0

by Stéphane Faure.  

Great Eric,

Sorry, I forgot to answer you about the date/time. We store the date/time at GMT in the Myddleware's database. But you are right, we should display it according to the php settings.

I have created an issue in our github : https://github.com/Myddleware/myddleware/issues/78

It will be fixed in the next release. Thanks for your feedback.

Don't hesitate to create other issues if you see other things which have to be improved.

Re: Myddleware and Magento

$
0
0

by Eric Messick.  

OK, thank you for all of your help.

core_course_duplicate_course: error/setting_locked_by_permission problem

$
0
0

by Anis Jradah.  

Dear All, Kindly, I am getting the error below while trying to duplicate a course using core_course_duplicate_course function:
<?xml version="1.0" encoding="UTF-8" ?><EXCEPTION class="base_setting_exception"><ERRORCODE>setting_locked_by_permission</ERRORCODE><MESSAGE>error/setting_locked_by_permission</MESSAGE></EXCEPTION>


my code:

$functionname = 'core_course_duplicate_course';

$restformat = 'xml';


$params = array(

  'courseid' => 2,

  'fullname' => 'duplicated Introduction to Moodle', // New course full name

  'shortname' => 'dup Introduction to Moodle', // New course shortname

  'categoryid' => 1, // New course category id

  'visible' => 1, // Make the course visible after duplicating

  'options' => array( array('name'=>'activities', 'value'=>1)

                    ) // Backup options

);

/// REST CALL

header('Content-Type: text/plain');

$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;

$curl = new curl;

//if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2

$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';

$resp = $curl->post($serverurl . $restformat, $params);

print_r($resp);

Moodle version: 3.3.4

Thank you for all your help.

Best regards,

Anis


Re: Myddleware and Magento

$
0
0

by Eric Messick.  

Hi Stéphane. I had a good look at your tutorials and your test site for Prestashop and Suite CRM but am stuck. I'm wanting customers to gain access to my Moodle courses when they buy courses through Magento. Here is where I am struggling:


  1. When trying to make rules I am getting confused with where the field names come from for source and target. Are these from the databases? Is there somewhere I can look to easily see how these field names relate to the data that I can see in Moodle/Magento?
  2. For "relationships," in my source column (for magento) drop-down menus there are two options: "ID orders" and "Customer ID.""Customer ID" is listed as a possible field for the rule, but "ID orders" is not. Where are these field names from..or is this a bug?
  3. Some field names in the target have stars next to them (E.g., email, firstname, lastname, username in Moodle), is that because these are required fields?
  4. When I click on "create formula" when making a rule, and then click on the target drop-down menu, I have only one field (auth) and its data options for Moodle as a target...seems like the drop-down should have all fields...is that a bug?
  5. I don't understand how "relationships" work. I think this is what I need to do to link orders with customers like in your test server. Seems like I need some unique identifier for items purchases...probably the SKU. So thinking that Myddleware would use a rule to detect a new order and pass the customer and SKU to the right fields in moodle so that the customer gets enrolled in the course identified by the SKU.
  6. If you have any Moodle/Magento working examples of rules then that would be helpful. The screenshot of the rule you sent me earlier was really helpful in making formulae (thanks).

Best,

Eric


Re: core_course_duplicate_course: error/setting_locked_by_permission problem

$
0
0

by Anis Jradah.  

Dear All,

I was able to run my code, I just removed the backup options part in $params and a course was duplicated.


Best regards,

Anis



core_user_get_users on custom fields

$
0
0

by Zadok Lindt.  

I am aware we can do this:

https://example.com/moodle/webservice/rest/server.php?wstoken=secret&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=email&criteria[0][value]=person@example.com

I can't seem to work out how to do this for custom fields, i.e. If you have another field "secondary_email", this doesnt appear to work for me:

https://example.com/moodle/webservice/rest/server.php?wstoken=secret&wsfunction=core_user_get_users&moodlewsrestformat=json&criteria[0][key]=secondary_email&criteria[0][value]=person@example.com

I realise there might be some trick to make a "customfields" array, my googling has come across some vaguely related PHP code, but we are not using PHP (thus I am attempting to work out how to build the URL without php.

Thanks!

Re: Returning multidimensional arrays in web services

$
0
0

by Mike Wilson.  

For any-one who's stuck at the same point as I was here's the working version. You can map a multidimensional array from the main function to the returns function. The structure in the return is a single structure with a multi structure which contains another single structure.

Hope this saves someone else a headache.

    foreach($feedbacks as $feedback){

        $feedbackId = $feedback->id; 
        $academicyear = academicyear($feedback->timecreated); 
        $rawcomment = strip_tags($feedback->commenttext);
        $marker = $feedback->firstname.' '.$feedback->lastname;
        $feedbackdate = date('d.m.Y',$feedback->timemodified);
        $unitname = $feedback->fullname; 
        $assignmentname = $feedback->name; 

        $feeds[$feedbackId] = array(
                    'feedbackId' => $feedbackId,
                    'academicyear' => $academicyear,
                    'unitname' => $unitname,
                    'assignmentname' => $assignmentname,
                    'feedbackcomment' => $rawcomment,
                    'markername' => $marker,
                    'feedbackdate' => $feedbackdate
                    );
    }

    $portal = array(
        'source' => 'Moodle',
        'username' => $user->username,
        'firstname' => $user->firstname,
        'lastname' => $user->lastname,
        'email' => $user->email,
        'feedback' => $feeds
    );

    return $portal;       

}

public static function personal_tutor_portal_returns() {
    return new external_single_structure(
            array(
                'source' => new external_value(PARAM_TEXT, 'where data came from - moodle'),
                'username' => new external_value(PARAM_TEXT, 'username of student'),
                'firstname' => new external_value(PARAM_TEXT, 'first name of student'),
                'lastname' => new external_value(PARAM_TEXT, 'last name of student'),
                'email' => new external_value(PARAM_TEXT, 'email of student'),
                'feedback' => new external_multiple_structure(
                    new external_single_structure(
                        array(
                        'feedbackId' => new external_value(PARAM_INT,'assign_grade id'),
                        'academicyear'  => new external_value(PARAM_TEXT, 'academic year of feedback comment', VALUE_OPTIONAL),
                        'unitname'  => new external_value(PARAM_TEXT, 'unit of study for feedback comment', VALUE_OPTIONAL),
                        'assignmentname'  => new external_value(PARAM_TEXT, 'assignment name for feedback comment', VALUE_OPTIONAL),
                        'feedbackcomment'  => new external_value(PARAM_TEXT, 'feedback comment with html tags stripped out', VALUE_OPTIONAL),
                        'markername'  => new external_value(PARAM_TEXT, 'name of lecturer who marked assignment', VALUE_OPTIONAL),
                        'feedbackdate'  => new external_value(PARAM_TEXT, 'date assignment was last marked', VALUE_OPTIONAL)
                        )
                    )                
                )
            )
        );
}

Re: Myddleware and Magento

$
0
0

by Stéphane Faure.  

Hi Eric,

Sorry for the delay of our answer.

1. We usually use an API function to get the available fields and modules. However, these kind of function doesn’t exist for Moodle so we have added manually the fields and module into Moodle connector. About Magento, we have to improve the connector to use the metadata endpoints like  /V1/attributeMetadata/customer

2.The ID orders field is the id of the current module (order here). It should be available in the list field. We will have a look when we will improve the connector.

3.This stars are just an indication in Myddleware to show which field should be required in the target application. However, for some reasons we don't force you to fill them in Myddleware.

4.There are only the values for picklist field in the dropdown. But for Moodle and Magento, we have added them manually. We will improve this for Magento when we will work on the Magento connector.

5.About relationship, you can read this tutorial, we talk about relationship in the chapters 3.2.3 and 6.1) : http://community.myddleware.com/index.php/tutorial/

6.Unfortunately we have only example between Moodle and Prestashop with a Myddleware template. This template create few rules in Myddleware to send Prestashop Client to Moodle user and to enrol them to Moodle courses depending of which product they bought.

The problem is that Magento connector isn’t complete like Prestashop connector is. There is some development to make to be able to do the same thing with Magento.We plan to improve the Magento connector in a few weeks.

But if you want it quickly, and if you are or you know a developer we can guide you to improve Magento connector in Myddleware. Then you could share your code in our github. If you aren’t developer and if you want we work on it, no problem, just contact us via our contact page : http://www.myddleware.com/contact-us Then we will talk privately.

Have a nice day,

Stéphane

Re: Grade point update using core_grades_update_grades function?

$
0
0

by Julian David.  

Missing parameter `source`: 

http://localhost/webservice/rest/server.php?wstoken=668e1da48055ba6e02f8f12&wsfunction=core_grades_update_grades&courseid=2

&component=Col2&itemnumber=4&userid=1&finalgrade=100.0&feedback=well&source=XYZ

Re: Myddleware and Magento

$
0
0

by Eric Messick.  

OK, that all makes sense thank you.


Get user token in SSO environment

$
0
0

by JF Bélisle.  

HI,

I see a lot of post of people asking to use Web Services with an SSO auth plugin, but... no answers... 

In order to use a web service, we need to provide a token which can be obtain when providing username and password:

moodle/login/token.php?username=USERNAME&password=PASSWORD&service=SERVICE

Since there is no password in moodle database when using SSO, how can we get a token ??


We upgraded to moodle 3.4 to have the mobile moodle additionnal features, which is fine, I can define like typeoflogin to present an "in app" webview with the predefined login url.

How to intergrate all of that in an external native application that's needs fetching user authenticated data ?


Thank you 




Re: Get user token in SSO environment

$
0
0

by Eric Breton.  

This questions is verty pertinent to us, if someone could add their input, or links to possible solutions, it would be appreciated !

Viewing all 2361 articles
Browse latest View live


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