[Hw4mdl-svn] SF.net SVN: hw4mdl: [165] trunk/moodle/mod/liveclassroom
Brought to you by:
jhlinder,
trollinger
|
From: <hu...@us...> - 2007-01-04 16:14:25
|
Revision: 165
http://svn.sourceforge.net/hw4mdl/?rev=165&view=rev
Author: hugues
Date: 2007-01-04 08:14:21 -0800 (Thu, 04 Jan 2007)
Log Message:
-----------
http://u.horizonwimba.com/bugzilla/show_bug.cgi?id=10620
- Fixed the room update
Modified Paths:
--------------
trunk/moodle/mod/liveclassroom/api.php
trunk/moodle/mod/liveclassroom/lib.php
trunk/moodle/mod/liveclassroom/manageRoomAction.php
Modified: trunk/moodle/mod/liveclassroom/api.php
===================================================================
--- trunk/moodle/mod/liveclassroom/api.php 2007-01-04 14:51:15 UTC (rev 164)
+++ trunk/moodle/mod/liveclassroom/api.php 2007-01-04 16:14:21 UTC (rev 165)
@@ -363,8 +363,6 @@
$final_list = "&target=$roomid"."&longname=$roomname".$list_attributes;
$enc_list = str_replace(" ", "+", $final_list);
-//DEBUG: error($enc_list);
-
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_CREATE_CLASS, $enc_list);
preg_match("(\d*)", $data, $matches);
@@ -625,10 +623,10 @@
global $CFG;
global $COURSE;
+ $list_attributes = "";
+
while (list($key, $val) = each($table_attributes)) {
-
if(($key!='class_id')&&(isset($val))&&($val!="")){
-
$list_attributes .= "&".$key."=".$val;
}
}
@@ -637,19 +635,21 @@
$enc_list = str_replace(" ", "+", $final_list);
+//DEBUG:
+//error($enc_list);
+
$data = liveclassroom_api_send_query(LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $enc_list);
preg_match("(\d*)", $data, $matches);
- $respcode = $matches[0];
+ $respcode = $matches[0];
if ( $respcode != 100) {
- add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("errorModifyRoom100","roomId=$roomid&courseId=".$COURSE->id), "Room modification failed");
- return false;
- }
+ add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("errorModifyRoom100","roomId=$roomid&courseId=".$COURSE->id), "Room modification failed");
+ return false;
+ }
add_to_log($COURSE->id, "liveclassroom", "Modify Room", liveclassroom_send_logs("modifyRoom","roomId=$roomid&courseId=".$COURSE->id), "$roomid has been modified with success");
return true;
-
}
Modified: trunk/moodle/mod/liveclassroom/lib.php
===================================================================
--- trunk/moodle/mod/liveclassroom/lib.php 2007-01-04 14:51:15 UTC (rev 164)
+++ trunk/moodle/mod/liveclassroom/lib.php 2007-01-04 16:14:21 UTC (rev 165)
@@ -315,6 +315,45 @@
return liveclassroom_api_get_session ($userid, $nickname);
}
+
+/**
+ * Updates the parameters of a room
+ *
+ */
+function liveclassroom_update_room ($course_id, $roomname, $instructor_led, $attributes) {
+
+ //set media_type and media_format according to the appropriate values according to the media_type attribute
+ $attributes = liveclassroom_check_media($attributes);
+
+ //print_r($list_attributes);
+ //Test if the type of room has been changed
+ if($_SESSION['led']!=$attributes['led']) { // Type changed
+ if($list_attributes['led']=='instructor'){
+ liveclassroom_api_remove_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid) , 'Instructor') ;
+ liveclassroom_api_add_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid), 'Student');
+ }
+ else {
+ liveclassroom_api_remove_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid) , 'Student') ;
+ liveclassroom_api_add_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid), 'Instructor');
+ }
+ }
+ unset($attributes['led']);
+ unset($attributes['link']);
+
+ //print_r($list_attributes);
+ if(!liveclassroom_api_modify_room($_GET['id'],$attributes)) {
+ return false;
+ }
+ //Guest enabled?
+ if ($attributes['guests']==1) {
+ if (! liveclassroom_api_add_user_role ($_GET['id'], 'Guest' , 'Student')) {
+ return false;
+ }
+ }
+ return true;
+}
+
+
/*
* Create a room
* call the function create_class to create the room into the server
@@ -333,15 +372,7 @@
$studentid = LIVECLASSROOM_MOODLE_PREFIX.$enc_coursename.LIVECLASSROOM_STUDENT_SUFFIX;
//set media_type and media_format according to the appropriate values according to the media_type attribute
- if ($attributes['media_type'] == "none") {
- $attributes['media_format'] = "none";
- }
- else if ($attributes['media_type'] == "one-way-video") {
- $attributes['media_format'] = "realmedia";
- }
- else if ($attributes['media_type'] == "two-way-audio") {
- $attributes['media_format'] = "hms";
- }
+ $attributes = liveclassroom_check_media($attributes);
if($instructor_led==true) { // main lecture hall
@@ -1105,5 +1136,20 @@
return $version;
}
+
+function liveclassroom_check_media($attributes) {
+ //set media_type and media_format according to the appropriate values according to the media_type attribute
+ if ($attributes['media_type'] == "none") {
+ $attributes['media_format'] = "none";
+ }
+ else if ($attributes['media_type'] == "one-way-video") {
+ $attributes['media_format'] = "realmedia";
+ }
+ else if ($attributes['media_type'] == "two-way-audio") {
+ $attributes['media_format'] = "hms";
+ }
+
+ return $attributes;
+}
?>
Modified: trunk/moodle/mod/liveclassroom/manageRoomAction.php
===================================================================
--- trunk/moodle/mod/liveclassroom/manageRoomAction.php 2007-01-04 14:51:15 UTC (rev 164)
+++ trunk/moodle/mod/liveclassroom/manageRoomAction.php 2007-01-04 16:14:21 UTC (rev 165)
@@ -87,7 +87,9 @@
$messageType = 'roomCreated';
}
else if($_GET['action']=='updateRoom') {
- if($list_attributes['led']=='instructor'){
+
+ $instructor_led = ($list_attributes['led']=='instructor');
+ if($instructor_led){
if (!isset($list_attributes['chatenable'])) $list_attributes['chatenable']="0";
if (!isset($list_attributes['student_wb_liveapp'])) $list_attributes['student_wb_liveapp']="0";
if (!isset($list_attributes['hms_two_way_enabled'])) $list_attributes['hms_two_way_enabled']="0";
@@ -103,31 +105,11 @@
if (!isset($list_attributes['preview'])) $list_attributes['preview']=1;
if (!isset($list_attributes['student_wb_enabled'])) $list_attributes['student_wb_enabled']="0";
-
-
- //print_r($list_attributes);
- //Test if the type of room has been changed
- if($_SESSION['led']!=$list_attributes['led']) { // Type changed
- if($list_attributes['led']=='instructor'){
- liveclassroom_api_remove_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid) , 'Instructor') ;
- liveclassroom_api_add_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid), 'Student');
- }
- else {
- liveclassroom_api_remove_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid) , 'Student') ;
- liveclassroom_api_add_user_role ($_GET['id'], liveclassroom_api_get_student_user_id ($courseid), 'Instructor');
- }
- }
- //print_r($list_attributes);
- if(!liveclassroom_api_modify_room($_GET['id'],$list_attributes)) {
+ if (!liveclassroom_update_room($courseid, $list_attributes['longname'], $instructor_led, $list_attributes)) {
notice(get_string("roommodificationfailed", "liveclassroom"), $_SERVER["HTTP_REFERER"]);
exit;
- }
- //Guest enabled?
- if ($list_attributes['guests']==1) {
- if (! liveclassroom_api_add_user_role ($_GET['id'], 'Guest' , 'Student')) {
- return false;
- }
}
+
$messageType = 'roomUpdated';
}
else if($_GET['action']=='deleteRoom') {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|