diff --git a/swad_changelog.h b/swad_changelog.h
index a8396c234..04483edd0 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -364,10 +364,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 18.27.4 (2019-01-04)"
+#define Log_PLATFORM_VERSION "SWAD 18.27.5 (2019-01-04)"
#define CSS_FILE "swad18.22.css"
#define JS_FILE "swad17.17.1.js"
/*
+ Version 18.27.5: Jan 04, 2019 Selection of classroom in form to create group. (238964 lines)
Version 18.27.4: Jan 04, 2019 New field in groups table to select a classroom. (238881 lines)
1 change necessary in database:
ALTER TABLE crs_grp ADD COLUMN ClaCod INT NOT NULL DEFAULT -1 AFTER GrpName,ADD INDEX (ClaCod);
diff --git a/swad_classroom.c b/swad_classroom.c
index 991cb4118..74d7a59e0 100644
--- a/swad_classroom.c
+++ b/swad_classroom.c
@@ -97,7 +97,7 @@ void Cla_SeeClassrooms (void)
Cla_GetParamClaOrder ();
/***** Get list of classrooms *****/
- Cla_GetListClassrooms ();
+ Cla_GetListClassrooms (Cla_ALL_DATA);
/***** Table head *****/
Box_StartBox (NULL,Txt_Classrooms,Cla_PutIconsListingClassrooms,
@@ -229,7 +229,7 @@ void Cla_EditClassrooms (void)
extern const char *Txt_Classrooms;
/***** Get list of classrooms *****/
- Cla_GetListClassrooms ();
+ Cla_GetListClassrooms (Cla_ALL_DATA);
/***** Start box *****/
Box_StartBox (NULL,Txt_Classrooms,Cla_PutIconsEditingClassrooms,
@@ -278,7 +278,7 @@ void Cla_PutIconToViewClassrooms (void)
/************************** List all the classrooms **************************/
/*****************************************************************************/
-void Cla_GetListClassrooms (void)
+void Cla_GetListClassrooms (Cla_WhichData_t WhichData)
{
static const char *OrderBySubQuery[Cla_NUM_ORDERS] =
{
@@ -294,17 +294,32 @@ void Cla_GetListClassrooms (void)
struct Classroom *Cla;
/***** Get classrooms from database *****/
- NumRows = DB_QuerySELECT (&mysql_res,"can not get classrooms",
- "SELECT ClaCod,"
- "ShortName,"
- "FullName,"
- "Capacity,"
- "Location"
- " FROM classrooms"
- " WHERE CtrCod=%ld"
- " ORDER BY %s",
- Gbl.CurrentCtr.Ctr.CtrCod,
- OrderBySubQuery[Gbl.Classrooms.SelectedOrder]);
+ switch (WhichData)
+ {
+ case Cla_ALL_DATA:
+ NumRows = DB_QuerySELECT (&mysql_res,"can not get classrooms",
+ "SELECT ClaCod,"
+ "ShortName,"
+ "FullName,"
+ "Capacity,"
+ "Location"
+ " FROM classrooms"
+ " WHERE CtrCod=%ld"
+ " ORDER BY %s",
+ Gbl.CurrentCtr.Ctr.CtrCod,
+ OrderBySubQuery[Gbl.Classrooms.SelectedOrder]);
+ break;
+ case Cla_ONLY_SHRT_NAME:
+ default:
+ NumRows = DB_QuerySELECT (&mysql_res,"can not get classrooms",
+ "SELECT ClaCod,"
+ "ShortName"
+ " FROM classrooms"
+ " WHERE CtrCod=%ld"
+ " ORDER BY ShortName",
+ Gbl.CurrentCtr.Ctr.CtrCod);
+ break;
+ }
/***** Count number of rows in result *****/
if (NumRows) // Classrooms found...
@@ -333,17 +348,20 @@ void Cla_GetListClassrooms (void)
Str_Copy (Cla->ShrtName,row[1],
Cla_MAX_BYTES_SHRT_NAME);
- /* Get the full name of the classroom (row[2]) */
- Str_Copy (Cla->FullName,row[2],
- Cla_MAX_BYTES_FULL_NAME);
+ if (WhichData == Cla_ALL_DATA)
+ {
+ /* Get the full name of the classroom (row[2]) */
+ Str_Copy (Cla->FullName,row[2],
+ Cla_MAX_BYTES_FULL_NAME);
- /* Get seating capacity in this classroom (row[3]) */
- if (sscanf (row[3],"%u",&Cla->Capacity) != 1)
- Cla->Capacity = Cla_UNLIMITED_CAPACITY;
+ /* Get seating capacity in this classroom (row[3]) */
+ if (sscanf (row[3],"%u",&Cla->Capacity) != 1)
+ Cla->Capacity = Cla_UNLIMITED_CAPACITY;
- /* Get the full name of the classroom (row[4]) */
- Str_Copy (Cla->Location,row[4],
- Cla_MAX_BYTES_LOCATION);
+ /* Get the full name of the classroom (row[4]) */
+ Str_Copy (Cla->Location,row[4],
+ Cla_MAX_BYTES_LOCATION);
+ }
}
}
else
diff --git a/swad_classroom.h b/swad_classroom.h
index 8856a725f..88a22f3f1 100644
--- a/swad_classroom.h
+++ b/swad_classroom.h
@@ -66,6 +66,13 @@ typedef enum
} Cla_Order_t;
#define Cla_ORDER_DEFAULT Cla_ORDER_BY_LOCATION
+/***** Get all data or only short name *****/
+typedef enum
+ {
+ Cla_ALL_DATA,
+ Cla_ONLY_SHRT_NAME,
+ } Cla_WhichData_t;
+
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
@@ -73,8 +80,11 @@ typedef enum
void Cla_SeeClassrooms (void);
void Cla_EditClassrooms (void);
void Cla_PutIconToViewClassrooms (void);
-void Cla_GetListClassrooms (void);
+void Cla_GetListClassrooms (Cla_WhichData_t WhichData);
void Cla_FreeListClassrooms (void);
+
+void Cla_GetListClassroomsInThisCtr (void);
+
void Cla_GetDataOfClassroomByCod (struct Classroom *Cla);
long Cla_GetParamClaCod (void);
diff --git a/swad_global.h b/swad_global.h
index 18c617086..be952ca90 100644
--- a/swad_global.h
+++ b/swad_global.h
@@ -475,6 +475,7 @@ struct Globals
struct GroupType GrpTyp;
long GrpCod; // Group to be edited, removed...
char GrpName[Grp_MAX_BYTES_GROUP_NAME + 1];
+ long ClaCod;
unsigned MaxStudents;
bool Open;
bool FileZones;
diff --git a/swad_group.c b/swad_group.c
index 33187c9cd..eff9459c9 100644
--- a/swad_group.c
+++ b/swad_group.c
@@ -232,6 +232,9 @@ static void Grp_ReqEditGroupsInternal1 (Ale_AlertType_t AlertTypeGroupTypes,cons
/***** Get list of groups types and groups in this course *****/
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ALL_GROUP_TYPES);
+ /***** Get list of classrooms in this centre *****/
+ Cla_GetListClassrooms (Cla_ONLY_SHRT_NAME);
+
/***** Show optional alert *****/
if (MessageGroupTypes)
if (MessageGroupTypes[0])
@@ -261,6 +264,9 @@ static void Grp_ReqEditGroupsInternal2 (Ale_AlertType_t AlertTypeGroups,const ch
/***** End groups section *****/
Lay_EndSection ();
+ /***** Free list of classrooms in this centre *****/
+ Cla_FreeListClassrooms ();
+
/***** Free list of groups types and groups in this course *****/
Grp_FreeListGrpTypesAndGrps ();
}
@@ -1572,7 +1578,7 @@ static void Grp_ListGroupsForEdition (void)
fprintf (Gbl.F.Out,"