Skip to content

Commit

Permalink
Version 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrodriguez-dis committed Sep 26, 2013
0 parents commit fc8a41f
Show file tree
Hide file tree
Showing 165 changed files with 25,231 additions and 0 deletions.
9 changes: 9 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Development: Juan Carlos Rodriguez-del-Pino, jcrodriguez@dis.ulpgc.es
Online help: Margarita Díaz-Roca, José Daniel González-Domínguez, Zenón Hernández-Figueroa
Translations:
Catalan: Antonio Piedras Morente
Japanese: Imaizumi Takashi
Polish: Marcin Kolodziej, Michal Kedzia
German: Lang Michael: michael.lang.ima10@fh-joanneum.at,
Lückl Bernd: bernd.lueckl.ima10@fh-joanneum.at and
Lang Johannes: johannes.lang.ima10@fh-joanneum.at
674 changes: 674 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
===========================================
VPL - Virtual Programming Lab for Moodle 2
===========================================

VPL is a programming assignment management system that lets edit and execute
programs and enable the automatic and continuous assessment.

This software is distributed under the terms of the General Public License
(see http://www.gnu.org/licenses/gpl.txt for details)

This software is provided "AS IS" without a warranty of any kind.

For more detail access the web site http://vpl.dis.ulpgc.es

258 changes: 258 additions & 0 deletions backup/moodle1/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
<?php
/**
* Provides support for the conversion of moodle1 backup to
* the moodle2 backup format
*
* @version $Id: lib.php,v 1.1 2012-06-05 23:22:20 juanca Exp $
* @package VPL
* @copyright 2012 Juan Carlos Rodríguez-del-Pino
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Juan Carlos Rodríguez-del-Pino <jcrodriguez@dis.ulpgc.es>
*/

defined('MOODLE_INTERNAL') || die();

/**
* VPL conversion handler
*/
class moodle1_mod_vpl_handler extends moodle1_mod_handler {

/** @var moodle1_file_manager */
protected $fileman = null;

/** @var int cmid */
protected $moduleid = null;

/** @var int module id */
protected $instanceid = null;

/**
* Declare the paths in moodle.xml we are able to convert
*
* The method returns list of {@link convert_path} instances.
* For each path returned, the corresponding conversion method must be
* defined.
*
* Note that the path /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL does not
* actually exist in the file. The last element with the module name was
* appended by the moodle1_converter class.
*
* @return array of {@link convert_path} instances
*/
public function get_paths() {
return array(
new convert_path(
'vpl', '/MOODLE_BACKUP/COURSE/MODULES/MOD/VPL',
array(
'newfields' => array(
'emailteachers' =>0,
'worktype' => 0

),
'renamefields' => array(
'availablefrom' => 'startdate'
),
'dropfields' => array(
'visiblefrom'
)
)
)
,
new convert_path(
'vpl_variations', '/MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/VARIATIONS'
)
,
new convert_path(
'vpl_variation', '/MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/VARIATIONS/VARIATION'
)
,
new convert_path(
'vpl_submissions', '/MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/SUBMISSIONS'
)
,
new convert_path(
'vpl_submission', '/MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/SUBMISSIONS/SUBMISSION'
,
array(
'newfields' => array(
'mailed' =>0,
'highlight' => 0
)
)
)
);
}

public function get_data_path() {
return $this->converter->get_tempdir_path().'/moddata/vpl/';
}

public function get_config_path() {
return $this->get_data_path().$this->instanceid.'/config/';
}

public function get_submission_path($userid,$subid) {
return $this->get_data_path().$this->instanceid.'/usersdata/'.
$userid.'/'.$subid.'/';
}

public function get_fulldescription() {
$path = $this->get_config_path().'fulldescription.html';
if(file_exists($path)){
return file_get_contents($path);
}
return '';
}

private function get_files($base,$dirname){
$files = array();
$filelst =$dirname.'.lst';
$extrafiles=array($filelst,$filelst.'.keep','submitedfilelist.txt',
'compilation.txt','execution.txt','grade_comments.txt');
foreach($extrafiles as $file){
if(file_exists($base.$file)){
$data = array();
$data['name'] =$file;
$data['content'] = file_get_contents($base.$file);
$files[] = $data;
}
}
$dirpath = $base.$dirname;
if(file_exists($dirpath)){
$dirlst = opendir($dirpath);
while (false !== ($filename=readdir($dirlst))) {
if ($filename=="." || $filename=="..") {
continue;
}
$data = array();
$data['name'] =$dirname.'/'.$filename;
$data['content'] = file_get_contents($dirpath.'/'.$filename);
$files[] = $data;
}
closedir($dirlst);
}
return $files;
}
public function process_execution_files() {
$files = $this->get_files($this->get_config_path(),'execution_files');
if(count($files)>0){
$this->xmlwriter->begin_tag('execution_files');
foreach($files as $file){
$this->write_xml('execution_file',$file);
}
$this->xmlwriter->end_tag('execution_files');
}
}

public function process_required_files() {
$files = $this->get_files($this->get_config_path(),'required_files');
if(count($files)>0){
$this->xmlwriter->begin_tag('required_files');
foreach($files as $file){
$this->write_xml('required_file',$file);
}
$this->xmlwriter->end_tag('required_files');
}
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL
* data available
*/
public function process_vpl($data) {
// get the course module id and context id
$this->instanceid = $data['id'];
$cminfo = $this->get_cminfo($this->instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);

// Get intro from file
$data['intro'] = $this->get_fulldescription();
$data['introformat'] = 1;

// start writing vpl.xml
$this->open_xml_writer("activities/vpl_{$this->moduleid}/vpl.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $this->instanceid, 'moduleid' => $this->moduleid,
'modulename' => 'vpl', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('vpl', array('id' => $this->instanceid));

foreach ($data as $field => $value) {
if ($field <> 'id') {
$this->xmlwriter->full_tag($field, $value);
}
}
$this->process_required_files();
$this->process_execution_files();
return $data;
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/VARIATIONS/VARIATIONS
* data available
*/
public function on_vpl_variations_start() {
$this->xmlwriter->begin_tag('variations');
}

public function on_vpl_variations_end() {
$this->xmlwriter->end_tag('variations');
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/VARIATIONS/VARIATIONS/VARIATION
* data available
*/
public function process_vpl_variation($data) {
$this->write_xml('variation', $data, array('/variation/id'));
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/SUBMISSIONS
* data available
*/
public function on_vpl_submissions_start() {
$this->xmlwriter->begin_tag('submissions');
}

public function on_vpl_submissions_end() {
$this->xmlwriter->end_tag('submissions');
}

public function process_submitted_files($userid,$subid) {
$path = $this->get_submission_path($userid,$subid);
$files = $this->get_files($path,'submitedfiles');
if(count($files)>0){
$this->xmlwriter->begin_tag('submission_files');
foreach($files as $file){
$this->write_xml('submission_file',$file);
}
$this->xmlwriter->end_tag('submission_files');
}
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/VPL/SUBMISSIONS/SUBMISSION
* data available
*/
public function process_vpl_submission($data) {
$this->xmlwriter->begin_tag('submission',$data,array('/submission/id'));
$this->process_submitted_files($data['userid'],$data['id']);
$this->xmlwriter->end_tag('submission');
}

/**
* This is executed when we reach the closing </MOD> tag of 'vpl'
*/
public function on_vpl_end() {
// finish writing vpl.xml
$this->xmlwriter->end_tag('vpl');
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();

// write inforef.xml
$this->open_xml_writer("activities/vpl_{$this->moduleid}/inforef.xml");
$this->xmlwriter->begin_tag('inforef');
$this->xmlwriter->end_tag('inforef');
$this->close_xml_writer();
}
}
51 changes: 51 additions & 0 deletions backup/moodle2/backup_vpl_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* VPL backup task class that provides all the settings and steps to perform one
* complete backup of the activity
*
* @version $Id: backup_vpl_activity_task.class.php,v 1.2 2012-06-20 14:55:49 juanca Exp $
* @package VPL
* @copyright 2012 Juan Carlos Rodríguez-del-Pino
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Juan Carlos Rodríguez-del-Pino <jcrodriguez@dis.ulpgc.es>
*/

defined('MOODLE_INTERNAL') || die();
require_once dirname(__FILE__).'/backup_vpl_stepslib.php';

class backup_vpl_activity_task extends backup_activity_task {

/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity
}

/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
$this->add_step(new backup_vpl_activity_structure_step('vpl_structure', 'vpl.xml'));
}

/**
* Code the transformations to perform in the activity in
* order to get transportable (encoded) links
*/
static public function encode_content_links($content) {
global $CFG;

$base = preg_quote($CFG->wwwroot,"/");

// Link to the list of VPL instances
$search="/(".$base."\/mod\/vpl\/index.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@VPLINDEX*$2@$', $content);

// Link to VPL view by moduleid
$search="/(".$base."\/mod\/vpl\/view.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@VPLVIEWBYID*$2@$', $content);

return $content;
}
}
Loading

0 comments on commit fc8a41f

Please sign in to comment.