Tämä osio sisältää esimerkkejä CSV- ja XML-tiedostoista, joilla voit ladata tietoja. Jos olet Moodlea verkkopalveluiden avulla päivittävä ylläpitäjä, tästä osiosta näet myös esimerkkejä Get- ja Handle-komennoista sekä PHP- ja ASP.net-verkkopalveluiden koodista.


CSV-tiedostomuodot

Conduit-taulukoiden tietueita voidaan viedä CSV- tai Excel-muodossa. Vietävät tiedot ovat suodatinasetusten mukaisia. Jos haluat viedä taulukon tiedot, napsauta avattavaa Vie-valikkoa ja valitse haluamasi tiedostomuoto. Näyttöön avautuu selainasetustesi mukainen tallennuksen valintaikkuna.

  • Kurssi: luo, päivitä ja poista kursseja.
  • Käyttäjä: luo, päivitä ja poista käyttäjiä.
  • Kurssille rekisteröityminen: luo, päivitä ja poista rekisteröitymisiä.
  • Vanhemman määrittäminen käyttäjälle: luo, päivitä ja poista roolimäärityksiä.
  • Ryhmät: luo, päivitä ja poista ryhmiä.
  • Ryhmän jäsenet: luo, päivitä ja poista ryhmän jäseniä.

XML-tiedostomuodot

Kurssi: luo, päivitä ja poista kursseja.

<?xml version="1.0" encoding="UTF-8"?><data><datum action="create">
<mapping name="shortname">BUS_101</mapping>
<mapping name="category">Business_Administration</mapping>
<mapping name="fullname">Introduction to Business</mapping>
<mapping name="idnumber">40056</mapping>
<mapping name="format">Topic</mapping>
<mapping name="template">BUS_Template</mapping>
<mapping name="visibility">Yes</mapping>
<mapping name="startdate">integer</mapping>
</datum>
<datum action="update">
<mapping name="shortname">BIO_101</mapping>
<mapping name="fullname">Introduction to Biology</mapping>
</datum>
<datum action="delete">
<mapping name="shortname">ENGL_101</mapping>
</datum></data>

Käyttäjä: luo, päivitä ja poista käyttäjiä.

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="username">joesmith</mapping>
<mapping name="firstname">Joe</mapping>
<mapping name="lastname">Smith</mapping>
<mapping name="email">[email protected]</mapping>
<mapping name="password">changeme</mapping>
</datum>
<datum action="update">
<mapping name="username">tom</mapping>
<mapping name="firstname">Tommy</mapping>
</datum>
<datum action="delete">
<mapping name="username">bob</mapping>
</datum></data>

Kurssille rekisteröityminen: luo, päivitä ja poista rekisteröitymisiä.

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="course">conduitcourse0</mapping>
<mapping name="user">user0</mapping>
<mapping name="role">student</mapping>
<mapping name="status">1</mapping>
</datum>
<datum action="update">
<mapping name="course">conduitcourse0</mapping>
<mapping name="user">user0</mapping>
<mapping name="role">student</mapping>
<mapping name="status">0</mapping>
</datum>
<datum action="delete">
<mapping name="course">conduitcourse0</mapping>
<mapping name="user">user0</mapping>
</datum></data>

Vanhemman määrittäminen käyttäjälle: luo, päivitä ja poista rekisteröitymisiä.

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="context">user</mapping>
<mapping name="moodlekey">user0</mapping>
<mapping name="user">parent0</mapping>
<mapping name="role">editingteacher</mapping>
</datum></data><?xml version="1.0" encoding="UTF-8"?><data>
<datum action="update">
<mapping name="context">user</mapping>
<mapping name="moodlekey">user0</mapping>
<mapping name="user">parent0</mapping>
<mapping name="role">editingteacher</mapping>
</datum></data><?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<<mapping name="context">user</mapping>
<mapping name="moodlekey">user0</mapping>
<mapping name="user">parent0</mapping>
<mapping name="role">editingteacher</mapping>
</datum></data>

Ryhmät: luo, päivitä ja poista ryhmiä.

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="course">testcourse</mapping>
<mapping name="group">testgroup</mapping>
<mapping name="description">This is a test Conduit group</mapping>
</datum>
<datum action="update">
<mapping name="course">testcourse</mapping>
<mapping name="group">testgroup</mapping>
<mapping name="newgroup">testgroup2</mapping>
<mapping name="description">This is a test Conduit group update</mapping>
</datum>
<datum action="delete">
<mapping name="course">testcourse</mapping>
<mapping name="group">testgroup</mapping>
</datum></data>

Ryhmän jäsenet: luo, päivitä ja poista ryhmän jäseniä.

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="course">testcourse</mapping>
<mapping name="user">testuser</mapping>
<mapping name="group">testgroup</mapping>
</datum>
<datum action="update">
<mapping name="course">testcourse</mapping>
<mapping name="user">testuser</mapping>
<mapping name="group">testgroup</mapping>
</datum>
<datum action="delete">
<mapping name="course">testcourse</mapping>
<mapping name="user">testuser</mapping>
<mapping name="group">testgroup</mapping>
</datum></data>


Conduit-verkkopalvelut

Conduit RESTful -verkkopalvelu on jaettu eri verkkopalvelupäätepisteisiin:

  1. kurssi
  2. enroll
  3. ryhmät
  4. group_members
  5. role_assign
  6. käyttäjä

Jokaista Conduit RESTful -verkkopalvelua kutsutaan HTTPS-osoitteesta. Esimerkki URL-osoitteesta:

https://{site}/blocks/conduit/webservices/rest/{service_name}.php?method=handle&token=TOKENVAL&xml=XMLSTRING

Sana site korvataan asiakkaan Blackboard Open LMS -sivuston URL-osoitteella (usein se on seuraavan kaltainen: clientname.mrooms.net). Kohta service_name korvataan arvolla user, course, enroll, groups tai group_members.

Jokainen Conduit RESTful -verkkopalvelu edellyttää, että kaksi HTML post -muuttujaa välitetään HTTPS-kutsussa. Nämä muuttujat ovat seuraavat:

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) Tähän täytyy määrittää kutsuttavan menetelmän nimi.

Get- ja Handle-komentomenetelmät verkkopalveluille

Perusrakenne

XML-perusrakenne kaikille pyynnöille kaikkiin päätepisteisiin, jotka käyttävät handle-menetelmää, on seuraava:

<?xml version='1.0'?>
<data>
<datum action="{action}">
<mapping name="{mappingname}">{value}</mapping>
</datum>
<datum action="{action}">
<mapping name="{mappingname}">{value}</mapping>
</datum>
</data>

