Saltar al contenido principal
pdf?stylesheet=default
Blackboard Help

Ejemplos: Subir archivos, Obtener comandos y Manejar comandos

En esta página
  1. Formatos de archivos CSV
  2. Formatos de archivos XML
  3. Servicios web de Conduit
    1. Obtener y manejar métodos de comandos para servicios web
      1. Estructura básica
    2. Servicio web del usuario
      1. Extremo
      2. Métodos
        1. GET_USER
        2. GET_USER_COURSE_RECENT_ACTIVITY
        3. GET_USER_COURSE_ACTIVITIES_DUE
        4. GET_USER_COURSE_EVENTS
        5. GET_USER_GRADES
        6. Controlador
    3. Servicios web del curso
      1. Extremo
      2. Métodos
        1. GET_COURSE
        2. get_course_grades
        3. CONTROLADOR
  4. Extremo de servicio web de las matriculaciones
    1. Métodos
      1. CONTROLADOR
    2. Extremo de servicio web de la asignación de roles
    3. Métodos
      1. CONTROLADOR
    4. Servicios web de grupos
      1. Extremo
      2. Métodos
        1. CONTROLADOR
        2. GET_GROUPS
    5. Definición del servicio web de los miembros del grupo
      1. Extremo
      2. Métodos
        1. CONTROLADOR
        2. RESPONDER DEFINICIÓN XML
    6. Ejemplos del código del servicio web de PHP Conduit
      1. Métodos
        1. get_user
        2. get_user_course_recent_activity
        3. get_user_course_activities_due
        4. get_user_course_events
        5. get_user_grades
        6. Controlador
    7. Ejemplos del servicio web del curso
      1. Métodos
        1. get_course
        2. get_course_grades
      2. Controlador
    8. Ejemplos del servicio web de la matriculación
      1. Controlador
    9. Ejemplos del servicio web de la asignación de roles
      1. Controlador
    10. Ejemplos del servicio web de los grupos
      1. Método
        1. get_groups
      2. Controlador
        1. get_user_grades
    11. Ejemplos del servicio web de los miembros del grupo
      1. Controlador
      2. get_user_grades
  5. Ejemplos del código del servicio web de ASP.Net Conduit
    1. Ejemplos del servicio web del usuario
      1. Métodos
        1. get_user
        2. get_user_course_recent_activity
        3. get_user_course_activities_due
        4. get_user_course_events
        5. get_user_grades
        6. Controlador
    2. Ejemplos del servicio web del curso
      1. Métodos
        1. get_course
        2. get_course_grades
        3. Controlador
    3. Ejemplos del servicio web de la matriculación
      1. Controlador
      2. get_user_grades
    4. Ejemplos del servicio web de la asignación de roles
      1. Controlador
    5. Ejemplos del servicio web de los grupos
      1. Métodos
        1. get_groups
        2. Controlador
    6. Ejemplos del servicio web de los miembros del grupo
      1. Controlador

En esta sección se incluyen ejemplos de los formatos de archivos CSV y formatos de archivos XML en caso de subir archivos. Para los administradores que actualizan Moodle mediante servicios web, esta sección también contiene ejemplos de obtener y manejar comandos, además de códigos de servicios web PHP y ASP.net.

Formatos de archivos CSV

Cualquier registro de las tablas de Conduit puede exportarse en formatos CSV y Excel. Los datos que se exportarán son los datos que coinciden con los ajustes del filtro. Para exportar los datos de la tabla, haga clic en el menú desplegable Exportar y seleccione el formato de archivo con el que desea exportar. Según el navegador que utilice, aparecerá el cuadro de diálogo Guardar.

  • Curso: Crear, actualizar y eliminar cursos.
  • Usuario: Crear, actualizar y eliminar usuarios.
  • Matriculación del curso: Crear, actualizar y eliminar matriculaciones.
  • Asignar un padre a un usuario: Crear, actualizar y eliminar asignaciones de roles.
  • Grupos: Crear, actualizar y eliminar grupos.
  • Miembros del grupo: Crear, actualizar y eliminar miembros del grupo.

Formatos de archivos XML

