Revision: 113
http://svn.sourceforge.net/hw4mdl/?rev=113&view=rev
Author: shazan
Date: 2006-12-20 08:40:43 -0800 (Wed, 20 Dec 2006)
Log Message:
-----------
block displayed like the specs requirements
Modified Paths:
--------------
trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php
Modified: trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php
===================================================================
--- trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php 2006-12-18 09:24:56 UTC (rev 112)
+++ trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php 2006-12-20 16:40:43 UTC (rev 113)
@@ -1,7 +1,43 @@
<?PHP
-
+error_reporting(E_ALL);
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_next_liveclassroom extends block_base {
function init() {
@@ -10,8 +46,11 @@
}
function applicable_formats() {
- return array('site' => true, 'course-view' => true, 'course-view-social' => false, 'course-view-topics' => true, 'course-view-weeks' => true);
- }
+ //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() {
@@ -25,16 +64,22 @@
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 = '';
- //$gnumber =5;
- //$cnumber= 3;
+
$gnumber = $CFG->block_next_liveclassroom_globalnumber;
$cnumber = $CFG->block_next_liveclassroom_coursenumber;
-
+
//liveclassroom module
@@ -68,13 +113,16 @@
$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");
@@ -83,6 +131,8 @@
$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);
}
}
@@ -92,23 +142,31 @@
}
$sectionnumber++;
}
- $this->content->text .= '<table width="100%">';
+ $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 .= '<a href="'.$CFG->wwwroot.'/mod/liveclassroom/view.php?id='.$block['cm_id'].'" >';
+
+ $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 .= '</tr></td>';
- $this->content->text .= '<tr style="font-style:italic; color: #969696;"><td>';
+ }
+ $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 .= '<tr style="border-bottom: 1px solid #666666; "><td ></td></tr>';
-
+
+ $this->content->text .= '</table>';
+ $this->content->text .= '</td></tr>';
}
+
$this->content->text .= '</table>';
@@ -124,17 +182,18 @@
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($result1)>=$cnumber){
+ if(sizeof($result)>=$cnumber){
$full=true;
}
else {
@@ -145,6 +204,8 @@
$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);
}
}
@@ -152,21 +213,40 @@
}
}
}
- $this->content->text .= '<table width="100%">';
+ $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 .= '<a href="'.$CFG->wwwroot.'/mod/liveclassroom/view.php?id='.$block['cm_id'].'" >'.$block['lc_name'].'</a>';
- $this->content->text .= '</tr> </td>';
+ $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) {
- $this->content->text .= '<tr style="font-style:italic; color: #969696;"><td>';
- $this->content->text .= $block['summary'];
- $this->content->text .= '</tr></td>';
+ //$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 .= '<tr style="border-bottom: 1px solid #666666; "><td ></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>';
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|