2023-04-01 01:01:12 +02:00
|
|
|
|
// swad_project_config.c: projects configuration
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h> // For boolean type
|
2023-05-23 10:13:14 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2023-05-03 11:02:06 +02:00
|
|
|
|
#include <string.h> // For string functions
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
#include "swad_action_list.h"
|
|
|
|
|
#include "swad_alert.h"
|
|
|
|
|
#include "swad_box.h"
|
|
|
|
|
#include "swad_database.h"
|
2023-05-17 15:28:15 +02:00
|
|
|
|
#include "swad_error.h"
|
2023-04-01 01:01:12 +02:00
|
|
|
|
#include "swad_form.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_parameter.h"
|
2023-05-17 15:28:15 +02:00
|
|
|
|
#include "swad_parameter_code.h"
|
2023-04-01 01:01:12 +02:00
|
|
|
|
#include "swad_project.h"
|
|
|
|
|
#include "swad_project_config.h"
|
|
|
|
|
#include "swad_project_database.h"
|
2023-04-12 00:08:02 +02:00
|
|
|
|
#include "swad_rubric.h"
|
2023-04-17 23:55:22 +02:00
|
|
|
|
#include "swad_rubric_database.h"
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
static void PrjCfg_ShowFormNETCanCreate (const struct PrjCfg_Config *Config);
|
2023-05-17 15:28:15 +02:00
|
|
|
|
static void PrjCfg_ShowFormsRubrics (void);
|
|
|
|
|
static void PrjCfg_ShowFormsRubricsOfType (const struct Rub_Rubrics *Rubrics,
|
|
|
|
|
PrjCfg_RubricType_t RubricType);
|
2023-04-04 09:05:36 +02:00
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
static void PrjCfg_GetConfigDataFromRow (MYSQL_RES *mysql_res,
|
2023-04-13 14:25:52 +02:00
|
|
|
|
struct PrjCfg_Config *Config);
|
2023-05-17 15:28:15 +02:00
|
|
|
|
static void PrjCfg_GetListRubCods (const struct Rub_Rubrics *Rubrics,
|
|
|
|
|
struct PrgCfg_ListRubCods *ListRubCods);
|
2023-04-10 14:41:20 +02:00
|
|
|
|
static bool PrjCfg_GetIfNETCanCreateFromForm (void);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get configuration of projects for current course *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
void PrjCfg_GetConfig (struct PrjCfg_Config *Config)
|
2023-04-10 14:41:20 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
Config->NETCanCreate = PrjCfg_NET_CAN_CREATE_DEFAULT;
|
2023-04-10 14:41:20 +02:00
|
|
|
|
if (Prj_DB_GetConfig (&mysql_res))
|
2023-04-13 14:25:52 +02:00
|
|
|
|
PrjCfg_GetConfigDataFromRow (mysql_res,Config);
|
2023-04-10 14:41:20 +02:00
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Can I configure all projects? **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
Usr_Can_t PrjCfg_CheckIfICanConfig (void)
|
2023-04-01 01:01:12 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t ICanConfigAllProjects[Rol_NUM_ROLES] =
|
2023-04-01 01:01:12 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
[Rol_TCH ] = Usr_CAN,
|
|
|
|
|
[Rol_SYS_ADM] = Usr_CAN,
|
2023-04-01 01:01:12 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ICanConfigAllProjects[Gbl.Usrs.Me.Role.Logged];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Configuration of all projects ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void PrjCfg_ShowFormConfig (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Projects;
|
|
|
|
|
extern const char *Txt_Configure_projects;
|
2023-05-07 22:18:21 +02:00
|
|
|
|
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
2023-05-04 18:27:32 +02:00
|
|
|
|
extern const char *Txt_Rubrics;
|
2023-04-01 01:01:12 +02:00
|
|
|
|
struct Prj_Projects Projects;
|
|
|
|
|
|
|
|
|
|
/***** Reset projects *****/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
Prj_ResetPrjsAndReadConfig (&Projects);
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Configure_projects,Prj_PutIconsListProjects,&Projects,
|
2023-04-01 01:01:12 +02:00
|
|
|
|
Hlp_ASSESSMENT_Projects,Box_NOT_CLOSABLE);
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/***** Projects are editable by non-editing teachers? *****/
|
|
|
|
|
Frm_BeginForm (ActChgNETCanCrePrj);
|
2023-05-05 17:00:50 +02:00
|
|
|
|
HTM_FIELDSET_Begin (NULL);
|
2023-05-07 22:18:21 +02:00
|
|
|
|
HTM_LEGEND (Txt_Actions[ActChgPrj]);
|
2023-04-13 14:25:52 +02:00
|
|
|
|
PrjCfg_ShowFormNETCanCreate (&Projects.Config);
|
2023-05-04 18:27:32 +02:00
|
|
|
|
HTM_FIELDSET_End ();
|
2023-04-01 01:01:12 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/***** Rubrics *****/
|
2023-05-21 19:15:55 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // TODO: Remove this rectriction when rubrics are finished
|
|
|
|
|
{
|
|
|
|
|
HTM_FIELDSET_Begin (NULL);
|
|
|
|
|
HTM_LEGEND (Txt_Rubrics);
|
|
|
|
|
PrjCfg_ShowFormsRubrics ();
|
|
|
|
|
HTM_FIELDSET_End ();
|
|
|
|
|
}
|
2023-05-17 15:28:15 +02:00
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 00:08:02 +02:00
|
|
|
|
/*****************************************************************************/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/************ Show forms to edit rubrics associated to projects **************/
|
2023-04-12 00:08:02 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
static void PrjCfg_ShowFormsRubrics (void)
|
2023-04-12 00:08:02 +02:00
|
|
|
|
{
|
|
|
|
|
struct Rub_Rubrics Rubrics;
|
2023-05-17 15:28:15 +02:00
|
|
|
|
PrjCfg_RubricType_t RubricType;
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset rubrics context *****/
|
|
|
|
|
Rub_ResetRubrics (&Rubrics);
|
|
|
|
|
|
|
|
|
|
/***** Get list of rubrics *****/
|
|
|
|
|
Rub_GetListRubrics (&Rubrics);
|
|
|
|
|
|
2023-04-12 11:05:40 +02:00
|
|
|
|
/***** Rubric selectors *****/
|
2023-05-04 18:27:32 +02:00
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
2023-05-17 15:28:15 +02:00
|
|
|
|
for (RubricType = (PrjCfg_RubricType_t) 1;
|
|
|
|
|
RubricType <= (PrjCfg_RubricType_t) (PrjCfg_NUM_RUBRIC_TYPES - 1);
|
|
|
|
|
RubricType++)
|
|
|
|
|
PrjCfg_ShowFormsRubricsOfType (&Rubrics,RubricType);
|
2023-05-04 18:27:32 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-04-12 11:05:40 +02:00
|
|
|
|
/***** Free list of rubrics *****/
|
|
|
|
|
Rub_FreeListRubrics (&Rubrics);
|
|
|
|
|
}
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-04-12 11:05:40 +02:00
|
|
|
|
/*****************************************************************************/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/*** Show form to choose the rubrics of a given type associated to projects **/
|
2023-04-12 11:05:40 +02:00
|
|
|
|
/*****************************************************************************/
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
static void PrjCfg_ShowFormsRubricsOfType (const struct Rub_Rubrics *Rubrics,
|
|
|
|
|
PrjCfg_RubricType_t RubricType)
|
2023-04-12 11:05:40 +02:00
|
|
|
|
{
|
2024-03-22 09:59:20 +01:00
|
|
|
|
extern const char *Par_CodeStr[Par_NUM_PAR_COD];
|
2023-05-17 15:28:15 +02:00
|
|
|
|
extern const char *Prj_DB_RubricType[PrjCfg_NUM_RUBRIC_TYPES];
|
|
|
|
|
extern const char *Txt_PROJECT_RUBRIC[PrjCfg_NUM_RUBRIC_TYPES];
|
2023-04-13 14:25:52 +02:00
|
|
|
|
extern const char *Txt_no_rubric;
|
2023-05-17 15:28:15 +02:00
|
|
|
|
extern const char *Txt_add_rubric;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumRubricsThisType;
|
|
|
|
|
unsigned NumRubThisType;
|
|
|
|
|
unsigned NumRubThisCrs;
|
|
|
|
|
long RubCodThisType;
|
2023-04-17 23:55:22 +02:00
|
|
|
|
char Title[Rub_MAX_BYTES_TITLE + 1];
|
2023-05-17 15:28:15 +02:00
|
|
|
|
|
|
|
|
|
/***** Get project rubrics for current course from database *****/
|
|
|
|
|
NumRubricsThisType = Prj_DB_GetRubricsOfType (&mysql_res,RubricType);
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-04-12 11:05:40 +02:00
|
|
|
|
/***** Row with form for rubric *****/
|
2023-04-12 00:08:02 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label */
|
2023-10-18 11:08:13 +02:00
|
|
|
|
HTM_TD_TxtColon (Txt_PROJECT_RUBRIC[RubricType]);
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/* Selectors of rubrics */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
|
|
|
|
|
Frm_BeginForm (ActChgRubPrj);
|
|
|
|
|
Par_PutParString (NULL,"RubricType",Prj_DB_RubricType[RubricType]);
|
|
|
|
|
|
|
|
|
|
/* One selector for each rubric */
|
|
|
|
|
for (NumRubThisType = 0;
|
|
|
|
|
NumRubThisType < NumRubricsThisType;
|
|
|
|
|
NumRubThisType++)
|
2023-04-13 14:25:52 +02:00
|
|
|
|
{
|
2023-05-17 15:28:15 +02:00
|
|
|
|
RubCodThisType = DB_GetNextCode (mysql_res);
|
|
|
|
|
|
2024-05-14 10:19:48 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_ENABLED,HTM_NOT_REQUIRED,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,NULL,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"name=\"%s\" class=\"PrjCfg_RUBRIC_SEL\"",
|
|
|
|
|
Par_CodeStr[ParCod_Rub]);
|
|
|
|
|
/* First option to indicate that no rubric is selected */
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"-1",
|
2023-05-18 12:54:43 +02:00
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
HTM_ENABLED,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"[%s]",Txt_no_rubric);
|
|
|
|
|
|
|
|
|
|
/* One option for each rubric in this course */
|
|
|
|
|
for (NumRubThisCrs = 0;
|
|
|
|
|
NumRubThisCrs < Rubrics->Num;
|
|
|
|
|
NumRubThisCrs++)
|
|
|
|
|
{
|
|
|
|
|
Rub_DB_GetRubricTitle (Rubrics->Lst[NumRubThisCrs],Title,Rub_MAX_BYTES_TITLE);
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Rubrics->Lst[NumRubThisCrs],
|
2023-05-18 12:54:43 +02:00
|
|
|
|
Rubrics->Lst[NumRubThisCrs] == RubCodThisType ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
HTM_ENABLED,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"%s",Title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_BR ();
|
2023-04-13 14:25:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/* One extra selector to add a new rubric,
|
|
|
|
|
only if not all available rubrics are selected */
|
|
|
|
|
if (NumRubricsThisType < Rubrics->Num)
|
|
|
|
|
{
|
2024-05-14 10:19:48 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_ENABLED,HTM_NOT_REQUIRED,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,NULL,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"name=\"%s\" class=\"PrjCfg_RUBRIC_SEL\"",
|
|
|
|
|
Par_CodeStr[ParCod_Rub]);
|
|
|
|
|
|
|
|
|
|
/* First option to indicate that no rubric is selected */
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"-1",
|
2023-05-18 12:54:43 +02:00
|
|
|
|
HTM_OPTION_SELECTED,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
HTM_DISABLED,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"[%s]",Txt_add_rubric);
|
|
|
|
|
|
|
|
|
|
/* One option for each rubric in this course */
|
|
|
|
|
for (NumRubThisCrs = 0;
|
|
|
|
|
NumRubThisCrs < Rubrics->Num;
|
|
|
|
|
NumRubThisCrs++)
|
|
|
|
|
{
|
|
|
|
|
Rub_DB_GetRubricTitle (Rubrics->Lst[NumRubThisCrs],Title,Rub_MAX_BYTES_TITLE);
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Rubrics->Lst[NumRubThisCrs],
|
2023-05-18 12:54:43 +02:00
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
HTM_ENABLED,
|
2023-05-17 15:28:15 +02:00
|
|
|
|
"%s",Title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
}
|
2023-04-12 00:08:02 +02:00
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
2023-04-12 00:08:02 +02:00
|
|
|
|
HTM_TR_End ();
|
2023-05-17 15:28:15 +02:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2023-04-12 00:08:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get configuration values from a database table row *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void PrjCfg_GetConfigDataFromRow (MYSQL_RES *mysql_res,
|
2023-04-13 14:25:52 +02:00
|
|
|
|
struct PrjCfg_Config *Config)
|
2023-04-01 01:01:12 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
2023-05-03 11:02:06 +02:00
|
|
|
|
|
|
|
|
|
/***** Get row *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
/*
|
|
|
|
|
row[0] NETCanCreate
|
|
|
|
|
*/
|
|
|
|
|
/***** Get whether non-editing teachers can create new projects or not (row[0]) *****/
|
|
|
|
|
Config->NETCanCreate = (row[0][0] == 'Y');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Convert from string to type **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
PrjCfg_RubricType_t PrjCfg_GetRubricFromString (const char *Str)
|
2023-05-03 11:02:06 +02:00
|
|
|
|
{
|
2023-05-17 15:28:15 +02:00
|
|
|
|
extern const char *Prj_DB_RubricType[PrjCfg_NUM_RUBRIC_TYPES];
|
|
|
|
|
PrjCfg_RubricType_t RubricType;
|
2023-05-03 11:02:06 +02:00
|
|
|
|
|
|
|
|
|
/***** Compare string with all string types *****/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
for (RubricType = (PrjCfg_RubricType_t) 1;
|
|
|
|
|
RubricType <= (PrjCfg_RubricType_t) (PrjCfg_NUM_RUBRIC_TYPES - 1);
|
|
|
|
|
RubricType++)
|
|
|
|
|
if (!strcmp (Prj_DB_RubricType[RubricType],Str))
|
|
|
|
|
return RubricType;
|
2023-04-13 14:25:52 +02:00
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
return PrjCfg_RUBRIC_ERR;
|
2023-04-13 14:25:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Show form to edit if non-editing teachers create new projects ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void PrjCfg_ShowFormNETCanCreate (const struct PrjCfg_Config *Config)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Non_editing_teachers_can_create_new_projects;
|
2024-04-30 11:00:46 +02:00
|
|
|
|
Cns_Checked_t Checked;
|
2023-04-13 14:25:52 +02:00
|
|
|
|
|
2023-05-04 18:27:32 +02:00
|
|
|
|
HTM_LABEL_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ());
|
2024-04-30 11:00:46 +02:00
|
|
|
|
Checked = Config->NETCanCreate ? Cns_CHECKED :
|
|
|
|
|
Cns_UNCHECKED;
|
2024-05-15 18:38:25 +02:00
|
|
|
|
HTM_INPUT_CHECKBOX ("NETCanCreate",Checked,HTM_ENABLED,HTM_READWRITE,
|
2024-05-09 19:11:16 +02:00
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2024-04-30 11:00:46 +02:00
|
|
|
|
"id=\"NETCanCreate\" value=\"Y\"");
|
2023-05-04 18:27:32 +02:00
|
|
|
|
HTM_Txt (Txt_Non_editing_teachers_can_create_new_projects);
|
|
|
|
|
HTM_LABEL_End ();
|
2023-04-01 01:01:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/********* Change whether non-editing teachers can create projects ***********/
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
void PrjCfg_ChangeNETCanCreate (void)
|
2023-04-01 01:01:12 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_configuration_of_the_projects_has_been_updated;
|
|
|
|
|
struct Prj_Projects Projects;
|
|
|
|
|
|
|
|
|
|
/***** Reset projects *****/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
Prj_ResetPrjsAndReadConfig (&Projects);
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
2023-05-03 11:02:06 +02:00
|
|
|
|
/***** Get non-editing teachers can create new projects or not *****/
|
|
|
|
|
Projects.Config.NETCanCreate = PrjCfg_GetIfNETCanCreateFromForm ();
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/***** Update database *****/
|
|
|
|
|
Prj_DB_UpdateNETCanCreate (&Projects);
|
|
|
|
|
|
|
|
|
|
/***** Show confirmation message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_configuration_of_the_projects_has_been_updated);
|
|
|
|
|
|
|
|
|
|
/***** Show again the form to configure projects *****/
|
|
|
|
|
PrjCfg_ShowFormConfig ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change rubrics of a type ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void PrjCfg_ChangeRubricsOfType (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_configuration_of_the_projects_has_been_updated;
|
|
|
|
|
struct Rub_Rubrics Rubrics;
|
|
|
|
|
PrjCfg_RubricType_t RubricType;
|
|
|
|
|
struct PrgCfg_ListRubCods ListRubCods;
|
|
|
|
|
char StrType[32];
|
|
|
|
|
|
|
|
|
|
/***** Reset rubrics context *****/
|
|
|
|
|
Rub_ResetRubrics (&Rubrics);
|
|
|
|
|
|
|
|
|
|
/***** Get list of rubrics *****/
|
|
|
|
|
Rub_GetListRubrics (&Rubrics);
|
|
|
|
|
|
|
|
|
|
/***** Get parameter with the type of rubric *****/
|
|
|
|
|
Par_GetParText ("RubricType",StrType,sizeof (StrType) - 1);
|
|
|
|
|
RubricType = PrjCfg_GetRubricFromString (StrType);
|
|
|
|
|
|
|
|
|
|
/***** Get multiple parameter with rubric codes of this type *****/
|
|
|
|
|
PrjCfg_GetListRubCods (&Rubrics,&ListRubCods);
|
2023-04-13 14:25:52 +02:00
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/***** Update database *****/
|
2023-05-19 23:00:30 +02:00
|
|
|
|
Prj_DB_UpdateRubrics (RubricType,&ListRubCods);
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/***** Show confirmation message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_configuration_of_the_projects_has_been_updated);
|
|
|
|
|
|
|
|
|
|
/***** Show again the form to configure projects *****/
|
|
|
|
|
PrjCfg_ShowFormConfig ();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 15:28:15 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get list of rubric codes of a type **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void PrjCfg_GetListRubCods (const struct Rub_Rubrics *Rubrics,
|
|
|
|
|
struct PrgCfg_ListRubCods *ListRubCods)
|
|
|
|
|
{
|
2024-03-22 09:59:20 +01:00
|
|
|
|
extern const char *Par_CodeStr[Par_NUM_PAR_COD];
|
2023-05-17 15:28:15 +02:00
|
|
|
|
char *ParLstRubCods;
|
|
|
|
|
const char *Ptr;
|
|
|
|
|
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
|
|
|
|
unsigned NumRub;
|
|
|
|
|
unsigned MaxSizeListRubCods;
|
|
|
|
|
|
|
|
|
|
/***** Reset number of rubrics specified *****/
|
|
|
|
|
ListRubCods->NumRubrics = 0;
|
|
|
|
|
if (Rubrics->Num) // If course has rubrics
|
|
|
|
|
{
|
|
|
|
|
/***** Allocate memory for the list of rubric codes specified *****/
|
|
|
|
|
MaxSizeListRubCods = ((Cns_MAX_DECIMAL_DIGITS_LONG + 1) * Rubrics->Num) - 1;
|
|
|
|
|
if ((ParLstRubCods = malloc (MaxSizeListRubCods + 1)) == NULL)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get parameter with list of groups to list *****/
|
|
|
|
|
Par_GetParMultiToText (Par_CodeStr[ParCod_Rub],ParLstRubCods,MaxSizeListRubCods);
|
|
|
|
|
if (ParLstRubCods[0])
|
|
|
|
|
{
|
|
|
|
|
/***** Count number of rubric codes from ParLstRubCods *****/
|
|
|
|
|
for (Ptr = ParLstRubCods, NumRub = 0;
|
|
|
|
|
*Ptr;
|
|
|
|
|
NumRub++)
|
|
|
|
|
Par_GetNextStrUntilSeparParMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
|
|
|
|
ListRubCods->NumRubrics = NumRub;
|
|
|
|
|
|
|
|
|
|
if (ListRubCods->NumRubrics) // If rubrics specified...
|
|
|
|
|
{
|
|
|
|
|
/***** Create a list of rubric codes from ParLstRubCods *****/
|
|
|
|
|
if ((ListRubCods->RubCods = calloc (ListRubCods->NumRubrics,
|
|
|
|
|
sizeof (*ListRubCods->RubCods))) == NULL)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
for (Ptr = ParLstRubCods, NumRub = 0;
|
|
|
|
|
*Ptr;
|
|
|
|
|
NumRub++)
|
|
|
|
|
{
|
|
|
|
|
Par_GetNextStrUntilSeparParMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
|
|
|
|
ListRubCods->RubCods[NumRub] = Str_ConvertStrCodToLongCod (LongStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for the list of groups to show *****/
|
|
|
|
|
free (ParLstRubCods);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/*****************************************************************************/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
/****** Get if projects are creatable by non-editing teachers from form *******/
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-10 14:41:20 +02:00
|
|
|
|
static bool PrjCfg_GetIfNETCanCreateFromForm (void)
|
2023-04-01 01:01:12 +02:00
|
|
|
|
{
|
2023-04-10 14:41:20 +02:00
|
|
|
|
return Par_GetParBool ("NETCanCreate");
|
2023-04-01 01:01:12 +02:00
|
|
|
|
}
|