Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: e-learningforkids.org.

Development:e-learningforkids.org: Difference between revisions

From MoodleDocs
(web service response)
Line 121: Line 121:


==Web services==
==Web services==
===Request===


Web service REST scripts could be called similarly to the web display scripts and would return the data structured as XML.
Web service REST scripts could be called similarly to the web display scripts and would return the data structured as XML.
Line 137: Line 139:


The script should employ strong security practices to make sure input data is sanitised before it comes in contact with program language or databases.
The script should employ strong security practices to make sure input data is sanitised before it comes in contact with program language or databases.
===Response===
The response content of web service requests can be XML or JSON format, take XML format for example:
  <courses>
    <course>
      <codename>MA101</codename>
      <coursename>Math 101</coursename>
    </course>
    <course>
      <codename>MA102</codename>
      <coursename>Math 102</coursename>
    </course>
  </courses>
The above response contains two courses: Math 101 and Math 102.
XML format response is readable and widely accepted, but it takes more memory and CPU time to generate and parse, JSON can be easily encoded and decoded by PHP and Javascript, you can get JSON representation of a value by json_encode function, read more:  http://php.net/manual/en/book.json.php

Revision as of 07:07, 9 November 2009

This document is a very quick specification for a re-implementation of e-learningforkids.org using a database and web services, to help them create something that Moodle and similar systems can connect to.

Currently the web site is a set of manually-created web pages and has no database and no services.

Database

All the pages under http://e-learningforkids.org/courses.html should be generated from data in a database table.

Advantages:

  • Easy to add new courses
  • Consistent appearance across pages with minimal maintenance
  • Can provide a search functionality
  • Same data for web site can be used to provide web services, or to generate a CD-ROM version with a customised look and feel, and so on.

This describes a very simple design. A fully normalised design might put authors, licenses, categories, languages, views and other fields into separate tables and just include references between them.

'course' table

Name Type Description
id int Auto-incrementing courseid
coursename varchar Full name of the course
codename varchar A short codename for the course, such as M0601
authors varchar Name of the authoring team etc
license varchar License name of the course content (eg Creative Commons Attribution-Noncommercial-No Derivative Works)
timeadded int The time/date that the course was added
timeupdated int The last time/date that the course was updated
language varchar The language of the course (eg en, es, fr, pt, zh, etc)
category varchar A simple name for the category this course belongs to (eg math, science, computer, language, health etc). The script displaying the page would convert this to something in the appropriate language.
topic varchar A very short description of the content, just a few words.
summary text A one-sentence description of the content
description text A full description of the content, could be pages including teacher's instructions etc
minage int A minimum age that this resource is aimed at
maxage int A maximum age that this resource is aimed at
height int An ideal height for the course, if any, in pixels
width int An ideal width for the course, if any, in pixels
flashfile varchar A relative url to a single flash file if there is only one. Helps external systems avoid the starting page.
views int A count of all the views this course has had

Screenshots do not need to be stored in this table, as they can always be in the same place on the server, using the unique codename (eg http://e-learningforkids.org/screenshots/M0601-en.jpg)

Same for the actual link to the starting page for the course, these can be stored on the server disk in standard locations like http://e-learningforkids.org/courses/M0601-en/index.html

Data entry

To make data entry easier, you'll need scripts to browse, add and update entries in the database. The forms should allow an authenticated user (admin) to add new entries, upload screenshots and date etc.

To make the authentication easier, a CMS like Drupal could be used as the framework for the web site.

The scripts should employ strong security practices to make sure input data is sanitised before it comes in contact with program language or databases.


Web site display

The pages on the web site should be generated using a scripting language like PHP. These scripts call the database for information and build the pages as required.

This could be called http://e-learningforkids.org/courses/index.php and take several parameters such as 'search', 'lang', or 'category' to display different subsets of the database.

The pages should be valid XHTML Strict or HTML 5.

The scripts should employ strong security practices to make sure input data is sanitised before it comes in contact with program language or databases.


Web services

Request

Web service REST scripts could be called similarly to the web display scripts and would return the data structured as XML.

http://e-learningforkids.org/rest.php

might return a list of categories, while

http://e-learningforkids.org/rest.php?category=math 

would return a list of just the math courses, and

http://e-learningforkids.org/rest.php?category=math&minage=5&maxage=10&search=turtle

would return all the math courses for users between 5 and 10 that contain the word "turtle".

The script should employ strong security practices to make sure input data is sanitised before it comes in contact with program language or databases.

Response

The response content of web service requests can be XML or JSON format, take XML format for example:

 <courses>
   <course>
     <codename>MA101</codename>
     <coursename>Math 101</coursename>
   </course>
   <course>
     <codename>MA102</codename>
     <coursename>Math 102</coursename>
   </course>
 </courses>

The above response contains two courses: Math 101 and Math 102.

XML format response is readable and widely accepted, but it takes more memory and CPU time to generate and parse, JSON can be easily encoded and decoded by PHP and Javascript, you can get JSON representation of a value by json_encode function, read more: http://php.net/manual/en/book.json.php