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.
|
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
#include "swad_action_list.h"
|
|
|
|
|
#include "swad_alert.h"
|
|
|
|
|
#include "swad_box.h"
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_form.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#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-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-10 14:41:20 +02:00
|
|
|
|
static void PrjCfg_ShowFormNETCanCreate (const struct Prj_Projects *Projects);
|
2023-04-12 00:08:02 +02:00
|
|
|
|
static void PrjCfg_ShowFormRubrics (void);
|
2023-04-04 09:05:36 +02:00
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
static void PrjCfg_GetConfigDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Prj_Projects *Projects);
|
2023-04-10 14:41:20 +02:00
|
|
|
|
static bool PrjCfg_GetIfNETCanCreateFromForm (void);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get configuration of projects for current course *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void PrjCfg_GetConfig (struct Prj_Projects *Projects)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
|
|
|
|
/***** Get configuration of projects for current course from database *****/
|
|
|
|
|
if (Prj_DB_GetConfig (&mysql_res))
|
|
|
|
|
PrjCfg_GetConfigDataFromRow (mysql_res,Projects);
|
|
|
|
|
else
|
|
|
|
|
Projects->Config.NETCanCreate = PrjCfg_NET_CAN_CREATE_DEFAULT;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Can I configure all projects? **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool PrjCfg_CheckIfICanConfig (void)
|
|
|
|
|
{
|
|
|
|
|
static const bool ICanConfigAllProjects[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
|
|
|
|
[Rol_TCH ] = true,
|
|
|
|
|
[Rol_SYS_ADM] = true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
extern const char *Txt_Save_changes;
|
|
|
|
|
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 *****/
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Configure_projects,
|
|
|
|
|
Prj_PutIconsListProjects,&Projects,
|
|
|
|
|
Hlp_ASSESSMENT_Projects,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Begin form *****/
|
|
|
|
|
Frm_BeginForm (ActRcvCfgPrj);
|
|
|
|
|
|
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
|
|
|
|
|
2023-04-04 09:05:36 +02:00
|
|
|
|
/***** Projects are editable by non-editing teachers? *****/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
PrjCfg_ShowFormNETCanCreate (&Projects);
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
2023-04-12 00:08:02 +02:00
|
|
|
|
/***** Rubrics *****/
|
|
|
|
|
PrjCfg_ShowFormRubrics ();
|
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
|
|
|
|
/***** Send button *****/
|
|
|
|
|
Btn_PutConfirmButton (Txt_Save_changes);
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 09:05:36 +02:00
|
|
|
|
/*****************************************************************************/
|
2023-04-12 00:08:02 +02:00
|
|
|
|
/****** Show form to edit if non-editing teachers create new projects ********/
|
2023-04-04 09:05:36 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-10 14:41:20 +02:00
|
|
|
|
static void PrjCfg_ShowFormNETCanCreate (const struct Prj_Projects *Projects)
|
2023-04-04 09:05:36 +02:00
|
|
|
|
{
|
2023-04-10 14:41:20 +02:00
|
|
|
|
extern const char *Txt_Create_project;
|
|
|
|
|
extern const char *Txt_Non_editing_teachers_can_create_new_projects;
|
2023-04-04 09:05:36 +02:00
|
|
|
|
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Label *****/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT FORM_IN_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_TxtColon (Txt_Create_project);
|
|
|
|
|
HTM_TD_End ();
|
2023-04-04 09:05:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Data *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2023-04-10 14:41:20 +02:00
|
|
|
|
HTM_LABEL_Begin ("class=\"DAT_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_INPUT_CHECKBOX ("NETCanCreate",HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"NETCanCreate\" value=\"Y\"%s",
|
|
|
|
|
Projects->Config.NETCanCreate ? " checked=\"checked\"" :
|
|
|
|
|
"");
|
|
|
|
|
HTM_Txt (Txt_Non_editing_teachers_can_create_new_projects);
|
|
|
|
|
HTM_LABEL_End ();
|
2023-04-04 09:05:36 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 00:08:02 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Show form to edit rubrics associated to projects ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void PrjCfg_ShowFormRubrics (void)
|
|
|
|
|
{
|
|
|
|
|
struct Rub_Rubrics Rubrics;
|
|
|
|
|
unsigned NumRub;
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
struct Rub_Rubric Tutors;
|
|
|
|
|
struct Rub_Rubric Evaluators;
|
|
|
|
|
struct Rub_Rubric Global;
|
|
|
|
|
} PrjRubrics = {};
|
|
|
|
|
|
|
|
|
|
/***** Reset rubrics context *****/
|
|
|
|
|
Rub_ResetRubrics (&Rubrics);
|
|
|
|
|
|
|
|
|
|
/***** Get list of rubrics *****/
|
|
|
|
|
Rub_GetListRubrics (&Rubrics);
|
|
|
|
|
|
|
|
|
|
/***** Rubric for tutors *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label */
|
|
|
|
|
HTM_TD_Begin ("class=\"RT FORM_IN_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_TxtColon ("Rúbrica para tutores");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"id=\"rub_tut\" name=\"rub_tut\" class=\"LICENSE\"");
|
|
|
|
|
for (NumRub = 0;
|
|
|
|
|
NumRub < Rubrics.Num;
|
|
|
|
|
NumRub++)
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Rubrics.Lst[NumRub].RubCod,
|
|
|
|
|
Rubrics.Lst[NumRub].RubCod == PrjRubrics.Global.RubCod,false,
|
|
|
|
|
"%s",Rubrics.Lst[NumRub].Title);
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Rubric for evaluators *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
/* Label */
|
|
|
|
|
HTM_TD_Begin ("class=\"RT FORM_IN_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_TxtColon ("Rúbrica para evaluadores");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"id=\"rub_eva\" name=\"rub_eva\" class=\"LICENSE\"");
|
|
|
|
|
for (NumRub = 0;
|
|
|
|
|
NumRub < Rubrics.Num;
|
|
|
|
|
NumRub++)
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Rubrics.Lst[NumRub].RubCod,
|
|
|
|
|
Rubrics.Lst[NumRub].RubCod == PrjRubrics.Global.RubCod,false,
|
|
|
|
|
"%s",Rubrics.Lst[NumRub].Title);
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Rubric global *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label */
|
|
|
|
|
HTM_TD_Begin ("class=\"RT FORM_IN_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_TxtColon ("Rúbrica global");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"id=\"rub_gbl\" name=\"rub_gbl\" class=\"LICENSE\"");
|
|
|
|
|
for (NumRub = 0;
|
|
|
|
|
NumRub < Rubrics.Num;
|
|
|
|
|
NumRub++)
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Rubrics.Lst[NumRub].RubCod,
|
|
|
|
|
Rubrics.Lst[NumRub].RubCod == PrjRubrics.Global.RubCod,false,
|
|
|
|
|
"%s",Rubrics.Lst[NumRub].Title);
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Free list of rubrics *****/
|
|
|
|
|
Rub_FreeListRubrics (&Rubrics);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 01:01:12 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get configuration values from a database table row *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void PrjCfg_GetConfigDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Prj_Projects *Projects)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get row *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2023-04-10 14:41:20 +02:00
|
|
|
|
/***** Get whether non-editing teachers can create new projects or not *****/
|
|
|
|
|
Projects->Config.NETCanCreate = (row[0][0] == 'Y');
|
2023-04-01 01:01:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Receive configuration of projects for current course ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void PrjCfg_ReceiveConfig (void)
|
|
|
|
|
{
|
|
|
|
|
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-04-10 14:41:20 +02:00
|
|
|
|
/***** Get non-editing teachers can create new projects or not *****/
|
|
|
|
|
Projects.Config.NETCanCreate = PrjCfg_GetIfNETCanCreateFromForm ();
|
2023-04-01 01:01:12 +02:00
|
|
|
|
|
|
|
|
|
/***** Update database *****/
|
2023-04-10 14:41:20 +02:00
|
|
|
|
Prj_DB_UpdateCrsPrjsConfig (Projects.Config.NETCanCreate);
|
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-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
|
|
|
|
}
|