[Hw4mdl-svn] SF.net SVN: hw4mdl: [89] trunk/moodle
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-10-16 12:51:25
|
Revision: 89
http://svn.sourceforge.net/hw4mdl/?rev=89&view=rev
Author: shazan
Date: 2006-10-16 05:51:06 -0700 (Mon, 16 Oct 2006)
Log Message:
-----------
add liveclassroom block
Added Paths:
-----------
trunk/moodle/blocks/
trunk/moodle/blocks/next_liveclassroom/
trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php
trunk/moodle/blocks/next_liveclassroom/config_global.html
Added: trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php
===================================================================
--- trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php (rev 0)
+++ trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php 2006-10-16 12:51:06 UTC (rev 89)
@@ -0,0 +1,151 @@
+<?PHP
+
+require_once($CFG->libdir.'/datalib.php');
+
+class block_next_liveclassroom extends block_base {
+
+ function init() {
+ $this->title = get_string('blocktitle', 'block_next_liveclassroom');
+ $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);
+ }
+
+ 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;
+ }
+
+ $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
+ 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($result1)==$gnumber) {
+ $full=true;
+ break;
+ }
+ else{
+ array_push($result,$line);
+ $liveclassroom = get_record("liveclassroom", "id", "$cm->instance");
+ array_push($result1,$liveclassroom->name);
+ }
+ }
+ }
+ }
+ }
+ }
+ $sectionnumber++;
+ }
+
+
+
+ }
+ 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($result1)==$cnumber){
+ $full=true;
+ }
+ else {
+ array_push($result,$line);
+ $liveclassroom = get_record("liveclassroom", "id", "$cm->instance");
+ array_push($result1,$liveclassroom->name);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+ $this->content->text .= '<table width="100%">';
+ //Display the list
+ for($r=0;$r<sizeof($result);$r++) {
+ // $this->content->text .= '<div style="text-align: left; font-size: 1; padding-top: 5px;">';
+ $this->content->text .= '<tr><td>';
+ $this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/liveclassroom/view.php?id='.$result[$r].'" >'.$result1[$r].'</a>';
+ $this->content->text .= '</tr> </td>';
+ // $this->content->text .= '</div>';
+ }
+ $this->content->text .= '</table>';
+
+ return $this->content;
+ }
+
+ function has_config() {
+ return true;
+ }
+
+
+
+}
+
+
+?>
\ No newline at end of file
Property changes on: trunk/moodle/blocks/next_liveclassroom/block_next_liveclassroom.php
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author Id
Name: svn:eol-style
+ native
Added: trunk/moodle/blocks/next_liveclassroom/config_global.html
===================================================================
--- trunk/moodle/blocks/next_liveclassroom/config_global.html (rev 0)
+++ trunk/moodle/blocks/next_liveclassroom/config_global.html 2006-10-16 12:51:06 UTC (rev 89)
@@ -0,0 +1,33 @@
+ <table cellpadding="9" cellspacing="0">
+<tr valign="top">
+ <td align="right"><?php print_string('coursenumbers', 'block_next_liveclassroom') ?></td>
+ <td>
+ <input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
+ <input name="block_next_liveclassroom_coursenumber" type="text" size="5" value="<?php
+ if(isset($CFG->block_next_liveclassroom_coursenumber)) {
+ p($CFG->block_next_liveclassroom_coursenumber);
+ } else {
+ p(3);
+ } ?>" />
+ </td>
+
+</tr>
+<tr>
+<tr valign="top">
+ <td align="right"><?php print_string('globalnumbers', 'block_next_liveclassroom') ?></td>
+
+ <td>
+ <input name="block_next_liveclassroom_globalnumber" type="text" size="5" value="<?php
+ if(isset($CFG->block_next_liveclassroom_globalnumber)) {
+ p($CFG->block_next_liveclassroom_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/next_liveclassroom/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.
|