G2 and Moodle

tokyonami

Joined: 2005-09-15
Posts: 10
Posted: Fri, 2005-09-16 02:04

I have some scripts to integrate Moodle and Gallery if anyone is interested. They are development stage and not fully tested. Is there an area on gallery.menalto.com to upload them?

Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Wed, 2005-09-28 23:57

I'm working on a Gallery Module for Moodle and I have run into a snag.

After I call the following code:

$g2data = GalleryEmbed::handleRequest();
if ($g2data['isDone']) {
exit(); // G2 has already sent output (redirect or binary data)
}

The Moodle API for database handling looses its associative array ... ability.

SO, after the above call, Moodle database functions will return

Array
(
[0] => stdClass Object
(
[0] => 1
[1] =>
)
etc...

Instead of
Array
(
[0] => stdClass Object
(
[0] => 1
[sectionnum] => 1
[1] =>
[summary] =>
)
etc....

Here is the moodle function (found in moodle/lib/datalib.php) if it helps:

function get_records_sql($sql) {

global $CFG, $db;

if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; };

if (!$rs = $db->Execute($sql)) {
if (isset($CFG->debug) and $CFG->debug > 7) {
notify($db->ErrorMsg() .'<br /><br />'. $sql);
}
if (!empty($CFG->dblogerror)) {
$debug=array_shift(debug_backtrace());
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
}
return false;
}

if ( $rs->RecordCount() > 0 ) {
if ($records = $rs->GetAssoc(true)) {
foreach ($records as $key => $record) {
$objects[$key] = (object) $record;
}
return $objects;
} else {
return false;
}
} else {
return false;
}
}

I'm running G2 which has a separate install (DB and folder) from my Moodle 1.5.X+ Install
PHP is 4.3.11
Apache Apache/1.3.33 (Darwin) PHP/4.3.11
Doing Localhost on Mac OS 10.3.9

Any help would be appreciated,
Mark

Login or register to post comments
tokyonami

Joined: 2005-09-15
Posts: 10
Posted: Thu, 2005-09-29 00:27

Mark,

Sorry, I am not a programmer, I'm just a teacher using Moodle and Gallery in class. I had the scripts made and can share them with you if it helps. I would be very interested to see how your Gallery Moodle integration works out. I am having a programmer work on an embedded version and will ask him to contact you.

How can I upload my Moodle/Gallery files?

Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Thu, 2005-09-29 03:57

Thanks for the quick reply. Now, for your question...

First, zip up your files (or however you do compression) so there is just one file. Then, post a reply to this comment and attach it using the Attachments section of the comment form. I hope that all makes sense :) When you save your comment, I'll be able to download it and check it out.

Cheers,
Mark

Login or register to post comments
tokyonami

Joined: 2005-09-15
Posts: 10
Posted: Wed, 2005-10-05 03:05

Hi,

I tried to upload a .rar file but upload failed. What types of files does this site support? Here is a ZIP file instead. Let me know if you need more details to install

AttachmentSize
moodle-gallery.zip24.24 KB
Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Wed, 2005-10-05 03:45

Thank you very much for posting this. I'm sure it will be helpful! I'll take a look at the code this week and next. I'll post back with my progress or comments.

Cheers,
Mark

Login or register to post comments
jasonaedwards

Joined: 2005-10-05
Posts: 4
Posted: Thu, 2005-10-06 01:45

the zip file appears to be corrupted. I can download it, but it won't open. Tried a different program, and it unzips, but contains just one file that I cannot open. Is there anyway you can repost the attachment? Thanks!

Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Thu, 2005-10-06 02:18

The zip works fine for me. MacOS X with Stuffit Expander.

Login or register to post comments
tokyonami

Joined: 2005-09-15
Posts: 10
Posted: Sun, 2005-10-09 12:44

Here are the zipped files again. Hope they work. After I create the zip file on my HD, I can open it ok using winzip. If you still have a problem opening it, it might be with the upload function of this forum.

AttachmentSize
gallery_moodle.zip22.15 KB
Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Wed, 2005-10-12 22:40

Through the help of the moodle forums, it was found that $ADODB_FETCH_MODE was getting changed by G2 and thus messing up Moodle. A fix for this should be included in the embed code (perhaps save the value of $ADODB_FETCH_MODE from the embedApp and then restore it after the embed code executes).

For now, I call the following two lines after the G2 embed code to fix the problem:

global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;

Login or register to post comments
Ru4Real
Ru4Real's picture

Joined: 2006-03-02
Posts: 7
Posted: Thu, 2006-03-02 06:24

Hi all

Is the zip in this thread/or is there a working integration for Gallery2 and Moodle anywhere? Been hunting around and have only found a few posts mentioning Moodle (this being the latest) and looking at the integration "How to" but being new to all this have no idea what I'm looking at :(

Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Thu, 2006-03-02 07:03

The zip is an interesting hack to moodle that provides some integration. I'm currently working on a more fully featured integration of moodle and gallery2 by creating a moodle module to embed gallery into moodle. When I have a working version out, I'll post back here (I'm hoping mid March or so).

Cheers

Login or register to post comments
Ru4Real
Ru4Real's picture

Joined: 2006-03-02
Posts: 7
Posted: Fri, 2006-03-03 04:01

Hi watermark

Thanks for the prompt reply and update, I look forward to seeing the results of your work :)

Regards
Harry

Login or register to post comments
watermark
watermark's picture

Joined: 2005-09-28
Posts: 7
Posted: Sat, 2006-03-25 01:26

Moodle/Gallery beta integration released! Check out this forum post at moodle.org for more information: http://moodle.org/mod/forum/discuss.php?d=42459#194827

Login or register to post comments