Tässä perusrakenteessa on kolme muuttuja-arvoa: action, mappingname ja value. Action-muuttuja sisältää toiminnon, jonka haluat Conduitin suorittavan. Mappingname on sen Conduitin yhdistetyn kentän arvo, jonka value-muuttuja määrittää. Jos haluat esimerkiksi päivittää yhdistetyn username-kentän arvoksi johndoe, käytä seuraavaa XML-koodia:

<?xml version='1.0'?>
<data>
<datum action="{action}">
<mapping name="username">johndoe</mapping>
</datum>
</data>

Jokaisella XML-pyynnöllä voi olla datum omilla toiminnoillaan. XML-tiedosto voi myös yhdistellä toimintotyyppejä.

Conduitin XML-vastausrakenne näyttää seuraavalta. Jokainen verkkopalvelupäätepiste vastaa samankaltaisella tavalla. Ainoa osa, joka muuttuu alla olevassa rakenteessa, on service name -muuttuja Tämä on arvo on päätepisteen nimi.

<xml version='1.0'?><Service_{service name} generator="zend" version="1.0">
<handle>
<message&gt; String(All Errors)</message>
<status&gt; Integer (1 or 0)</status>
</handle></Service_Rest_{service name}>

Käyttäjäverkkopalvelu

Päätepiste

https://<site>/blocks/conduit/webservices/rest/user.php

Menetelmät

GET_USER

Hae Moodle-käyttäjän profiilin räätälöityjen kenttien tiedot.

POST-PARAMETRIT:

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user.
  • string value: (pakollinen) tämä on haettava käyttäjäarvo, esimerkiksi käyttäjän nimi.
  • string field: (vapaaehtoinen, oletusarvo on username) Tämä on Moodle-taulukon kenttä, josta haetaan. Se voi olla id, username, idnumber tai email.

PALAUTETTU XML-RAKENNE

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user>
<user>
<id>int</id>
<auth>string<auth>
<confirmed>int</confirmed>
<policyagreed>int</policyagreed>
<deleted>int</deleted>
<mnethostid>int</mnethostid>
<username>string</username>
<idnumber>string</idnumber>
<firstname>string</firstname>
<lastname>string</lastname>
<email>string</email>
<emailstop>int</emailstop>
<icq>string</icq>
<skype>string</skype>
<yahoo>string</yahoo>
<aim>string</aim>
<msn>string</msn>
<phone1>string</phone1>
<phone2>string</phone2>
<institution>string</institution>
<department>string</department>
<address>string</address>
<city>string</city>
<country>string</country>
<lang>string</lang>
<theme>string</theme>
<timezone>int</timezone>
<firstaccess>int</firstaccess>
<lastaccess>int</lastaccess>
<lastlogin>int</lastlogin>
<currentlogin>int</currentlogin>
<picture>int</picture>
<url>string</url>
<description>string</description>
<mailformat>int</mailformat>
<maildigest>int</maildigest>
<maildisplay>int</maildisplay>
<htmleditor>int</htmleditor>
<ajax>int</ajax>
<autosubscribe>int</autosubscribe>
<trackforums>int</trackforums>
<timemodified>int</timemodified>
<trustbitmask>int</trustbitmask>
<imagealt>string</imagealt>
<screenreader>int</screenreader>
</user>
<status>success</status>
</get_user></Service_User>

GET_USER_COURSE_RECENT_ACTIVITY

Conduit-käyttäjäverkkopalvelun menetelmä get_user_course_recent_activity tarjoaa ulkoisen liittymän, jolla voidaan hakea tietoja kaikista aktiviteeteista, jotka on lisätty, päivitetty tai poistettu kursseilla sinä aikana, kun käyttäjä on ollut niille rekisteröityneenä.

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user_course_recent_activity.
  • string username: (pakollinen) tämä on käyttäjän käyttäjänimi.
  • string course: (vapaaehtoinen, oletusarvo on NULL) Tämä on kurssin tunnistenumero. Jos sitä ei välitetä, kaikki käyttäjän kurssit palautetaan.
  • int fromdate: (vapaaehtoinen, oletusarvo on NULL) tämä on alkamispäivämäärän UNIX-aikaleima.

PALAUTETUN XML:N MUOTO

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_recent_activity>
<courses>
<course>
<id>integer</id>
<fullname>string</fullname>
<shortname>string</shortname>
<idnumber>string</idnumber>
<url>string</url>
<visible>int</visible>
<activities>
<activity>
<id>integer</id>
<type>string</type>
<name>string</name>
<timestamp>integer(unixtimestamp)</timestamp>
<descriptionhtml>string(html)/descriptionhtml>
<descriptiontext>string</descriptiontext>
<url>string</url>
</activity>
</activities>
</course>
</courses>
<status>success/fail</status>
</get_user_course_recent_activity></Service_User>

ESIMERKKI PALAUTETUSTA XML:STÄ

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_recent_activity>
<courses>
<course>
<id>12088</id>
<fullname>Reporting Course</fullname>
<shortname>REPO</shortname>
<idnumber>IDNUM</idnumber>
<url>http://example.com/course/view.php?id=12088</url>
<visible>1</visible>
<activities>
<activity>
<id>6114</id>
<type>assignment</type>
<name>Not graded</name>
<timestamp>1245093524</timestamp>
<descriptionhtml>Added Assignment by Admin User:<a href="http://example.com/mod/assignment/view.php?id=6114"></descriptionhtml>
<descriptiontext>Added Assignment by Admin User: Not graded</descriptiontext>
<url>http://example.com/mod/assignment/view.php?id=6114</url>
</activity>
<activity>
<id>6115</id>
<type>assignment</type>
<name>Graded</name>
<timestamp>1245093540</timestamp>
<descriptionhtml>Added Assignment by Admin User:<a href="http://example.com/mod/assignment/view.php?id=6115></descriptionhtml>
<descriptiontext>Added Assignment by Admin User: Graded</descriptiontext>
<url>http://example.com/mod/assignment/view.php?id=6115</url>
</activity>
<activity>
<id>6116</id>
<type>quiz</type>
<name>Graded quiz</name>
<timestamp>1245093564</timestamp>
<descriptionhtml>Added Quiz by Admin User:<a href="http://example.com/mod/quiz/view.php?id=6116"></descriptionhtml>
<descriptiontext>Added Quiz by Admin User: Graded quiz</descriptiontext>
<url>
http://example.com/mod/quiz/view.php?id=6116</url>
</activity>
<activity>
<id>6117</id>
<type>quiz</type>
<name>Not graded quiz</name>
<timestamp>1245093655</timestamp>
<descriptionhtml>Added Quiz by Admin User:<a href="
http://example.com/mod/quiz/view.php?id=6117"></descriptionhtml>
<descriptiontext>Added Quiz by Admin User: Not graded quiz</descriptiontext>
<url>http://example.com/mod/quiz/view.php?id=6117</url>
</activity>
</activities>
</course>
</courses>
<status>success</status>
</get_user_course_recent_activity></Service_User>

