Module repositories

Re: Module repositories

by Mark Hughes -
Number of replies: 0

Alright....our last exchange got me to thinking....and I think I've got something that'll make everybody happy.  We've got a list of the sites, we could go into the directories and take what's different (different=stuff we want).  But that wouldn't solve the problem of courses, glossaries, and themes (which ideally would be tarred or zipped).  So whether for Moodle.org or the casual moodle user, we could use this function (which is a tad overbuilt) to find registered sites (based on the list maintained at http://moodle.org/sites/index.php) and that gives us a place to start.

//this code takes the information at moodle.org/sites/index.php
//and tosses away everything that isn't a url

<?php
function link_miner($siteurl){
    $MoodleSites = curl_init($siteurl);
    //CURLOPT_RETURNTRANSFER returns the page as a string
    curl_setopt($MoodleSites, CURLOPT_RETURNTRANSFER, 1);
 //get the file and put it into $FileString
    $FileString = curl_exec($MoodleSites);
    //now extract sites
    $a = array();
 //suck up everything except the bookmarks, leave spaces where bookmarks are for debugging purposes
    if (preg_match_all('/<a\s+.*?href=[\"']?([^#\"' >]*)[\"']?[^>]*>(?:.*?)<\/a>/i', $FileString, $matches,PREG_SET_ORDER)){
      foreach($matches as $match) {
        array_push($a,array($match[1]));
      }
    }
$c=0; 
$stringa = '';
    while($c < count($a)){
  //decide how to put data into string comma seperated, etc...
        if($a[$c]['0']){ //only print if there is something there; remove spaces left for bookmarks
  $stringa .= $a[$c]['0']."<BR>";
  }
  $stringb = preg_replace('/,,/',',',$stringa);
  
        $c +=1;
    }
echo $stringb;  //change to return...depends on what ends up happening from here.
}

link_miner('http://moodle.org/sites/index.php');

?>

We could add some file pulling utility to this and have a wealth of information right now...but it'd be rude to grab food off of other people's plate without asking.....so here's what I was thinking -- we add a folder caled "shared" (or whatever) to the standard moodle distribution and the little "share me" button to courses, themes, glossaries, etc.  In the case of glossaries, the "share me" button would cause an export of the glossary to be written to the "shared" folder.  In the case of courses, it would provide a soft-link to the automated course backup...yada, yada, yada.  Moodle.org would run a crontask every hour or so and go find new things with a file utility.

    But how to give a file description?  Probably not worth the hassle to write more information to the database (we'd need an authorized user to retrieve it and also probably a little difficult to synchronize with a file).  So to the things we want to share, how about a form that creates a short txt file with description and author info that'll reside in the same folder as the file we want to share...once moodle.org sucks it over we could toss it into the database for ratings and the like.

What do you think would be the most efficient way for all of this to go?

Mark