Curso: Crear, actualizar y eliminar cursos.

<?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>

Usuario: Crear, actualizar y eliminar usuarios.

<?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">joesmith@example.com</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>

Matriculación del curso: Crear, actualizar y eliminar matriculaciones.

<?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>

Asignar un padre a un usuario: Crear, actualizar y eliminar matriculaciones.

<?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>

Grupos: Crear, actualizar y eliminar grupos.

<?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>

Miembros del grupo: Crear, actualizar y eliminar miembros del grupo.

<?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>

Servicios web de Conduit

El servicio web RESTful de Conduit está dividido en diferentes extremos de servicio web:

  1. course
  2. enroll
  3. groups
  4. group_members
  5. role_assign
  6. user

Cada servicio web RESTful de Conduit se ejecuta desde una URL HTTPS. Una URL de ejemplo es la siguiente:

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

El sitio será reemplazado con la URL del sitio de Moodlerooms del cliente, normalmente por algo similar a clientname.mrooms.net. El service_name se reemplazará con cualquier usuario, curso, matriculación, grupo o miembro del grupo.

Cada uno de los servicios web RESTful de Conduit requiere que se envíen dos variables de mensaje HTML a través de una llamada HTTPS. Estas variables son las siguientes:

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado con el nombre del método que se está ejecutando.

Obtener y manejar métodos de comandos para servicios web

Estructura básica

La estructura XML básica para todas las solicitudes de todos los extremos que usan el método "controlador" es de la siguiente manera:

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

Hay tres valores variables dentro de esta estructura básica: acción, nombre de mapeo y valor. La variable de la acción contiene la acción que desea que Conduit ejecute. El nombre de mapeo es el valor del campo mapeado de Conduit que la variable del valor configurará. Por ejemplo, si quisiera actualizar el campo mapeado llamado “username” a “johndoe”, mi XML sería de la siguiente manera:

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

Cada solicitud de XML puede tener datos con sus propias acciones, y un archivo XML también puede combinar tipos de acciones.

La estructura de respuesta XML de Conduit es de la siguiente manera. Cada extremo de servicio web responderá de manera similar. La única parte que cambiará es la variable del nombre de servicio en la siguiente estructura. Este valor será el nombre del extremo.

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

Servicio web del usuario

Extremo

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

Métodos

GET_USER

Obtenga los datos de perfil de un usuario de Moodle con los campos del perfil personalizado.

PARÁMETROS POST:

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como get_user.
  • string value: (Obligatorio) El valor del usuario que se debe buscar, como el nombre del usuario.
  • string field: (Opcional, predeterminado: nombre de usuario) El campo de la tabla de Moodle en que se realiza la búsqueda. Puede ser ID, nombre de usuario, número de ID o correo electrónico.

ESQUEMA XML DEVUELTO

<?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

El método get_user_course_recent_activity del servicio web del usuario de Conduit proporciona una interfaz externa para recuperar información acerca de todas las actividades que se agregaron, actualizaron o eliminaron durante un período en los cursos en los que un usuario está matriculado.

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method:(Obligatorio) Debe estar configurado como get_user_course_recent_activity.
  • string username: (Obligatorio) El otro nombre del usuario.
  • string course: (Opcional, predeterminado: NULO) El número de ID del curso; si no está aprobado, se devuelven todos los cursos del usuario.
  • int fromdate: (Opcional, predeterminado: NULO) Marca de tiempo de UNIX de la fecha de inicio.

FORMATO XML DEVUELTO

<?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>

EJEMPLO DE XML DEVUELTO

<?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

El método get_user_course_activities_due del servicio web del usuario de Conduit proporciona acceso externo a las actividades que un usuario debe entregar en un curso dentro de un determinado período.

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como get_user_course_activities_due.
  • string username: (Obligatorio) El nombre de usuario del usuario.
  • int todate: (Obligatorio) Marca de tiempo de Unix de la fecha de finalización.
  • string course: (Opcional, predeterminado = NULO) El número de ID del curso; si no está aprobado, se devuelven todos los cursos del usuario.

FORMATO XML DEVUELTO

<?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>

EJEMPLO DE XML DEVUELTO

<?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

El método get_user_course_events del servicio web del usuario de Conduit proporciona acceso externo a los eventos del curso del usuario dentro de un curso. Utilice el servicio get_user_course_activities_due para acceder a las fechas de entrega de la actividad.

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como get_user_course_events.
  • string username: (Obligatorio) El otro nombre del usuario.
  • int fromdate: (Obligatorio) Marca de tiempo de UNIX de la fecha de inicio.
  • int todate: (Obligatorio) Marca de tiempo de UNIX de la fecha de finalización.
  • string course: (Opcional, predeterminado: NULO) El número de ID del curso; si no está aprobado, se devuelven todos los cursos del usuario.

FORMATO XML DEVUELTO

<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>

EJEMPLO DE XML DEVUELTO

<?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

Los servicios web del curso y usuario de Conduit proporcionan sistemas externos con una manera de extraer calificaciones de Moodle. Hay ajustes específicos para estos servicios y pueden encontrarse en la sección Calificaciones en la subficha Ajustes de Conduit > Servicios web. Conduit proporciona dos extremos para recuperar las calificaciones de Moodle.

PARÁMETROS POST:

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la subficha Ajustes de Conduit > Servicios web.
  • string method:(Obligatorio) Debe estar configurado como get_user_grades.
  • string user: (Obligatorio) El usuario al que se deben devolver las calificaciones.
  • int batchsize: (Opcional) La cantidad de calificaciones que se deben devolver. Debe ser menos de 10 000.
  • int lastprocessedid: (Opcional) El ID de la última calificación procesada y devuelta desde el servicio web. Esto ayuda a pasar a través de todas las calificaciones de Moodle porque si lo aprueba, el servicio solo devolverá calificaciones con ID superiores a este.
  • int starttime:(Opcional) Utilice para obtener calificaciones que han sido modificadas después de esta hora. Se aprueba en la forma de una marca de tiempo UNIX.
  • int endtime: (Opcional) Utilice para obtener calificaciones que han sido modificadas antes de esta hora. Se aprueba en la forma de una marca de tiempo UNIX.
  • string course: (Opcional) Utilice para obtener calificaciones de un curso específico para el usuario. El valor debe ser el nombre corto del curso o el número de ID según el ajuste "ID del curso" que se encuentra en la subficha Ajustes de Conduit > General. Si se omite, se devolverán todas las calificaciones del usuario.
  • string itemtypes: (Opcional, predeterminado: DEFAULT_SET) Aprueba una lista de CSV de tipos de elementos de calificación que se deben incluir. Para todos los tipos de elementos, aprueba una cadena vacía. Para obtener los elementos de calificación predeterminados que están configurados a través de Conduit, no apruebe este parámetro o configúrelo como DEFAULT_SET.

ESQUEMA XML DEVUELTO

Ambos extremos de servicios web de calificación devuelven el mismo esquema XML. El esquema devuelve los elementos de calificación y sus calificaciones. Las etiquetas de curso y usuario actúan como diccionarios ya que contienen todos los usuarios y cursos a los que pertenecen los elementos de calificación y las calificaciones. Utilice las etiquetas de ID del usuario e ID del curso para buscar los cursos y usuarios correspondientes. La etiqueta lastprocessedid es el ID de la última calificación que el servicio web procesó. Utilice este valor si desea usar el parámetro lastprocessedid del servicio web.

<?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>

item types: curso, mod, categoría, manual, nulo

Controlador

PARÁMETROS POST

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la subficha Ajustes de Conduit > Servicios web.
  • string method: (Obligatorio) Debe estar configurado como controlador.
  • string xml: (Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Actualizar
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ACTUALIZAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

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

RESPONDER DEFINICIÓN XML

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

Servicios web del curso

Extremo

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

Métodos

GET_COURSE

Obtenga los ajustes del curso de Moodle.

PARÁMETROS POST

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method:(Obligatorio) Debe estar configurado como get_course.
  • string value: (Obligatorio) El valor del curso que se debe buscar, como el nombre corto del curso.
  • string field: (Opcional, predeterminado = nombre corto) El campo de la tabla de Moodle en que se realiza la búsqueda. Puede ser ID, nombre corto o número de ID.

ESQUEMA XML DEVUELTO

<?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

El método get_course_grades de los servicios web del curso de Conduit proporcionó sistemas externos con una manera de extraer calificaciones de Moodle.

Hay ajustes específicos para estos servicios web de calificaciones y pueden encontrarse en la sección Calificaciones en la ficha Ajustes de Conduit > subficha Servicios web.

El valor get_course_grades devuelve todas las calificaciones para todos los usuarios del curso incluso si fueron desmatriculados del curso.

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method:(Obligatorio) Configurado como get_course_grades.
  • string course: (Opcional) Utilice para obtener calificaciones de un curso específico para el usuario. El valor debe ser el nombre corto del curso o el número de ID según el ajuste ID del curso que se encuentra en la subficha Ajustes de Conduit > General. Si se omite, se devolverán todos los cursos.
  • int batchsize:(Opcional) La cantidad de calificaciones que se deben devolver. Debe ser menos de 10 000.
  • int lastprocessedid: (Opcional) El ID de la última calificación procesada y devuelta desde el servicio web. Esto ayuda a pasar a través de todas las calificaciones de Moodle porque si lo aprueba, el servicio solo devolverá calificaciones con ID superiores a este.
  • int starttime: (Opcional) Utilice para obtener calificaciones que han sido modificadas después de esta hora. Se aprueba en la forma de una marca de tiempo UNIX.
  • int endtime: (Opcional) Utilice para obtener calificaciones que han sido modificadas antes de esta hora. Se aprueba en la forma de una marca de tiempo UNIX.
  • string itemtypes: (Opcional, predeterminado: DEFAULT_SET) Aprueba una lista de CSV de tipos de elementos de calificación que se deben incluir. Para todos los tipos de elementos, aprueba una cadena vacía. Para obtener los elementos de calificación predeterminados que están configurados a través de Conduit, no apruebe este parámetro o configúrelo como DEFAULT_SET.

ESQUEMA XML DEVUELTO

El esquema devuelve los elementos de calificación y sus calificaciones. Las etiquetas de curso y usuario actúan como diccionarios ya que contienen todos los usuarios y cursos a los que pertenecen los elementos de calificación y las calificaciones. Utilice las etiquetas de ID del usuario e ID del curso para buscar los cursos y usuarios correspondientes. La etiqueta lastprocessedid es el ID de la última calificación que el servicio web procesó. Utilice este valor si desea usar el parámetro lastprocessedid del servicio web.

<?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>

Item types: curso, mod, categoría, manual, nulo.

CONTROLADOR

PARÁMETROS POST

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como controlador.
  • string xml: (Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Actualizar
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ACTUALIZAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

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

RESPONDER DEFINICIÓN XML

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

Extremo de servicio web de las matriculaciones

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

Métodos

CONTROLADOR

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como controlador.
  • string xml: (Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Actualizar
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ACTUALIZAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

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

RESPONDER DEFINICIÓN XML

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

Extremo de servicio web de la asignación de roles

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

Métodos

CONTROLADOR

PARÁMETROS POST

  • string token:(Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method:(Obligatorio) Debe estar configurado como controlador.
  • string xml:(Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Actualizar
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ACTUALIZAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

<?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>

RESPONDER DEFINICIÓN XML

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

Servicios web de grupos

Extremo

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

Métodos

CONTROLADOR

PARÁMETROS POST

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como controlador.
  • string xml: (Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Actualizar
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ACTUALIZAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

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

RESPONDER DEFINICIÓN XML

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

Obtenga los grupos de un curso.

PARÁMETROS POST

  • string method:(Obligatorio) Debe estar configurado como get_groups.
  • string value: (Obligatorio) El valor del curso que se debe buscar.
  • string field: (Opcional, predeterminado: número de ID) El campo del curso al que se relaciona el valor; puede ser ID, nombre corto o número de ID.

RESPONDER DEFINICIÓN XML

  <?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>

Definición del servicio web de los miembros del grupo

Extremo

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

Métodos

CONTROLADOR

PARÁMETROS POST

  • string token: (Obligatorio) Configurado con el valor de ajuste de Token utilizado en la ficha Ajustes de Conduit > subficha Servicios web.
  • string method: (Obligatorio) Debe estar configurado como get_user_course_events.
  • string xml:(Obligatorio) Esquema XML que contiene datos para operaciones realizadas en registros de Conduit.

ACCIONES VÁLIDAS

  • Crear
  • Eliminar

CREAR DEFINICIÓN XML DE ACCIÓN

<?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>

ELIMINAR DEFINICIÓN XML DE ACCIÓN

<?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>
RESPONDER DEFINICIÓN XML
  <Service_group_members generator="zend" version="1.0">
    <handle>
        <message>MESSAGE</message>
        <status>STATUS</status>
    </handle>
</Service_Rest_GroupmMembers>

Ejemplos del código del servicio web de PHP Conduit

Métodos

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' => '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' => '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' => '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' => 'guest',
                                    'fromdata' => '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' => '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>';
    ?>
Controlador

A continuación, se indican ejemplos de archivos controladores que puede usar para crear registros.

Acción Crear

<?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"> test@localhost.com</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>';
?>

Acción Actualizar

<?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">test@localhost.com</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>';
?>

Acción Eliminar

<?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>';
?>

Ejemplos del servicio web del curso

Métodos

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>';
    ?>

Controlador

A continuación, se indican ejemplos de archivos controladores que puede usar para crear registros.

Acción Crear

<?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>';
?>

Acción Actualizar

<?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>';
?>

Acción Eliminar

<?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>';
?>

Ejemplos del servicio web de la matriculación

Controlador

Acción Añadir

<?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>';
?>

Acción Soltar

<?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>';
?>

Ejemplos del servicio web de la asignación de roles

Controlador

Acción Añadir

<?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>';
?>

Acción Soltar

<?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>';
?>

Ejemplos del servicio web de los grupos

Método

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' => '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>';
    ?>

Controlador

get_user_grades

Acción Crear

<?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>';
?>

Acción Actualizar

<?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>';
?>

Acción Eliminar

<?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>';
?>

Ejemplos del servicio web de los miembros del grupo

Controlador

Acción Crear

<?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>';
?>

Ejemplos del código del servicio web de ASP.Net Conduit

Ejemplos del servicio web del usuario

Métodos

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
 
        }
 
    }
 
}
 
Controlador

A continuación, se indican ejemplos de archivos controladores que puede usar para crear registros.

Acción Crear

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">
 testuser@localhost.com
 </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> </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
 
        }
 
    }
 
}
 