GET_USER_COURSE_ACTIVITIES_DUE

Conduit-käyttäjäverkkopalvelun get_user_course_activities_due-menetelmä mahdollistaa ulkoisen käytön aktiviteeteille, joiden määräpäivä käyttäjällä on kurssilla määritetyllä ajanjaksolla.

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user_course_activities_due.
  • string username: (pakollinen) tämä on käyttäjän käyttäjänimi.
  • int todate: (pakollinen) tämä on päättymispäivän UNIX-aikaleima.
  • string course: (vapaaehtoinen, oletusarvo on NULL) Tämä on kurssin tunnistenumero. Jos sitä ei välitetä, kaikki käyttäjän kurssit palautetaan.

PALAUTETUN XML:N MUOTO

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_activities_due>
<courses>
<course>
<id>integer</id>
<fullname>string</fullname>
<shortname>string</shortname>
<idnumber>string</idnumber>
<url>string</url>
<activities>
<activity>
<id>integer</id>
<type>string</type>
<name>string</name>
<descriptionhtml>string(html)</descriptionhtml>
<descriptiontext>string</descriptiontext>
<duedate>integer(unixtimestamp)</duedate>
<url>string</url>
</activity>
</activities>
</course>
</courses>
<status>success/fail</status>
</get_user_course_activities_due></Service_User>

ESIMERKKI PALAUTETUSTA XML:STÄ

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_activities_due>
<courses>
<course>
<id>12088</id>
<fullname>Reporting Course</fullname>
<shortname>REPO</shortname>
<idnumber>IDNUM</idnumber>
<url>http://example.com/course/view.php?id=12088</url>
<activities>
<activity>
<id>7797</id>
<type>quiz</type>
<name>Another quiz</name>
<descriptionhtml>&lt;p&gt;asdf &lt;/p&gt;</descriptionhtml>
<descriptiontext>asdf</descriptiontext>
<duedate>0</duedate>
<url>http://example.com/mod/quiz/view.php?id=7797</url>
</activity>
<activity>
<id>6114</id>
<type>assignment</type>
<name>Not graded</name>
<descriptionhtml>&lt;p&gt; Descasdf&lt;/p&gt;</descriptionhtml>
<descriptiontext>Descasdf</descriptiontext>
<duedate>1277234100</duedate>
<url>http://example.com/mod/assignment/view.php?id=6114</url>
</activity>
<activity>
<id>9103</id>
<type>assignment</type>
<name>eFolio</name>
<descriptionhtml>&lt;p&gt; Introduction &lt;/p&gt;</descriptionhtml>
<descriptiontext>Introduction</descriptiontext>
<duedate>1306360800</duedate>
<url>http://example.com/mod/assignment/view.php?id=9103</url>
</activity>
</activities>
</course>
</courses>
<status>success</status>
</get_user_course_activities_due></Service_User>

GET_USER_COURSE_EVENTS

Conduit-käyttäjäverkkopalvelun get_user_course_events-menetelmä mahdollistaa ulkoisen käytön käyttäjän kurssitapahtumille. Jos haluat käyttää aktiviteettien määräpäiviä, käytä menetelmää get_user_course_activities_due.

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user_course_events.
  • string username: (pakollinen) tämä on käyttäjän käyttäjänimi.
  • int fromdate: (pakollinen) tämä on alkamispäivän UNIX-aikaleima.
  • int todate: (pakollinen) tämä on päättymispäivän UNIX-aikaleima.
  • string course: (vapaaehtoinen, oletusarvo on NULL) Tämä on kurssin tunnistenumero. Jos sitä ei välitetä, kaikki käyttäjän kurssit palautetaan.

PALAUTETUN XML:N MUOTO

<div><code><?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_events>
<courses>
<course>
<id>integer</id>
<fullname>string</fullname>
<shortname>string</shortname>
<idnumber>string</idnumber>
<url>string</url>
<events>
<event>
<id>integer</id>
<name>string</name>
<timestart>integer(unix timestamp)</timestart>
<timeend>integer(unix timestamp)</timeend>
<description>string</description>
<url>string</url>
</event>
</events>
</course>
</courses>
<status>success</status>
</get_user_course_events></Service_User>

ESIMERKKI PALAUTETUSTA XML:STÄ

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_course_events>
<courses>
<course>
<id>12088</id>
<fullname>Reporting Course</fullname>
<shortname>REPO</shortname>
<idnumber>IDNUM</idnumber>
<url>http://example.com/course/view.php?id=12088</url>
<events>
<event>
<id>507</id>
<name>Event 1</name>
<timestart>1259827200</timestart>
<timeend>1259827200</timeend>
<description>This is the event.</description>
<url>http://example.com/calendar/view.php?view=day&amp;amp;course=12088&amp;a... </event>
</events>
</course>
</courses>
<status>success</status>
</get_user_course_events></Service_User>

GET_USER_GRADES

Conduitin käyttäjä- ja kurssiverkkopalvelut tarjoavat ulkoisille järjestelmille tavan hakea arvosanoja Moodlesta. Näillä palveluilla on omat asetuksensa, jotka löydät Conduit-asetusten verkkopalveluiden alavälilehden Arvosanat-kohdasta. Conduit tarjoaa kaksi päätepistettä Moodle-arvosanojen hakemiseen.

POST-PARAMETRIT:

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user_grades.
  • string user: (pakollinen) tämä on käyttäjä, jonka arvosanat palautetaan.
  • int batchsize: (vapaaehtoinen) Tämä on palautettavien arvosanojen määrä. Määrän täytyy olla alle 10 000.
  • int lastprocessedid: (vapaaehtoinen) Tämä on viimeinen käsitelty ja verkkopalvelusta palautettu arvosana. Tämä helpottaa kaikkien Moodle-arvosanojen indeksointia, sillä välittäessäsi tämän arvon, palvelu palauttaa vain ne arvosanat, joiden tunnus on suurempi kuin tämä.
  • int starttime: (vapaaehtoinen) Tämän avulla voit hakea tietyn ajankohdan jälkeen muokattuja arvosanoja. Välitä aika UNIX-aikaleimamuodossa.
  • int endtime: (vapaaehtoinen) Tämän avulla voit hakea ennen tiettyä ajankohtaa muokattuja arvosanoja. Välitä aika UNIX-aikaleimamuodossa.
  • string course: (vapaaehtoinen) Tämän avulla voit hakea käyttäjän arvosanat tietyltä kurssilta. Arvon täytyy olla joko kurssin lyhenne tai tunnistenumero. Löydät sen Conduit-asetusten yleisten asetusten alavälilehden Kurssitunnus-asetuksesta. Jos jätät tämän asetuksen määrittämättä, kaikki käyttäjän arvosanat palautetaan.
  • string itemtypes: (vapaaehtoinen, oletusarvo on DEFAULT_SET) Välitä CSV-luettelo palautettavista arviointikohdetyypeistä. Jos haluat palauttaa kaikki kohdetyypit, välitä tyhjä merkkijono. Jos haluat hakea oletusarviointikohteet, jotka määritetään Conduitin avulla, älä välitä tätä parametria tai määritä sen arvoksi DEFAULT_SET.

