[Hw4mdl-svn] SF.net SVN: hw4mdl: [57] trunk/moodle/mod/liveclassroom
Brought to you by:
jhlinder,
trollinger
From: <sh...@us...> - 2006-09-07 13:20:11
|
Revision: 57 http://svn.sourceforge.net/hw4mdl/?rev=57&view=rev Author: shazan Date: 2006-09-07 06:19:56 -0700 (Thu, 07 Sep 2006) Log Message: ----------- the rooms are crated with their own attributes depending if they are main or discussion room. Mainroom list and discussion list rooms are now available and activities list by room too. Creation of new room is ok and depending of the course. 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-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/api.php 2006-09-07 13:19:56 UTC (rev 57) @@ -56,6 +56,7 @@ $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM = 'function=modifyClass'; $LIVECLASSROOM_API_FUNCTION_CREATE_ROLE = 'function=createRole'; $LIVECLASSROOM_API_FUNCTION_DELETE_ROLE = 'function=deleteRole'; +$LIVECLASSROOM_API_FUNCTION_LIST_ROLE = 'function=listRole'; $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST = 'function=listClass'; $LIVECLASSROOM_API_FUNCTION_CREATE_GROUP = 'function=createGroup'; $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP = 'function=modifyGroup'; @@ -331,8 +332,7 @@ //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; } @@ -421,50 +421,35 @@ * ID. * * @param userid User ID to filter by, null if none - * @param role Optional role to filter by, use ACCESS_PRIV_ constants from ListCommand. + * @param role Optional role to filter by * @param roomid * @return */ - function liveclassroom_api_get_room_list($userid, $role, $roomid) { + function liveclassroom_api_get_room_list($userid) { global $CFG; global $LIVECLASSROOM_API_ADMIN, $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; - $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&target=$roomid&longname=$roomname"); + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&attribute=longname"); + preg_match("(\d*)", $data, $matches); $respcode = $matches[0]; if ( $respcode != 100) { return false; } - - + print $data; + return true; } -function liveclassroom_api_get_room($roomname) { - global $CFG; - global $LIVECLASSROOM_API_ADMIN, - $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; - $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname"); - - preg_match("(\d*)", $data, $matches); - $respcode = $matches[0]; - - if ( $respcode != 100) { - return false; - } - return $list; -} - - - /** -* Check if a room exist on the server +* Check if a room exist on the server * * @param roomname +* Return a boolean : true if the room exist, false if not! */ function liveclassroom_api_room_exist($roomname) { @@ -585,7 +570,7 @@ } /** - * deleteRoom on the server + * delete Room from the server * * @param roomid : id of the to delete */ @@ -635,7 +620,7 @@ * * @param roomid : id of the room to close */ - function liveclassroom_api_close_room($roomid) { +function liveclassroom_api_close_room($roomid) { global $CFG; global $LIVECLASSROOM_API_ADMIN, $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM; @@ -653,69 +638,44 @@ } return true; - } +} - -/** - * Enroll the given user into the group. - * - * @param userid - * @param groupid - *//* -function liveclassroom_api_add_user_in_group($userid, $groupid) { - - global $CFG; - global $LIVECLASSROOM_API_ADMIN; - global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP; - - $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&add_user=$user"); - - if ( $respcode != 100 && $respcode != 301) { - error( "Can't add user from group"); - return false; - } - - return true; -}*/ - - /** - * Remove the given user from the group. - * - * @param userif - * @param groupif - *//* -function liveclassroom_api_remove_user_from_group($userid, $groupid) { - global $CFG; - global $LIVECLASSROOM_API_ADMIN; - global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP; - - $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&delete_user=$user"); - - if ( $respcode != 100 && $respcode != 301) { - error( "Can't remove user from group"); - return false; - } - - return true; - -}*/ - - /* * Modify the settings of a room * @param $roomid : the id of the room * -* IMPLEMENT ME !!! +* TO CHECK !!!!! */ -function liveclassroom_api_modify_room($roomid) { +function liveclassroom_api_modify_attribute_room($roomid,$title,$description,$media_type,$student_eboard_enabled,$student_screengrab_enabled,$public_chatenable,$private_chatenable,$userlimit) { global $CFG; global $LIVECLASSROOM_API_ADMIN; global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM; - $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid"); + $list_attributes_info ="&target=$roomid&longname=$title&description=$description" ; + + $list_attributes_media ="&media_type=$media_type&"; + $list_attributes_features ="&student-wb-enabled=$student_eboard_enabled" ; // GRAB TOOL ?? student-wb-liveapp + $list_attributes_chat = "&chatenable=$public_chatenable&privatechatenable=$private_chatenable"; + $list_attributes_access = "&userlimit=$userlimit" ; + $final_list = $list_attributes_info.$list_attributes_media.$list_attributes_features.$list_attributes_chat.$list_attributes_access; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, $final_list); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + + + //Add in moodle database the new room + + return true; + } /* @@ -730,14 +690,14 @@ $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&filter00=archive&filter00value=1"); - - } /* -* user last name = course shortname -* +* Check if a user exist in the course given +* link : user last name = course shortname +* @param $course : an instance of a course +* Return boolean : true if the user exist, false if not! */ function liveclassroom_api_user_exist($course) { @@ -747,10 +707,8 @@ 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]; @@ -760,22 +718,185 @@ } $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; } } +/* +* Give the rights for a lecture room to the room given +* @param $roomid : the id of the room to modifiy the settings +* TO CHECK !!!!! +*/ +function liveclassroom_api_give_lectureroom_attributes($roomid) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM; + + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + return true; +} +/* +* Give the rights for a breackout room to the room given +* @param $roomid : the id of the room to modifiy the settings +* TO CHECK !!!!! +*/ +function liveclassroom_api_give_discussionroom_attributes($roomid) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_ROOM, "&target=$roomid&media_type=two-way-audio&hms_simulcast=public&chatenable=1&privatechatenable=1&hms_two_way_enabled=1&userlimit=-1&can_archive=1&can_liveshare=1&can_ppt_import=1"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + + return true; +} + +/* +* GIVE THE ROLE OF THE USER ON THE ROOM GIVEN +* +* @param $roomid : the id of the room +* @param $userid : the id of the user +* +* return a string : the role of the user +*/ +function liveclassroom_api_role_user_room($roomid, $userid) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_RECORD_SEPERATOR; + global $LIVECLASSROOM_API_FUNCTION_LIST_ROLE; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_ROLE, "&attribute=role_id&filter01=user_id&filter01value=$userid&filter02=object_id&filter02value=$roomid"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + + $tok = split("100 OK",$data); + $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]); + $result = liveclassroom_parse_line($tok1[0],"role_id="); + //Remove le " " at the end of the line + $response = substr($result,0,-1); + return $response; + +} + +/* +* Give the user id for a room -- because of the link between the course->shortname and the user last_name +* +* @param $lastname : string user last_name +* return a string : the id of the student user for a course +*/ +function liveclassroom_api_get_student_user_id ($lastname){ + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_RECORD_SEPERATOR; + global $LIVECLASSROOM_API_FUNCTION_LIST_USER; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_LIST_USER, "&filter00=last_name&filter00value=$lastname&filter01=first_name&filter01value=Student"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + + $tok = split("100 OK",$data); + $tok1 = split($LIVECLASSROOM_API_RECORD_SEPERATOR,$tok[1]); + $result = liveclassroom_parse_line($tok1[0],"user_id="); + //Remove le " " at the end of the line + $response = substr($result,0,-1); + + return $response; + +} + +/** + * Enroll the given user into the group. + * + * @param userid + * @param groupid + *//* +function liveclassroom_api_add_user_in_group($userid, $groupid) { + + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&add_user=$user"); + + if ( $respcode != 100 && $respcode != 301) { + error( "Can't add user from group"); + return false; + } + + return true; + +}*/ + + /** + * Remove the given user from the group. + * + * @param userif + * @param groupif + *//* +function liveclassroom_api_remove_user_from_group($userid, $groupid) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN; + global $LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_MODIFY_GROUP, "&target=$groupid&delete_user=$user"); + + if ( $respcode != 100 && $respcode != 301) { + error( "Can't remove user from group"); + return false; + } + + return true; + +}*/ +/* +function liveclassroom_api_get_room($roomname) { + global $CFG; + global $LIVECLASSROOM_API_ADMIN, + $LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST; + + $data = liveclassroom_api_send_query($ch,$LIVECLASSROOM_API_FUNCTION_GET_ROOM_LIST,"&filter00=longname&filter00value=$roomname"); + + preg_match("(\d*)", $data, $matches); + $respcode = $matches[0]; + + if ( $respcode != 100) { + return false; + } + return $list; +} + +*/ ?> Modified: trunk/moodle/mod/liveclassroom/db/mysql.sql =================================================================== --- trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-09-07 13:19:56 UTC (rev 57) @@ -62,10 +62,10 @@ ) COMMENT='Defines liveclassroom rooms'; -INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Main Lecture Hall', '0',''); +INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Main classroom', '0',''); +INSERT INTO prefix_liveclassroom_type_rooms VALUES ('', '0', 'Other classroom', '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-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/index.php 2006-09-07 13:19:56 UTC (rev 57) @@ -1,4 +1,5 @@ <?PHP + /****************************************************************************** * * * Copyright (c) 1999-2006 Horizon Wimba, All Rights Reserved. * @@ -30,6 +31,7 @@ /// This page lists all the instances of liveclassroom in a particular course + require_once("../../config.php"); require_once("lib.php"); @@ -76,81 +78,117 @@ notice("There are no liveclassrooms", "../../course/view.php?id=$course->id"); die; } +?> + <head> + <script type="text/javascript" src='<?PHP p($CFG->liveclassroom_servername)?>/js/launch.js'></script> + <SCRIPT language="javascript" src="test.js"></SCRIPT> -/// Print the list of instances (your module will probably extend this) - $timenow = time(); - $strname = get_string("name"); - $strweek = get_string("week"); - $strtopic = get_string("topic"); + <link rel="STYLESHEET" href="css/StyleSheet.css" type="text/css" /> - $room_type = "Room Type"; - $room_info = "Get Info"; - $room_enter = "Enter Room"; - $room_tracking = "Tracking"; - $room_settings = "Settings"; - $room_delete = "Remove"; + </head> - - $image1 = "<img alt='' src='$CFG->wwwroot/mod/liveclassroom/information.gif'/>"; - $image2 = "<img alt='' src='$CFG->wwwroot/mod/liveclassroom/tracking_small.gif'/>"; - $image3 = "<img alt='' src='$CFG->wwwroot/mod/liveclassroom/modify.gif'/>"; - $image4 = "<a href='$CFG->wwwroot/course/mod.php?delete=$id;&sesskey=sesskey();&sr=0'><img alt='' src='$CFG->wwwroot/mod/liveclassroom/small_delete.gif'/> </a>"; + <br> + + <span id="admin_Menu"> + <table style="width: 1000" cellspacing="0" cellpadding="1" border="1" align="center"> + <tr class="button_disabled" id="menu_admin"> + + <td width="12%" align="center" > + <a href="javascript:Horizon('hzA=<?php p($usersession)?>');" > + <img src="pictures/launch_Black.png" border="0" + alt="Edit RoomSettings" title="Launch Room" id="launch_icon" name="launch_icon" height="24" width="24"><br /> + Launch</a> + + </td> + <td width="12%" align="center" > + <a href="javascript:Horizon('hzA=<?php p($usersession)?>');" > + <img src="pictures/launch_Black.png" border="0" + alt="Edit RoomSettings" title="Launch Room" id="launch_icon" name="launch_icon" height="24" width="24"><br /> + Add Activity</a> + + </td> + <td style="border-right: 1px solid #666666;"> </td> + <td width="5px"></td> + <td width="12%" align=center class="button_enabled"> + + <!-- a href="<%="ManageRoom.aspx?time="+ session.getTimeOfLoad()+"&"+session.url_params+"signature="+Util.mD5Crypt(session.getSignature()+Setup.getInstance().getHashKey()) %>"> --> + <img src="pictures/new.png" border="0" alt="Calendar" title="Calendar" id="Img1" height="24" width="24"> + <br />New Room</a> + </td> + <td width="5px"></td> + <td width="12%" align="center" > + <!-- <a href="javascript:doOpenExtern('<%=Setup.getInstance().getLcServerURL()%>/admin/class/carousels.epl','hzA=<?php p($usersession)?>')" > + --> <img src="pictures/content_Black.png" border="0" + alt="Manage Content" title="Manage Content" id="content_icon" name="content_icon" height="24" width="24"><br /> + Content</a> + </td> + <td width="12%" align="center" > + <!-- <a href="javascript:doOpen(true,'View_Report.aspx','hzA=<?php p($usersession)?>')" > + --> <img src="pictures/poll_Black.png" border="0" + alt="View Room Records" title="View Poll Results" id="poll_icon" name="poll_icon" height="24" width="24"><br /> + Poll</a> + </td> + <td style="border-right: 1px solid #666666;"> </td> + <td width="12%" align="center" > + <!-- <a href="javascript:doOpen(false,'AddCalendarEvent.aspx','time=<%=session.getTimeOfLoad() %>&<%=session.url_params %>signature=<%=Util.mD5Crypt(session.getSignature()+ Setup.getInstance().getHashKey())%>')" > + --> <img src="pictures/schedule_Black.png" border="0" alt="Schedule" + name="schedule_icon" id="schedule_icon" height="24" width="24" ><br /> + Availability</a> + </td> + + <td width="12%" align="center" > + <!-- <a href="javascript:doOpen(false,'ManageRoom.aspx','time=<%=session.getTimeOfLoad()%>&<%=session.url_params %>action=editRoom&signature=<%=Util.mD5Crypt(session.getSignature()+ Setup.getInstance().getHashKey())%>')" > + --> <img src="pictures/settings_Black.png" border="0" + alt="Edit RoomSettings" title="Edit Room Settings" id="settings_icon" name="settings_icon" height="24" width="24"><br /> + Settings</a> + </td> + + + <td width="12%" align="center" > + <!-- <a href="javascript:doOpen(false,'','time=<%=session.getTimeOfLoad()%>&<%=session.url_params %>action=deleteRoom&signature=<%=Util.mD5Crypt(session.getSignature()+ Setup.getInstance().getHashKey())%>')" onclick=";return confirm('Are you sure to delete this room ?');" > + --> <img src="pictures/delete_Black.png" border="0" + alt="Delete Room" title="Delete Room" id="delete_icon" height="24" width="24"><br /> + Delete</a> + </td> + </tr> + <!-- message --> + <tr> + <td colspan="12" style="background-color: #c9d2df; " > + <div id="main_title"> + <a href="javascript:hideBloc('main')" title="Expand/Collapse Archive List"> + <!-- <img src="<%=Setup.getInstance().getLcServerURL()%>/images/integration/small_collapse.gif" name="toggleimgmain" + border="0" alt="Expand/Collapse More Options" /> + --> <strong style="color: white">Main rooms:</a> + </strong></div></td> + </tr> + + <tr> + <td colspan="12" > + <div id="main" style=" overflow-y:auto;overflow-x: hidden;width:100%;" > + + </div> + </td> + </tr> + + <tr> + <td colspan="12" style="background-color: #c9d2df; " > + <div id="breakout_title"> + <a href="javascript:hideBloc('breakout')" title="Expand/Collapse Archive List"> + <!-- <img src="<%=Setup.getInstance().getLcServerURL()%>/images/integration/small_collapse.gif" name="toggleimgbreakout" + border="0" alt="Expand/Collapse More Options" />--><strong style="color: white">Discussion rooms:</a> + </strong></div></td> + </tr> + <tr> + <td colspan="12" > + <div id="breakout" style=" overflow-y:auto;overflow-x: hidden;width:100%" > + </div> + </td> + </tr> + </table> + </span> - if ($course->format == "weeks") { - if (isteacher($course->id, $USER->id)) { - $table->head = array ($strweek, $strname, $room_type, $room_info, $room_tracking, $room_settings, $room_delete); - $table->align = array ("CENTER", "LEFT", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER"); - } - else { - $table->head = array ($strweek, $strname, $room_type); - $table->align = array ("CENTER", "LEFT", "CENTER"); - } - } else if ($course->format == "topics") { - $table->head = array ($strtopic, $strname); - $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT"); - } else { - $table->head = array ($strname); - $table->align = array ("LEFT", "LEFT", "LEFT"); - } - - foreach ($liveclassrooms as $liveclassroom) { - if (!$liveclassroom->visible) { - //Show dimmed if the mod is hidden - // $link = "<A class=\"dimmed\" HREF=\"view.php?id=$liveclassroom->coursemodule\">$liveclassroom->name</A>"; - $link = "<A class=\"dimmed\" HREF=\"view.php?id=2\">$liveclassroom->name</A>"; - } else { - //Show normal if the mod is visible - $link = "<A HREF=\"view.php?id=$liveclassroom->coursemodule\">$liveclassroom->name</A>"; - } - - if ($course->format == "weeks" or $course->format == "topics") { - if (isteacher($course->id, $USER->id)) { - $table->data[] = array ($liveclassroom->section, $link, liveclassroom_get_room_name($course,$liveclassroom->type), $image1, $image2, $image3, $image4); - } - else { - $table->data[] = array ($liveclassroom->section, $link, $liveclassroom->type); - } - - } else { - $table->data[] = array ($link); - } - } - - //$list = liveclassroom_api_get_room_list($USER->firstname, $USER->firstname, $id); - //$test = liveclassroom_api_get_room($room->id); - //$list2 = liveclassroom_api_get_list_users($USER->id, $USER->firstname, $room->id); - - $fichier=fopen('C:\wampserver\www\moodle\mod\liveclassroom\user.txt','w+'); - //fputs($fichier,$id); - fputs($fichier,$room->id); - 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;'> <td valign='top'> @@ -162,14 +200,77 @@ <td style="border-bottom: 2px solid #999;"><span class='fnt0'></span> </td> </tr> - </table> + </table>--> + <table> <?php - echo "<br>"; + echo "<br> Main room"; + if(!$tab = liveclassroom_get_main_room_list($course)){ + // error("gigigigi"); + } + //echo sizeof($tab); + for($i=0;$i<sizeof($tab);$i++) {?> + <tr> + <td> + <?php + echo " ".$tab[$i]; + $table_activities = liveclassroom_get_activities_list_per_room($course,$tab[$i]); + for($j=0;$j<sizeof($table_activities);$j++) { + ?> + <tr> + <td> + <?php + echo " ++".$table_activities[$j]; + ?> + </td> + </tr> + <?php + } + ?> + </td> + </tr> + <?php + } +?> +</table> +<table> +<?php + echo "<br>Breakcout room"; + $tab = liveclassroom_get_breackout_room_list($course); + for($i=0;$i<sizeof($tab);$i++) {?> + <tr> + <td> + <?php + echo " ".$tab[$i]; + $table_activities = liveclassroom_get_activities_list_per_room($course,$tab[$i]); + for($j=0;$j<sizeof($table_activities);$j++) { + ?> + <tr> + <td> + <?php + echo " ++".$table_activities[$j]; + ?> + </td> + </tr> + <?php + } + ?> + </td> + </tr> + <?php + } +?> +</table> + +<form name="forme" method="post" action="edit.php?id=<?php p($course->id)?>"> + <input type="text" name="name" size="30" value=""> + <input type="submit" value="creer room" /> +</form> +<?php print_table($table); /// Finish the page print_footer($course); -?> +?> \ No newline at end of file Modified: trunk/moodle/mod/liveclassroom/lib.php =================================================================== --- trunk/moodle/mod/liveclassroom/lib.php 2006-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/lib.php 2006-09-07 13:19:56 UTC (rev 57) @@ -223,6 +223,7 @@ return true; } + /** * Create the different kind of room on this course * call the function create_room for each type of room available for the course given @@ -230,38 +231,13 @@ */ function liveclassroom_create_rooms ($course) { - $coursename = $course->shortname; - //get the list of existing types - $list_type = liveclassroom_get_list_type_rooms(); - - // 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"); + liveclassroom_create_room($course->id, "Main classroom", true); + liveclassroom_create_room($course->id, "Other classroom", true); + //teachers and students have the same rights + liveclassroom_create_room($course->id, "Group 1", false); + liveclassroom_create_room($course->id, "Group 2", false); -// } -// else { //Room already exist -// -// } - - -/* - for($i=0;$i<sizeof($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; } @@ -288,7 +264,7 @@ * @param $courseid : the id of the course where the room will be created * @param $roomname : the name of the room */ -function liveclassroom_create_room ($courseid, $roomname) { +function liveclassroom_create_room ($courseid, $roomname, $bool) { global $CFG; global $LIVECLASSROOM_TEACHER_SUFFIX, $LIVECLASSROOM_STUDENT_SUFFIX; @@ -309,8 +285,11 @@ $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; @@ -320,16 +299,36 @@ return false; } - if (! liveclassroom_api_add_user_role ($roomid, $teacherid, 'ClassAdmin')) { + if($bool==true) { // main lecture hall + 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_give_lectureroom_attributes($roomid)) { + return false; + } + } + else if($bool==false){ // discussion out + 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, 'Instructor')) { + //error('liveclassroom_create_room: Cannot add Participant right to students'); + return false; + } + if(!liveclassroom_api_give_discussionroom_attributes($roomid)) { + 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; } @@ -365,22 +364,46 @@ /** * Give the list of type of room available + * @param $course : an instance of a course * @return the list of type of room available */ -function liveclassroom_get_list_type_rooms() { +function liveclassroom_get_list_type_rooms($course) { + if (!($list = get_records('liveclassroom_type_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++; + } + + return $list_name; +} + +/** + * Give the list of type of room available + * @return the list of type of room available + */ +function liveclassroom_get_list_type_rooms_first_time() { + if (!($list = get_records('liveclassroom_type_rooms','course',0) )) { error( "Response get list type room : query to database failed"); } - - for($i=0;$i<sizeof($list);$i++) { - $list_name[$i] = $list[$i+1]->name; + + $i=0; + foreach($list as $liveclassroom_type_rooms) { + $list_name[$i]= $liveclassroom_type_rooms->name; + $i++; } - + return $list_name; } + + /* * Get the list of the rooms per course for a course given * @param $course : object course @@ -392,10 +415,12 @@ error( "Response get list type room per course : query to database failed"); } - for($i=0;$i<sizeof($list);$i++) { - $list_name[$i] = $list[$i+1]->name; + $i=0; + foreach($list as $liveclassroom_rooms) { + $list_name[$i] = $liveclassroom_rooms->name; + $i++; } - + return $list_name; } @@ -409,7 +434,7 @@ if(!(insert_record("liveclassroom_rooms", $liveclassroom_rooms))) { error( "Response: creation of new instance failed"); - return false; + //return false; } return true; } @@ -419,24 +444,202 @@ * Create a new type to liveclassroom Room * @param $name : the name of the type */ -function liveclassroom_rooms_add_new_type($name) { +function liveclassroom_rooms_add_new_type($courseid,$name) { $liveclassroom_type_room->timemodified = time(); - $liveclassroom_type_room->course = 0 ; + $liveclassroom_type_room->course = $courseid ; $liveclassroom_type_room->lc_id = 0 ; $liveclassroom_type_room->name = $name ; if(!(insert_record("liveclassroom_type_rooms", $liveclassroom_type_room))) { error( "Response: creation of new type $name failed"); } + return true; } + /* +* Check if the room exist in the moodle database liveclassroom_rooms +* @param $liveclassroom : a liveclassroom instance +* return true if the room exist, false if not. +*/ + +function liveclassroom_rooms_exists($liveclassroom) { + + if(!get_records('liveclassroom_rooms','lc_id',$liveclassroom->id)) { + return false; + } + else return true; + +} + +/* +* Give the shortnamefor a courseid given +* @param $courseid : the id of the course +* Return a string : the shortname of the course +*/ +function liveclassroom_get_course_shortname($courseid) { + + if(!($course = get_record('course','id',$courseid))) { + //error( "Response get room name: query to database failed"); + return false; + } + else { + $name = $course->shortname; + return $name; + } +} + + +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() { + +} + +/* +* Give the name of the room with it room id +* @param $roomis : the id of the room on the server +* Return the name of the room +*/ +function liveclassroom_get_room_name_from_id($roomid) { + + if(!($list = get_record('liveclassroom_rooms','room_id',$roomid))) { + error( "Response get list type room per course : query to database failed"); + } + return $list->name; + +} + +/* +* List the room_id of all the room available for a course +* +* @param $course +* return a table with all the room_id of the room for the course given +*/ +function liveclassroom_get_roomid_list($course) { + + if(!($rooms = get_records('liveclassroom_rooms','course',$course->id))) { + error( "Response get list type room per course : query to database failed"); + } + + $i=0; + foreach ($rooms as $liveclassroom_rooms) { + if($liveclassroom_rooms->course==$course->id) { + $list_roomid[$i]=$liveclassroom_rooms->room_id; + $i++; + } + } + return $list_roomid; +} + +/* +* List all the room "Lecture or Main rooms" for a course given +* @param $course +* return a table with all the room name considering as a lecture/main room +*/ +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; + + for($i=0;$i<sizeof($list_roomid);$i++) { + $role = liveclassroom_api_role_user_room($list_roomid[$i], $studentuserid); + if($role=='Student') { + $list_return[$j] = liveclassroom_get_room_name_from_id($list_roomid[$i]); + $j++; + } + } + + 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); + + $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 all the activities for a course given ans a type of Room +* @param $course : the course +* @param $roomnase = the name of the room +* Return a table with the activities name +*/ +function liveclassroom_get_activities_list_per_room($course,$roomname) { + + if(!($activity_list = get_records('liveclassroom','course',$course->id))) { + error( "Response get_activities_list : query to database failed"); + } + + $i=0; + foreach($activity_list as $liveclassroom) { + if($liveclassroom->type==$roomname) { + //print "yo"; + $list_return[$i] = $liveclassroom->name; + $i++; + } + } + + return $list_return; +} +/* +function liveclassroom_get_type_room($roomname) { + + if(!($lc = get_record('liveclassroom_type_rooms','name',$roomname))) { + error( "Response get type name: query to database failed2"); + return false; + } + else { + $type = $lc->id-1; + return $type; + } +} +*/ +/* * Get the type number of liveclassroom * @param $liveclassroom : the object liveclassroom * return the type number of the liveclassroom */ +/* function liveclassroom_get_type($liveclassroom) { if(!($lc = get_record('liveclassroom','id',$liveclassroom->id))) { @@ -446,13 +649,13 @@ return $lc->type; } } - +*/ /** * Give the name of the room for the course and the type given * @param $course : course * @param $type : type of the room * return the name of the room for the course -*/ +*//* function liveclassroom_get_room_name($course,$type) { /* global $LIVECLASSROOM_MOODLE_PREFIX; @@ -464,44 +667,15 @@ } -*/ + if(!($lc = get_record('liveclassroom_type_rooms','id',$type+1))) { error( "Response get room name: query to database failed"); } else { $name = $lc->name; - - return $name; } } - -/* -* Check if the room exist in the moodle database liveclassroom_rooms -* return true if the room exist, false if not. */ -function liveclassroom_rooms_exists($liveclassroom) { - - if(!get_records('liveclassroom_rooms','lc_id',$liveclassroom->id)) { - return false; - } - else return true; - -} - -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-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/mod.html 2006-09-07 13:19:56 UTC (rev 57) @@ -2,8 +2,17 @@ <!-- It is used from /course/mod.php. The whole instance is available as $form. --> <?php + require_once($CFG->dirroot.'/calendar/lib.php'); include_once($CFG->dirroot.'/mod/liveclassroom/lib.php'); - + $id = optional_param('id', 0, PARAM_INT); + + if ($id) { + + if (! $course = get_record("course", "id", $id)) { + error("Course is misconfigured"); + } + + } /// First we check that form variables have been initialised if (!isset($form->name)) { $form->name = ''; @@ -17,48 +26,158 @@ if (!isset($form->descrption)) { $form->descrption = ''; } +if (empty($form->timeopen)) { + $form->timeopen = ""; + $form->timerestrict = 0; + } else { + $form->timerestrict = 1; + } // More similar blocks go here... ?> -<form name="form" method="post" action="mod.php"> +<script type="text/javascript"> + +function validate(){ + // name can't be null + if(document.form.name.value != "") { + return true; + } + else { + alert("You must enter a name"); + return false; + } +} + +</script> + + +<form name="form" method="post" action="mod.php" onsubmit="return validate()"> <center> -<table cellpadding="5"> + + +<table width="800" cellpadding="5"> + +<tr> + <td><br></td> +</tr> + <tr valign="top"> + <td align="right"><b><font color="red">*</font><?php print_string("name") ?>:</b></td> + <td> + <input type="text" name="name" size="30" value=""> + </td> +</tr> + +<tr valign="top"> + +<?php + if($course->format == "weeks"){ + $form->timeopen = $course->startdate + (($form->section - 1) * 608400); ?> + <td align="right"><b><?php print_string('weeksformat', 'liveclassroom')?>:</b></td> + <td> + <?php + print_date_selector("openday", "openmonth", "openyear", $form->timeopen); + print_time_selector("openhour", "openminute", $form->timeopen); + ?> + </td> +<?php + } + else if($course->format == "topics"){ ?> + <tr valign="top"> + <td align="right"><b><?php print_string("topicformat") ?>:</b></td> + <td> + <select> + <option value=""> + </select> + </td> + </tr> +<?php + } + + +?> +</tr> + +<tr valign="top"> <td align="right"><b><?php print_string('liveclassroomtype', 'liveclassroom')?>:</b></td> <td> <?php include_once($CFG->dirroot.'/mod/liveclassroom/lib.php'); - //Get the list of rype of rooms available - $list_type_rooms = liveclassroom_get_list_type_rooms(); - //sort($list_type_rooms); - choose_from_menu($list_type_rooms, 'type', $form->type, ''); - helpbutton('liveclassroomtype', get_string('liveclassroomtype', 'liveclassroom'), 'liveclassroom'); + //Get the list of type of rooms available + if(!(liveclassroom_api_user_exist($course))){ + $list_type_rooms = liveclassroom_get_list_type_rooms_first_time(); + } + else { + $list_type_rooms = liveclassroom_get_list_type_rooms($course); + }?> + + <SELECT name="type"> + <?php + for($i=0;$i<sizeof($list_type_rooms);$i++) { + ?> + + <OPTION VALUE="<?php p($list_type_rooms[$i]) ?>"><?php p($list_type_rooms[$i]) ?></OPTION> + + <?php + } + ?> + </SELECT> </td> </tr> -<tr valign="top"> - <td align="right"><b><?php print_string("name") ?>:</b></td> - <td> - <input type="text" name="name" size="30" value="<?php p(get_string("modulename", "liveclassroom")) ?>"> - </td> -</tr> + <!-- More rows go in here... --> -<tr valign="top"> - <td align="right"><b><?php print_string("description") ?>:</b></td> - <td> - <TEXTAREA rows="2" name="description" ></TEXTAREA> - </td> -</tr> + <!-- The following line for Moodle 1.5 prints the visibility setting form element --> <?php print_visible_setting($form); ?> <!-- and if your module uses groups you would also have --> <?php print_groupmode_setting($form); ?> +<tr> + <td><br></td> +</tr> + +<tr > + <td colspan=2 > + <table width=100% cellpadding="5" style="border-top:#818181 1px solid; border-bottom:#818181 1px solid"> + <tr> + <td align=left width=70% > + <font color="red">*</font><?php print_string('requiredfields', 'liveclassroom')?> + </td> + <td align=center width=15%> + <input type="reset" value="<?php print_string("cancel") ?>" onclick="self.location.href='view.php?id=<?php p($id)?>'"> + <input type="submit" value="<?php print_string("add") ?>" /> + </td> + + </tr> + </table> + </td> +</tr> + + + +<!-- + +<table width="100%" border="1" bgcolor="#DDDDDD" cellpadding="0"> +<tr border="1"> + <td> + <font color="red">*</font><?php print_string('requiredfields', 'liveclassroom')?> + </td> + <td align="right"> + <input type="reset" value="<?php print_string("cancel") ?>" /> + <input type="submit" value="<?php print_string("add") ?>" /> + </td> + + </table> +</tr> + +--> +</table> <!-- These hidden variables are always the same --> <input type="hidden" name=course value="<?php p($form->course) ?>" /> <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" /> @@ -68,7 +187,7 @@ <input type="hidden" name=modulename value="<?php p($form->modulename) ?>" /> <input type="hidden" name=instance value="<?php p($form->instance) ?>" /> <input type="hidden" name=mode value="<?php p($form->mode) ?>" /> -<input type="submit" value="<?php print_string("savechanges") ?>" /> + </center> </form> Modified: trunk/moodle/mod/liveclassroom/view.php =================================================================== --- trunk/moodle/mod/liveclassroom/view.php 2006-09-01 14:08:15 UTC (rev 56) +++ trunk/moodle/mod/liveclassroom/view.php 2006-09-07 13:19:56 UTC (rev 57) @@ -35,15 +35,7 @@ $id = optional_param('id', 0, PARAM_INT); $a = optional_param('a', 0, PARAM_INT);// liveclassroom ID - //optional_variable($id); // Course Module ID, or - // optional_variable($a); // liveclassroom ID - -/* - $fichier=fopen('C:\wampserver\www\moodle\mod\liveclassroom\fichier.txt','w+'); - //fputs($fichier,$id); - fputs($fichier,$a); - fclose($fichier); // ferme le fichier txt - */ + if ($id) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect 1 "); @@ -86,10 +78,10 @@ } else { //update le lc with it room id - $name = liveclassroom_get_room_name($course, $liveclassroom->type); + /*$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); + update_record('liveclassroom', $liveclassroom);*/ } @@ -98,9 +90,6 @@ error ("Cannot create session"); } - - - /// Print the page header if ($course->category) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |