[Hw4mdl-svn] SF.net SVN: hw4mdl: [56] trunk/moodle/mod/liveclassroom
Brought to you by:
jhlinder,
trollinger
|
From: <sh...@us...> - 2006-09-01 14:08:35
|
Revision: 56
http://svn.sourceforge.net/hw4mdl/?rev=56&view=rev
Author: shazan
Date: 2006-09-01 07:08:15 -0700 (Fri, 01 Sep 2006)
Log Message:
-----------
Rooms and users are managed with prefix.
It test if the user exist before created the new rooms.
The activities in moodle are linked with the room.
Modified Paths:
--------------
trunk/moodle/mod/liveclassroom/api.php
trunk/moodle/mod/liveclassroom/db/mysql.sql
trunk/moodle/mod/liveclassroom/index.php
trunk/moodle/mod/liveclassroom/lib.php
trunk/moodle/mod/liveclassroom/mod.html
trunk/moodle/mod/liveclassroom/view.php
Modified: trunk/moodle/mod/liveclassroom/api.php
===================================================================
--- trunk/moodle/mod/liveclassroom/api.php 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/api.php 2006-09-01 14:08:15 UTC (rev 56)
@@ -43,10 +43,13 @@
require_once('System.php');
+$LIVECLASSROOM_MOODLE_PREFIX = '_moodle_';
$LIVECLASSROOM_API_ADMIN = '/admin/api/api.pl?';
$LIVECLASSROOM_API_FUNCTION_NOOP = 'function=NOOP';
$LIVECLASSROOM_API_FUNCTION_CREATE_USER = 'function=createUser';
+$LIVECLASSROOM_API_FUNCTION_MODIFY_USER = 'function=modifyUser';
+$LIVECLASSROOM_API_FUNCTION_LIST_USER = 'function=listUser';
$LIVECLASSROOM_API_FUNCTION_GET_TOKEN = 'function=getAuthToken';
$LIVECLASSROOM_API_FUNCTION_CREATE_CLASS = 'function=createClass';
$LIVECLASSROOM_API_FUNCTION_DELETE_ROOM = 'function=deleteClass';
@@ -60,6 +63,8 @@
$LIVECLASSROOM_API_RECORD_SEPERATOR = "=END RECORD";
+
+
/**
* Creates a CURL session with the Live Classroom server. Upon success, it
* returns a CURL Handle authenticated and ready for use. It returns false
@@ -138,7 +143,7 @@
global $CFG;
global $LIVECLASSROOM_API_ADMIN;
global $LIVECLASSROOM_API_FUNCTION_CREATE_USER;
-
+ global $LIVECLASSROOM_MOODLE_PREFIX;
$data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_CREATE_USER, "&target=$userid&first_name=$rolename&last_name=$coursename");
@@ -282,7 +287,7 @@
error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
return false;
}
-
+
return true;
}
@@ -293,6 +298,8 @@
$LIVECLASSROOM_API_FUNCTION_CREATE_ROLE;
+ // liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_CREATE_ROLE,"&target=$roomid&user_id=$userid&role_id=$role");
+
if (!$ch = liveclassroom_api_authenticate()) {
return false;
}
@@ -324,6 +331,8 @@
//error( "Response: Cannot Create Class with id:$roomid, and name: $roomname.");
return false;
}
+ print $roomid."<br>". $userid."<br>". $role."<br>";
+ print $url."<br>";
return true;
}
@@ -726,6 +735,47 @@
}
+/*
+* user last name = course shortname
+*
+*/
+function liveclassroom_api_user_exist($course) {
+ global $CFG;
+ global $LIVECLASSROOM_API_ADMIN;
+ global $LIVECLASSROOM_API_FUNCTION_LIST_USER;
+ global $LIVECLASSROOM_API_RECORD_SEPERATOR;
+
+ $name = $course->shortname;
+ // print $name;
+ $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$name");
+
+ //print $data."<br>";
+
+ preg_match("(\d*)", $data, $matches);
+ $respcode = $matches[0];
+
+ if ( $respcode != 100) {
+ return false;
+ }
+ $tok = split("100 OK",$data);
+ // print sizeof($tok);
+ // print $tok[1]."<br>";
+ $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]);
+
+// print sizeof($tok1);
+
+ if(sizeof($tok1)>1){
+ return true;
+ }
+ else {
+ // print"caca1";
+ return false;
+ }
+}
+
+
+
+
?>
Modified: trunk/moodle/mod/liveclassroom/db/mysql.sql
===================================================================
--- trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-09-01 14:08:15 UTC (rev 56)
@@ -62,8 +62,10 @@
) COMMENT='Defines liveclassroom rooms';
-INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'LectureHall', '0','');
-INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'BreackOut', '0','');
+INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Main Lecture Hall', '0','');
+INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Group 1', '0','');
+INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Group 2', '0','');
+INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Group 3', '0','');
# --------------------------------------------------------
# INSERT INTO prefix_log_display VALUES ('liveclassroom', 'view', 'liveclassroom', 'name');
Modified: trunk/moodle/mod/liveclassroom/index.php
===================================================================
--- trunk/moodle/mod/liveclassroom/index.php 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/index.php 2006-09-01 14:08:15 UTC (rev 56)
@@ -147,6 +147,9 @@
fclose($fichier); //
//print_r($list);
+
+
+
?>
<table cellpadding='2' border='0' align='center' width='100%' valign='top'>
<tr style='background-color:#EEEEEE; font-weight:normal; color:black;'>
Modified: trunk/moodle/mod/liveclassroom/lib.php
===================================================================
--- trunk/moodle/mod/liveclassroom/lib.php 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/lib.php 2006-09-01 14:08:15 UTC (rev 56)
@@ -204,17 +204,19 @@
global $CFG;
global $LIVECLASSROOM_TEACHER_SUFFIX;
global $LIVECLASSROOM_STUDENT_SUFFIX;
-
- $userid = $CFG->liveclassroom_settinguniqueid."_".$course->id.$LIVECLASSROOM_TEACHER_SUFFIX;
+ global $LIVECLASSROOM_MOODLE_PREFIX;
+
+ //$userid = $CFG->liveclassroom_settinguniqueid."_".$course->id.$LIVECLASSROOM_TEACHER_SUFFIX;
+ $userid = $LIVECLASSROOM_MOODLE_PREFIX.$course->shortname.$LIVECLASSROOM_TEACHER_SUFFIX;
//add_to_log($course->id, "liveclassroom", "", "liveclassroom_create_profiles", "Creating $userId as Teacher");
- if (! liveclassroom_api_create_user ($userid, $course->fullname, 'Teacher')) {
+ if (! liveclassroom_api_create_user ($userid, $course->shortname, 'Teacher')) {
//error("Cannot Create Teacher profile");
return false;
}
- $userid = $CFG->liveclassroom_settinguniqueid.'_'.$course->id.$LIVECLASSROOM_STUDENT_SUFFIX;
+ $userid = $LIVECLASSROOM_MOODLE_PREFIX.$course->shortname.$LIVECLASSROOM_STUDENT_SUFFIX;
//add_to_log($course->id, "liveclassroom", "", "", "Creating $userId as Student");
- if (! liveclassroom_api_create_user ($userid, $course->fullname, 'Student')) {
+ if (! liveclassroom_api_create_user ($userid, $course->shortname, 'Student')) {
//error("Cannot Create Student profile");
return false;
}
@@ -232,16 +234,33 @@
//get the list of existing types
$list_type = liveclassroom_get_list_type_rooms();
- //For each type, check if the room exist on the server
+ // Check if the rooms exist on the server
+ //if(!(liveclassroom_api_user_exist($course))){
+ // print"room will be created";
+ //teacher is the lead of the presentation
+ liveclassroom_create_room($course->id, "Main Lecture Hall");
+ //teachers and students have the same rigth
+ liveclassroom_create_room($course->id, "Group 1");
+ liveclassroom_create_room($course->id, "Group 2");
+ liveclassroom_create_room($course->id, "Group 3");
+
+// }
+// else { //Room already exist
+//
+// }
+
+
+/*
for($i=0;$i<sizeof($list_type);$i++) {
- $name = $coursename.'_'.$list_type[$i];
+ // $name = $coursename.'_'.$list_type[$i];
+ $name = $list_type[$i];
if(!liveclassroom_api_room_exist($name)){ //Create room
liveclassroom_create_room ($course->id, $name);
}
else { //Room already exist
}
- }
+ }*/
return true;
@@ -251,8 +270,9 @@
global $CFG, $USER;
global $LIVECLASSROOM_TEACHER_SUFFIX;
global $LIVECLASSROOM_STUDENT_SUFFIX;
+ global $LIVECLASSROOM_MOODLE_PREFIX;
- $userid = $CFG->liveclassroom_settinguniqueid."_".$course->id.
+ $userid = $LIVECLASSROOM_MOODLE_PREFIX.$course->shortname.
($isteacher?$LIVECLASSROOM_TEACHER_SUFFIX:$LIVECLASSROOM_STUDENT_SUFFIX);
$nickname = fullname ($USER);
@@ -272,35 +292,44 @@
global $CFG;
global $LIVECLASSROOM_TEACHER_SUFFIX,
$LIVECLASSROOM_STUDENT_SUFFIX;
-
- $roomid = $CFG->liveclassroom_settinguniqueid.'_'.$courseid.'_'.rand();
- $teacherid = $CFG->liveclassroom_settinguniqueid."_".$courseid.$LIVECLASSROOM_TEACHER_SUFFIX;
- $studentid = $CFG->liveclassroom_settinguniqueid."_".$courseid.$LIVECLASSROOM_STUDENT_SUFFIX;
-
+
+ global $LIVECLASSROOM_MOODLE_PREFIX;
+ //Change for PREFIX
+ $course_name = liveclassroom_get_course_shortname($courseid);
+ $roomid = $LIVECLASSROOM_MOODLE_PREFIX.$course_name.'_'.rand();
+
+ $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_add_instance($liveclassroom_rooms);
- 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 (! 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 (! liveclassroom_api_add_user_role ($roomid, $teacherid, 'ClassAdmin')) {
+
+ //error('liveclassroom_create_room: Cannot add classadminright to Teachers');
+ return false;
+ }
+ if (! liveclassroom_api_add_user_role ($roomid, $studentid, 'Student')) {
+ //error('liveclassroom_create_room: Cannot add Participant right to students');
+ return false;
+ }
- if (! liveclassroom_api_add_user_role ($roomid, $teacherid, 'ClassAdmin')) {
- //error('liveclassroom_create_room: Cannot add classadminright to Teachers');
- return false;
- }
- if (! liveclassroom_api_add_user_role ($roomid, $studentid, 'Student')) {
- //error('liveclassroom_create_room: Cannot add Participant right to students');
- return false;
- }
-
return true;
}
@@ -425,15 +454,25 @@
* return the name of the room for the course
*/
function liveclassroom_get_room_name($course,$type) {
+/*
+ global $LIVECLASSROOM_MOODLE_PREFIX;
+ if($type == 0) {//Main Lecture Hall
+ return $LIVECLASSROOM_MOODLE_PREFIX.$course->shortname;
+ }
+ else if ($type == 1) { //Discussion room
+
+ }
+
+*/
if(!($lc = get_record('liveclassroom_type_rooms','id',$type+1))) {
error( "Response get room name: query to database failed");
}
else {
- $name = $course->shortname;
- $typename = $lc->name;
+ $name = $lc->name;
+
- return $name.'_'.$typename;
+ return $name;
}
}
@@ -451,5 +490,18 @@
}
+function liveclassroom_get_course_shortname($courseid) {
+
+ if(!($course = get_record('course','id',$courseid))) {
+ error( "Response get room name: query to database failed");
+ }
+ else {
+ $name = $course->shortname;
+
+ return $name;
+ }
+}
+
+
?>
Modified: trunk/moodle/mod/liveclassroom/mod.html
===================================================================
--- trunk/moodle/mod/liveclassroom/mod.html 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/mod.html 2006-09-01 14:08:15 UTC (rev 56)
@@ -14,6 +14,10 @@
if (!isset($form->intro)) {
$form->intro = '';
}
+if (!isset($form->descrption)) {
+ $form->descrption = '';
+}
+
// More similar blocks go here...
?>
@@ -25,17 +29,12 @@
<td>
<?php
include_once($CFG->dirroot.'/mod/liveclassroom/lib.php');
- //recuperation de la liste des types de rooms
+ //Get the list of rype of rooms available
$list_type_rooms = liveclassroom_get_list_type_rooms();
- //sort($list_type_rooms);
- //$list_type_rooms[sizeof($list_type_rooms)] = get_string('otherroom', 'liveclassroom');
-
+ //sort($list_type_rooms);
choose_from_menu($list_type_rooms, 'type', $form->type, '');
helpbutton('liveclassroomtype', get_string('liveclassroomtype', 'liveclassroom'), 'liveclassroom');
-
-
-
- ?>
+ ?>
</td>
Modified: trunk/moodle/mod/liveclassroom/view.php
===================================================================
--- trunk/moodle/mod/liveclassroom/view.php 2006-08-30 12:29:03 UTC (rev 55)
+++ trunk/moodle/mod/liveclassroom/view.php 2006-09-01 14:08:15 UTC (rev 56)
@@ -73,31 +73,27 @@
require_login($course->id);
add_to_log($course->id, "liveclassroom", "view", "view.php?id=$cm->id", "$liveclassroom->id");
-
-// make sure the profiles exist
- if (!liveclassroom_create_profiles ($course)) {
- error ("Cannot create liveclassroom profiles");
- }
- liveclassroom_create_rooms ($course);
-
-//Check if the room is already link in the database with the liveclassroom
- if(!liveclassroom_rooms_exists ($liveclassroom)) {
- $type = liveclassroom_get_type($liveclassroom);
- $name =liveclassroom_get_room_name($course,$type);
- //create the liveclassroom_rooms in moodle database
- $liveclassroom_rooms->course = $liveclassroom->course;
- $liveclassroom_rooms->name = $name;
- $liveclassroom_rooms->lc_id = $liveclassroom->id;
- $liveclassroom_rooms->room_id = liveclassroom_api_get_roomid($name);
- if(!liveclassroom_rooms_add_instance($liveclassroom_rooms)) {
- return false;
- }
- }
-
-// Create the session fir this user
+ // Check if the rooms exist on the server
+ if(!(liveclassroom_api_user_exist($course))){
+ // make sure the profiles exist
+ if (!liveclassroom_create_profiles ($course)) {
+ error ("Cannot create liveclassroom profiles");
+ }
+ liveclassroom_create_rooms ($course);
+ }
+ else {
+ //update le lc with it room id
+ $name = liveclassroom_get_room_name($course, $liveclassroom->type);
+ $lcr = get_record("liveclassroom_rooms", "course", $course->id, "name", $name);
+ $liveclassroom->room_id = $lcr->room_id;
+ update_record('liveclassroom', $liveclassroom);
+ }
+
+
+// Create the session for this user
if (!$usersession = liveclassroom_create_session ($course, isteacher($course->id, $USER->id))) {
error ("Cannot create session");
}
@@ -137,6 +133,18 @@
$groupparam = "";
}
+*//*
+
+// if groups are being used, get the groupid and create the LC into moodle linked to this group.
+ print mygroupid($course->id);
+ if ($groupmode = groupmode($course, $cm)) {
+ print $groupmode;
+ $test = mygroupid($course->id);
+ $liveclassroom->groupid = mygroupid($course->id);
+
+ update_record("liveclassroom",$liveclassroom);
+
+ }
*/
/// Print the main part of the page
@@ -151,7 +159,8 @@
</script>
<?php
- $classid = liveclassroom_api_get_roomid(liveclassroom_get_room_name($course,liveclassroom_get_type($liveclassroom)));
+ //$classid = liveclassroom_api_get_roomid(liveclassroom_get_room_name($course,liveclassroom_get_type($liveclassroom)));
+ $classid = $liveclassroom->room_id;
if (isstudent($course->id)) {
?>
<body onload="javascript:startHorizon('<?php p($classid) ?>',null,null,null,null,'hzA=<?php p($usersession)?>' )">
@@ -184,6 +193,7 @@
</tr>
<?php
if (isteacher($course->id, $USER->id)) {
+
?>
<tr>
<td>
@@ -192,18 +202,10 @@
</a>
</td>
<tr>
-
- <tr>
- <td>
- <form method="get" name="createRoom" action="edit.php">
- <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>"
- <input type="hidden" name="id" value="<?php echo $course->id ?>">
- <input type="submit" value="Edit Room Type">
- </form>
- </td>
- </tr>
- <!--
-
+
+
+
+ <!-- REMOVE THIS
<tr>
<td>
<form method="get" name="createRoom" action="create.php">
@@ -250,7 +252,7 @@
</table>
- <tr style="background-color:#EEEEEE; font-weight:normal; color:black;"><td style="border-right:1px solid #999;"> </td><td> </td></tr>
+ <tr style="background-color:#EEEEEE; font-weight:normal; color:black;"><td style="border-right:1px solid #999;"> </td><td> </td></tr>
</table>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|