PALAUTETTU XML-RAKENNE

Molemmat arvosanaverkkopalvelupäätepisteet palauttavat saman XML-rakenteen. Rakenne palauttaa arviointikohteet ja niiden arvosanat. User- ja Course-tunnisteet toimivat kuin sanakirjat: ne sisältävät kaikki käyttäjät ja kurssit, joihin arviointikohteet ja arvosanat kuuluvat. Courseid- ja userid-tunnisteilla voit hakea niitä vastaavat kurssit ja käyttäjät. Lastprocessedid-tunniste määrittää viimeisen verkkopalvelun käsittelemän arvosanatunnuksen. Jos haluat käyttää verkkopalvelun lastprocessedid-parametria, käytä tätä arvoa.

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_user_grades>
<users>
<id_X>
<user>
<id>integer</id>
<fullname>string</fullname>
<username>string</username>
<idnumber>string</idnumber>
</user>
</id_X>
</users>
<courses>
<id_X>
<course>
<id>integer</id>
<fullname>string</fullname>
<shortname>string</shortname>
<idnumber>string</idnumber>
</course>
</id_X>
</courses>
<gradeitems>
<gradeitem>
<courseid>integer</courseid>
<itemtype>string(course, mod, category, manual, null)</itemtype>
<itemname>string</itemname>
<itemmodule>string</itemmodule>
<iteminstance>integer</iteminstance>
<grades>
<grade>
<id>integer</id>
<userid>integer</userid>
<finalgrade>number</finalgrade>
<gradeletter>string</gradeletter>
<gradepercent>string</gradepercent>
<timemodified>integer</timemodified>
<deleted>1/0</deleted>
</grade>
</grades>
</gradeitem>
</gradeitems>
<lastprocessedid>integer</lastprocessedid>
<status>success/fail</status>
</get_user_grades></Service_User>

kohdetyypit: course, mod, category, manual, null

Handle

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla handle.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Päivitä
  • Poista

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="username">string</mapping>
<mapping name="auth">string</mapping>
<mapping name="mnethostid">integer</mapping>
<mapping name="password">string</mapping>
<mapping name="idnumber">string</mapping>
<mapping name="firstname">string</mapping>
<mapping name="lastname">string</mapping>
<mapping name="email">string</mapping>
<mapping name="emailstop">integer</mapping>
<mapping name="icq">string</mapping>
<mapping name="skype">string</mapping>
<mapping name="yahoo">string</mapping>
<mapping name="aim">string</mapping>
<mapping name="man">string</mapping>
<mapping name="phone1">string</mapping>
<mapping name="phone2">string</mapping>
<mapping name="institution">string</mapping>
<mapping name="department">string</mapping>
<mapping name="address">string</mapping>
<mapping name="city">string</mapping>
<mapping name="country">string</mapping>
<mapping name="lang">string</mapping>
<mapping name="theme">string</mapping>
<mapping name="timezone">string</mapping>
<mapping name="picture">integer</mapping>
<mapping name="url">string</mapping>
<mapping name="description">string</mapping>
<mapping name="mailformat">integer</mapping>
<mapping name="maildigest">integer</mapping>
<mapping name="maildisplay">integer</mapping>
<mapping name="htmleditor">integer</mapping>
<mapping name="ajax">integer</mapping>
<mapping name="autosubscribe">integer</mapping>
<mapping name="trackforums">string</mapping>
<mapping name="imagealt">integer</mapping>
<mapping name="screenreader">integer</mapping>
<mapping name="studentyear">string</mapping>
<mapping name="textarea">string</mapping>
<mapping name="managersemail">string</mapping>
</datum></data>

UPDATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="update">
<mapping name="username">string</mapping>
<mapping name="auth">string</mapping>
<mapping name="mnethostid">integer</mapping>
<mapping name="password">string</mapping>
<mapping name="idnumber">string</mapping>
<mapping name="firstname">string</mapping>
<mapping name="lastname">string</mapping>
<mapping name="email">string</mapping>
<mapping name="emailstop">integer</mapping>
<mapping name="icq">string</mapping>
<mapping name="skype">string</mapping>
<mapping name="yahoo">string</mapping>
<mapping name="aim">string</mapping>
<mapping name="man">string</mapping>
<mapping name="phone1">string</mapping>
<mapping name="phone2">string</mapping>
<mapping name="institution">string</mapping>
<mapping name="department">string</mapping>
<mapping name="address">string</mapping>
<mapping name="city">string</mapping>
<mapping name="country">string</mapping>
<mapping name="lang">string</mapping>
<mapping name="theme">string</mapping>
<mapping name="timezone">string</mapping>
<mapping name="picture">integer</mapping>
<mapping name="url">string</mapping>
<mapping name="description">string</mapping>
<mapping name="mailformat">integer</mapping>
<mapping name="maildigest">integer</mapping>
<mapping name="maildisplay">integer</mapping>
<mapping name="htmleditor">integer</mapping>
<mapping name="ajax">integer</mapping>
<mapping name="autosubscribe">integer</mapping>
<mapping name="trackforums">string</mapping>
<mapping name="imagealt">integer</mapping>
<mapping name="screenreader">integer</mapping>
<mapping name="studentyear">string</mapping>
<mapping name="textarea">string</mapping>
<mapping name="managersemail">string</mapping>
</datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="username">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_User generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_User>

Kurssiverkkopalvelut

Päätepiste

https://<site>/blocks/conduit/webservices/rest/course.php

Menetelmät

GET_COURSE

Hae Moodle-kurssin asetukset.

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_course.
  • string value: (pakollinen) tämä on haettava kurssiarvo, esimerkiksi kurssin lyhenne.
  • string field: (vapaaehtoinen, oletusarvo on username) Tämä on Moodle-taulukon kenttä, josta haetaan. Se voi olla id, shortname tai idnumber.

PALAUTETTU XML-RAKENNE

<?xml version="1.0" encoding="UTF-8"?><Service_Course generator="zend" version="1.0"> <get_course> <course> <id>int</id> <category>int</category> <sortorder>int</sortorder> <password>string</password> <fullname>string</fullname> <shortname>string</shortname> <idnumber>string</idnumber> <summary>string</summary> <format>string</format> <showgrades>int</showgrades> <newsitems>int</newsitems> <startdate>int</startdate> <enrolperiod>int</enrolperiod> <numsections>int</numsections> <marker>int</marker> <maxbytes>int</maxbytes> <showreports>int</showreports> <visible>int</visible> <hiddensections>int</hiddensections> <groupmode>int</groupmode> <groupmodeforce>int</groupmodeforce> <defaultgroupingid>int</defaultgroupingid> <lang>string</lang> <theme>string</theme> <timecreated>int</timecreated> <timemodified>int</timemodified> <requested>int</requested> <restrictmodules>int</restrictmodules> </course> <status>success</status> </get_course></Service_Course>

get_course_grades

Conduitin kurssiverkkopalveluiden get_course_grades-menetelmä tarjoaa ulkoisille järjestelmille tavan hakea arvosanoja Moodlesta.

Arvosanojen verkkopalveluilla on omat asetuksensa, jotka löydät Conduit-asetusten verkkopalveluiden alavälilehden Arvosanat-kohdasta.

get_course_grades palauttaa kurssien kaikkien käyttäjien kaikki arvosanat, vaikka käyttäjän rekisteröinti kurssille olisi peruutettu.

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_course_grades.
  • string course: (vapaaehtoinen) Tämän avulla voit hakea käyttäjän arvosanat tietyltä kurssilta. Arvon täytyy olla joko kurssin lyhenne tai tunnistenumero. Löydät sen Conduit-asetusten yleisten asetusten alavälilehden Kurssitunnus-asetuksesta. Jos jätät tämän asetuksen määrittämättä, kaikki kurssit palautetaan.
  • int batchsize: (vapaaehtoinen) Tämä on palautettavien arvosanojen määrä. Määrän täytyy olla alle 10 000.
  • int lastprocessedid: (vapaaehtoinen) Tämä on viimeinen käsitelty ja verkkopalvelusta palautettu arvosana. Tämä helpottaa kaikkien Moodle-arvosanojen indeksointia, sillä välittäessäsi tämän arvon, palvelu palauttaa vain ne arvosanat, joiden tunnus on suurempi kuin tämä.
  • int starttime: (vapaaehtoinen) Tämän avulla voit hakea tietyn ajankohdan jälkeen muokattuja arvosanoja. Välitä aika UNIX-aikaleimamuodossa.
  • int endtime: (vapaaehtoinen) Tämän avulla voit hakea ennen tiettyä ajankohtaa muokattuja arvosanoja. Välitä aika UNIX-aikaleimamuodossa.
  • string itemtypes: (vapaaehtoinen, oletusarvo on DEFAULT_SET) Välitä CSV-luettelo palautettavista arviointikohdetyypeistä. Jos haluat palauttaa kaikki kohdetyypit, välitä tyhjä merkkijono. Jos haluat hakea oletusarviointikohteet, joka määritetään Conduitin avulla, älä välitä tätä parametria tai määritä sen arvoksi DEFAULT_SET.

PALAUTETTU XML-RAKENNE

Rakenne palauttaa arviointikohteet ja niiden arvosanat. User- ja Course-tunnisteet toimivat kuin sanakirjat: ne sisältävät kaikki käyttäjät ja kurssit, joihin arviointikohteet ja arvosanat kuuluvat. Courseid- ja userid-tunnisteilla voit hakea niitä vastaavat kurssit ja käyttäjät. Lastprocessedid-tunniste määrittää viimeisen verkkopalvelun käsittelemän arvosanatunnuksen. Jos haluat käyttää verkkopalvelun lastprocessedid-parametria, käytä tätä arvoa.

<?xml version="1.0" encoding="UTF-8"?><Service_User generator="zend" version="1.0">
<get_course_grades>
<users>
<id_X>
<user>
<id>integer</id>
<fullname>string</fullname>
<username>string</username>
<idnumber>string</idnumber>
</user>
</id_X>
</users>
<courses>
<id_X>
<course>
<id>integer</id>
<fullname>string</fullname>
<shortname>string</shortname>
<idnumber>string</idnumber>
</course>
</id_X>
</courses>
<gradeitems>
<gradeitem>
<courseid>integer</courseid>
<itemtype>string(course, mod, category, manual, null)</itemtype>
<itemname>string</itemname>
<itemmodule>string</itemmodule>
<iteminstance>integer</iteminstance>
<grades>
<grade>
<id>integer</id>
<userid>integer</userid>
<finalgrade>number</finalgrade>
<gradeletter>string</gradeletter>
<gradepercent>string</gradepercent>
<timemodified>integer</timemodified>
<deleted>1/0</deleted>
</grade>
</grades>
</gradeitem>
</gradeitems>
<lastprocessedid>integer</lastprocessedid>
<status>success/fail</status>
</get_course_grades></Service_User>

Kohdetyypit: course, mod, category, manual, null.

HANDLE

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla handle.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Päivitä
  • Poista

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="shortname">string</mapping>
<mapping name="category">string</mapping>
<mapping name="password">string</mapping>
<mapping name="fullname"><string/mapping>
<mapping name="idnumber">string</mapping>
<mapping name="summary">string</mapping>
<mapping name="summaryformat">integer</mapping>
<mapping name="format">string</mapping>
<mapping name="showgrades">integer</mapping>
<mapping name="newsitems">integer</mapping>
<mapping name="startdate">integer</mapping>
<mapping name="numsections">integer</mapping>
<mapping name="marker">integer</mapping>
<mapping name="maxbytes">integer</mapping>
<mapping name="showreports">integer</mapping>
<mapping name="visible">integer</mapping>
<mapping name="hiddensections">integer</mapping>
<mapping name="groupmode">integer</mapping>
<mapping name="groupmodeforce">integer</mapping>
<mapping name="defaultgroupingid"></mapping>
<mapping name="lang">string</mapping>
<mapping name="theme">string</mapping>
<mapping name="requested">integer</mapping>
<mapping name="restrictmodules">integer</mapping>
<mapping name="enablecompletion">integer</mapping>
<mapping name="completionstartonenrol">integer</mapping>
<mapping name="completionnotify">integer</mapping>
<mapping name="coursetemplate">string</mapping>
</datum></data>

UPDATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="update">
<mapping name="shortname">string</mapping>
<mapping name="category">string</mapping>
<mapping name="password">string</mapping>
<mapping name="fullname"><string/mapping>
<mapping name="idnumber">string</mapping>
<mapping name="summary">string</mapping>
<mapping name="summaryformat">integer</mapping>
<mapping name="format">string</mapping>
<mapping name="showgrades">integer</mapping>
<mapping name="newsitems">integer</mapping>
<mapping name="startdate">integer</mapping>
<mapping name="numsections">integer</mapping>
<mapping name="marker">integer</mapping>
<mapping name="maxbytes">integer</mapping>
<mapping name="showreports">integer</mapping>
<mapping name="visible">integer</mapping>
<mapping name="hiddensections">integer</mapping>
<mapping name="groupmode">integer</mapping>
<mapping name="groupmodeforce">integer</mapping>
<mapping name="defaultgroupingid"></mapping>
<mapping name="lang">string</mapping>
<mapping name="theme">string</mapping>
<mapping name="requested">integer</mapping>
<mapping name="restrictmodules">integer</mapping>
<mapping name="enablecompletion">integer</mapping>
<mapping name="completionstartonenrol">integer</mapping>
<mapping name="completionnotify">integer</mapping>
<mapping name="coursetemplate">string</mapping>
</datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="shortname">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_Course generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_Course>


Rekisteröitymisverkkopalvelun päätepiste

https://<site>/blocks/conduit/webservices/rest/enroll.php

Menetelmät

HANDLE

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla handle.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Päivitä
  • Poista

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="create">
<mapping name="coursekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="rolekey">string</mapping>
<mapping name="timestart">integer</mapping>
<mapping name="timeend">integer</mapping>
</datum></datum></data>

UPDATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="update">
<mapping name="coursekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="rolekey">string</mapping>
<mapping name="timestart">integer</mapping>
<mapping name="timeend">integer</mapping>
</datum></datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="delete">
<mapping name="coursekey">string</mapping>
<mapping name="userkey">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_Enrol generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_Enrol>

Roolimääritysverkkopalvelun päätepiste

https://<site>/blocks/conduit/webservices/rest/role_assign.php

Menetelmät

HANDLE

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla handle.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Päivitä
  • Poista

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="create">
<mapping name="context">course|user</mapping>
<mapping name="moodlekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="rolekey">string</mapping>
<mapping name="timestart">integer</mapping>
<mapping name="timeend">integer</mapping>
</datum></datum></data>

UPDATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="update">
<mapping name="context">course|user</mapping>
<mapping name="moodlekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="rolekey">string</mapping>
<mapping name="timestart">integer</mapping>
<mapping name="timeend">integer</mapping>
</datum></datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version='1.0'?><data>
<datum action="delete">
<mapping name="context">course|user</mapping>
<mapping name="moodlekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="rolekey">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_Enrol generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_Enrol>

Ryhmäverkkopalvelut

Päätepiste

https://<site>/blocks/conduit/webservices/rest/groups.php

Menetelmät

HANDLE

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla handle.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Päivitä
  • Poista

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="coursekey">string</mapping>
<mapping name="groupkey">string</mapping>
<mapping name="description">string</mapping>
<mapping name="enrollmentkey">string</mapping>
<mapping name="hidepicture">integer</mapping>
</datum></data>

UPDATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="update">
<mapping name="coursekey">string</mapping>
<mapping name="groupkey">string</mapping>
<mapping name="newgroupkey">string</mapping>
<mapping name="description">string</mapping>
<mapping name="enrollmentkey">string</mapping>
<mapping name="hidepicture">integer</mapping>
</datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="coursekey">string</mapping>
<mapping name="groupkey">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_Groups generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_Groups>

GET_GROUPS

Hae kurssin ryhmät.

POST-PARAMETRIT

  • string method: (pakollinen) tämän arvon täytyy olla get_groups.
  • string value: (pakollinen) tämä on haettava kurssiarvo.
  • string field: (vapaaehtoinen, oletusarvo on idnumber) Tämä on kurssikenttä, johon arvon täytyy täsmätä. Tämä voi olla id, shortname tai idnumber.

VASTAUKSEN XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><Service_Groups generator="zend" version="1.0">
<get_groups>
<groups>
<group>
<courseid>int</courseid>
<name>string</name>
<description>string</description>
<enrolmentkey>string</enrolmentkey>
<picture>int</picture>
<hidepicture>int</hidepicture>
<timecreated>int</timecreated>
<timemodified>int</timemodified>
<id>int</id>
</group>
</groups>
<status>success</status>
</get_groups></Service_Groups>

Ryhmäjäsenten verkkopalvelumääritelmä

Päätepiste

https://<site>/blocks/conduit/webservices/rest/groups_members.php

Menetelmät

HANDLE

POST-PARAMETRIT

  • string token: (pakollinen) määritä Token-asetuksen arvo Conduit-asetusten välilehden verkkopalveluiden alavälilehdessä.
  • string method: (pakollinen) tämän arvon täytyy olla get_user_course_events.
  • string xml: (pakollinen) tämä on XML-rakenne, joka sisältää tiedot toimintojen suorittamiseksi Conduit-tietueille.

KELVOLLISET TOIMINNOT

  • Create
  • Delete

CREATE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="coursekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="groupkey">string</mapping>
</datum></data>

DELETE-TOIMINNON XML-MÄÄRITELMÄ

<?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="coursekey">string</mapping>
<mapping name="userkey">string</mapping>
<mapping name="groupkey">string</mapping>
</datum></data>

VASTAUKSEN XML-MÄÄRITELMÄ

<Service_group_members generator="zend" version="1.0">
<handle>
<message>MESSAGE</message>
<status>STATUS</status>
</handle></Service_Rest_GroupmMembers>

Conduitin PHP-verkkopalveluiden koodiesimerkit

Menetelmät

get_user

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_user', 'username' =&gt; 'guest' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

get_user_course_recent_activity

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_user_course_recent_activity', 'username' =&gt; 'guest' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

get_user_course_activities_due

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_user_course_activities_due', 'username' =&gt; 'guest', 'todate' = time() )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

get_user_course_events

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_user_course_events', 'field' =>'username', 'value' =&gt; 'guest', 'fromdata' =&gt; '1291506600'; 'todate' = time() )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

get_user_grades

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_user_grades', 'user.php' =&gt; 'test' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

Handle

Alla on esimerkkejä handle-tiedostosta, jolla voit luoda tietueita

