[Hw4mdl-svn] SF.net SVN: hw4mdl: [47] trunk/moodle/mod/liveclassroom/lib.php
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-08-25 10:38:26
|
Revision: 47 Author: shazan Date: 2006-08-25 03:38:19 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/hw4mdl/?rev=47&view=rev Log Message: ----------- Modified Paths: -------------- trunk/moodle/mod/liveclassroom/lib.php Modified: trunk/moodle/mod/liveclassroom/lib.php =================================================================== --- trunk/moodle/mod/liveclassroom/lib.php 2006-08-25 10:37:42 UTC (rev 46) +++ trunk/moodle/mod/liveclassroom/lib.php 2006-08-25 10:38:19 UTC (rev 47) @@ -1,4 +1,4 @@ -<?PHP + <?PHP /****************************************************************************** * * * Copyright (c) 1999-2006 Horizon Wimba, All Rights Reserved. * @@ -40,6 +40,8 @@ + + /** * Validate the data in passed in the configuration page * @param $config - the information from the form mod.html @@ -215,20 +217,34 @@ return true; } - /** * Create the different kind of room on this course */ function liveclassroom_create_rooms ($course) { - // Chek if the rooms doesn't exist for this course - if (sizeof(liveclassroom_get_list_type_rooms_per_course($course))==0) { - //add them - $list_type = liveclassroom_get_list_type_rooms(); - for($i=0;$i<sizeof($list_type);$i++) { - liveclassroom_create_room ($course->id, $list_type->name); + $coursename = $course->shortname; + //get the list of existing types + $list_type = liveclassroom_get_list_type_rooms(); + + //For each type, check if the room exist on the server + for($i=0;$i<sizeof($list_type);$i++) { + $name = $coursename.'_'.$list_type[$i]; + if(!liveclassroom_api_room_exist($name)){ //Create room + liveclassroom_create_room ($course->id, $name); } + else { //Room already exist + //Create in the moodle database + /* $type = liveclassroom_get_type($liveclassroom); + //create the liveclassroom_rooms in moodle database + $liveclassroom_rooms->course = $liveclassroom->course; + $liveclassroom_rooms->name = liveclassroom_get_room_name($course,$type); + $liveclassroom_rooms->lc_id = $liveclassroom->id; + if(!liveclassroom_rooms_add_instance($liveclassroom_rooms)) { + return false; + }*/ + } } + return true; } @@ -321,9 +337,13 @@ */ function liveclassroom_get_list_type_rooms() { + //$sql = "SELECT u.name FROM mdl_liveclassroom_rooms u WHERE u.course=0"; + //$n = count_records_sql($sql); + //$list0 = get_records_sql($sql); - $list = get_records('liveclassroom_rooms','course',0); + $list = get_records('liveclassroom_type_rooms','course',0); + for($i=0;$i<sizeof($list);$i++) { $list_name[$i] = $list[$i+1]->name; } @@ -344,20 +364,51 @@ } function liveclassroom_rooms_add_instance($liveclassroom_rooms) { - /// Given an object containing all the necessary data, -/// (defined by the form in mod.html) this function -/// will create a new instance and return the id number -/// of the new instance. - $liveclassroom_rooms->timemodified = time(); - # May have to add extra stuff in here # return insert_record("liveclassroom_rooms", $liveclassroom_rooms); } +function liveclassroom_rooms_add_new_type($name) { + + $liveclassroom_type_room->timemodified = time(); + + $liveclassroom_type_room->course = 0 ; + $liveclassroom_type_room->lc_id = 0 ; + $liveclassroom_type_room->name = $name ; + + return insert_record("liveclassroom_type_rooms", $liveclassroom_type_room); + +} + + + +/* +* Get the type number of liveclassroom +*/ +function liveclassroom_get_type($liveclassroom) { + if($lc = get_record('liveclassroom','id',$liveclassroom->id)) { + return $lc->type; + } + else return false; +} + +/** +* Give the name of the room for the course +*/ +function liveclassroom_get_room_name($course,$type) { + $lc = get_record('liveclassroom_type_rooms','id',$type+1); + $name = $course->shortname; + $typename = $lc->name; + + return $name.'_'.$typename; +} + + + ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |