Skip to content

Commit

Permalink
Cleaned files to fit Moodle coding style.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiemer committed Apr 9, 2019
1 parent 860f8f6 commit 6d2cd2b
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 137 deletions.
1 change: 0 additions & 1 deletion backup/moodle2/backup_ubicast_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
10 changes: 4 additions & 6 deletions backup/moodle2/backup_ubicast_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,26 +24,25 @@

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

/**
/**
* Define the complete ubicast structure for backup, with file and id annotations
*/
class backup_ubicast_activity_structure_step extends backup_activity_structure_step {

protected function define_structure() {
//the ubicast module stores no user info
// The ubicast module stores no user info

// Define each element separated
$media = new backup_nested_element('ubicast', array('id'), array('name', 'intro', 'introformat', 'mediaid', 'timemodified'));


// Build the tree
//nothing here for ubicast
// Nothing here for ubicast

// Define sources
$media->set_source_table('ubicast', array('id' => backup::VAR_ACTIVITYID));

// Define id annotations
//module has no id annotations
// Module has no id annotations

// Define file annotations
$media->annotate_files('mod_ubicast', 'intro', null); // This file area hasn't itemid
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/restore_ubicast_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/restore_ubicast_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion classes/event/course_module_instance_list_viewed.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
3 changes: 1 addition & 2 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -46,7 +45,7 @@ protected function init() {
$this->data['objecttable'] = 'ubicast';
}

/**
/**
* Replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
Expand Down
2 changes: 0 additions & 2 deletions db/access.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -46,4 +45,3 @@
'clonepermissionsfrom' => 'moodle/course:manageactivities'
),
);

1 change: 0 additions & 1 deletion db/install.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
9 changes: 4 additions & 5 deletions db/log.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -26,8 +25,8 @@
defined('MOODLE_INTERNAL') || die();

$logs = array(
array('module'=>'ubicast', 'action'=>'view', 'mtable'=>'ubicast', 'field'=>'name'),
array('module'=>'ubicast', 'action'=>'view all', 'mtable'=>'ubicast', 'field'=>'name'),
array('module'=>'ubicast', 'action'=>'update', 'mtable'=>'ubicast', 'field'=>'name'),
array('module'=>'ubicast', 'action'=>'add', 'mtable'=>'ubicast', 'field'=>'name'),
array('module' => 'ubicast', 'action' => 'view', 'mtable' => 'ubicast', 'field' => 'name'),
array('module' => 'ubicast', 'action' => 'view all', 'mtable' => 'ubicast', 'field' => 'name'),
array('module' => 'ubicast', 'action' => 'update', 'mtable' => 'ubicast', 'field' => 'name'),
array('module' => 'ubicast', 'action' => 'add', 'mtable' => 'ubicast', 'field' => 'name'),
);
1 change: 0 additions & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
15 changes: 7 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,9 +24,9 @@

require('../../config.php');

$id = required_param('id', PARAM_INT); // course id
$id = required_param('id', PARAM_INT); // Course id.

$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);

require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
Expand Down Expand Up @@ -91,15 +90,15 @@
}

$extra = empty($cm->extra) ? '' : $cm->extra;
$media_type = 'video';
$mediatype = 'video';
if ($entry->mediaid[0] == 'l') {
$media_type = 'live';
$mediatype = 'live';
} else if ($entry->mediaid[0] == 'p') {
$media_type = 'photos';
$mediatype = 'photos';
}
$icon = '<img src="'.$OUTPUT->image_url($media_type, 'ubicast').'" class="activityicon" alt="'.$media_type.'" /> ';
$icon = '<img src="'.$OUTPUT->image_url($mediatype, 'ubicast').'" class="activityicon" alt="'.$mediatype.'" /> ';

$class = $entry->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed
$class = $entry->visible ? '' : 'class="dimmed"'; // Hidden modules are dimmed.
$table->data[] = array (
$printsection,
"<a $class $extra href=\"view.php?id=$cm->id\">".$icon.format_string($entry->name)."</a>",
Expand Down
7 changes: 3 additions & 4 deletions lang/en/ubicast.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,7 +24,7 @@

$string['language_code'] = 'en';

// moodle required strings
// Moodle required strings
$string['modulename'] = 'MediaServer resource';
$string['modulename_help'] = 'The UbiCast MediaServer module enables a teacher to provide a channel or a media from a MediaServer web TV as a course resource.';
$string['modulename_link'] = 'mod/ubicast/view';
Expand All @@ -35,12 +34,12 @@
$string['ubicast:addinstance'] = 'Add a new MediaServer resource';
$string['ubicast:view'] = 'View MediaServer resource';

// forms
// Forms
$string['form_resource_header'] = 'Resource';
$string['form_resource'] = 'Resource ID';
$string['form_resource_help'] = 'Select resource from MediaServer. You can also copy-paste a resource ID manually (example: "v124cbdfb0e5c9e28a30").';

// settings page
// Settings page
$string['settings_url'] = 'MediaServer base URL';
$string['settings_url_help'] = 'Enter the MediaServer base URL. Example: "https://mediaserver.ubicast.tv".';
$string['settings_ltikey'] = 'MediaServer LTI key';
Expand Down
7 changes: 3 additions & 4 deletions lang/fr/ubicast.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,7 +24,7 @@

$string['language_code'] = 'fr';

// moodle required strings
// Moodle required strings
$string['modulename'] = 'Ressource du MediaServer';
$string['modulename_help'] = 'Le module UbiCast MediaServer permet aux professeurs d\'ajouter des chaînes et des médias issus d\'une web TV MediaServer en tant que ressources d\'un cours.';
$string['modulename_link'] = 'mod/ubicast/view';
Expand All @@ -35,12 +34,12 @@
$string['ubicast:addinstance'] = 'Ajouter une ressource du MediaServer';
$string['ubicast:view'] = 'Voir la ressource du MediaServer';

// forms
// Forms
$string['form_resource_header'] = 'Ressource';
$string['form_resource'] = 'ID de la ressource';
$string['form_resource_help'] = 'Sélectionnez une ressource. Vous pouvez aussi copier-coller un ID de ressource (exemple: "v124cbdfb0e5c9e28a30").';

// settings page
// Settings page
$string['settings_url'] = 'URL du MediaServer';
$string['settings_url_help'] = 'Entrez l\'URL du MediaServer. Par exemple: "https://mediaserver.ubicast.tv".';
$string['settings_ltikey'] = 'Clé LTI du MediaServer';
Expand Down
5 changes: 2 additions & 3 deletions launch.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -51,8 +50,8 @@
require_once($CFG->dirroot.'/mod/ubicast/lib.php');
require_once($CFG->dirroot.'/mod/ubicast/locallib.php');

$id = required_param('id', PARAM_INT); // Course Module ID.
$mediaId = required_param('mediaId', PARAM_ALPHANUM); // MediaServer media object ID.
$id = required_param('id', PARAM_INT); // Course Module ID.
$mediaId = required_param('mediaId', PARAM_ALPHANUM); // MediaServer media object ID.

$cm = get_coursemodule_from_id('ubicast', $id, 0, false, MUST_EXIST);

Expand Down
79 changes: 49 additions & 30 deletions lib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -25,25 +24,45 @@

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

// List of features supported in ubicast module
// List of features supported in ubicast module.
function ubicast_supports($feature) {
switch($feature) {
case FEATURE_MOD_ARCHETYPE: return MOD_ARCHETYPE_RESOURCE;
case FEATURE_GROUPS: return false;
case FEATURE_GROUPINGS: return false;
case FEATURE_GROUPMEMBERSONLY: return true;
case FEATURE_MOD_INTRO: return true;
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
case FEATURE_GRADE_HAS_GRADE: return false;
case FEATURE_GRADE_OUTCOMES: return false;
case FEATURE_BACKUP_MOODLE2: return true;
case FEATURE_SHOW_DESCRIPTION: return true;

default: return null;
switch ($feature) {
case FEATURE_MOD_ARCHETYPE:
return MOD_ARCHETYPE_RESOURCE;

case FEATURE_GROUPS:
return false;

case FEATURE_GROUPINGS:
return false;

case FEATURE_GROUPMEMBERSONLY:
return true;

case FEATURE_MOD_INTRO:
return true;

case FEATURE_COMPLETION_TRACKS_VIEWS:
return true;

case FEATURE_GRADE_HAS_GRADE:
return false;

case FEATURE_GRADE_OUTCOMES:
return false;

case FEATURE_BACKUP_MOODLE2:
return true;

case FEATURE_SHOW_DESCRIPTION:
return true;

default:
return null;
}
}

// Returns all other caps used in module
// Returns all other caps used in module.
function ubicast_get_extra_capabilities() {
return array('moodle/site:accessallgroups');
}
Expand All @@ -53,12 +72,12 @@ function ubicast_reset_userdata($data) {
return array();
}

// List of view style log actions
// List of view style log actions.
function ubicast_get_view_actions() {
return array('view', 'view all');
}

// List of update style log actions
// List of update style log actions.
function ubicast_get_post_actions() {
return array('update', 'add');
}
Expand Down Expand Up @@ -95,24 +114,24 @@ function ubicast_update_instance($data, $mform) {
function ubicast_delete_instance($id) {
global $DB;

$ubicast_media = $DB->get_record('ubicast', array('id'=>$id));
if (!$ubicast_media) {
$ubicastresource = $DB->get_record('ubicast', array('id' => $id));
if (!$ubicastresource) {
return false;
}

// note: all context files are deleted automatically
// Note: all context files are deleted automatically.

$DB->delete_records('ubicast', array('id'=>$ubicast_media->id));
$DB->delete_records('ubicast', array('id' => $ubicastresource->id));

return true;
}

// Return user outline
function ubicast_user_outline($course, $user, $mod, $ubicast_media) {
// Return user outline.
function ubicast_user_outline($course, $user, $mod, $ubicastresource) {
global $DB;

if ($logs = $DB->get_records('log', array('userid'=>$user->id, 'module'=>'ubicast',
'action'=>'view', 'info'=>$ubicast_media->id), 'time ASC')) {
if ($logs = $DB->get_records('log', array('userid' => $user->id, 'module' => 'ubicast',
'action' => 'view', 'info' => $ubicastresource->id), 'time ASC')) {

$numviews = count($logs);
$lastlog = array_pop($logs);
Expand All @@ -126,12 +145,12 @@ function ubicast_user_outline($course, $user, $mod, $ubicast_media) {
return NULL;
}

// Displays last time seen by user
function ubicast_user_complete($course, $user, $mod, $ubicast_media) {
// Displays last time seen by user.
function ubicast_user_complete($course, $user, $mod, $ubicastresource) {
global $CFG, $DB;

if ($logs = $DB->get_records('log', array('userid'=>$user->id, 'module'=>'ubicast',
'action'=>'view', 'info'=>$ubicast_media->id), 'time ASC')) {
if ($logs = $DB->get_records('log', array('userid' => $user->id, 'module' => 'ubicast',
'action' => 'view', 'info' => $ubicastresource->id), 'time ASC')) {
$numviews = count($logs);
$lastlog = array_pop($logs);

Expand Down
Loading

0 comments on commit 6d2cd2b

Please sign in to comment.