Create-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="create">
<mapping name="username">testuser</mapping>
<mapping name="password">testuser</mapping>
<mapping name="idnumber">ts101</mapping>
<mapping name="firstname">Test</mapping>
<mapping name="lastname">User</mapping>
<mapping name="email"&gt; [email protected]</mapping>
<mapping name="phone1">(123) 456-7891</mapping>
<mapping name="phone2">(123) 456-7891</mapping>
<mapping name="address">1234 Some Street</mapping>
<mapping name="city">Baltimore</mapping>
<mapping name="country">US</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Update-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="update">
<mapping name="username">testuser</mapping>
<mapping name="password">testuser</mapping>
<mapping name="idnumber">ts1012</mapping>
<mapping name="firstname">Test</mapping>
<mapping name="lastname">User</mapping>
<mapping name="email">[email protected]</mapping>
<mapping name="phone1">(123) 456-7891</mapping>
<mapping name="phone2">(123) 456-7891</mapping>
<mapping name="address">1234 Some Street</mapping>
<mapping name="city">Baltimore</mapping>
<mapping name="country">US</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebod = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Delete-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="delete">
<mapping name="username">testuser</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/user.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Kurssiverkkopalvelun esimerkkejä

Menetelmät

get_course

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'value'=>'CF101' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

get_course_grades

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'course.php'=>'CF101' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

Handle

Alla on esimerkkejä handle-tiedostosta, jolla voit luoda tietueita

Create-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="create">
<mapping name="shortname">testcourse</mapping>
<mapping name="fullname">Test Course</mapping>
<mapping name="idnumber">test</mapping>
<mapping name="summary">Web service test</mapping>
<mapping name="enrolllable">1</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Update-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="update">
<mapping name="shortname">testcourse</mapping>
<mapping name="fullname">Test Course</mapping>
<mapping name="idnumber">test</mapping>
<mapping name="summary">Web service test</mapping>
<mapping name="enrolllable">1</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Delete-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="delete">
<mapping name="shortname">testcourse</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/course.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Rekisteröitymisverkkopalvelun esimerkkejä

Handle

Add-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="add">
<mapping name="course">testcourse</mapping>
<mapping name="username">testuser</mapping>
<mapping name="role">student</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/enroll.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Drop-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="drop">
<mapping name="course">testcourse</mapping>
<mapping name="username">testuser</mapping>
<mapping name="role">student</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/enroll.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Roolimääritysverkkopalvelun esimerkkejä

Handle

Add-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="create">
<mapping name="context">user</mapping>
<mapping name="moodlekey">testuser</mapping>
<mapping name="userkey">parent</mapping>
<mapping name="rolekey">manager</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/role_assign.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Drop-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?>
<data>
<datum action="create">
<mapping name="context">user</mapping>
<mapping name="moodlekey">testuser</mapping>
<mapping name="userkey">parent</mapping>
<mapping name="rolekey">manager</mapping>
<mapping name="timestart">1296762421</mapping>
<mapping name="timeend">1296770000</mapping>
</datum>
</data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/role_assign.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Ryhmäverkkopalvelun esimerkkejä

Menetelmä

get_groups

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php'); $client->setParameterPost(array('token'=>'<token>', 'method'=>'get_groups', 'shortname' =&gt; 'CF101' )); $response = $client->request('POST'); $lastrequest = $client->getLastRequest(); $responsebody = $response->getBody(); $lastrequestbody = $lastrequest->getBody(); echo '<pre>'; print_r($lastrequestbody); echo '</pre>'; echo '<pre>'; print_r($responsebody); echo '</pre>'; ?>

Handle

get_user_grades

Create-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="course">testcourse</mapping>
<mapping name="name">testgroup</mapping>
<mapping name="description">This is a test Conduit group</mapping>
</datum></data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Update-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?><data>
<datum action="update">
<mapping name="course">testcourse</mapping>
<mapping name="name">testgroup</mapping>
<mapping name="newname">testgroup2</mapping>
<mapping name="description">This is a test Conduit group update</mapping>
</datum></data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Delete-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="course">testcourse</mapping>
<mapping name="name">testgroup</mapping>
</datum></data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

Ryhmäjäsenten verkkopalvelun esimerkkejä

Handle

Create-toiminto

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?><data>
<datum action="create">
<mapping name="course">testcourse</mapping>
<mapping name="user">testuser</mapping>
<mapping name="groupname">testgroup</mapping>
</datum></data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups_members.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>

get_user_grades

<?php $baseDir = dirname(dirname(__FILE__)); set_include_path(dirname($baseDir).'/lib/zend'. PATH_SEPARATOR. "$baseDir/library". PATH_SEPARATOR. "$baseDir/application/models". PATH_SEPARATOR. get_include_path()); require_once('Zend/Debug.php'); require_once('Zend/Http/Client.php'); $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?><data>
<datum action="delete">
<mapping name="course">testcourse</mapping>
<mapping name="user">testuser</mapping>
<mapping name="groupname">testgroup</mapping>
</datum></data>XML;$client = new Zend_Http_Client('http://{site}/blocks/conduit/webservices/rest/groups_members.php');$client->setParameterPost(array('token'=>'<token>', 'method'=>'handle', 'xml'=>$xml ));$response = $client->request('POST');$lastrequest = $client->getLastRequest();$responsebody = $response->getBody();$lastrequestbody = $lastrequest->getBody();echo '<pre>';print_r($lastrequestbody);echo '</pre>';echo '<pre>';print_r($responsebody);echo '</pre>';?>


Conduit ASP.Net -verkkopalvelun koodiesimerkkejä

Käyttäjäverkkopalvelun esimerkkejä

Menetelmät

get_user

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = "james"; string username = "guest"; string postData = "method=get_user&token=" + token + "username="+username+"todate="+DateTime.Now.ToString(); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_user_course_recent_activity

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = "james"; string username = "guest"; string postData = "method=get_user_course_recent_activity&token=" + token + "username="+username+"todate="+DateTime.Now.ToString(); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_user_course_activities_due

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = "james"; string username = "guest"; string postData = "method=get_user_course_activities_due&token=" + token + "username="+username+"todate="+DateTime.Now.ToString(); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_user_course_events

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = "james"; string field = "username", value = "guest", fromdata = "1291506600"; string postData = "method=get_user_course_events&token=" + token + "field="+user+ "value="+value+ "fromdata="+fromdata+"todate="+DateTime.Now.ToString(); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_user_grades

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = "", user = "james"; string postData = "method=get_user_grades&token=" + token + "user="+user; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Handle

