[Hw4mdl-svn] SF.net SVN: hw4mdl: [74] trunk/moodle/mod/liveclassroom/lib.php
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-09-29 13:42:17
|
Revision: 74
http://svn.sourceforge.net/hw4mdl/?rev=74&view=rev
Author: shazan
Date: 2006-09-29 06:42:12 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
functions about instance creation updated
Modified Paths:
--------------
trunk/moodle/mod/liveclassroom/lib.php
Modified: trunk/moodle/mod/liveclassroom/lib.php
===================================================================
--- trunk/moodle/mod/liveclassroom/lib.php 2006-09-29 13:38:40 UTC (rev 73)
+++ trunk/moodle/mod/liveclassroom/lib.php 2006-09-29 13:42:12 UTC (rev 74)
@@ -232,10 +232,14 @@
function liveclassroom_create_rooms ($course) {
//teacher is the lead of the presentation
+ add_to_log("", "liveclassroom", "", "liveclassroom_create_rooms", "first ".time());
liveclassroom_create_room($course->id, "Main classroom", true);
+ add_to_log("", "liveclassroom", "", "liveclassroom_create_rooms", "second ".time());
liveclassroom_create_room($course->id, "Other classroom", true);
+ add_to_log("", "liveclassroom", "", "liveclassroom_create_rooms", "third ".time());
//teachers and students have the same rights
liveclassroom_create_room($course->id, "Group 1", false);
+ add_to_log("", "liveclassroom", "", "liveclassroom_create_rooms", "4th ".time());
liveclassroom_create_room($course->id, "Group 2", false);
return true;
@@ -276,30 +280,19 @@
$teacherid = $LIVECLASSROOM_MOODLE_PREFIX.$course_name.$LIVECLASSROOM_TEACHER_SUFFIX;
$studentid = $LIVECLASSROOM_MOODLE_PREFIX.$course_name.$LIVECLASSROOM_STUDENT_SUFFIX;
-
- if (! liveclassroom_api_create_class ($roomid, $roomname)) {
- //error ("liveclassroom_create_room: Cannot create room with id:$roomid and name: $roomname");
- return false;
- }
- //save this room in moodle database
- $liveclassroom_rooms->course = $courseid;
- $liveclassroom_rooms->name = $roomname;
- $liveclassroom_rooms->room_id = $roomid;
- //$liveclassroom_rooms->type = $bool;
-
- liveclassroom_rooms_add_instance($liveclassroom_rooms);
- liveclassroom_rooms_add_new_type($courseid,$roomname);
-
- if (! liveclassroom_api_remove_user_role ($roomid, 'Guest' , 'Student')) {
- //error('liveclassroom_create_room: Cannot remove Participant right to Guest');
- return false;
- }
+
+ /*
if (! liveclassroom_api_remove_group_role ($roomid, 'RegisteredUser', 'Student')) {
//error('liveclassroom_create_room: Cannot remove Participant right to RegisteredUser');
return false;
- }
+ }*/
if($bool==true) { // main lecture hall
+
+ if (! liveclassroom_api_create_class ($roomid, $roomname, $bool)) {
+ //error ("liveclassroom_create_room: Cannot create room with id:$roomid and name: $roomname");
+ return false;
+ }
if (! liveclassroom_api_add_user_role ($roomid, $teacherid, 'ClassAdmin')) {
//error('liveclassroom_create_room: Cannot add classadminright to Teachers');
@@ -309,11 +302,16 @@
//error('liveclassroom_create_room: Cannot add Participant right to students');
return false;
}
- if(!liveclassroom_api_give_lectureroom_attributes($roomid)) {
- return false;
+ if (! liveclassroom_api_remove_user_role ($roomid, 'Guest' , 'Student')) {
+ //error('liveclassroom_create_room: Cannot remove Participant right to Guest');
+ return false;
}
}
else if($bool==false){ // discussion room
+ if (! liveclassroom_api_create_class ($roomid, $roomname, $bool)) {
+ //error ("liveclassroom_create_room: Cannot create room with id:$roomid and name: $roomname");
+ return false;
+ }
if (! liveclassroom_api_add_user_role ($roomid, $teacherid, 'ClassAdmin')) {
//error('liveclassroom_create_room: Cannot add classadminright to Teachers');
@@ -323,11 +321,17 @@
//error('liveclassroom_create_room: Cannot add Participant right to students');
return false;
}
- if(!liveclassroom_api_give_discussionroom_attributes($roomid)) {
- return false;
- }
+ if (! liveclassroom_api_remove_user_role ($roomid, 'Guest' , 'Student')) {
+ //error('liveclassroom_create_room: Cannot remove Participant right to Guest');
+ return false;
+ }
}
-
+ //save this room in moodle database
+ $liveclassroom_rooms->course = $courseid;
+ $liveclassroom_rooms->name = $roomname;
+ $liveclassroom_rooms->room_id = $roomid;
+
+ liveclassroom_rooms_add_instance($liveclassroom_rooms);
return true;
}
@@ -369,14 +373,15 @@
*/
function liveclassroom_get_list_type_rooms($course) {
- if (!($list = get_records('liveclassroom_type_rooms','course',$course->id) )) {
+ if (!($list = get_records('liveclassroom_rooms','course',$course->id) )) {
error( "Response get list type room : query to database failed");
}
-
- $i=0;
- foreach($list as $liveclassroom_type_rooms) {
- $list_name[$i]= $liveclassroom_type_rooms->name;
- $i++;
+ $list_name=array();
+ //$i=0;
+ foreach($list as $liveclassroom_rooms) {
+ array_push($list_name,$liveclassroom_rooms->name);
+ //$list_name[$i]= $liveclassroom_rooms->name;
+ //$i++;
}
return $list_name;
@@ -439,7 +444,18 @@
return true;
}
+function liveclassroom_rooms_update_instance($liveclassroom_rooms) {
+ $liveclassroom_rooms->timemodified = time();
+ $liveclassroom_rooms->id = $liveclassroom_rooms->instance;
+
+ if(!(update_record("liveclassroom_rooms", $liveclassroom_rooms))) {
+ error( "Response: update of instance liveclassroom_rooms failed");
+ //return false;
+ }
+ return true;
+}
+
/*
* Create a new type to liveclassroom Room
* @param $name : the name of the type
@@ -492,26 +508,18 @@
}
-function widget_add_instance($roomname,$bool){
-
- //Add new room into the LC server
- liveclassroom_create_room ($courseid, $roomname, $bool) ;
- //Add new room in Moodle database
- liveclassroom_rooms_add_new_type($roomname);
-}
-function widget_delete_instance() {
- //delete the room from the server
- liveclassroom_api_delete_room($roomid);
- //delete the room from the moodle database
-/* if(!(delete_record("liveclassroom_type_rooms", $liveclassroom_type_room))) {
- error( "Response: creation of new type $name failed");
- }
-*/
-}
-function widget_update_instance() {
-
+function liveclassroom_get_room_id($course,$roomnane){
+ if(!($rooms = get_records('liveclassroom_rooms','course',$course->id))) {
+ error( "Response get roomid : query to database failed");
+ }
+ foreach($rooms as $room){
+ if (($room->name)==$roomnane){
+ $roomid = $room->room_id;
+ }
+ }
+ return $roomid;
}
/*
@@ -550,56 +558,16 @@
return $list_roomid;
}
-/*
-* List all the room "Lecture or Main rooms" and all the room "Breackout or Discussion rooms" for a course given
-* @param $course
-* return a table 2 dimensions with all the room name
-*/
-function liveclassroom_get_main_room_list($course) {
-
- $list_roomid = liveclassroom_get_roomid_list($course);
- $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
-
- $j=0;
- $k=0;
- for($i=0;$i<sizeof($list_roomid);$i++) {
- $role = liveclassroom_api_role_user_room($list_roomid[$i], $studentuserid);
- if($role=='Student') {
- //$list_return[0][$j] = liveclassroom_get_room_name_from_id($list_roomid[$i]);
- $list_return[0][$j] = $list_roomid[$i];
- $j++;
- }
- else if($role=='Instructor'){
- // $list_return[1][$k] = liveclassroom_get_room_name_from_id($list_roomid[$i]);
- $list_return[1][$k] = $list_roomid[$i];
- $k++;
- }
- }
- return $list_return;
-}
-
-/*
-* List all the room "Breackout or Discussion rooms" for a course given
-* @param $course
-* Return a table with all the room name considering as a breackout/discussion room
-*/
-function liveclassroom_get_breackout_room_list($course) {
-
- $list_roomid = liveclassroom_get_roomid_list($course);
+function liveclassroom_test_get_room_list($course) {
- $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
- $j=0;
- for($i=0;$i<sizeof($list_roomid);$i++) {
- $role = liveclassroom_api_role_user_room($list_roomid[$i], $studentuserid);
- if($role=='Instructor') {
- $list_return[$j] = liveclassroom_get_room_name_from_id($list_roomid[$i]);
- $j++;
- }
- }
- return $list_return;
+// $list_roomid = liveclassroom_get_roomid_list($course);
+ $studentuserid = liveclassroom_api_get_student_user_id($course->shortname);
+ $teacherid = liveclassroom_api_get_teacher_user_id($course->shortname);
+ liveclassroom_api_get_room_list($teacherid);
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|