"
- "");
-
/* Description of the project */
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Prj->Description,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
@@ -645,7 +601,6 @@ static void Prj_PutParams (void)
if (Gbl.Prjs.PrjCodToEdit > 0)
Prj_PutParamPrjCod (Gbl.Prjs.PrjCodToEdit);
Prj_PutHiddenParamPrjOrder ();
- Grp_PutParamWhichGrps ();
Pag_PutHiddenParamPagNum (Pag_PROJECTS,Gbl.Prjs.CurrentPage);
}
@@ -686,24 +641,11 @@ void Prj_GetListProjects (void)
sprintf (OrderBySubQuery,"EndTime DESC,StartTime DESC,Title DESC");
break;
}
- if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
- sprintf (Query,"SELECT PrjCod"
- " FROM projects"
- " WHERE CrsCod=%ld%s"
- " AND (PrjCod NOT IN (SELECT PrjCod FROM prj_grp) OR"
- " PrjCod IN (SELECT prj_grp.PrjCod FROM prj_grp,crs_grp_usr"
- " WHERE crs_grp_usr.UsrCod=%ld AND prj_grp.GrpCod=crs_grp_usr.GrpCod))"
- " ORDER BY %s",
- Gbl.CurrentCrs.Crs.CrsCod,
- HiddenSubQuery,
- Gbl.Usrs.Me.UsrDat.UsrCod,
- OrderBySubQuery);
- else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
- sprintf (Query,"SELECT PrjCod"
- " FROM projects"
- " WHERE CrsCod=%ld%s"
- " ORDER BY %s",
- Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,OrderBySubQuery);
+ sprintf (Query,"SELECT PrjCod"
+ " FROM projects"
+ " WHERE CrsCod=%ld%s"
+ " ORDER BY %s",
+ Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,OrderBySubQuery);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get projects");
if (NumRows) // Projects found...
@@ -852,9 +794,6 @@ static void Prj_GetDataOfProject (struct Project *Prj,const char *Query)
/* Get the URL of the project (row[11]) */
Str_Copy (Prj->URL,row[11],
Cns_MAX_BYTES_WWW);
-
- /* Can I do this project? */
- Prj->IBelongToCrsOrGrps = Prj_CheckIfIBelongToCrsOrGrpsThisProject (Prj->PrjCod);
}
/***** Free structure that stores the query result *****/
@@ -880,7 +819,6 @@ static void Prj_ResetProject (struct Project *Prj)
Prj->Knowledge[0] = '\0';
Prj->Materials[0] = '\0';
Prj->URL[0] = '\0';
- Prj->IBelongToCrsOrGrps = false;
}
/*****************************************************************************/
@@ -930,7 +868,6 @@ void Prj_ReqRemProject (void)
/***** Get parameters *****/
Prj_GetParamPrjOrder ();
- Grp_GetParamWhichGrps ();
Gbl.Prjs.CurrentPage = Pag_GetParamPagNum (Pag_PROJECTS);
/***** Get project code *****/
@@ -969,9 +906,6 @@ void Prj_RemoveProject (void)
/***** Get data of the project from database *****/
Prj_GetDataOfProjectByCod (&Prj); // Inside this function, the course is checked to be the current one
- /***** Remove all the groups of this project *****/
- Prj_RemoveAllTheGrpsAssociatedToAProject (Prj.PrjCod);
-
/***** Remove project *****/
sprintf (Query,"DELETE FROM projects"
" WHERE PrjCod=%ld AND CrsCod=%ld",
@@ -1107,7 +1041,6 @@ void Prj_RequestCreatOrEditPrj (void)
/***** Get parameters *****/
Prj_GetParamPrjOrder ();
- Grp_GetParamWhichGrps ();
Gbl.Prjs.CurrentPage = Pag_GetParamPagNum (Pag_PROJECTS);
/***** Get the code of the project *****/
@@ -1247,9 +1180,6 @@ void Prj_RequestCreatOrEditPrj (void)
""
"");
- /***** Groups *****/
- Prj_ShowLstGrpsToEditProject (Prj.PrjCod);
-
/***** End table, send button and end box *****/
if (ItsANewProject)
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_project);
@@ -1305,66 +1235,6 @@ static void Prj_FreeMemProject (struct Project *Prj)
}
}
-/*****************************************************************************/
-/****************** Show list of groups to edit and project ******************/
-/*****************************************************************************/
-
-static void Prj_ShowLstGrpsToEditProject (long PrjCod)
- {
- extern const char *Hlp_USERS_Groups;
- extern const char *The_ClassForm[The_NUM_THEMES];
- extern const char *Txt_Groups;
- extern const char *Txt_The_whole_course;
- unsigned NumGrpTyp;
-
- /***** Get list of groups types and groups in this course *****/
- Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
-
- if (Gbl.CurrentCrs.Grps.GrpTypes.Num)
- {
- /***** Start box and table *****/
- fprintf (Gbl.F.Out,"
"
- "
"
- "%s:"
- "
"
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_Groups);
- Box_StartBoxTable ("100%",NULL,NULL,
- Hlp_USERS_Groups,Box_NOT_CLOSABLE,0);
-
- /***** First row: checkbox to select the whole course *****/
- fprintf (Gbl.F.Out,"
"
- "
"
- ""
- "
"
- "
",
- Txt_The_whole_course,Gbl.CurrentCrs.Crs.ShrtName);
-
- /***** List the groups for each group type *****/
- for (NumGrpTyp = 0;
- NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
- NumGrpTyp++)
- if (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
- Grp_ListGrpsToEditAsgPrjAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
- PrjCod,Grp_PROJECT);
-
- /***** End table and box *****/
- Box_EndBoxTable ();
- fprintf (Gbl.F.Out,""
- "");
- }
-
- /***** Free list of groups types and groups in this course *****/
- Grp_FreeListGrpTypesAndGrps ();
- }
-
/*****************************************************************************/
/******************** Receive form to create a new project *******************/
/*****************************************************************************/
@@ -1440,9 +1310,6 @@ void Prj_RecFormProject (void)
/***** Create a new project or update an existing one *****/
if (NewProjectIsCorrect)
{
- /* Get groups for this projects */
- Grp_GetParCodsSeveralGrps ();
-
if (ItsANewProject)
{
Prj_CreateProject (&Prj); // Add new project to database
@@ -1459,9 +1326,6 @@ void Prj_RecFormProject (void)
Ale_ShowAlert (Ale_SUCCESS,Txt_The_project_has_been_modified);
}
- /* Free memory for list of selected groups */
- Grp_FreeListCodSelectedGrps ();
-
/***** Show projects again *****/
Prj_SeeProjects ();
}
@@ -1505,10 +1369,6 @@ static void Prj_CreateProject (struct Project *Prj)
Prj->Materials,
Prj->URL);
Prj->PrjCod = DB_QueryINSERTandReturnCode (Query,"can not create new project");
-
- /***** Create groups *****/
- if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)
- Prj_CreateGrps (Prj->PrjCod);
}
/*****************************************************************************/
@@ -1543,176 +1403,6 @@ static void Prj_UpdateProject (struct Project *Prj)
Prj->URL,
Prj->PrjCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE (Query,"can not update project");
-
- /***** Update groups *****/
- /* Remove old groups */
- Prj_RemoveAllTheGrpsAssociatedToAProject (Prj->PrjCod);
-
- /* Create new groups */
- if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)
- Prj_CreateGrps (Prj->PrjCod);
- }
-
-/*****************************************************************************/
-/************* Check if a project is associated to any group *****************/
-/*****************************************************************************/
-
-static bool Prj_CheckIfPrjIsAssociatedToGrps (long PrjCod)
- {
- char Query[256];
-
- /***** Get if a project is associated to a group from database *****/
- sprintf (Query,"SELECT COUNT(*) FROM prj_grp WHERE PrjCod=%ld",
- PrjCod);
- return (DB_QueryCOUNT (Query,"can not check if a project is associated to groups") != 0);
- }
-
-/*****************************************************************************/
-/************** Check if a project is associated to a group ******************/
-/*****************************************************************************/
-
-bool Prj_CheckIfPrjIsAssociatedToGrp (long PrjCod,long GrpCod)
- {
- char Query[256];
-
- /***** Get if a project is associated to a group from database *****/
- sprintf (Query,"SELECT COUNT(*) FROM prj_grp"
- " WHERE PrjCod=%ld AND GrpCod=%ld",
- PrjCod,GrpCod);
- return (DB_QueryCOUNT (Query,"can not check if a project is associated to a group") != 0);
- }
-
-/*****************************************************************************/
-/*********************** Remove groups of a project **************************/
-/*****************************************************************************/
-
-static void Prj_RemoveAllTheGrpsAssociatedToAProject (long PrjCod)
- {
- char Query[256];
-
- /***** Remove groups of the project *****/
- sprintf (Query,"DELETE FROM prj_grp WHERE PrjCod=%ld",PrjCod);
- DB_QueryDELETE (Query,"can not remove the groups associated to a project");
- }
-
-/*****************************************************************************/
-/****************** Remove one group from all the projects *******************/
-/*****************************************************************************/
-
-void Prj_RemoveGroup (long GrpCod)
- {
- char Query[256];
-
- /***** Remove group from all the projects *****/
- sprintf (Query,"DELETE FROM prj_grp WHERE GrpCod=%ld",GrpCod);
- DB_QueryDELETE (Query,"can not remove group from the associations between projects and groups");
- }
-
-/*****************************************************************************/
-/************* Remove groups of one type from all the projects ***************/
-/*****************************************************************************/
-
-void Prj_RemoveGroupsOfType (long GrpTypCod)
- {
- char Query[256];
-
- /***** Remove group from all the projects *****/
- sprintf (Query,"DELETE FROM prj_grp USING crs_grp,prj_grp"
- " WHERE crs_grp.GrpTypCod=%ld"
- " AND crs_grp.GrpCod=prj_grp.GrpCod",
- GrpTypCod);
- DB_QueryDELETE (Query,"can not remove groups of a type from the associations between projects and groups");
- }
-
-/*****************************************************************************/
-/*********************** Create groups of a project **************************/
-/*****************************************************************************/
-
-static void Prj_CreateGrps (long PrjCod)
- {
- unsigned NumGrpSel;
- char Query[256];
-
- /***** Create groups of the project *****/
- for (NumGrpSel = 0;
- NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
- NumGrpSel++)
- {
- /* Create group */
- sprintf (Query,"INSERT INTO prj_grp"
- " (PrjCod,GrpCod)"
- " VALUES"
- " (%ld,%ld)",
- PrjCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
- DB_QueryINSERT (Query,"can not associate a group to a project");
- }
- }
-
-/*****************************************************************************/
-/*********** Get and write the names of the groups of a project **************/
-/*****************************************************************************/
-
-static void Prj_GetAndWriteNamesOfGrpsAssociatedToPrj (struct Project *Prj)
- {
- extern const char *Txt_Group;
- extern const char *Txt_Groups;
- extern const char *Txt_and;
- extern const char *Txt_The_whole_course;
- char Query[512];
- MYSQL_RES *mysql_res;
- MYSQL_ROW row;
- unsigned long NumRow;
- unsigned long NumRows;
-
- /***** Get groups associated to a project from database *****/
- sprintf (Query,"SELECT crs_grp_types.GrpTypName,crs_grp.GrpName"
- " FROM prj_grp,crs_grp,crs_grp_types"
- " WHERE prj_grp.PrjCod=%ld"
- " AND prj_grp.GrpCod=crs_grp.GrpCod"
- " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
- " ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
- Prj->PrjCod);
- NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get groups of a project");
-
- /***** Write heading *****/
- fprintf (Gbl.F.Out,"
%s: ",
- Prj->Hidden ? "ASG_GRP_LIGHT" :
- "ASG_GRP",
- (NumRows == 1) ? Txt_Group :
- Txt_Groups);
-
- /***** Write groups *****/
- if (NumRows) // Groups found...
- {
- /* Get and write the group types and names */
- for (NumRow = 0;
- NumRow < NumRows;
- NumRow++)
- {
- /* Get next group */
- row = mysql_fetch_row (mysql_res);
-
- /* Write group type name and group name */
- fprintf (Gbl.F.Out,"%s %s",row[0],row[1]);
-
- if (NumRows >= 2)
- {
- if (NumRow == NumRows-2)
- fprintf (Gbl.F.Out," %s ",Txt_and);
- if (NumRows >= 3)
- if (NumRow < NumRows-2)
- fprintf (Gbl.F.Out,", ");
- }
- }
- }
- else
- fprintf (Gbl.F.Out,"%s %s",
- Txt_The_whole_course,Gbl.CurrentCrs.Crs.ShrtName);
-
- fprintf (Gbl.F.Out,"
");
-
- /***** Free structure that stores the query result *****/
- DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
@@ -1723,57 +1413,11 @@ void Prj_RemoveCrsProjects (long CrsCod)
{
char Query[512];
- /***** Remove groups *****/
- sprintf (Query,"DELETE FROM prj_grp USING projects,prj_grp"
- " WHERE projects.CrsCod=%ld"
- " AND projects.PrjCod=prj_grp.PrjCod",
- CrsCod);
- DB_QueryDELETE (Query,"can not remove all the groups associated to projects of a course");
-
/***** Remove projects *****/
sprintf (Query,"DELETE FROM projects WHERE CrsCod=%ld",CrsCod);
DB_QueryDELETE (Query,"can not remove all the projects of a course");
}
-/*****************************************************************************/
-/*********** Check if I belong to any of the groups of a project *************/
-/*****************************************************************************/
-
-static bool Prj_CheckIfIBelongToCrsOrGrpsThisProject (long PrjCod)
- {
- char Query[512];
-
- switch (Gbl.Usrs.Me.Role.Logged)
- {
- case Rol_STD:
- case Rol_NET:
- case Rol_TCH:
- // Students and teachers can do projects depending on groups
- /***** Get if I can do a project from database *****/
- sprintf (Query,"SELECT COUNT(*) FROM projects"
- " WHERE PrjCod=%ld"
- " AND "
- "("
- "PrjCod NOT IN (SELECT PrjCod FROM prj_grp)" // Project is for the whole course
- " OR "
- "PrjCod IN" // Project is for specific groups
- " (SELECT prj_grp.PrjCod FROM prj_grp,crs_grp_usr"
- " WHERE crs_grp_usr.UsrCod=%ld"
- " AND prj_grp.GrpCod=crs_grp_usr.GrpCod)"
- ")",
- PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod);
- return (DB_QueryCOUNT (Query,"can not check if I can do a project") != 0);
- case Rol_DEG_ADM:
- case Rol_CTR_ADM:
- case Rol_INS_ADM:
- case Rol_SYS_ADM:
- // Admins can view projects
- return true;
- default:
- return false;
- }
- }
-
/*****************************************************************************/
/******************** Get number of projects in a course *********************/
/*****************************************************************************/
diff --git a/swad_project.h b/swad_project.h
index 39d7e6290..cfcd54a88 100644
--- a/swad_project.h
+++ b/swad_project.h
@@ -59,10 +59,6 @@ struct Project
char *Knowledge;
char *Materials;
char URL[Cns_MAX_BYTES_WWW + 1];
- bool IBelongToCrsOrGrps; // I can do this assignment
- // (it is associated to no groups
- // or, if associated to groups,
- // I belong to any of the groups)
};
#define Prj_ORDER_DEFAULT Dat_START_TIME
@@ -86,9 +82,6 @@ void Prj_RemoveProject (void);
void Prj_HideProject (void);
void Prj_ShowProject (void);
void Prj_RecFormProject (void);
-bool Prj_CheckIfPrjIsAssociatedToGrp (long PrjCod,long GrpCod);
-void Prj_RemoveGroup (long GrpCod);
-void Prj_RemoveGroupsOfType (long GrpTypCod);
void Prj_RemoveCrsProjects (long CrsCod);
unsigned Prj_GetNumProjectsInCrs(long CrsCod);
diff --git a/swad_survey.c b/swad_survey.c
index 6475b5865..8c1321738 100644
--- a/swad_survey.c
+++ b/swad_survey.c
@@ -2044,7 +2044,7 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod)
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
NumGrpTyp++)
if (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
- Grp_ListGrpsToEditAsgPrjAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
+ Grp_ListGrpsToEditAsgAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
SvyCod,Grp_SURVEY);
/***** End table and box *****/