Acción Actualizar

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">
 testuser@localhost.com</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> </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
 
        }
 
    }
 
}
 

Acción Eliminar

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> </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
 
        }
 
    }
 
}
 

Ejemplos del servicio web del curso

Métodos

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
 
        }
 
    }
 
}
 
Controlador

A continuación, se indican ejemplos de archivos controladores que puede usar para crear registros.

Acción Crear

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> </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
 
        }
 
    }
 
}
 

Acción Actualizar

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> </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
 
        }
 
    }
 
}
 

Acción Eliminar

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> </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
 
        }
 
    }
 
}
 

Ejemplos del servicio web de la matriculación

Controlador

Acción Crear

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> </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
 
        }
 
    }
 
}
 

Acción Actualizar

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> </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> </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
 
        }
 
    }
 
}
 

Ejemplos del servicio web de la asignación de roles

Controlador

Acción Crear

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> </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
 
        }
 
    }
 
}
 

Acción Actualizar

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> </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
 
        }
 
    }
 
}
 

Acción Eliminar

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> </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
 
        }
 
    }
 
}
 

Ejemplos del servicio web de los grupos

Métodos

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
 
        }
 
    }
 
}
 
Controlador

Acción Crear

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> </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
 
        }
 
    }
 
}
 

Acción Actualizar

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> </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 }
 

Acción Eliminar

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> </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
 
        }
 
    }
 
}
 

Ejemplos del servicio web de los miembros del grupo

Controlador

Acción Crear


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> </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
 
        }
 
    }
 
}
 

Acción Eliminar

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> </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
        }
    }
}