[Hw4mdl-svn] SF.net SVN: hw4mdl: [116] trunk/moodle/blocks
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-12-21 10:11:01
|
Revision: 116
http://svn.sourceforge.net/hw4mdl/?rev=116&view=rev
Author: shazan
Date: 2006-12-21 02:10:57 -0800 (Thu, 21 Dec 2006)
Log Message:
-----------
block rename blivecalassroom
Added Paths:
-----------
trunk/moodle/blocks/bliveclassroom/
trunk/moodle/blocks/bliveclassroom/block_bliveclassroom.php
trunk/moodle/blocks/bliveclassroom/config_global.html
Added: trunk/moodle/blocks/bliveclassroom/block_bliveclassroom.php
===================================================================
--- trunk/moodle/blocks/bliveclassroom/block_bliveclassroom.php (rev 0)
+++ trunk/moodle/blocks/bliveclassroom/block_bliveclassroom.php 2006-12-21 10:10:57 UTC (rev 116)
@@ -0,0 +1,273 @@
+<?PHP
+
+require_once($CFG->libdir.'/datalib.php');
+require_once($CFG->dirroot.'/mod/liveclassroom/api.php');
+
+?>
+
+<style>
+table.fontCurrent
+{
+ font-family:Verdana;
+ font-size:12px;
+
+}
+
+a.list:link
+{
+
+ color : #0000FF ;
+ text-decoration : underline ;
+}
+a.list:hover
+{
+ color : #0000FF ;
+ text-decoration : none ;
+}
+a.list:visited
+{
+ color : #0000FF ;
+ text-decoration : underline ;
+}
+a.list:active
+{
+ color : #0000FF ;
+ text-decoration : none ;
+}
+</style>
+
+<?php
+
+class block_bliveclassroom extends block_base {
+
+ function init() {
+ $this->title = get_string('blocktitle', 'block_bliveclassroom');
+ $this->version = 2004111200;
+ }
+
+ function applicable_formats() {
+ //return array('site' => true, 'course-view' => true, 'course-view-social' => false, 'course-view-topics' => true, 'course-view-weeks' => true);
+ return array('all' => true);
+
+
+ }
+
+ function get_content() {
+
+ global $CFG, $USER, $COURSE;
+ if ($this->content !== NULL) {
+ return $this->content;
+ }
+
+ //guest and not logged user can't have access to the liveclassroom block
+ if(isguest() || !isloggedin()){
+ die;
+ }
+
+ // Return a string in text format
+ function txt($string){
+ $result = str_replace("<br />", "" ,$string);
+ $result = str_replace("<p>", "" ,$result);
+ $result = str_replace("</p>", "" ,$result);
+ return $result;
+ }
+
+ $this->content = new stdClass;
+
+ $this->content->text = '';
+ $this->content->footer = '';
+
+ if(isset($CFG->block_bliveclassroom_globalnumber)){
+ $gnumber = 5;
+ }
+ else $gnumber = $CFG->block_bliveclassroom_globalnumber;
+
+ if(isset($CFG->block_bliveclassroom_coursenumber)){
+ $cnumber = 3;
+ }
+ else $cnumber = $CFG->block_bliveclassroom_coursenumber;
+
+
+
+ //liveclassroom module
+ if(!$lc = get_record("modules", "name", "liveclassroom")) {
+ error("module liveclassroom not exist");
+ }
+
+ if (($COURSE->format == 'site')) { // Global block : displays the 5 next Live Classroom through any course the user is enrolled in (or a teacher for)
+
+ //table with the course module id
+ $result = array();
+ //table with the activities id
+ $result1 = array();
+ $full = false;
+
+ $allcourses = get_my_courses($USER->id);
+
+ $sectionnumber = 1;
+
+ while($full!=true && $sectionnumber<=10){
+
+ foreach($allcourses as $cours) {
+ $sections[$cours->id] = get_record("course_sections", "course", "$cours->id", "section", $sectionnumber);
+
+ }
+ foreach($sections as $section){
+
+ if ($full==true) {break;}
+ else{
+ if(($section->section!=0) && ($section->sequence!=null)){
+ $lines = explode(",",$section->sequence);
+ foreach($lines as $line) {
+ // print $line;
+
+ $cm = get_record("course_modules", "id", "$line");
+ if($cm->module==$lc->id) {
+ if(sizeof($result)>=$gnumber) {
+ $full=true;
+
+ break;
+ }
+ else{
+
+ $block_instance = array();
+
+ $course = get_record("course", "id", "$cm->course");
+ $block_instance['course'] =$course->fullname;
+ $block_instance['summary'] = $section->summary;
+ $block_instance['cm_id'] = $line; //$cm id
+ $liveclassroom = get_record("liveclassroom", "id", "$cm->instance");
+ $block_instance['lc_name'] = $liveclassroom->name;
+ $block_instance['roomId'] = $liveclassroom->type;
+ $block_instance['roomname'] = liveclassroom_api_get_room_name($liveclassroom->type);
+ array_push($result,$block_instance);
+ }
+ }
+ }
+ }
+ }
+ }
+ $sectionnumber++;
+ }
+ $this->content->text .= '<table class="fontCurrent" width="100%" border="1" style="margin:-5px;">';
+ //Display the list
+
+ foreach ($result as $block) {
+
+ $this->content->text .= '<tr><td>';
+ $this->content->text .= '<table>';
+ $this->content->text .= '<tr><td style="padding-left:5px;">';
+ $this->content->text .= '<a class="list" href="'.$CFG->wwwroot.'/mod/liveclassroom/view.php?id='.$block['cm_id'].'">';
+ if($block['summary'] !=null) {
+ $this->content->text .= $block['summary'].': ';
+ }
+ $this->content->text .= $block['lc_name'].'</a>';
+ $this->content->text .= '</td></tr>';
+ $this->content->text .= '<tr style="color: #969696;"><td style="padding-left:5px;">';
+ $this->content->text .= 'Room : '.$block['roomname'];
+ $this->content->text .= '</td></tr>';
+ $this->content->text .= '<tr><td style="padding-left:5px;">';
+ $this->content->text .= $block['course'];
+ $this->content->text .= '</tr></td>';
+
+ $this->content->text .= '</table>';
+ $this->content->text .= '</td></tr>';
+ }
+
+ $this->content->text .= '</table>';
+
+
+ }
+ else{ // Course Block display the 3 next Live Classroom
+ //table with the course module id
+ $result = array();
+ //table with the activities id
+ $result1 = array();
+ $full = false;
+ //all section in course
+ $sections = get_records_sql("SELECT *
+ FROM {$CFG->prefix}course_sections cs
+ WHERE cs.course = '$COURSE->id'
+ ORDER BY cs.section asc");
+
+ foreach($sections as $section){
+ if ($full==true) break;
+ else{
+ if(($section->section!=0) && ($section->sequence!=null)){
+ $lines = explode(",",$section->sequence);
+
+ foreach($lines as $line) {
+ //Look just the liveclasssroom instance
+ $cm = get_record("course_modules", "id", "$line");
+ if($cm->module==$lc->id) {
+ if(sizeof($result)>=$cnumber){
+ $full=true;
+ }
+ else {
+ $block_instance = array();
+
+ $block_instance['course'] =$COURSE->fullname;
+ $block_instance['summary'] = $section->summary;
+ $block_instance['cm_id'] = $line; //$cm id
+ $liveclassroom = get_record("liveclassroom", "id", "$cm->instance");
+ $block_instance['lc_name'] = $liveclassroom->name;
+ $block_instance['roomId'] = $liveclassroom->type;
+ $block_instance['roomname'] = liveclassroom_api_get_room_name($liveclassroom->type);
+ array_push($result,$block_instance);
+ }
+ }
+ }
+ }
+ }
+ }
+ $this->content->text .= '<table class="fontCurrent" width="100%" border="1" style="margin:-5px;">';
+ //Display the list
+
+ foreach ($result as $block) {
+ $this->content->text .= '<tr><td>';
+ $this->content->text .= '<table>';
+ $this->content->text .= '<tr><td style="padding-left:5px;">';
+ $this->content->text .= '<a class="list" href="'.$CFG->wwwroot.'/mod/liveclassroom/view.php?id='.$block['cm_id'].'" >'.$block['lc_name'].'</a>';
+ $this->content->text .= '</tr></td>';
+ $this->content->text .= '<tr style="color: #969696;"><td style="padding-left:5px;">';
+ $this->content->text .= 'Room : '.$block['roomname'];
+ $this->content->text .= '</tr></td>';
+ if($block['summary'] !=null) {
+ //$desc = format_text($thissection->summary, FORMAT_MOODLE, NULL, $course->id);
+ $descTxt = txt($block['summary']);
+ $minidesc = substr($descTxt, 0, 20);
+
+ if (strlen($descTxt)>20) {
+ $minidesc .= "...";
+ }
+ $this->content->text .= '<tr><td style="padding-left:5px;">';
+ $this->content->text .= $minidesc;
+ $this->content->text .= '</td></tr>';
+ }
+
+ $this->content->text .= '</table>';
+ $this->content->text .= '</td></tr>';
+ }
+
+ $this->content->text .= '<tr style="background-color:#F0F0F0;"><td align="center">';
+ $this->content->text .= '<img src='.$CFG->wwwroot.'/mod/liveclassroom/icon.gif> ';
+ $this->content->text .= '<a class="list" href='.$CFG->wwwroot.'/mod/liveclassroom/index.php?id='.$COURSE->id.'>All Live Classrooms...</a>';
+ $this->content->text .= '</td></tr>';
+
+ $this->content->text .= '</table>';
+ }
+
+
+ return $this->content;
+ }
+
+ function has_config() {
+ return true;
+ }
+
+
+
+}
+
+
+?>
\ No newline at end of file
Property changes on: trunk/moodle/blocks/bliveclassroom/block_bliveclassroom.php
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author Id
Name: svn:eol-style
+ native
Added: trunk/moodle/blocks/bliveclassroom/config_global.html
===================================================================
--- trunk/moodle/blocks/bliveclassroom/config_global.html (rev 0)
+++ trunk/moodle/blocks/bliveclassroom/config_global.html 2006-12-21 10:10:57 UTC (rev 116)
@@ -0,0 +1,33 @@
+ <table cellpadding="9" cellspacing="0">
+<tr valign="top">
+ <td align="right"><?php print_string('coursenumbers', 'block_bliveclassroom') ?></td>
+ <td>
+ <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
+ <input name="block_bliveclassroom_coursenumber" type="text" size="5" value="<?php
+ if(isset($CFG->block_bliveclassroom_coursenumber)) {
+ p($CFG->block_bliveclassroom_coursenumber);
+ } else {
+ p(3);
+ } ?>" />
+ </td>
+
+</tr>
+<tr>
+<tr valign="top">
+ <td align="right"><?php print_string('globalnumbers', 'block_bliveclassroom') ?></td>
+
+ <td>
+ <input name="block_bliveclassroom_globalnumber" type="text" size="5" value="<?php
+ if(isset($CFG->block_bliveclassroom_globalnumber)) {
+ p($CFG->block_bliveclassroom_globalnumber);
+ } else {
+ p(5);
+ } ?>" />
+ </td>
+
+</tr>
+
+ <td colspan="2" align="center">
+ <input type="submit" value="<?php print_string('savechanges') ?>" /></td>
+</tr>
+</table>
Property changes on: trunk/moodle/blocks/bliveclassroom/config_global.html
___________________________________________________________________
Name: svn:mime-type
+ text/html
Name: svn:keywords
+ Date Revision Author Id
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|