[Hw4mdl-svn] SF.net SVN: hw4mdl: [43] trunk/moodle/mod/liveclassroom
Brought to you by:
jhlinder,
trollinger
From: <sh...@us...> - 2006-08-24 09:29:28
|
Revision: 43 Author: shazan Date: 2006-08-24 02:29:06 -0700 (Thu, 24 Aug 2006) ViewCVS: http://svn.sourceforge.net/hw4mdl/?rev=43&view=rev Log Message: ----------- - Added several functions to the LC API (handles creation of different rooms) Modified Paths: -------------- trunk/moodle/mod/liveclassroom/create.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/create.php =================================================================== --- trunk/moodle/mod/liveclassroom/create.php 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/create.php 2006-08-24 09:29:06 UTC (rev 43) @@ -42,9 +42,13 @@ error("Guests are not allowed to create rooms", $_SERVER["HTTP_REFERER"]); } - $id = required_param('id', PARAM_INT); // Course Module ID - $roomname = required_param('roomname', PARAM_TEXT); // Room name + $id = optional_param('id', 0, PARAM_INT); + // $id = required_param('id', PARAM_INT); // Course Module ID + + $roomname = optional_param('idroomname', 0, PARAM_TEXT); + //$roomname = required_param('roomname', PARAM_TEXT); // Room name + if (! $course = get_record("course", "id", $id)) { error("Course is misconfigured"); } @@ -52,6 +56,9 @@ require_login($id, false); + + + if (isstudent($course->id)) { error("Students are not allowed to create rooms", $_SERVER["HTTP_REFERER"]); } Modified: trunk/moodle/mod/liveclassroom/db/mysql.sql =================================================================== --- trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/db/mysql.sql 2006-08-24 09:29:06 UTC (rev 43) @@ -36,10 +36,21 @@ CREATE TABLE `prefix_liveclassroom` ( `id` int(10) unsigned NOT NULL auto_increment, `course` int(10) unsigned NOT NULL default '0', + `type` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '', + `description` text NOT NULL default '', `timemodified` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) COMMENT='Defines liveclassroom'; + +CREATE TABLE `prefix_liveclassroom_rooms` ( + `id` int(10) unsigned NOT NULL auto_increment, + `course` int(10) unsigned NOT NULL default '0', + `name` varchar(255) NOT NULL default '', + `lc_id` int(10) unsigned NOT NULL default '0', + `room_id` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) +) COMMENT='Defines liveclassroom rooms'; # -------------------------------------------------------- # INSERT INTO prefix_log_display VALUES ('liveclassroom', 'view', 'liveclassroom', 'name'); Modified: trunk/moodle/mod/liveclassroom/index.php =================================================================== --- trunk/moodle/mod/liveclassroom/index.php 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/index.php 2006-08-24 09:29:06 UTC (rev 43) @@ -32,9 +32,21 @@ require_once("../../config.php"); require_once("lib.php"); + + $id = optional_param('id', 0, PARAM_INT); - require_variable($id); // course + $course = optional_param('course', 0, PARAM_INT); + $roomname = optional_param('idroomname', 0, PARAM_TEXT); + //$roomid = optional_param('idroom', 0, PARAM_TEXT); + + if (! $room = get_record("liveclassroom", "course", $id)) { + error("Course ID is incorrect"); + } + //$id = require_param('id', 0, PARAM_INT); + //require_variable($id); // course + + if (! $course = get_record("course", "id", $id)) { error("Course ID is incorrect"); } @@ -72,9 +84,28 @@ $strweek = get_string("week"); $strtopic = get_string("topic"); + $room_type = "Room Type"; + $room_info = "Get Info"; + $room_enter = "Enter Room"; + $room_tracking = "Tracking"; + $room_settings = "Settings"; + $room_delete = "Remove"; + + + $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>"; + if ($course->format == "weeks") { - $table->head = array ($strweek, $strname); - $table->align = array ("CENTER", "LEFT"); + 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"); @@ -86,21 +117,52 @@ 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=$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") { - $table->data[] = array ($liveclassroom->section, $link); + if (isteacher($course->id, $USER->id)) { + $table->data[] = array ($liveclassroom->section, $link, $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); - echo "<BR>"; + $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'> + <strong><font size='+1'><?php p(get_string('listroom', 'liveclassroom'))?> <em><?php p($course->fullname)?></em>.</font> + </strong> + </td> + </tr> + <tr> + <td style="border-bottom: 2px solid #999;"><span class='fnt0'></span> + </td> + </tr> + </table> +<?php + echo "<br>"; + print_table($table); /// Finish the page Modified: trunk/moodle/mod/liveclassroom/lib.php =================================================================== --- trunk/moodle/mod/liveclassroom/lib.php 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/lib.php 2006-08-24 09:29:06 UTC (rev 43) @@ -217,11 +217,20 @@ /** - * Create the Lecture Hall room and as many study rooms as groups oin this course + * Create the different kind of room on this course */ function liveclassroom_create_rooms ($course) { - //Implement me! + + // 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); + } + } return true; + } function liveclassroom_create_session ($course, $isteacher) { @@ -306,6 +315,49 @@ return '0'; } +/** + * Give the list of type of room available + * @return the list of type of room available + */ +function liveclassroom_get_list_type_rooms() { + + + $list = get_records('liveclassroom_rooms','course',0); + + for($i=0;$i<sizeof($list);$i++) { + $list_name[$i] = $list[$i+1]->name; + } + return $list_name; +} +function liveclassroom_get_list_type_rooms_per_course($course) { + + + $list = get_records('liveclassroom_rooms','course',$course->id); + + for($i=0;$i<sizeof($list);$i++) { + $list_name[$i] = $list[$i+1]->name; + } + + return $list_name; +} + +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); + +} + + + ?> Modified: trunk/moodle/mod/liveclassroom/mod.html =================================================================== --- trunk/moodle/mod/liveclassroom/mod.html 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/mod.html 2006-08-24 09:29:06 UTC (rev 43) @@ -2,10 +2,18 @@ <!-- It is used from /course/mod.php. The whole instance is available as $form. --> <?php + include_once($CFG->dirroot.'/mod/liveclassroom/lib.php'); + /// First we check that form variables have been initialised if (!isset($form->name)) { $form->name = ''; } +if (!isset($form->type)) { + $form->type = ''; +} +if (!isset($form->intro)) { + $form->intro = ''; +} // More similar blocks go here... ?> @@ -13,13 +21,39 @@ <center> <table cellpadding="5"> <tr valign="top"> + <td align="right"><b><?php print_string('liveclassroomtype', 'liveclassroom')?>:</b></td> + <td> + <?php + include_once($CFG->dirroot.'/mod/liveclassroom/lib.php'); + //recuperation de la liste des types de rooms + $list_type_rooms = liveclassroom_get_list_type_rooms(); + // asort($LIVECLASSROOM_TYPES); + //$list_type_rooms[sizeof($list_type_rooms)] = get_string('otherroom', 'liveclassroom'); + + choose_from_menu($list_type_rooms, 'type', $form->type, ''); + helpbutton('liveclassroomtype', get_string('liveclassroomtype', 'liveclassroom'), 'liveclassroom'); + + + + ?> + </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 --> Modified: trunk/moodle/mod/liveclassroom/view.php =================================================================== --- trunk/moodle/mod/liveclassroom/view.php 2006-07-05 16:49:45 UTC (rev 42) +++ trunk/moodle/mod/liveclassroom/view.php 2006-08-24 09:29:06 UTC (rev 43) @@ -33,12 +33,20 @@ require_once("../../config.php"); require_once("lib.php"); - optional_variable($id); // Course Module ID, or - optional_variable($a); // liveclassroom ID + $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"); + error("Course Module ID was incorrect 1 "); } if (! $course = get_record("course", "id", $cm->course)) { @@ -46,12 +54,13 @@ } if (! $liveclassroom = get_record("liveclassroom", "id", $cm->instance)) { - error("Course module is incorrect"); + error("Course module is incorrect1"); } } else { if (! $liveclassroom = get_record("liveclassroom", "id", $a)) { - error("Course module is incorrect"); + + error("Course module is incorrect2"); } if (! $course = get_record("course", "id", $liveclassroom->course)) { error("Course is misconfigured"); @@ -73,8 +82,22 @@ if (!liveclassroom_create_rooms ($course)) { error ("Cannot create liveclassroom rooms"); } + //ajouter ds la BD liveclassroom_rooms l'instance correspondant + if($liveclassroom->type==0) { //lecture hall + $name = $course->shortname.'_LectureHall'; + } + else if($liveclassroom->type==1) { // breackout + $name = $course->shortname.'_BreackOut'; + } + $liveclassroom_rooms->course = $liveclassroom->course; + $liveclassroom_rooms->lc_id = $liveclassroom->id; + $liveclassroom_rooms->name = $name; + + if(!liveclassroom_rooms_add_instance($liveclassroom_rooms)) { + return false; + } + - // Create the session fir this user if (!$usersession = liveclassroom_create_session ($course, isteacher($course->id, $USER->id))) { error ("Cannot create session"); @@ -136,10 +159,22 @@ </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> + <!-- + <tr> <td> <form method="get" name="createRoom" action="create.php"> - <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" /> + <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" <label for="createroomname"><?php echo get_string('labelcreateroom', 'liveclassroom') ?></label> <input id="createroomname" type="text" size="10" name="roomname"> <input type="hidden" name="id" value="<?php echo $course->id ?>"> @@ -147,6 +182,7 @@ </form> </td> </tr> + --> <?php } ?> @@ -177,9 +213,16 @@ </table> </td> </tr> + + </table> + + <tr style="background-color:#EEEEEE; font-weight:normal; color:black;"><td style="border-right:1px solid #999;"> </td><td> </td></tr> </table> + + + <?PHP /// Finish the page print_footer($course); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |