Sunday, August 16, 2009

Pencils down

Today is the firm 'pencils down' date, and I am happy with my accomplishments this summer. My completed project includes the old features mentioned in previous posts and the new ones I have been working on lately:

- Moodle Forms. Ability to fill out a form, save it, store it in the local database and synchronize (save the data in the remote db) when switching to online mode. At the same time, I began following a structured way to deal with different tables (so far Logs and Moodle Forms). The goal would be to have a nice, similar to the existing database API to deal with all the interactions that require changes to the database. Offline forms do not support file uploading at the moment.

- Assignments are also accessible in offline mode. Similar to the Forums module, all the student's assignments are cached for offline visualization.

- A WorkerPool script to cache all the static files in the background. This helps to speed up Moodle similar to the turbo version of Wordpress.

- An option to "go offline", provided the user is logged in. The site page and the course pages are cached, as well as each module's main page and all forums. In offline mode, all the unavailable links are disabled through JavaScript.

- An indicator of the connection availabiliity. Currently this is used to generate warnings, but in the future we could use it to go automatically offline or online.

- A progress bar to indicate the percentage of files cached.

Future work

Even though the program of GSoC is over, integrating an offline implementation to Moodle is an ongoing task, which will not be entirely ready until the official 2.0 release is made. I really had fun working on this project, and I would like to continue spending time on it, maintaining the code, fixing bugs, and adding features.

For all of those interested in following the work I have started, I suggest to focus on local database API's, HTML 5 offline caching implementation, file uploading, more modules and backward compatibility.

And now I would like to thank Dongsheng Cai for his patience, feedback and incredible support. Thanks a lot also to Helen Foster, my co-mentors and the rest of the Moodle community for being part of this work. I hope many users can benefit from my contribution, and that this project becomes the beginning of much more advanced offline support for Moodle.

Tuesday, August 4, 2009

Synch

Last week, my mentor and I defined the next top priorities for this project:

- Offline logs (tracking user activity), and updating the log table in the remote database.
- Offline Moodle forms
- More offline modules (assignment, more if possible)

In other words, we want to spend the last official weeks of GSoC dealing with synchronization of local and remote databases. This is the most interesting aspect of offline web applications: being able to make changes and update them when we get online. I spent the last few days dealing with the first of those three priorities: logs. At this stage, all the user activity in the accessible modules / pages is recorded and updated when the user goes into online mode. However, these activities will be recorded twice because, when we create the local store, Moodle thinks that the user has visited all the cached pages (the PHP code adds the logs when gathering the HTML output). Therefore, this week I would like to spend some time fixing this repetition and getting started with moodle forms and other modules.

I also want to improve the user interface, add a progress bar when going synchronizing the databases, and add a desktop functionality similar to the one of the Google sites. Remember to download the latest copy of my own repository at http://github.com/ajv/Offline-Caching/
All feedback, ideas and bugs found are greatly appreciated. Thanks!

Tuesday, July 28, 2009

Progressbar, YUI and Databases

This past week I finally got started with the Gears Database API. I'm looking into ways of handling logs while offline, and then synchronizing back when we recover the connection. Logs are the most frequently updated entries in the Moodle database, so this code needs to be done first and in an efficient way. Logs track all the activity, and they are useful for creating reports and learning more about the users. The problem comes when we try to save information that the remote server would know (IP address, for example), but doing so locally, without any connection and without our useful server scripts. Therefore, my task these days is to somehow translate the relevant PHP code into JavaScript, deal with a local database and synch with the remote one. I hope to finish this code soon.

I also added a progress bar to the user interface for calculating the time to go offline and I am getting more involved with the YUI library and other ajaxy stuff. More to come soon...

Tuesday, July 21, 2009

TURBO!

I just finished coding the transition to a Moodle in turbo version. Using the workerpool class provided by Gears, I created a patch to download all the static files in Moodle, without slowing down the user's experience. Once all the static files are cached, the application will use these from the local server, reducing the time to get them online and improving the performance. Again, this is just in testing version, so any comments or bugs found are more than welcome.

I also added a percentage indicator when switching to offline mode. My goal is to make it look similar to the Google apps running GG (Docs, Gmail, Reader, etc). Therefore I will also code a desktop function and move on to a nicer UI. Handling logs and synchronizing changes is also in my near future todo list, as well as dealing with the local database.

Tuesday, July 14, 2009

Midway through

I spent the past week working on disabling the unavailable features when offline. It seems to be working fine, but I need help from the community to make sure there are no bugs or regressions.

I also added a graphical button to check the server availability. This week I will begin using the WorkerPool for running JavaScript in the background. A possible use for this will be storing all the static files and improve the performance of Moodle. I also need to start looking into handling logs (again) and figure out how to run PHP scripts offline. When I get all these things working and well tested, I will move on to the most challenging part: synchronizing data.

Monday, July 6, 2009

Forums

I just finished an integration of the Forum activity into the offline caching implementation. A user should now be able to go into "offline" mode and be able to browse through his/her accessible forums. This functionality will need some testing as I continue coding. Remember to visit http://github.com/ajv/Offline-Caching/ to see the actual code. Next: going back to JavaScript and hacking the DOM.

Sunday, July 5, 2009

Home Sweet Home

I arrived home last Sunday. After recovering from the jet lag and settling down, I continued working on Moodle. There were many changes in the output interface for Moodle 2.0, and I needed to adjust these changes with my code for the offline caching integration. Until then, I had been using a library that will be deprecated in the next major release of Moodle. I had to change this part of the code constantly, and I spent the past week modifying the calls to JavaScript funcions, stylesheets, and module icons, for example, as they play a major role in the manifest declaration. I also began using github more activily so that anyone can watch my progress without the need of patches that would become useless after a few hours (see http://github.com/ajv)

This week is midterm evaluations. I am confident about my project and that I will finish on time, specially now that I'm done with schoolwork and exams. My main goal for this week is to have the module called "Forums" ready for offline visualization. At this point it would be too hard to make the user add a comment while "offline" and then synchronize. What I want to achieve is that the user is at least capable of going through all his/her accessible forum threads without an internet connection. We will leave the synchronizing part for later, when the base architecture gets tested thoroughly. The same goes for other modules. Then I will continue working on handling logs of the user activity and on letting the user know which links are not available (dealing with the DOM has taken more time so I'm leaving it for later). And of course, I will continue looking into the new functions of Moodle 2.0 to update my code and make it more flexible with any new additions.