Alla on esimerkkejä handle-tiedostosta, jolla voit luoda tietueita

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="username">testuser</mapping>"); sb.Append("<mapping name="password">testuser</mapping>"); sb.Append("<mapping name="idnumber">Test10001</mapping>"); sb.Append("<mapping name="firstname">Test</mapping>"); sb.Append("<mapping name="lastname">User</mapping>"); sb.Append("<mapping name="email"&gt; [email protected] </mapping>"); sb.Append("<mapping name="phone1">(123) 456-7891</mapping>"); sb.Append("<mapping name="phone2">(123) 456-7891</mapping>"); sb.Append("<mapping name="address">1234 Some Street</mapping>"); sb.Append("<mapping name="city">Baltimore</mapping>"); sb.Append("<mapping name="country">US</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Update-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="update">"); sb.Append("<mapping name="username">testuser</mapping>"); sb.Append("<mapping name="password">testuser</mapping>"); sb.Append("<mapping name="idnumber">Test10001</mapping>"); sb.Append("<mapping name="firstname">Test</mapping>"); sb.Append("<mapping name="lastname">User</mapping>"); sb.Append("<mapping name="email"&gt; [email protected]</mapping>"); sb.Append("<mapping name="phone1">(123) 456-7891</mapping>"); sb.Append("<mapping name="phone2">(123) 456-7891</mapping>"); sb.Append("<mapping name="address">1234 Some Street</mapping>"); sb.Append("<mapping name="city">Baltimore</mapping>"); sb.Append("<mapping name="country">US</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Delete-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/user.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="username">testuser</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Kurssiverkkopalvelun esimerkkejä

Menetelmät

get_course

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = "", value="CF101"; string postData = "method=get_course&token=" + token+"value="+value; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_course_grades

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = ""; string postData = "method=get_course_grades&token=" + token; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Handle

Alla on esimerkkejä handle-tiedostosta, jolla voit luoda tietueita

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="shortname">testcourse</mapping>"); sb.Append("<mapping name="fullname">Test Course</mapping>"); sb.Append("<mapping name="idnumber">test</mapping>"); sb.Append("<mapping name="summary">Web service test</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Update-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="update">"); sb.Append("<mapping name="shortname">testcourse</mapping>"); sb.Append("<mapping name="fullname">Test Course</mapping>"); sb.Append("<mapping name="idnumber">test</mapping>"); sb.Append("<mapping name="summary">Web service test</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Delete-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/course.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="shortname">testcourse</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Rekisteröitymisverkkopalvelun esimerkkejä

Handle

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="userkey">testuser</mapping>"); sb.Append("<mapping name="rolekey">student</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Update-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="update">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="userkey">testuser</mapping>"); sb.Append("<mapping name="timestart">1296762421</mapping>"); sb.Append("<mapping name="timeend">1296760000</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

get_user_grades

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/enroll.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="userkey">testuser</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Roolimääritysverkkopalvelun esimerkkejä

Kahva

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="context">user</mapping>"); sb.Append("<mapping name="moodlekey">testuser</mapping>"); sb.Append("<mapping name="userkey">parent</mapping>"); sb.Append("<mapping name="rolekey">manager</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Update-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="update">"); sb.Append("<mapping name="context">user</mapping>"); sb.Append("<mapping name="moodlekey">testuser</mapping>"); sb.Append("<mapping name="userkey">parent</mapping>"); sb.Append("<mapping name="rolekey">manager</mapping>"); sb.Append("<mapping name="timestart">1296762421</mapping>"); sb.Append("<mapping name="timeend">1296760000</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Delete-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/role_assign.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="context">user</mapping>"); sb.Append("<mapping name="moodlekey">testuser</mapping>"); sb.Append("<mapping name="userkey">parent</mapping>"); sb.Append("<mapping name="rolekey">manager</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Ryhmäverkkopalvelun esimerkkejä

Menetelmät

get_groups

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = ""; string shortname = "CF101"; string postData = "method=get_groups&token=" + token + "shortname="+shortname; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Handle

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="groupkey">testgroup</mapping>"); sb.Append("<mapping name="description">This is a test Conduit group</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Update-toiminto

01 using System; 02 using System.Collections; 03 using System.Configuration; 04 using System.Data; 05 using System.Linq; 06 using System.Web; 07 using System.Web.Security; 08 using System.Web.UI; 09 using System.Web.UI.HtmlControls; 10 using System.Web.UI.WebControls; 11 using System.Web.UI.WebControls.WebParts; 12 using System.Xml.Linq; 13 using System.IO; 14 using System.Text; 15 using System.Xml; 16 using System.Net; 17 using System.Diagnostics; 18 19 public partial class TestPage : System.Web.UI.Page 20 { 21 protected void Page_Load(object sender, EventArgs e) 22 { 23 24 } 25 26 protected void btnSubmit_Click(object sender, EventArgs e) 27 { 28 string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = ""; 29 StringBuilder sb = new StringBuilder(); 30 31 sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); 32 sb.Append("<data><datum action="update">"); 33 sb.Append("<mapping name="coursekey">testcourse</mapping>"); 34 sb.Append("<mapping name="groupkey">testgroup</mapping>"); 35 sb.Append("<mapping name="newgroupkey">testgroup2</mapping>"); 36 sb.Append("<mapping name="description">This is a test Conduit group</mapping>"); 37 sb.Append("</datum&gt; </data>"); 38 39 string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); 40 41 StreamWriter myWriter = null; 42 HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); 43 objRequest.Method = "POST"; 44 objRequest.ContentType = "application/x-www-form-urlencoded"; 45 objRequest.ContentLength = postData.Length; 46 47 if (sb.ToString() != "") 48 { 49 try 50 { 51 myWriter = new StreamWriter(objRequest.GetRequestStream()); 52 myWriter.Write(postData); 53 } 54 catch (Exception ex) 55 { 56 response = ex.Message; 57 } 58 finally 59 { 60 myWriter.Close(); 61 } 62 } 63 64 HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); 65 using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) 66 { 67 response = sr.ReadToEnd(); 68 Response.Write(response); 69 sr.Close(); // Close and clean up the StreamReader 70 } 71 } 72 }

Delete-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/groups.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="groupkey">testgroup</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Ryhmäjäsenten verkkopalvelun esimerkkejä

Handle

Create-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/groups_members.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="create">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="userkey">testuser</mapping>"); sb.Append("<mapping name="groupkey">testgroup</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } } }

Delete-toiminto

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using System.Text; using System.Xml; using System.Net; using System.Diagnostics; public partial class TestPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { string url = "http://{sitename}/blocks/conduit/webservices/rest/groups_members.php", token = "{token}", response = ""; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version="1.0" encoding="UTF-8"?>"); sb.Append("<data><datum action="delete">"); sb.Append("<mapping name="coursekey">testcourse</mapping>"); sb.Append("<mapping name="userkey">testuser</mapping>"); sb.Append("<mapping name="groupkey">testgroup</mapping>"); sb.Append("</datum&gt; </data>"); string postData = "method=handle&token=" + token + "&xml=" + Server.UrlEncode(sb.ToString()); StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.ContentLength = postData.Length; if (sb.ToString() != "") { try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(postData); } catch (Exception ex) { response = ex.Message; } finally { myWriter.Close(); } } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { response = sr.ReadToEnd(); Response.Write(response); sr.Close(); // Close and clean up the StreamReader } }}