swad-core/swad_degree.c

2694 lines
92 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_degree.c: degrees
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01: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 <ctype.h> // For isprint, isspace, etc.
#include <linux/stddef.h> // For NULL
2015-10-16 02:24:29 +02:00
#include <stdbool.h> // For boolean type
2019-02-18 14:41:46 +01:00
#include <stdio.h> // For fprintf, etc.
2014-12-01 23:55:08 +01:00
#include <stdlib.h> // For exit, system, calloc, free, etc.
#include <string.h> // For string functions
#include <mysql/mysql.h> // To access MySQL databases
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2014-12-01 23:55:08 +01:00
#include "swad_changelog.h"
#include "swad_config.h"
#include "swad_database.h"
#include "swad_degree.h"
2016-03-20 16:30:52 +01:00
#include "swad_degree_type.h"
2014-12-01 23:55:08 +01:00
#include "swad_exam.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
2015-10-06 20:34:49 +02:00
#include "swad_help.h"
2016-11-14 16:47:46 +01:00
#include "swad_hierarchy.h"
2014-12-01 23:55:08 +01:00
#include "swad_indicator.h"
#include "swad_info.h"
2018-12-08 16:43:13 +01:00
#include "swad_language.h"
2015-01-17 13:31:25 +01:00
#include "swad_logo.h"
2014-12-01 23:55:08 +01:00
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_QR.h"
#include "swad_RSS.h"
#include "swad_string.h"
2015-01-04 15:48:24 +01:00
#include "swad_tab.h"
2017-06-11 20:09:59 +02:00
#include "swad_table.h"
2015-01-04 15:48:24 +01:00
#include "swad_theme.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/*************************** Public constants ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private types *********************************/
/*****************************************************************************/
typedef enum
{
Deg_FIRST_YEAR,
Deg_LAST_YEAR,
} Deg_FirstOrLastYear_t;
/*****************************************************************************/
2019-04-07 12:17:10 +02:00
/**************************** Private variables ******************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2019-04-08 23:34:58 +02:00
static struct Degree *Deg_EditingDeg = NULL; // Static variable to keep the degree being edited
2019-04-07 12:17:10 +02:00
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/**************************** Private prototypes *****************************/
/*****************************************************************************/
static void Deg_Configuration (bool PrintView);
2016-05-05 20:16:28 +02:00
static void Deg_PutIconsToPrintAndUpload (void);
2017-05-21 16:48:30 +02:00
static void Deg_ShowNumUsrsInCrssOfDeg (Rol_Role_t Role);
2014-12-01 23:55:08 +01:00
static void Deg_ListDegreesForEdition (void);
2016-11-06 23:56:43 +01:00
static bool Deg_CheckIfICanEditADegree (struct Degree *Deg);
2014-12-01 23:55:08 +01:00
static Deg_StatusTxt_t Deg_GetStatusTxtFromStatusBits (Deg_Status_t Status);
static Deg_Status_t Deg_GetStatusBitsFromStatusTxt (Deg_StatusTxt_t StatusTxt);
static void Deg_PutFormToCreateDegree (void);
static void Deg_PutHeadDegreesForSeeing (void);
static void Deg_PutHeadDegreesForEdition (void);
2017-05-11 20:04:38 +02:00
static void Deg_CreateDegree (unsigned Status);
2016-03-20 13:18:56 +01:00
2014-12-01 23:55:08 +01:00
static void Deg_ListDegrees (void);
2016-11-07 00:03:50 +01:00
static bool Deg_CheckIfICanCreateDegrees (void);
2018-11-15 12:52:56 +01:00
static void Deg_PutIconsListingDegrees (void);
2016-03-20 13:18:56 +01:00
static void Deg_PutIconToEditDegrees (void);
static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg);
2019-04-07 12:17:10 +02:00
static void Deg_EditDegreesInternal (void);
2017-04-30 02:56:25 +02:00
static void Deg_PutIconsEditingDegrees (void);
2014-12-01 23:55:08 +01:00
static void Deg_RecFormRequestOrCreateDeg (unsigned Status);
static void Deg_PutParamOtherDegCod (long DegCod);
static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row);
2017-03-09 11:16:17 +01:00
2016-10-28 10:03:37 +02:00
static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName);
2018-10-20 19:58:28 +02:00
static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
long DegCod,long CtrCod);
2017-03-09 11:16:17 +01:00
static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName);
2016-10-20 16:49:42 +02:00
static void Deg_UpdateDegCtrDB (long DegCod,long CtrCod);
2017-03-07 01:56:41 +01:00
static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
2016-10-19 23:17:36 +02:00
2019-04-08 14:52:13 +02:00
static void Deg_ShowAlertAndButtonToGoToDeg (void);
2017-05-11 20:04:38 +02:00
static void Deg_PutParamGoToDeg (void);
2019-04-07 12:17:10 +02:00
static void Deg_EditingDegreeConstructor (void);
static void Deg_EditingDegreeDestructor (void);
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************* List degrees with pending courses ***********************/
/*****************************************************************************/
void Deg_SeeDegWithPendingCrss (void)
{
2017-03-27 13:38:10 +02:00
extern const char *Hlp_SYSTEM_Hierarchy_pending;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Degrees_with_pending_courses;
extern const char *Txt_Degree;
extern const char *Txt_Courses_ABBREVIATION;
extern const char *Txt_There_are_no_degrees_with_requests_for_courses_to_be_confirmed;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDegs;
unsigned NumDeg;
struct Degree Deg;
2015-09-04 19:26:08 +02:00
const char *BgColor;
2014-12-01 23:55:08 +01:00
/***** Get degrees with pending courses *****/
2017-06-04 18:18:54 +02:00
switch (Gbl.Usrs.Me.Role.Logged)
2014-12-01 23:55:08 +01:00
{
2015-04-07 21:44:24 +02:00
case Rol_DEG_ADM:
2018-10-30 15:26:20 +01:00
NumDegs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees"
" with pending courses",
"SELECT courses.DegCod,COUNT(*)"
" FROM admin,courses,degrees"
" WHERE admin.UsrCod=%ld AND admin.Scope='%s'"
" AND admin.Cod=courses.DegCod"
" AND (courses.Status & %u)<>0"
" AND courses.DegCod=degrees.DegCod"
" GROUP BY courses.DegCod ORDER BY degrees.ShortName",
2019-04-01 23:15:17 +02:00
Gbl.Usrs.Me.UsrDat.UsrCod,
2019-04-03 20:57:04 +02:00
Sco_GetDBStrFromScope (Hie_DEG),
2018-10-30 15:26:20 +01:00
(unsigned) Crs_STATUS_BIT_PENDING);
2014-12-01 23:55:08 +01:00
break;
2015-04-07 21:44:24 +02:00
case Rol_SYS_ADM:
2018-10-30 15:26:20 +01:00
NumDegs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees"
" with pending courses",
"SELECT courses.DegCod,COUNT(*)"
" FROM courses,degrees"
" WHERE (courses.Status & %u)<>0"
" AND courses.DegCod=degrees.DegCod"
" GROUP BY courses.DegCod ORDER BY degrees.ShortName",
(unsigned) Crs_STATUS_BIT_PENDING);
2014-12-01 23:55:08 +01:00
break;
default: // Forbidden for other users
return;
}
/***** Get degrees *****/
2018-10-30 15:26:20 +01:00
if (NumDegs)
2014-12-01 23:55:08 +01:00
{
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Txt_Degrees_with_pending_courses,NULL,
2017-06-12 15:03:29 +02:00
Hlp_SYSTEM_Hierarchy_pending,Box_NOT_CLOSABLE,2);
2017-06-12 14:16:33 +02:00
/***** Write heading *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"RIGHT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Degree,
Txt_Courses_ABBREVIATION);
/***** List the degrees *****/
for (NumDeg = 0;
NumDeg < NumDegs;
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
/* Get degree code (row[0]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]);
2019-04-03 20:57:04 +02:00
BgColor = (Deg.DegCod == Gbl.Hierarchy.Deg.DegCod) ? "LIGHT_BLUE" :
2015-09-04 19:26:08 +02:00
Gbl.ColorRows[Gbl.RowEvenOdd];
2014-12-01 23:55:08 +01:00
/* Get data of degree */
Deg_GetDataOfDegreeByCod (&Deg);
2015-11-12 01:27:33 +01:00
/* Degree logo and full name */
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-11-12 01:27:33 +01:00
"<td class=\"LEFT_MIDDLE %s\">",
2014-12-01 23:55:08 +01:00
BgColor);
2015-11-19 20:04:41 +01:00
Deg_DrawDegreeLogoAndNameWithLink (&Deg,ActSeeCrs,
"DAT_NOBR","CENTER_MIDDLE");
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Number of pending courses (row[1]) */
2015-09-04 17:10:27 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
2014-12-22 19:59:27 +01:00
"%s"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
BgColor,row[1]);
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2014-12-01 23:55:08 +01:00
}
else
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_INFO,Txt_There_are_no_degrees_with_requests_for_courses_to_be_confirmed);
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2015-11-19 20:04:41 +01:00
/*****************************************************************************/
/******************** Draw degree logo and name with link ********************/
/*****************************************************************************/
void Deg_DrawDegreeLogoAndNameWithLink (struct Degree *Deg,Act_Action_t Action,
const char *ClassLink,const char *ClassLogo)
{
extern const char *Txt_Go_to_X;
/***** Start form *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (Action);
2015-11-19 20:04:41 +01:00
Deg_PutParamDegCod (Deg->DegCod);
/***** Link to action *****/
2018-10-17 10:32:18 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Deg->FullName);
2018-11-09 20:47:39 +01:00
Frm_LinkFormSubmit (Gbl.Title,ClassLink,NULL);
2015-11-19 20:04:41 +01:00
/***** Draw degree logo *****/
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,16,ClassLogo,true);
2015-11-19 20:04:41 +01:00
/***** End link *****/
fprintf (Gbl.F.Out,"&nbsp;%s</a>",Deg->FullName);
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-11-19 20:04:41 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/****************** Show information of the current degree *******************/
/*****************************************************************************/
void Deg_ShowConfiguration (void)
{
Deg_Configuration (false);
2015-10-06 01:19:21 +02:00
2017-03-30 11:20:06 +02:00
/***** Show help to enrol me *****/
2015-10-06 20:34:49 +02:00
Hlp_ShowHelpWhatWouldYouLikeToDo ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****************** Print information of the current degree ******************/
/*****************************************************************************/
void Deg_PrintConfiguration (void)
{
Deg_Configuration (true);
}
/*****************************************************************************/
/******************* Information of the current degree ***********************/
/*****************************************************************************/
static void Deg_Configuration (bool PrintView)
{
2016-11-13 16:55:27 +01:00
extern const char *Hlp_DEGREE_Information;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2016-10-19 20:43:26 +02:00
extern const char *Txt_Centre;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Degree;
2015-02-04 20:03:23 +01:00
extern const char *Txt_Short_name;
2015-02-04 20:05:54 +01:00
extern const char *Txt_Web;
2015-03-07 18:09:42 +01:00
extern const char *Txt_Shortcut;
2018-12-08 16:43:13 +01:00
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
2016-10-19 20:43:26 +02:00
extern const char *Txt_Courses;
extern const char *Txt_Courses_of_DEGREE_X;
2014-12-01 23:55:08 +01:00
extern const char *Txt_QR_code;
2016-10-19 20:43:26 +02:00
unsigned NumCtr;
2019-04-03 20:57:04 +02:00
bool PutLink;
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Trivial check *****/
if (Gbl.Hierarchy.Deg.DegCod <= 0) // No degree selected
return;
2016-10-19 20:43:26 +02:00
2019-04-03 20:57:04 +02:00
/***** Start box *****/
if (PrintView)
Box_StartBox (NULL,NULL,NULL,
NULL,Box_NOT_CLOSABLE);
else
Box_StartBox (NULL,NULL,Deg_PutIconsToPrintAndUpload,
Hlp_DEGREE_Information,Box_NOT_CLOSABLE);
/***** Title *****/
PutLink = !PrintView && Gbl.Hierarchy.Deg.WWW[0];
fprintf (Gbl.F.Out,"<div class=\"FRAME_TITLE FRAME_TITLE_BIG\">");
if (PutLink)
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"FRAME_TITLE_BIG\" title=\"%s\">",
Gbl.Hierarchy.Deg.WWW,
Gbl.Hierarchy.Deg.FullName);
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,64,NULL,true);
fprintf (Gbl.F.Out,"<br />%s",
Gbl.Hierarchy.Deg.FullName);
if (PutLink)
fprintf (Gbl.F.Out,"</a>");
fprintf (Gbl.F.Out,"</div>");
/***** Start table *****/
Tbl_StartTableWide (2);
2016-10-19 20:43:26 +02:00
2019-04-03 20:57:04 +02:00
/***** Centre *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"OthCtrCod\" class=\"%s\">%s:</label>"
"</td>"
"<td class=\"DAT_N LEFT_MIDDLE\">",
The_ClassFormInBox[Gbl.Prefs.Theme],
Txt_Centre);
2016-10-19 20:43:26 +02:00
2019-04-03 20:57:04 +02:00
if (!PrintView &&
Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)
// Only institution admins and system admin can move a degree to another centre
{
/* Get list of centres of the current institution */
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
/* Put form to select centre */
Frm_StartForm (ActChgDegCtrCfg);
fprintf (Gbl.F.Out,"<select id=\"OthCtrCod\" name=\"OthCtrCod\""
" class=\"INPUT_SHORT_NAME\""
" onchange=\"document.getElementById('%s').submit();\">",
Gbl.Form.Id);
for (NumCtr = 0;
2019-04-04 10:45:15 +02:00
NumCtr < Gbl.Hierarchy.Ins.Ctrs.Num;
2019-04-03 20:57:04 +02:00
NumCtr++)
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].CtrCod,
Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].CtrCod == Gbl.Hierarchy.Ctr.CtrCod ? " selected=\"selected\"" :
2019-04-03 20:57:04 +02:00
"",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr].ShrtName);
2019-04-03 20:57:04 +02:00
fprintf (Gbl.F.Out,"</select>");
Frm_EndForm ();
2016-10-19 20:43:26 +02:00
2019-04-03 20:57:04 +02:00
/* Free list of centres */
Ctr_FreeListCentres ();
}
else // I can not move degree to another centre
fprintf (Gbl.F.Out,"%s",Gbl.Hierarchy.Ctr.FullName);
2016-10-19 20:43:26 +02:00
2019-04-03 20:57:04 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Degree full name *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"FullName\" class=\"%s\">%s:</label>"
"</td>"
"<td class=\"DAT_N LEFT_MIDDLE\">",
The_ClassFormInBox[Gbl.Prefs.Theme],
Txt_Degree);
if (!PrintView &&
Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)
// Only centre admins, institution admins and system admins
// can edit degree full name
{
/* Form to change degree full name */
Frm_StartForm (ActRenDegFulCfg);
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"FullName\" name=\"FullName\""
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_FULL_NAME\""
" onchange=\"document.getElementById('%s').submit();\" />",
Hie_MAX_CHARS_FULL_NAME,
Gbl.Hierarchy.Deg.FullName,
Gbl.Form.Id);
Frm_EndForm ();
}
else // I can not edit degree full name
fprintf (Gbl.F.Out,"%s",Gbl.Hierarchy.Deg.FullName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Degree short name *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"ShortName\" class=\"%s\">%s:</label>"
"</td>"
"<td class=\"DAT_N LEFT_MIDDLE\">",
The_ClassFormInBox[Gbl.Prefs.Theme],
Txt_Short_name);
if (!PrintView &&
Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)
// Only centre admins, institution admins and system admins
// can edit degree short name
{
/* Form to change degree short name */
Frm_StartForm (ActRenDegShoCfg);
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"ShortName\" name=\"ShortName\""
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_SHORT_NAME\""
" onchange=\"document.getElementById('%s').submit();\" />",
Hie_MAX_CHARS_SHRT_NAME,
Gbl.Hierarchy.Deg.ShrtName,
Gbl.Form.Id);
Frm_EndForm ();
}
else // I can not edit degree short name
fprintf (Gbl.F.Out,"%s",Gbl.Hierarchy.Deg.ShrtName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Degree WWW *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"WWW\" class=\"%s\">%s:</label>"
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">",
The_ClassFormInBox[Gbl.Prefs.Theme],
Txt_Web);
if (!PrintView &&
Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
// Only degree admins, centre admins, institution admins
// and system admins can change degree WWW
{
/* Form to change degree WWW */
Frm_StartForm (ActChgDegWWWCfg);
fprintf (Gbl.F.Out,"<input type=\"url\" id=\"WWW\" name=\"WWW\""
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_WWW\""
" onchange=\"document.getElementById('%s').submit();\" />",
Cns_MAX_CHARS_WWW,
Gbl.Hierarchy.Deg.WWW,
Gbl.Form.Id);
Frm_EndForm ();
}
else // I can not change degree WWW
fprintf (Gbl.F.Out,"<div class=\"EXTERNAL_WWW_LONG\">"
"<a href=\"%s\" target=\"_blank\" class=\"DAT\">"
"%s"
"</a>"
"</div>",
Gbl.Hierarchy.Deg.WWW,
Gbl.Hierarchy.Deg.WWW);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Shortcut to the degree *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">"
"<a href=\"%s/%s?deg=%ld\" class=\"DAT\" target=\"_blank\">"
"%s/%s?deg=%ld"
"</a>"
"</td>"
"</tr>",
The_ClassFormInBox[Gbl.Prefs.Theme],
Txt_Shortcut,
Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Hierarchy.Deg.DegCod,
Cfg_URL_SWAD_CGI,
Lan_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Hierarchy.Deg.DegCod);
if (PrintView)
{
/***** QR code with link to the degree *****/
2016-10-23 16:37:45 +02:00
fprintf (Gbl.F.Out,"<tr>"
2019-04-03 20:57:04 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
2016-10-23 16:37:45 +02:00
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],
2019-04-03 20:57:04 +02:00
Txt_QR_code);
QR_LinkTo (250,"deg",Gbl.Hierarchy.Deg.DegCod);
2016-10-23 16:37:45 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2019-04-03 20:57:04 +02:00
}
else
{
/***** Number of courses *****/
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2019-04-03 20:57:04 +02:00
"%s:"
2014-12-01 23:55:08 +01:00
"</td>"
2019-04-03 20:57:04 +02:00
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],
2019-04-03 20:57:04 +02:00
Txt_Courses);
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/* Form to go to see courses of this degree */
Frm_StartFormGoTo (ActSeeCrs);
Deg_PutParamDegCod (Gbl.Hierarchy.Deg.DegCod);
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Courses_of_DEGREE_X,
Gbl.Hierarchy.Deg.ShrtName);
Frm_LinkFormSubmit (Gbl.Title,"DAT",NULL);
fprintf (Gbl.F.Out,"%u</a>",
Crs_GetNumCrssInDeg (Gbl.Hierarchy.Deg.DegCod));
Frm_EndForm ();
2014-12-08 17:35:48 +01:00
2019-04-03 20:57:04 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2016-03-18 20:48:24 +01:00
2019-04-03 20:57:04 +02:00
/***** Number of users *****/
Deg_ShowNumUsrsInCrssOfDeg (Rol_TCH);
Deg_ShowNumUsrsInCrssOfDeg (Rol_NET);
Deg_ShowNumUsrsInCrssOfDeg (Rol_STD);
Deg_ShowNumUsrsInCrssOfDeg (Rol_UNK);
2014-12-01 23:55:08 +01:00
}
2019-04-03 20:57:04 +02:00
/***** End table *****/
Tbl_EndTable ();
/***** End box *****/
Box_EndBox ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-05-05 20:16:28 +02:00
/************ Put contextual icons in configuration of a degree **************/
2016-03-18 20:48:24 +01:00
/*****************************************************************************/
2016-05-05 20:16:28 +02:00
static void Deg_PutIconsToPrintAndUpload (void)
2016-03-18 20:48:24 +01:00
{
2016-05-05 20:16:28 +02:00
/***** Link to print info about degree *****/
2017-06-11 19:13:28 +02:00
Ico_PutContextualIconToPrint (ActPrnDegInf,NULL);
2016-05-05 20:16:28 +02:00
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
2016-10-24 18:25:12 +02:00
// Only degree admins, centre admins, institution admins and system admins
// have permission to upload logo of the degree
2016-05-05 20:16:28 +02:00
/***** Link to upload logo of degree *****/
2019-04-03 20:57:04 +02:00
Log_PutIconToChangeLogo (Hie_DEG);
2016-03-18 20:48:24 +01:00
}
2017-05-21 16:48:30 +02:00
/*****************************************************************************/
/***************** Number of users in courses of this degree *****************/
/*****************************************************************************/
static void Deg_ShowNumUsrsInCrssOfDeg (Rol_Role_t Role)
{
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2017-05-21 16:48:30 +02:00
extern const char *Txt_Users_in_courses;
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">"
"%u"
"</td>"
"</tr>",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],
2017-05-21 16:48:30 +02:00
(Role == Rol_UNK) ? Txt_Users_in_courses :
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
2019-04-03 20:57:04 +02:00
Usr_GetNumUsrsInCrssOfDeg (Role,Gbl.Hierarchy.Deg.DegCod));
2017-05-21 16:48:30 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*************************** Write selector of degree ************************/
/*****************************************************************************/
2016-11-14 16:47:46 +01:00
void Deg_WriteSelectorOfDegree (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Degree;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDegs;
unsigned NumDeg;
long DegCod;
/***** Start form *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeCrs);
2016-12-20 10:03:00 +01:00
fprintf (Gbl.F.Out,"<select id=\"deg\" name=\"deg\" style=\"width:175px;\"");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2015-10-22 14:49:48 +02:00
fprintf (Gbl.F.Out," onchange=\"document.getElementById('%s').submit();\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
else
fprintf (Gbl.F.Out," disabled=\"disabled\"");
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,">"
"<option value=\"\"");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod < 0)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\">[%s]</option>",
Txt_Degree);
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2014-12-01 23:55:08 +01:00
{
/***** Get degrees belonging to the current centre from database *****/
2018-10-30 15:26:20 +01:00
NumDegs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees"
" of a centre",
"SELECT DegCod,ShortName"
" FROM degrees"
" WHERE CtrCod=%ld"
" ORDER BY ShortName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod);
2014-12-01 23:55:08 +01:00
/***** Get degrees of this centre *****/
for (NumDeg = 0;
NumDeg < NumDegs;
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
/* Get degree code (row[0]) */
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
2015-07-25 20:20:07 +02:00
Lay_ShowErrorAndExit ("Wrong degree.");
2014-12-01 23:55:08 +01:00
/* Write option */
fprintf (Gbl.F.Out,"<option value=\"%ld\"",DegCod);
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0 &&
(DegCod == Gbl.Hierarchy.Deg.DegCod))
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",row[1]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/***** End form *****/
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Show the degrees belonging to the current centre **************/
/*****************************************************************************/
void Deg_ShowDegsOfCurrentCtr (void)
{
2019-04-03 20:57:04 +02:00
/***** Trivial check *****/
if (Gbl.Hierarchy.Ctr.CtrCod <= 0) // No centre selected
return;
/***** Get list of centres and degrees *****/
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
Deg_GetListDegsOfCurrentCtr ();
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Write menu to select country, institution and centre *****/
Hie_WriteMenuHierarchy ();
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Show list of degrees *****/
Deg_ListDegrees ();
2014-12-01 23:55:08 +01:00
2019-04-03 20:57:04 +02:00
/***** Free list of degrees and centres *****/
Deg_FreeListDegs (&Gbl.Hierarchy.Ctr.Degs);
Ctr_FreeListCentres ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* List current degrees for edition **********************/
/*****************************************************************************/
static void Deg_ListDegreesForEdition (void)
{
extern const char *Txt_DEGREE_STATUS[Deg_NUM_STATUS_TXT];
unsigned NumDeg;
struct DegreeType *DegTyp;
struct Degree *Deg;
unsigned NumDegTyp;
2017-03-07 01:56:41 +01:00
char WWW[Cns_MAX_BYTES_WWW + 1];
2014-12-01 23:55:08 +01:00
struct UsrData UsrDat;
bool ICanEdit;
Deg_StatusTxt_t StatusTxt;
2016-04-16 15:05:18 +02:00
unsigned NumCrss;
2014-12-01 23:55:08 +01:00
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Write heading *****/
2017-06-11 20:09:59 +02:00
Tbl_StartTableWide (2);
2014-12-01 23:55:08 +01:00
Deg_PutHeadDegreesForEdition ();
/***** List the degrees *****/
for (NumDeg = 0;
2019-04-03 20:57:04 +02:00
NumDeg < Gbl.Hierarchy.Ctr.Degs.Num;
2014-12-01 23:55:08 +01:00
NumDeg++)
{
2019-04-03 20:57:04 +02:00
Deg = &(Gbl.Hierarchy.Ctr.Degs.Lst[NumDeg]);
2014-12-01 23:55:08 +01:00
2016-04-16 15:05:18 +02:00
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
2016-11-06 23:56:43 +01:00
ICanEdit = Deg_CheckIfICanEditADegree (Deg);
2014-12-01 23:55:08 +01:00
/* Put icon to remove degree */
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"BM\">");
2016-04-16 15:05:18 +02:00
if (NumCrss || // Degree has courses ==> deletion forbidden
2014-12-01 23:55:08 +01:00
!ICanEdit)
2017-06-11 19:13:28 +02:00
Ico_PutIconRemovalNotAllowed ();
2014-12-01 23:55:08 +01:00
else
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActRemDeg);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2017-06-11 19:13:28 +02:00
Ico_PutIconRemove ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>");
/* Degree code */
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"DAT CODE\">"
2014-12-22 19:59:27 +01:00
"%ld"
"</td>",
2014-12-01 23:55:08 +01:00
Deg->DegCod);
/* Degree logo */
2015-12-05 13:37:23 +01:00
fprintf (Gbl.F.Out,"<td title=\"%s LEFT_MIDDLE\" style=\"width:25px;\">",
2014-12-01 23:55:08 +01:00
Deg->FullName);
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,20,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/* Degree short name */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (ICanEdit)
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActRenDegSho);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-10-22 14:49:48 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"ShortName\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_SHORT_NAME\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 14:12:33 +01:00
Hie_MAX_CHARS_SHRT_NAME,Deg->ShrtName,Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
2016-10-28 10:03:37 +02:00
fprintf (Gbl.F.Out,"%s",Deg->ShrtName);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/* Degree full name */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (ICanEdit)
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActRenDegFul);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-10-22 14:49:48 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FullName\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_FULL_NAME\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 14:12:33 +01:00
Hie_MAX_CHARS_FULL_NAME,Deg->FullName,Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
fprintf (Gbl.F.Out,"%s",Deg->FullName);
fprintf (Gbl.F.Out,"</td>");
/* Degree type */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (ICanEdit)
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgDegTyp);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-09-06 19:51:06 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthDegTypCod\""
2015-09-28 18:28:29 +02:00
" style=\"width:62px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
for (NumDegTyp = 0;
2019-04-04 10:45:15 +02:00
NumDegTyp < Gbl.DegTypes.Num;
2014-12-01 23:55:08 +01:00
NumDegTyp++)
{
2019-04-04 10:45:15 +02:00
DegTyp = &Gbl.DegTypes.Lst[NumDegTyp];
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
DegTyp->DegTypCod,
(DegTyp->DegTypCod == Deg->DegTypCod) ? " selected=\"selected\"" :
"",
DegTyp->DegTypName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
for (NumDegTyp = 0;
2019-04-04 10:45:15 +02:00
NumDegTyp < Gbl.DegTypes.Num;
2014-12-01 23:55:08 +01:00
NumDegTyp++)
2019-04-04 10:45:15 +02:00
if (Gbl.DegTypes.Lst[NumDegTyp].DegTypCod == Deg->DegTypCod)
fprintf (Gbl.F.Out,"%s",Gbl.DegTypes.Lst[NumDegTyp].DegTypName);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/* Degree WWW */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (ICanEdit)
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgDegWWW);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2016-11-20 14:32:15 +01:00
fprintf (Gbl.F.Out,"<input type=\"url\" name=\"WWW\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_WWW\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-07 01:56:41 +01:00
Cns_MAX_CHARS_WWW,Deg->WWW,Gbl.Form.Id);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
{
2017-01-17 03:10:43 +01:00
Str_Copy (WWW,Deg->WWW,
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2017-03-04 01:27:54 +01:00
fprintf (Gbl.F.Out,"<div class=\"EXTERNAL_WWW_SHORT\">"
"<a href=\"%s\" target=\"_blank\""
2017-01-17 03:10:43 +01:00
" class=\"DAT\" title=\"%s\">"
"%s"
2017-03-04 01:27:54 +01:00
"</a>"
"</div>",
2014-12-01 23:55:08 +01:00
Deg->WWW,Deg->WWW,WWW);
}
fprintf (Gbl.F.Out,"</td>");
/* Current number of courses in this degree */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%u"
"</td>",
2016-04-16 15:05:18 +02:00
NumCrss);
2014-12-01 23:55:08 +01:00
2017-03-17 00:46:28 +01:00
/* Degree requester */
UsrDat.UsrCod = Deg->RequesterUsrCod;
2019-03-19 13:22:14 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS);
2017-05-02 01:05:23 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT INPUT_REQUESTER LEFT_TOP\">");
2017-05-02 01:16:06 +02:00
Msg_WriteMsgAuthor (&UsrDat,true,NULL);
2017-05-01 21:17:38 +02:00
fprintf (Gbl.F.Out,"</td>");
2017-03-17 00:46:28 +01:00
2014-12-01 23:55:08 +01:00
/* Degree status */
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
2017-03-17 00:46:28 +01:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM &&
2014-12-01 23:55:08 +01:00
StatusTxt == Deg_STATUS_PENDING)
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgDegSta);
2014-12-01 23:55:08 +01:00
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<select name=\"Status\" class=\"INPUT_STATUS\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"%u\" selected=\"selected\">%s</option>"
"<option value=\"%u\">%s</option>"
2015-03-13 00:16:02 +01:00
"</select>",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id,
2014-12-01 23:55:08 +01:00
(unsigned) Deg_GetStatusBitsFromStatusTxt (Deg_STATUS_PENDING),
Txt_DEGREE_STATUS[Deg_STATUS_PENDING],
(unsigned) Deg_GetStatusBitsFromStatusTxt (Deg_STATUS_ACTIVE),
Txt_DEGREE_STATUS[Deg_STATUS_ACTIVE]);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
2017-03-17 00:46:28 +01:00
else if (StatusTxt != Deg_STATUS_ACTIVE) // If active ==> do not show anything
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"%s",Txt_DEGREE_STATUS[StatusTxt]);
2017-03-17 00:46:28 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
}
/***** End table *****/
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/*****************************************************************************/
/************** Check if I can edit, remove, etc. a degree *******************/
/*****************************************************************************/
2016-11-06 23:56:43 +01:00
static bool Deg_CheckIfICanEditADegree (struct Degree *Deg)
2014-12-01 23:55:08 +01:00
{
2017-06-04 18:18:54 +02:00
return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM || // I am a centre administrator or higher
2014-12-01 23:55:08 +01:00
((Deg->Status & Deg_STATUS_BIT_PENDING) != 0 && // Degree is not yet activated
Gbl.Usrs.Me.UsrDat.UsrCod == Deg->RequesterUsrCod)); // I am the requester
}
/*****************************************************************************/
/******************* Set StatusTxt depending on status bits ******************/
/*****************************************************************************/
// Deg_STATUS_UNKNOWN = 0 // Other
// Deg_STATUS_ACTIVE = 1 // 00 (Status == 0)
// Deg_STATUS_PENDING = 2 // 01 (Status == Deg_STATUS_BIT_PENDING)
// Deg_STATUS_REMOVED = 3 // 1- (Status & Deg_STATUS_BIT_REMOVED)
static Deg_StatusTxt_t Deg_GetStatusTxtFromStatusBits (Deg_Status_t Status)
{
if (Status == 0)
return Deg_STATUS_ACTIVE;
if (Status == Deg_STATUS_BIT_PENDING)
return Deg_STATUS_PENDING;
if (Status & Deg_STATUS_BIT_REMOVED)
return Deg_STATUS_REMOVED;
return Deg_STATUS_UNKNOWN;
}
/*****************************************************************************/
/******************* Set status bits depending on StatusTxt ******************/
/*****************************************************************************/
// Deg_STATUS_UNKNOWN = 0 // Other
// Deg_STATUS_ACTIVE = 1 // 00 (Status == 0)
// Deg_STATUS_PENDING = 2 // 01 (Status == Deg_STATUS_BIT_PENDING)
// Deg_STATUS_REMOVED = 3 // 1- (Status & Deg_STATUS_BIT_REMOVED)
static Deg_Status_t Deg_GetStatusBitsFromStatusTxt (Deg_StatusTxt_t StatusTxt)
{
switch (StatusTxt)
{
case Deg_STATUS_UNKNOWN:
case Deg_STATUS_ACTIVE:
return (Deg_Status_t) 0;
case Deg_STATUS_PENDING:
return Deg_STATUS_BIT_PENDING;
case Deg_STATUS_REMOVED:
return Deg_STATUS_BIT_REMOVED;
}
return (Deg_Status_t) 0;
}
/*****************************************************************************/
/*********************** Put a form to create a new degree *******************/
/*****************************************************************************/
static void Deg_PutFormToCreateDegree (void)
{
2017-04-30 02:56:25 +02:00
extern const char *Txt_New_degree;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Create_degree;
struct DegreeType *DegTyp;
unsigned NumDegTyp;
/***** Start form *****/
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM)
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActNewDeg);
2017-06-04 18:18:54 +02:00
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActReqDeg);
2014-12-01 23:55:08 +01:00
else
Lay_ShowErrorAndExit ("You can not edit degrees.");
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Txt_New_degree,NULL,
2017-06-12 15:03:29 +02:00
NULL,Box_NOT_CLOSABLE,2);
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Write heading *****/
2014-12-01 23:55:08 +01:00
Deg_PutHeadDegreesForEdition ();
2017-04-30 02:56:25 +02:00
/***** Column to remove degree, disabled here *****/
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>"
2017-04-30 02:56:25 +02:00
"<td class=\"BM\"></td>");
2014-12-01 23:55:08 +01:00
/***** Degree code *****/
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"CODE\"></td>");
2014-12-01 23:55:08 +01:00
/***** Degree logo *****/
2016-10-20 21:09:01 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\" style=\"width:25px;\">");
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_DEG,-1L,"",20,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/***** Degree short name *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2015-10-23 01:31:08 +02:00
"<input type=\"text\" name=\"ShortName\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
2016-11-19 02:54:56 +01:00
" class=\"INPUT_SHORT_NAME\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-04-07 12:17:10 +02:00
Hie_MAX_CHARS_SHRT_NAME,Deg_EditingDeg->ShrtName);
2014-12-01 23:55:08 +01:00
/***** Degree full name *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2015-10-23 01:31:08 +02:00
"<input type=\"text\" name=\"FullName\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
2016-11-19 02:54:56 +01:00
" class=\"INPUT_FULL_NAME\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-04-07 12:17:10 +02:00
Hie_MAX_CHARS_FULL_NAME,Deg_EditingDeg->FullName);
2014-12-01 23:55:08 +01:00
/***** Degree type *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2015-09-28 18:28:29 +02:00
"<select name=\"OthDegTypCod\" style=\"width:62px;\">");
2014-12-01 23:55:08 +01:00
for (NumDegTyp = 0;
2019-04-04 10:45:15 +02:00
NumDegTyp < Gbl.DegTypes.Num;
2014-12-01 23:55:08 +01:00
NumDegTyp++)
{
2019-04-04 10:45:15 +02:00
DegTyp = &Gbl.DegTypes.Lst[NumDegTyp];
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
DegTyp->DegTypCod,
2019-04-07 12:17:10 +02:00
DegTyp->DegTypCod == Deg_EditingDeg->DegTypCod ? " selected=\"selected\"" :
"",
2014-12-01 23:55:08 +01:00
DegTyp->DegTypName);
}
fprintf (Gbl.F.Out,"</select>"
"</td>");
/***** Degree WWW *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2016-11-20 14:32:15 +01:00
"<input type=\"url\" name=\"WWW\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
2016-11-19 02:54:56 +01:00
" class=\"INPUT_WWW\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-04-07 12:17:10 +02:00
Cns_MAX_CHARS_WWW,Deg_EditingDeg->WWW);
2014-12-01 23:55:08 +01:00
/***** Current number of courses in this degree *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"0"
"</td>");
2014-12-01 23:55:08 +01:00
/***** Degree requester *****/
2017-05-02 01:05:23 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT INPUT_REQUESTER LEFT_TOP\">");
2017-05-02 01:16:06 +02:00
Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL);
2017-05-01 21:17:38 +02:00
fprintf (Gbl.F.Out,"</td>");
2017-03-17 00:46:28 +01:00
/***** Degree status *****/
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
2017-06-12 14:16:33 +02:00
/***** End table, send button and end box *****/
2017-06-11 19:02:40 +02:00
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_degree);
2014-12-01 23:55:08 +01:00
2015-04-11 23:46:21 +02:00
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Write header with fields of a degree *******************/
/*****************************************************************************/
static void Deg_PutHeadDegreesForSeeing (void)
{
extern const char *Txt_Degree;
2015-12-05 21:15:30 +01:00
extern const char *Txt_Type;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Courses_ABBREVIATION;
fprintf (Gbl.F.Out,"<tr>"
"<th class=\"BM\"></th>"
"<th></th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"RIGHT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Degree,
2015-12-05 21:15:30 +01:00
Txt_Type,
2017-03-17 00:46:28 +01:00
Txt_Courses_ABBREVIATION);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Write header with fields of a degree *******************/
/*****************************************************************************/
static void Deg_PutHeadDegreesForEdition (void)
{
extern const char *Txt_Code;
2016-03-02 19:29:56 +01:00
extern const char *Txt_Short_name_of_the_degree;
extern const char *Txt_Full_name_of_the_degree;
2015-12-05 21:15:30 +01:00
extern const char *Txt_Type;
2014-12-01 23:55:08 +01:00
extern const char *Txt_WWW;
extern const char *Txt_Courses_ABBREVIATION;
extern const char *Txt_Requester;
fprintf (Gbl.F.Out,"<tr>"
"<th class=\"BM\"></th>"
2015-09-06 20:02:14 +02:00
"<th class=\"RIGHT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-12-05 21:15:30 +01:00
"<th></th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"RIGHT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"LEFT_MIDDLE\">"
2014-12-26 22:11:03 +01:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Code,
2016-03-02 19:29:56 +01:00
Txt_Short_name_of_the_degree,
Txt_Full_name_of_the_degree,
2015-12-05 21:15:30 +01:00
Txt_Type,
2014-12-01 23:55:08 +01:00
Txt_WWW,
Txt_Courses_ABBREVIATION,
Txt_Requester);
}
/*****************************************************************************/
/******************** Convert string to year of a degree *********************/
/*****************************************************************************/
unsigned Deg_ConvStrToYear (const char *StrYear)
{
int Year;
if (sscanf (StrYear,"%d",&Year) != 1)
return 0;
if (Year < 0)
return 0;
if (Year > Deg_MAX_YEARS_PER_DEGREE)
return Deg_MAX_YEARS_PER_DEGREE;
return (unsigned) Year;
}
/*****************************************************************************/
/***************************** Create a new degree ***************************/
/*****************************************************************************/
2017-05-11 20:04:38 +02:00
static void Deg_CreateDegree (unsigned Status)
2014-12-01 23:55:08 +01:00
{
/***** Create a new degree *****/
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod =
2018-11-03 01:45:36 +01:00
DB_QueryINSERTandReturnCode ("can not create a new degree",
"INSERT INTO degrees (CtrCod,DegTypCod,Status,"
"RequesterUsrCod,ShortName,FullName,WWW)"
" VALUES (%ld,%ld,%u,%ld,'%s','%s','%s')",
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->CtrCod,
Deg_EditingDeg->DegTypCod,
2018-11-03 01:45:36 +01:00
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->ShrtName,
Deg_EditingDeg->FullName,
Deg_EditingDeg->WWW);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** List degrees belonging to the current centre *****************/
/*****************************************************************************/
static void Deg_ListDegrees (void)
{
2016-11-13 15:04:02 +01:00
extern const char *Hlp_CENTRE_Degrees;
2016-03-20 13:18:56 +01:00
extern const char *Txt_Degrees_of_CENTRE_X;
extern const char *Txt_No_degrees;
2016-03-16 13:23:10 +01:00
extern const char *Txt_Create_another_degree;
2015-10-06 01:19:21 +02:00
extern const char *Txt_Create_degree;
2016-03-20 13:18:56 +01:00
unsigned NumDeg;
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Start box *****/
2018-10-17 10:32:18 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Degrees_of_CENTRE_X,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.ShrtName);
2018-11-15 12:52:56 +01:00
Box_StartBox (NULL,Gbl.Title,Deg_PutIconsListingDegrees,
2017-06-12 15:03:29 +02:00
Hlp_CENTRE_Degrees,Box_NOT_CLOSABLE);
2016-03-20 13:18:56 +01:00
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.Degs.Num) // There are degrees in the current centre
2016-03-20 13:18:56 +01:00
{
2017-04-30 14:03:45 +02:00
/***** Write heading *****/
2017-06-11 20:09:59 +02:00
Tbl_StartTableWideMargin (2);
2016-03-20 13:18:56 +01:00
Deg_PutHeadDegreesForSeeing ();
/***** List the degrees *****/
for (NumDeg = 0;
2019-04-03 20:57:04 +02:00
NumDeg < Gbl.Hierarchy.Ctr.Degs.Num;
2016-03-20 13:18:56 +01:00
NumDeg++)
2019-04-03 20:57:04 +02:00
Deg_ListOneDegreeForSeeing (&(Gbl.Hierarchy.Ctr.Degs.Lst[NumDeg]),NumDeg + 1);
2016-03-20 13:18:56 +01:00
/***** End table *****/
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2016-03-20 13:18:56 +01:00
}
else // No degrees created in the current centre
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_INFO,Txt_No_degrees);
2016-03-16 12:59:57 +01:00
2016-03-20 13:18:56 +01:00
/***** Button to create degree *****/
2016-11-07 00:03:50 +01:00
if (Deg_CheckIfICanCreateDegrees ())
2016-03-16 12:59:57 +01:00
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActEdiDeg);
2019-04-03 20:57:04 +02:00
Btn_PutConfirmButton (Gbl.Hierarchy.Ctr.Degs.Num ? Txt_Create_another_degree :
2016-10-20 00:57:00 +02:00
Txt_Create_degree);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-10-06 01:19:21 +02:00
}
2016-03-20 13:18:56 +01:00
2017-06-12 14:16:33 +02:00
/***** End box *****/
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2016-03-20 13:18:56 +01:00
}
2016-11-06 23:56:43 +01:00
/*****************************************************************************/
2016-11-07 00:03:50 +01:00
/********************** Check if I can create degrees ************************/
2016-11-06 23:56:43 +01:00
/*****************************************************************************/
2016-11-07 00:03:50 +01:00
static bool Deg_CheckIfICanCreateDegrees (void)
2016-11-06 23:56:43 +01:00
{
2017-06-04 18:18:54 +02:00
return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_GST);
2016-11-06 23:56:43 +01:00
}
/*****************************************************************************/
/***************** Put contextual icons in list of degrees *******************/
/*****************************************************************************/
2018-11-15 12:52:56 +01:00
static void Deg_PutIconsListingDegrees (void)
2016-11-06 23:56:43 +01:00
{
/***** Put icon to edit degrees *****/
2016-11-07 00:03:50 +01:00
if (Deg_CheckIfICanCreateDegrees ())
2016-11-06 23:56:43 +01:00
Deg_PutIconToEditDegrees ();
2017-03-26 16:47:02 +02:00
/***** Put icon to view degree types *****/
DT_PutIconToViewDegreeTypes ();
2016-11-06 23:56:43 +01:00
/***** Put icon to show a figure *****/
2019-02-12 14:46:14 +01:00
Gbl.Figures.FigureType = Fig_HIERARCHY;
Fig_PutIconToShowFigure ();
2016-11-06 23:56:43 +01:00
}
2016-03-20 13:18:56 +01:00
/*****************************************************************************/
/********************** Put link (form) to edit degrees **********************/
/*****************************************************************************/
static void Deg_PutIconToEditDegrees (void)
{
2017-06-11 19:13:28 +02:00
Ico_PutContextualIconToEdit (ActEdiDeg,NULL);
2016-03-20 13:18:56 +01:00
}
/*****************************************************************************/
/************************ List one degree for seeing *************************/
/*****************************************************************************/
static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg)
{
extern const char *Txt_DEGREE_With_courses;
extern const char *Txt_DEGREE_Without_courses;
extern const char *Txt_DEGREE_STATUS[Deg_NUM_STATUS_TXT];
struct DegreeType DegTyp;
const char *TxtClassNormal;
const char *TxtClassStrong;
const char *BgColor;
2017-03-17 00:46:28 +01:00
Deg_StatusTxt_t StatusTxt;
2016-04-16 15:05:18 +02:00
unsigned NumCrss;
/***** Get number of courses in this degree *****/
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
2016-03-20 13:18:56 +01:00
/***** Get data of type of degree of this degree *****/
DegTyp.DegTypCod = Deg->DegTypCod;
2016-03-20 22:31:57 +01:00
if (!DT_GetDataOfDegreeTypeByCod (&DegTyp))
2016-03-20 13:18:56 +01:00
Lay_ShowErrorAndExit ("Code of type of degree not found.");
if (Deg->Status & Deg_STATUS_BIT_PENDING)
{
TxtClassNormal = "DAT_LIGHT";
TxtClassStrong = "DAT_LIGHT";
}
else
{
TxtClassNormal = "DAT";
TxtClassStrong = "DAT_N";
}
2019-04-03 20:57:04 +02:00
BgColor = (Deg->DegCod == Gbl.Hierarchy.Deg.DegCod) ? "LIGHT_BLUE" :
2016-03-20 13:18:56 +01:00
Gbl.ColorRows[Gbl.RowEvenOdd];
2019-01-11 03:45:13 +01:00
/***** Put tip if degree has courses *****/
2016-03-20 13:18:56 +01:00
fprintf (Gbl.F.Out,"<tr>"
2019-01-11 03:45:13 +01:00
"<td class=\"%s CENTER_MIDDLE %s\" title=\"%s\">"
"%s"
2016-03-20 13:18:56 +01:00
"</td>",
2019-01-11 03:45:13 +01:00
TxtClassNormal,BgColor,
2016-04-16 15:05:18 +02:00
NumCrss ? Txt_DEGREE_With_courses :
Txt_DEGREE_Without_courses,
2019-01-11 03:45:13 +01:00
NumCrss ? "&check;" :
"&nbsp;");
2016-03-20 13:18:56 +01:00
/***** Number of degree in this list *****/
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
"%u"
"</td>",
TxtClassNormal,BgColor,
NumDeg);
/***** Degree logo and name *****/
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE %s\">",BgColor);
Deg_DrawDegreeLogoAndNameWithLink (Deg,ActSeeCrs,
TxtClassStrong,"CENTER_MIDDLE");
fprintf (Gbl.F.Out,"</td>");
/***** Type of degree *****/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">"
"%s"
"</td>",
TxtClassNormal,BgColor,DegTyp.DegTypName);
/***** Current number of courses in this degree *****/
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
"%u"
"</td>",
2016-04-16 15:05:18 +02:00
TxtClassNormal,BgColor,NumCrss);
2016-03-20 13:18:56 +01:00
/***** Degree status *****/
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
2017-03-17 00:46:28 +01:00
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
TxtClassNormal,BgColor);
if (StatusTxt != Deg_STATUS_ACTIVE) // If active ==> do not show anything
fprintf (Gbl.F.Out,"%s",Txt_DEGREE_STATUS[StatusTxt]);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2016-03-20 13:18:56 +01:00
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************************** Put forms to edit degrees ***********************/
/*****************************************************************************/
void Deg_EditDegrees (void)
2019-04-07 12:17:10 +02:00
{
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
/***** Edit degrees *****/
Deg_EditDegreesInternal ();
/***** Degree destructor *****/
Deg_EditingDegreeDestructor ();
}
static void Deg_EditDegreesInternal (void)
2014-12-01 23:55:08 +01:00
{
2017-04-30 02:56:25 +02:00
extern const char *Hlp_CENTRE_Degrees;
extern const char *Txt_Degrees_of_CENTRE_X;
2017-04-30 14:03:45 +02:00
extern const char *Txt_No_types_of_degree;
2014-12-01 23:55:08 +01:00
/***** Get list of degrees in the current centre *****/
Deg_GetListDegsOfCurrentCtr ();
2016-10-20 21:09:01 +02:00
/***** Get list of degree types *****/
2019-04-03 20:57:04 +02:00
DT_GetListDegreeTypes (Hie_SYS,DT_ORDER_BY_DEGREE_TYPE);
2014-12-01 23:55:08 +01:00
2018-11-15 12:52:56 +01:00
/***** Write menu to select country, institution and centre *****/
Hie_WriteMenuHierarchy ();
2017-06-12 14:16:33 +02:00
/***** Start box *****/
2018-10-17 10:32:18 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Degrees_of_CENTRE_X,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.ShrtName);
2017-06-10 21:38:10 +02:00
Box_StartBox (NULL,Gbl.Title,Deg_PutIconsEditingDegrees,
2017-06-12 15:03:29 +02:00
Hlp_CENTRE_Degrees,Box_NOT_CLOSABLE);
2017-04-30 02:56:25 +02:00
2019-04-04 10:45:15 +02:00
if (Gbl.DegTypes.Num)
2014-12-01 23:55:08 +01:00
{
2016-10-20 21:09:01 +02:00
/***** Put a form to create a new degree *****/
Deg_PutFormToCreateDegree ();
2014-12-01 23:55:08 +01:00
2016-10-20 21:09:01 +02:00
/***** Forms to edit current degrees *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.Degs.Num)
2016-10-20 21:09:01 +02:00
Deg_ListDegreesForEdition ();
2014-12-01 23:55:08 +01:00
}
2016-10-20 21:09:01 +02:00
else // No degree types
2014-12-01 23:55:08 +01:00
{
2017-03-26 17:32:19 +02:00
/***** Warning message *****/
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_No_types_of_degree);
2017-03-26 17:32:19 +02:00
/***** Form to create the first degree type *****/
2017-04-30 14:03:45 +02:00
if (DT_CheckIfICanCreateDegreeTypes ())
DT_EditDegreeTypes ();
2014-12-01 23:55:08 +01:00
}
2017-06-12 14:16:33 +02:00
/***** End box *****/
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2017-04-30 02:56:25 +02:00
2016-10-20 21:09:01 +02:00
/***** Free list of degree types *****/
DT_FreeListDegreeTypes ();
2014-12-01 23:55:08 +01:00
/***** Free list of degrees in the current centre *****/
2019-04-03 20:57:04 +02:00
Deg_FreeListDegs (&Gbl.Hierarchy.Ctr.Degs);
2014-12-01 23:55:08 +01:00
}
2017-04-30 02:56:25 +02:00
/*****************************************************************************/
/**************** Put contextual icons in edition of degrees *****************/
/*****************************************************************************/
static void Deg_PutIconsEditingDegrees (void)
{
/***** Put icon to view degrees *****/
Deg_PutIconToViewDegrees ();
/***** Put icon to view types of degree *****/
DT_PutIconToViewDegreeTypes ();
2018-11-15 12:52:56 +01:00
/***** Put icon to show a figure *****/
2019-02-12 14:46:14 +01:00
Gbl.Figures.FigureType = Fig_HIERARCHY;
Fig_PutIconToShowFigure ();
2017-04-30 02:56:25 +02:00
}
2018-11-15 18:51:13 +01:00
/*****************************************************************************/
/*********************** Put icon to view degrees ****************************/
/*****************************************************************************/
2018-11-15 12:52:56 +01:00
void Deg_PutIconToViewDegrees (void)
2017-04-30 02:56:25 +02:00
{
2018-11-15 12:52:56 +01:00
extern const char *Txt_Degrees;
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeDeg,NULL,NULL,
"graduation-cap.svg",
Txt_Degrees);
2017-04-30 02:56:25 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-16 15:05:18 +02:00
/********** Create a list with all the degrees that have students ************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-16 15:05:18 +02:00
void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDeg;
/***** Get degrees admin by me from database *****/
2018-10-30 15:26:20 +01:00
Degs->Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees"
" admin by you",
"SELECT DISTINCTROW degrees.DegCod,degrees.CtrCod,"
"degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod,"
"degrees.ShortName,degrees.FullName,degrees.WWW"
" FROM degrees,courses,crs_usr"
" WHERE degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" ORDER BY degrees.ShortName",
(unsigned) Rol_STD);
2016-04-16 15:05:18 +02:00
if (Degs->Num) // Degrees found...
2014-12-01 23:55:08 +01:00
{
/***** Create list with degrees *****/
2016-04-16 15:05:18 +02:00
if ((Degs->Lst = (struct Degree *) calloc (Degs->Num,sizeof (struct Degree))) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
/***** Get the degrees *****/
for (NumDeg = 0;
2016-04-16 15:05:18 +02:00
NumDeg < Degs->Num;
2014-12-01 23:55:08 +01:00
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
2016-04-16 15:05:18 +02:00
Deg_GetDataOfDegreeFromRow (&(Degs->Lst[NumDeg]),row);
2014-12-01 23:55:08 +01:00
}
}
else
2016-04-16 15:05:18 +02:00
Degs->Lst = NULL;
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/************ Get a list with the degrees of the current centre **************/
/*****************************************************************************/
2016-10-20 00:57:00 +02:00
void Deg_GetListDegsOfCurrentCtr (void)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned NumDeg;
/***** Get degrees of the current centre from database *****/
2018-10-30 15:26:20 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a centre",
"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod,"
"ShortName,FullName,WWW"
" FROM degrees WHERE CtrCod=%ld ORDER BY FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod);
2014-12-01 23:55:08 +01:00
/***** Count number of rows in result *****/
if (NumRows) // Degrees found...
{
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.Degs.Num = (unsigned) NumRows;
2014-12-01 23:55:08 +01:00
/***** Create list with degrees of this centre *****/
2019-04-03 20:57:04 +02:00
if ((Gbl.Hierarchy.Ctr.Degs.Lst = (struct Degree *) calloc (Gbl.Hierarchy.Ctr.Degs.Num,
2016-10-20 00:57:00 +02:00
sizeof (struct Degree))) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
/***** Get the degrees of this centre *****/
for (NumDeg = 0;
2019-04-03 20:57:04 +02:00
NumDeg < Gbl.Hierarchy.Ctr.Degs.Num;
2014-12-01 23:55:08 +01:00
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
2019-04-03 20:57:04 +02:00
Deg_GetDataOfDegreeFromRow (&Gbl.Hierarchy.Ctr.Degs.Lst[NumDeg],row);
2014-12-01 23:55:08 +01:00
}
}
2016-10-20 00:57:00 +02:00
else
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.Degs.Num = 0;
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
2016-10-20 00:57:00 +02:00
/*************************** Free list of degrees ****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-10-20 00:57:00 +02:00
void Deg_FreeListDegs (struct ListDegrees *Degs)
2014-12-01 23:55:08 +01:00
{
2016-10-20 00:57:00 +02:00
if (Degs->Lst)
2014-12-01 23:55:08 +01:00
{
2016-10-20 00:57:00 +02:00
free ((void *) Degs->Lst);
Degs->Lst = NULL;
Degs->Num = 0;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/****************** Receive form to request a new degree *********************/
/*****************************************************************************/
void Deg_RecFormReqDeg (void)
{
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
/***** Receive form to request a new degree *****/
2014-12-01 23:55:08 +01:00
Deg_RecFormRequestOrCreateDeg ((unsigned) Deg_STATUS_BIT_PENDING);
}
/*****************************************************************************/
/******************* Receive form to create a new degree *********************/
/*****************************************************************************/
void Deg_RecFormNewDeg (void)
{
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2019-04-07 19:49:53 +02:00
/***** Receive form to create a new degree *****/
2014-12-01 23:55:08 +01:00
Deg_RecFormRequestOrCreateDeg (0);
2019-04-07 12:17:10 +02:00
/***** Degree destructor *****/
Deg_EditingDegreeDestructor ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Receive form to create a new degree *********************/
/*****************************************************************************/
static void Deg_RecFormRequestOrCreateDeg (unsigned Status)
{
extern const char *Txt_The_degree_X_already_exists;
2019-04-08 14:52:13 +02:00
extern const char *Txt_Created_new_degree_X;
2014-12-01 23:55:08 +01:00
extern const char *Txt_You_must_specify_the_web_address_of_the_new_degree;
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_degree;
/***** Get parameters from form *****/
/* Set degree centre */
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->CtrCod = Gbl.Hierarchy.Ctr.CtrCod;
2014-12-01 23:55:08 +01:00
/* Get degree short name */
2019-04-07 12:17:10 +02:00
Par_GetParToText ("ShortName",Deg_EditingDeg->ShrtName,Hie_MAX_BYTES_SHRT_NAME);
2014-12-01 23:55:08 +01:00
/* Get degree full name */
2019-04-07 12:17:10 +02:00
Par_GetParToText ("FullName",Deg_EditingDeg->FullName,Hie_MAX_BYTES_FULL_NAME);
2014-12-01 23:55:08 +01:00
/* Get degree type */
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegTypCod = DT_GetAndCheckParamOtherDegTypCod (1);
2014-12-01 23:55:08 +01:00
/* Get degree WWW */
2019-04-07 12:17:10 +02:00
Par_GetParToText ("WWW",Deg_EditingDeg->WWW,Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
2019-04-07 12:17:10 +02:00
if (Deg_EditingDeg->ShrtName[0] &&
Deg_EditingDeg->FullName[0]) // If there's a degree name
2014-12-01 23:55:08 +01:00
{
2019-04-07 12:17:10 +02:00
if (Deg_EditingDeg->WWW[0])
2014-12-01 23:55:08 +01:00
{
/***** If name of degree was in database... *****/
2019-04-07 12:17:10 +02:00
if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Deg_EditingDeg->ShrtName,
-1L,Deg_EditingDeg->CtrCod))
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_degree_X_already_exists,
Deg_EditingDeg->ShrtName);
2019-04-07 12:17:10 +02:00
else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Deg_EditingDeg->FullName,
-1L,Deg_EditingDeg->CtrCod))
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_degree_X_already_exists,
Deg_EditingDeg->FullName);
2014-12-01 23:55:08 +01:00
else // Add new degree to database
2019-04-08 14:52:13 +02:00
{
2017-05-11 20:04:38 +02:00
Deg_CreateDegree (Status);
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Created_new_degree_X,
Deg_EditingDeg->FullName);
}
2014-12-01 23:55:08 +01:00
}
else // If there is not a degree logo or web
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_specify_the_web_address_of_the_new_degree);
2014-12-01 23:55:08 +01:00
}
else // If there is not a degree name
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_degree);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Request removing of a degree ***********************/
/*****************************************************************************/
void Deg_RemoveDegree (void)
{
extern const char *Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree;
extern const char *Txt_Degree_X_removed;
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2014-12-01 23:55:08 +01:00
/***** Get degree code *****/
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
2014-12-01 23:55:08 +01:00
2016-03-01 13:36:48 +01:00
/***** Get data of degree *****/
2019-04-07 12:17:10 +02:00
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
2014-12-01 23:55:08 +01:00
/***** Check if this degree has courses *****/
2019-04-07 12:17:10 +02:00
if (Crs_GetNumCrssInDeg (Deg_EditingDeg->DegCod)) // Degree has courses ==> don't remove
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
2014-12-01 23:55:08 +01:00
else // Degree has no courses ==> remove it
{
/***** Remove degree *****/
2019-04-07 12:17:10 +02:00
Deg_RemoveDegreeCompletely (Deg_EditingDeg->DegCod);
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Degree_X_removed,
Deg_EditingDeg->FullName);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******************** Write parameter with code of degree ********************/
/*****************************************************************************/
void Deg_PutParamDegCod (long DegCod)
{
2015-03-07 21:08:44 +01:00
Par_PutHiddenParamLong ("deg",DegCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Write parameter with code of degree ********************/
/*****************************************************************************/
static void Deg_PutParamOtherDegCod (long DegCod)
{
Par_PutHiddenParamLong ("OthDegCod",DegCod);
}
/*****************************************************************************/
/********************* Get parameter with code of degree *********************/
/*****************************************************************************/
2017-05-31 21:05:59 +02:00
long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed)
2014-12-01 23:55:08 +01:00
{
2016-10-23 18:39:04 +02:00
long DegCod;
2014-12-01 23:55:08 +01:00
2016-10-23 19:40:14 +02:00
/***** Get and check parameter with code of degree *****/
2017-05-31 21:05:59 +02:00
if ((DegCod = Par_GetParToLong ("OthDegCod")) < MinCodAllowed)
Lay_ShowErrorAndExit ("Code of degree is missing or invalid.");
2016-10-23 18:39:04 +02:00
return DegCod;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Get data of a degree from its code ********************/
/*****************************************************************************/
// Returns true if degree found
bool Deg_GetDataOfDegreeByCod (struct Degree *Deg)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
bool DegFound = false;
2016-12-30 01:20:49 +01:00
/***** Clear data *****/
Deg->CtrCod = -1L;
Deg->DegTypCod = -1L;
Deg->Status = (Deg_Status_t) 0;
Deg->RequesterUsrCod = -1L;
Deg->ShrtName[0] = '\0';
Deg->FullName[0] = '\0';
Deg->WWW[0] = '\0';
2019-04-04 10:45:15 +02:00
Deg->Crss.Lst = NULL;
2016-12-30 01:20:49 +01:00
/***** Check if degree code is correct *****/
if (Deg->DegCod > 0)
2014-12-01 23:55:08 +01:00
{
2016-12-30 01:20:49 +01:00
/***** Get data of a degree from database *****/
2018-10-30 15:26:20 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get data of a degree",
"SELECT DegCod,CtrCod,DegTypCod,Status,"
"RequesterUsrCod,ShortName,FullName,WWW"
" FROM degrees WHERE DegCod=%ld",
Deg->DegCod)) // Degree found...
2016-12-30 01:20:49 +01:00
{
/***** Get data of degree *****/
row = mysql_fetch_row (mysql_res);
Deg_GetDataOfDegreeFromRow (Deg,row);
2014-12-01 23:55:08 +01:00
2016-12-30 01:20:49 +01:00
/* Set return value */
DegFound = true;
}
2014-12-01 23:55:08 +01:00
2016-12-30 01:20:49 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
2014-12-01 23:55:08 +01:00
}
return DegFound;
}
/*****************************************************************************/
/********** Get data of a degree from a row resulting of a query *************/
/*****************************************************************************/
static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row)
{
/***** Get degree code (row[0]) *****/
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of degree.");
/***** Get centre code (row[1]) *****/
Deg->CtrCod = Str_ConvertStrCodToLongCod (row[1]);
/***** Get the code of the degree type (row[2]) *****/
Deg->DegTypCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get course status (row[3]) */
if (sscanf (row[3],"%u",&(Deg->Status)) != 1)
Lay_ShowErrorAndExit ("Wrong degree status.");
/* Get requester user's code (row[4]) */
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/***** Get degree short name (row[5]) *****/
2017-01-17 03:10:43 +01:00
Str_Copy (Deg->ShrtName,row[5],
2017-03-08 14:12:33 +01:00
Hie_MAX_BYTES_SHRT_NAME);
2014-12-01 23:55:08 +01:00
/***** Get degree full name (row[6]) *****/
2017-01-17 03:10:43 +01:00
Str_Copy (Deg->FullName,row[6],
2017-03-08 14:12:33 +01:00
Hie_MAX_BYTES_FULL_NAME);
2014-12-01 23:55:08 +01:00
2016-02-29 18:53:26 +01:00
/***** Get WWW (row[7]) *****/
2017-01-17 03:10:43 +01:00
Str_Copy (Deg->WWW,row[7],
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Get the short name of a degree from its code ******************/
/*****************************************************************************/
void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-10-28 10:03:37 +02:00
Deg->ShrtName[0] = '\0';
2014-12-01 23:55:08 +01:00
if (Deg->DegCod > 0)
{
/***** Get the short name of a degree from database *****/
2018-10-30 15:26:20 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a degree",
"SELECT ShortName FROM degrees WHERE DegCod=%ld",
Deg->DegCod) == 1)
2014-12-01 23:55:08 +01:00
{
/***** Get the short name of this degree *****/
row = mysql_fetch_row (mysql_res);
2017-01-13 01:51:23 +01:00
2017-01-17 03:10:43 +01:00
Str_Copy (Deg->ShrtName,row[0],
2017-03-08 14:12:33 +01:00
Hie_MAX_BYTES_SHRT_NAME);
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
}
2015-02-03 11:34:59 +01:00
/*****************************************************************************/
/************* Get the centre code of a degree from its code *****************/
/*****************************************************************************/
long Deg_GetCtrCodOfDegreeByCod (long DegCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long CtrCod = -1L;
if (DegCod > 0)
{
/***** Get the centre code of a degree from database *****/
2018-10-30 15:26:20 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get the centre of a degree",
"SELECT CtrCod FROM degrees WHERE DegCod=%ld",
DegCod) == 1)
2015-02-03 11:34:59 +01:00
{
/***** Get the centre code of this degree *****/
row = mysql_fetch_row (mysql_res);
CtrCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
return CtrCod;
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********** Get the institution code of a degree from its code ***************/
/*****************************************************************************/
long Deg_GetInsCodOfDegreeByCod (long DegCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long InsCod = -1L;
if (DegCod > 0)
{
2015-02-03 11:34:59 +01:00
/***** Get the institution code of a degree from database *****/
2018-10-30 15:26:20 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get the institution of a degree",
"SELECT centres.InsCod FROM degrees,centres"
" WHERE degrees.DegCod=%ld"
" AND degrees.CtrCod=centres.CtrCod",
DegCod) == 1)
2014-12-01 23:55:08 +01:00
{
2015-02-03 11:34:59 +01:00
/***** Get the institution code of this degree *****/
2014-12-01 23:55:08 +01:00
row = mysql_fetch_row (mysql_res);
InsCod = Str_ConvertStrCodToLongCod (row[0]);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
return InsCod;
}
/*****************************************************************************/
/***************************** Remove a degree *******************************/
/*****************************************************************************/
2016-03-20 16:30:52 +01:00
void Deg_RemoveDegreeCompletely (long DegCod)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow,NumRows;
long CrsCod;
2017-01-28 15:58:46 +01:00
char PathDeg[PATH_MAX + 1];
2014-12-01 23:55:08 +01:00
/***** Get courses of a degree from database *****/
2018-10-30 15:26:20 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
"SELECT CrsCod FROM courses"
" WHERE DegCod=%ld",
DegCod);
2014-12-01 23:55:08 +01:00
/* Get courses in this degree */
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next course */
row = mysql_fetch_row (mysql_res);
/* Get course code (row[0]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of course.");
/* Remove course */
Crs_RemoveCourseCompletely (CrsCod);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
2016-10-27 23:38:53 +02:00
/***** Remove all the threads and posts in forums of the degree *****/
2019-04-03 20:57:04 +02:00
For_RemoveForums (Hie_DEG,DegCod);
2016-10-28 00:23:02 +02:00
/***** Remove surveys of the degree *****/
2019-04-03 20:57:04 +02:00
Svy_RemoveSurveys (Hie_DEG,DegCod);
2014-12-01 23:55:08 +01:00
2015-01-20 02:00:42 +01:00
/***** Remove information related to files in degree *****/
2015-01-25 18:50:43 +01:00
Brw_RemoveDegFilesFromDB (DegCod);
/***** Remove directories of the degree *****/
2018-10-17 10:32:18 +02:00
snprintf (PathDeg,sizeof (PathDeg),
2019-03-20 01:36:36 +01:00
"%s/%02u/%u",
Cfg_PATH_DEG_PUBLIC,
2018-10-17 10:32:18 +02:00
(unsigned) (DegCod % 100),
(unsigned) DegCod);
2016-10-06 22:18:33 +02:00
Fil_RemoveTree (PathDeg);
2015-01-20 18:55:59 +01:00
2014-12-01 23:55:08 +01:00
/***** Remove administrators of this degree *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove administrators of a degree",
"DELETE FROM admin WHERE Scope='%s' AND Cod=%ld",
2019-04-03 20:57:04 +02:00
Sco_GetDBStrFromScope (Hie_DEG),DegCod);
2014-12-01 23:55:08 +01:00
/***** Remove the degree *****/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove a degree",
"DELETE FROM degrees WHERE DegCod=%ld",
DegCod);
2014-12-01 23:55:08 +01:00
/***** Delete all the degrees in sta_degrees table not present in degrees table *****/
Pho_RemoveObsoleteStatDegrees ();
}
/*****************************************************************************/
2019-04-07 12:17:10 +02:00
/************************ Change the name of a degree ************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Deg_RenameDegreeShort (void)
{
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2019-04-07 19:49:53 +02:00
/***** Rename degree *****/
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
Deg_RenameDegree (Deg_EditingDeg,Cns_SHRT_NAME);
2014-12-01 23:55:08 +01:00
}
2019-04-07 12:17:10 +02:00
void Deg_RenameDegreeFull (void)
2016-10-23 16:15:28 +02:00
{
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2019-04-07 19:49:53 +02:00
/***** Rename degree *****/
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
Deg_RenameDegree (Deg_EditingDeg,Cns_FULL_NAME);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2019-04-07 12:17:10 +02:00
/*************** Change the name of a degree in configuration ****************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2019-04-07 12:17:10 +02:00
void Deg_RenameDegreeShortInConfig (void)
2014-12-01 23:55:08 +01:00
{
2019-04-07 12:17:10 +02:00
Deg_RenameDegree (&Gbl.Hierarchy.Deg,Cns_SHRT_NAME);
2016-10-23 16:04:36 +02:00
}
2016-03-01 13:36:48 +01:00
2016-10-23 16:04:36 +02:00
void Deg_RenameDegreeFullInConfig (void)
{
2019-04-03 20:57:04 +02:00
Deg_RenameDegree (&Gbl.Hierarchy.Deg,Cns_FULL_NAME);
2016-10-23 16:04:36 +02:00
}
2016-03-01 13:36:48 +01:00
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************ Change the name of a degree ************************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_can_not_leave_the_name_of_the_degree_X_empty;
extern const char *Txt_The_degree_X_already_exists;
extern const char *Txt_The_name_of_the_degree_X_has_changed_to_Y;
extern const char *Txt_The_name_of_the_degree_X_has_not_changed;
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
2017-03-07 11:03:05 +01:00
unsigned MaxBytes = 0; // Initialized to avoid warning
2014-12-01 23:55:08 +01:00
char *CurrentDegName = NULL; // Initialized to avoid warning
2017-03-08 14:12:33 +01:00
char NewDegName[Hie_MAX_BYTES_FULL_NAME + 1];
2014-12-01 23:55:08 +01:00
2016-10-28 10:03:37 +02:00
switch (ShrtOrFullName)
2014-12-01 23:55:08 +01:00
{
2016-10-28 10:03:37 +02:00
case Cns_SHRT_NAME:
2014-12-01 23:55:08 +01:00
ParamName = "ShortName";
FieldName = "ShortName";
2017-03-08 14:12:33 +01:00
MaxBytes = Hie_MAX_BYTES_SHRT_NAME;
2016-10-28 10:03:37 +02:00
CurrentDegName = Deg->ShrtName;
2014-12-01 23:55:08 +01:00
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
2017-03-08 14:12:33 +01:00
MaxBytes = Hie_MAX_BYTES_FULL_NAME;
2014-12-01 23:55:08 +01:00
CurrentDegName = Deg->FullName;
break;
}
/***** Get parameters from form *****/
/* Get the new name for the degree */
2017-03-07 11:03:05 +01:00
Par_GetParToText (ParamName,NewDegName,MaxBytes);
2014-12-01 23:55:08 +01:00
2016-03-01 13:36:48 +01:00
/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (Deg);
2014-12-01 23:55:08 +01:00
/***** Check if new name is empty *****/
if (!NewDegName[0])
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_name_of_the_degree_X_empty,
CurrentDegName);
2014-12-01 23:55:08 +01:00
else
{
2019-01-02 15:10:51 +01:00
/***** Check if old and new names are the same
(this happens when return is pressed without changes) *****/
2014-12-01 23:55:08 +01:00
if (strcmp (CurrentDegName,NewDegName)) // Different names
{
/***** If degree was in database... *****/
2016-10-20 19:46:06 +02:00
if (Deg_CheckIfDegNameExistsInCtr (ParamName,NewDegName,Deg->DegCod,Deg->CtrCod))
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_degree_X_already_exists,
NewDegName);
2014-12-01 23:55:08 +01:00
else
{
/* Update the table changing old name by new name */
2017-03-09 11:16:17 +01:00
Deg_UpdateDegNameDB (Deg->DegCod,FieldName,NewDegName);
2014-12-01 23:55:08 +01:00
2016-03-01 13:36:48 +01:00
/* Write message to show the change made */
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_The_name_of_the_degree_X_has_changed_to_Y,
CurrentDegName,NewDegName);
2016-03-01 13:36:48 +01:00
/* Change current degree name in order to display it properly */
2017-01-17 03:10:43 +01:00
Str_Copy (CurrentDegName,NewDegName,
2017-03-07 11:03:05 +01:00
MaxBytes);
2014-12-01 23:55:08 +01:00
}
}
else // The same name
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_INFO,NULL,
Txt_The_name_of_the_degree_X_has_not_changed,
CurrentDegName);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/********************* Check if the name of degree exists ********************/
/*****************************************************************************/
2018-10-20 19:58:28 +02:00
static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
long DegCod,long CtrCod)
2014-12-01 23:55:08 +01:00
{
/***** Get number of degrees with a type and a name from database *****/
2018-11-03 13:13:11 +01:00
return (DB_QueryCOUNT ("can not check if the name of a degree"
" already existed",
"SELECT COUNT(*) FROM degrees"
" WHERE CtrCod=%ld AND %s='%s' AND DegCod<>%ld",
CtrCod,FieldName,Name,DegCod) != 0);
2014-12-01 23:55:08 +01:00
}
2017-03-09 11:16:17 +01:00
/*****************************************************************************/
/***************** Update degree name in table of degrees ********************/
/*****************************************************************************/
static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName)
{
/***** Update degree changing old name by new name *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the name of a degree",
"UPDATE degrees SET %s='%s' WHERE DegCod=%ld",
FieldName,NewDegName,DegCod);
2017-03-09 11:16:17 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************ Change the centre of a degree **********************/
/*****************************************************************************/
2016-10-20 16:49:42 +02:00
void Deg_ChangeDegCtrInConfig (void)
2016-10-19 20:43:26 +02:00
{
2016-10-20 19:46:06 +02:00
extern const char *Txt_The_degree_X_already_exists;
2016-10-19 20:43:26 +02:00
extern const char *Txt_The_degree_X_has_been_moved_to_the_centre_Y;
struct Centre NewCtr;
2016-10-23 18:50:21 +02:00
/***** Get parameter with centre code *****/
2017-05-31 21:05:59 +02:00
NewCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
2016-10-19 20:43:26 +02:00
2016-10-20 20:02:59 +02:00
/***** Check if centre has changed *****/
2019-04-03 20:57:04 +02:00
if (NewCtr.CtrCod != Gbl.Hierarchy.Deg.CtrCod)
2016-10-20 19:46:06 +02:00
{
/***** Get data of new centre *****/
Ctr_GetDataOfCentreByCod (&NewCtr);
2016-10-19 20:43:26 +02:00
2016-10-20 19:46:06 +02:00
/***** Check if it already exists a degree with the same name in the new centre *****/
2019-04-03 20:57:04 +02:00
if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Gbl.Hierarchy.Deg.ShrtName,Gbl.Hierarchy.Deg.DegCod,NewCtr.CtrCod))
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_WARNING,
Txt_The_degree_X_already_exists,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.ShrtName);
else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Gbl.Hierarchy.Deg.FullName,Gbl.Hierarchy.Deg.DegCod,NewCtr.CtrCod))
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_WARNING,
Txt_The_degree_X_already_exists,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.FullName);
2016-10-20 19:46:06 +02:00
else
{
/***** Update centre in table of degrees *****/
2019-04-03 20:57:04 +02:00
Deg_UpdateDegCtrDB (Gbl.Hierarchy.Deg.DegCod,NewCtr.CtrCod);
Gbl.Hierarchy.Deg.CtrCod =
Gbl.Hierarchy.Ctr.CtrCod = NewCtr.CtrCod;
2016-10-20 19:46:06 +02:00
/***** Initialize again current course, degree, centre... *****/
2016-11-14 17:26:32 +01:00
Hie_InitHierarchy ();
2016-10-20 19:46:06 +02:00
2019-03-09 20:12:44 +01:00
/***** Create alert to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_The_degree_X_has_been_moved_to_the_centre_Y,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.FullName,
Gbl.Hierarchy.Ctr.FullName);
2016-10-20 19:46:06 +02:00
}
}
2016-10-19 20:43:26 +02:00
}
/*****************************************************************************/
2016-10-20 16:49:42 +02:00
/** Show message of success after changing a degree in degree configuration **/
2016-10-19 20:43:26 +02:00
/*****************************************************************************/
void Deg_ContEditAfterChgDegInConfig (void)
{
2017-03-26 03:45:13 +02:00
/***** Write success / warning message *****/
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2016-10-19 20:43:26 +02:00
/***** Show the form again *****/
Deg_ShowConfiguration ();
}
2016-10-19 23:17:36 +02:00
/*****************************************************************************/
/********************** Update centre in table of degrees ********************/
/*****************************************************************************/
2016-10-20 16:49:42 +02:00
static void Deg_UpdateDegCtrDB (long DegCod,long CtrCod)
2016-10-19 23:17:36 +02:00
{
/***** Update centre in table of degrees *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the centre of a degree",
"UPDATE degrees SET CtrCod=%ld WHERE DegCod=%ld",
CtrCod,DegCod);
2016-10-19 23:17:36 +02:00
}
2019-04-07 12:17:10 +02:00
/*****************************************************************************/
/************************ Change the type of a degree ************************/
/*****************************************************************************/
void Deg_ChangeDegreeType (void)
{
extern const char *Txt_The_type_of_degree_of_the_degree_X_has_changed;
long NewDegTypCod;
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
/***** Get parameters from form *****/
/* Get degree code */
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
/* Get the new degree type */
NewDegTypCod = DT_GetAndCheckParamOtherDegTypCod (1);
/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
/***** Update the table of degrees changing old type by new type *****/
DB_QueryUPDATE ("can not update the type of a degree",
"UPDATE degrees SET DegTypCod=%ld WHERE DegCod=%ld",
NewDegTypCod,Deg_EditingDeg->DegCod);
2019-04-08 12:01:08 +02:00
Deg_EditingDeg->DegTypCod = NewDegTypCod;
2019-04-07 12:17:10 +02:00
2019-04-08 14:52:13 +02:00
/***** Create alert to show the change made
2019-04-07 12:17:10 +02:00
and put button to go to degree changed *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_The_type_of_degree_of_the_degree_X_has_changed,
Deg_EditingDeg->FullName);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************* Change the WWW of a degree ************************/
/*****************************************************************************/
void Deg_ChangeDegWWW (void)
{
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
2017-03-07 01:56:41 +01:00
char NewWWW[Cns_MAX_BYTES_WWW + 1];
2014-12-01 23:55:08 +01:00
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2014-12-01 23:55:08 +01:00
/***** Get parameters from form *****/
/* Get the code of the degree */
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
2014-12-01 23:55:08 +01:00
/* Get the new WWW for the degree */
2017-03-07 01:56:41 +01:00
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
2016-03-01 13:36:48 +01:00
/***** Get data of degree *****/
2019-04-07 12:17:10 +02:00
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
2016-03-01 13:36:48 +01:00
2014-12-01 23:55:08 +01:00
/***** Check if new WWW is empty *****/
if (NewWWW[0])
{
2016-03-01 13:36:48 +01:00
/***** Update the table changing old WWW by new WWW *****/
2019-04-07 12:17:10 +02:00
Deg_UpdateDegWWWDB (Deg_EditingDeg->DegCod,NewWWW);
Str_Copy (Deg_EditingDeg->WWW,NewWWW,
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
2019-03-09 20:12:44 +01:00
/***** Write alert to show the change made
2017-05-11 20:04:38 +02:00
and put button to go to degree changed *****/
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_The_new_web_address_is_X,
NewWWW);
2014-12-01 23:55:08 +01:00
}
else
2019-04-08 14:52:13 +02:00
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_You_can_not_leave_the_web_address_empty);
2016-10-23 16:37:45 +02:00
}
void Deg_ChangeDegWWWInConfig (void)
{
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
2017-03-07 01:56:41 +01:00
char NewWWW[Cns_MAX_BYTES_WWW + 1];
2016-10-23 16:37:45 +02:00
/***** Get parameters from form *****/
/* Get the new WWW for the degree */
2017-03-07 01:56:41 +01:00
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
2016-10-23 16:37:45 +02:00
/***** Check if new WWW is empty *****/
if (NewWWW[0])
2014-12-01 23:55:08 +01:00
{
2016-10-23 16:37:45 +02:00
/***** Update the table changing old WWW by new WWW *****/
2019-04-03 20:57:04 +02:00
Deg_UpdateDegWWWDB (Gbl.Hierarchy.Deg.DegCod,NewWWW);
Str_Copy (Gbl.Hierarchy.Deg.WWW,NewWWW,
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2016-10-23 16:37:45 +02:00
/***** Write message to show the change made *****/
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
2019-02-16 01:20:54 +01:00
NewWWW);
2014-12-01 23:55:08 +01:00
}
2016-10-23 16:37:45 +02:00
else
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty);
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
2016-10-23 16:37:45 +02:00
Deg_ShowConfiguration ();
}
/*****************************************************************************/
/**************** Update database changing old WWW by new WWW ****************/
/*****************************************************************************/
2017-03-07 01:56:41 +01:00
static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
2016-10-23 16:37:45 +02:00
{
/***** Update database changing old WWW by new WWW *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the web of a degree",
"UPDATE degrees SET WWW='%s' WHERE DegCod=%ld",
NewWWW,DegCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Change the status of a degree ***********************/
/*****************************************************************************/
void Deg_ChangeDegStatus (void)
{
extern const char *Txt_The_status_of_the_degree_X_has_changed;
Deg_Status_t Status;
Deg_StatusTxt_t StatusTxt;
2019-04-07 12:17:10 +02:00
/***** Degree constructor *****/
Deg_EditingDegreeConstructor ();
2014-12-01 23:55:08 +01:00
/***** Get parameters from form *****/
/* Get degree code */
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->DegCod = Deg_GetAndCheckParamOtherDegCod (1);
2014-12-01 23:55:08 +01:00
/* Get parameter with status */
2017-01-29 21:41:08 +01:00
Status = (Deg_Status_t)
Par_GetParToUnsignedLong ("Status",
0,
(unsigned long) Deg_MAX_STATUS,
(unsigned long) Deg_WRONG_STATUS);
2017-01-29 12:42:19 +01:00
if (Status == Deg_WRONG_STATUS)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong status.");
StatusTxt = Deg_GetStatusTxtFromStatusBits (Status);
Status = Deg_GetStatusBitsFromStatusTxt (StatusTxt); // New status
/***** Get data of degree *****/
2019-04-07 12:17:10 +02:00
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
2014-12-01 23:55:08 +01:00
/***** Update status in table of degrees *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the status of a degree",
"UPDATE degrees SET Status=%u WHERE DegCod=%ld",
2019-04-07 12:17:10 +02:00
(unsigned) Status,Deg_EditingDeg->DegCod);
Deg_EditingDeg->Status = Status;
2014-12-01 23:55:08 +01:00
2019-03-09 20:12:44 +01:00
/***** Write alert to show the change made
2017-05-11 20:04:38 +02:00
and put button to go to degree changed *****/
2019-03-09 20:12:44 +01:00
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_The_status_of_the_degree_X_has_changed,
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->ShrtName);
2019-04-08 14:52:13 +02:00
}
/*****************************************************************************/
2019-04-08 15:33:29 +02:00
/********* Show alerts after changing a degree and continue editing **********/
2019-04-08 14:52:13 +02:00
/*****************************************************************************/
void Deg_ContEditAfterChgDeg (void)
{
/***** Write message to show the change made
and put button to go to degree changed *****/
2017-05-11 20:04:38 +02:00
Deg_ShowAlertAndButtonToGoToDeg ();
2016-03-01 13:36:48 +01:00
/***** Show the form again *****/
2019-04-07 12:17:10 +02:00
Deg_EditDegreesInternal ();
2016-03-01 13:36:48 +01:00
2019-04-07 12:17:10 +02:00
/***** Degree destructor *****/
Deg_EditingDegreeDestructor ();
2014-12-01 23:55:08 +01:00
}
2016-03-01 13:36:48 +01:00
/*****************************************************************************/
2017-05-11 20:55:04 +02:00
/***************** Write message to show the change made ********************/
/***************** and put button to go to degree changed ********************/
2016-03-01 13:36:48 +01:00
/*****************************************************************************/
2019-04-08 14:52:13 +02:00
static void Deg_ShowAlertAndButtonToGoToDeg (void)
2016-03-01 13:36:48 +01:00
{
extern const char *Txt_Go_to_X;
2017-05-11 20:04:38 +02:00
// If the degree being edited is different to the current one...
2019-04-07 12:17:10 +02:00
if (Deg_EditingDeg->DegCod != Gbl.Hierarchy.Deg.DegCod)
2016-03-01 23:58:48 +01:00
{
2017-05-11 21:53:37 +02:00
/***** Alert with button to go to degree *****/
2018-10-17 10:32:18 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
2019-04-07 12:17:10 +02:00
Deg_EditingDeg->ShrtName);
2019-03-09 20:12:44 +01:00
Ale_ShowLastAlertAndButton (ActSeeCrs,NULL,NULL,Deg_PutParamGoToDeg,
Btn_CONFIRM_BUTTON,Gbl.Title);
2016-03-01 23:58:48 +01:00
}
2017-05-11 20:04:38 +02:00
else
2017-05-11 21:53:37 +02:00
/***** Alert *****/
2019-03-09 20:12:44 +01:00
Ale_ShowAlerts (NULL);
2017-05-11 20:04:38 +02:00
}
static void Deg_PutParamGoToDeg (void)
{
2019-04-07 12:17:10 +02:00
Deg_PutParamDegCod (Deg_EditingDeg->DegCod);
2016-03-01 13:36:48 +01:00
}
2015-01-17 19:31:21 +01:00
/*****************************************************************************/
/*********** Show a form for sending a logo of the current degree ************/
/*****************************************************************************/
void Deg_RequestLogo (void)
{
2019-04-03 20:57:04 +02:00
Log_RequestLogo (Hie_DEG);
2015-01-17 19:31:21 +01:00
}
/*****************************************************************************/
/***************** Receive the logo of the current degree ********************/
/*****************************************************************************/
void Deg_ReceiveLogo (void)
{
2019-04-03 20:57:04 +02:00
Log_ReceiveLogo (Hie_DEG);
2015-01-17 19:31:21 +01:00
}
2015-02-03 18:43:55 +01:00
/*****************************************************************************/
/****************** Remove the logo of the current degree ********************/
/*****************************************************************************/
void Deg_RemoveLogo (void)
{
2019-04-03 20:57:04 +02:00
Log_RemoveLogo (Hie_DEG);
2015-02-03 18:43:55 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********************** Get total number of degrees *************************/
/*****************************************************************************/
unsigned Deg_GetNumDegsTotal (void)
{
/***** Get total number of degrees from database *****/
2018-11-04 20:51:38 +01:00
return (unsigned) DB_GetNumRowsTable ("degrees");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Get number of degrees in a country ********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInCty (long InsCod)
{
/***** Get number of degrees in a country from database *****/
2018-11-03 13:13:11 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees in a country",
"SELECT COUNT(*) FROM institutions,centres,degrees"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****************** Get number of degrees in an institution ******************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInIns (long InsCod)
{
/***** Get number of degrees in an institution from database *****/
2018-11-03 13:13:11 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees"
" in an institution",
"SELECT COUNT(*) FROM centres,degrees"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Get number of degrees in a centre **********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInCtr (long CtrCod)
{
/***** Get number of degrees in a centre from database *****/
2018-11-03 13:13:11 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get the number of degrees in a centre",
"SELECT COUNT(*) FROM degrees"
" WHERE CtrCod=%ld",
CtrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Get number of centres with courses ********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsWithCrss (const char *SubQuery)
{
/***** Get number of degrees with courses from database *****/
2018-11-03 13:13:11 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get number of degrees with courses",
"SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod",
SubQuery);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Get number of degrees with users **********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
/***** Get number of degrees with users from database *****/
2018-11-03 13:13:11 +01:00
return
(unsigned) DB_QueryCOUNT ("can not get number of degrees with users",
"SELECT COUNT(DISTINCT degrees.DegCod)"
" FROM institutions,centres,degrees,courses,crs_usr"
" WHERE %sinstitutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u",
SubQuery,(unsigned) Role);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2015-11-23 00:44:39 +01:00
/***** Write institutions, centres and degrees administrated by an admin *****/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-14 16:47:46 +01:00
void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_all_degrees;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2015-11-23 00:44:39 +01:00
unsigned NumRow;
unsigned NumRows;
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2015-11-23 00:44:39 +01:00
struct Centre Ctr;
2015-11-19 20:04:41 +01:00
struct Degree Deg;
2014-12-01 23:55:08 +01:00
2015-11-23 00:44:39 +01:00
/***** Get institutions, centres, degrees admin by user from database *****/
2018-10-30 15:26:20 +01:00
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions,"
" centres, degrees"
" admin by a user",
"(SELECT %u AS S,-1 AS Cod,'' AS FullName"
" FROM admin"
" WHERE UsrCod=%ld"
" AND Scope='%s')"
" UNION "
"(SELECT %u AS S,admin.Cod,institutions.FullName"
" FROM admin,institutions"
" WHERE admin.UsrCod=%ld"
" AND admin.Scope='%s'"
" AND admin.Cod=institutions.InsCod)"
" UNION "
"(SELECT %u AS S,admin.Cod,centres.FullName"
" FROM admin,centres"
" WHERE admin.UsrCod=%ld"
" AND admin.Scope='%s'"
" AND admin.Cod=centres.CtrCod)"
" UNION "
"(SELECT %u AS S,admin.Cod,degrees.FullName"
" FROM admin,degrees"
" WHERE admin.UsrCod=%ld"
" AND admin.Scope='%s'"
" AND admin.Cod=degrees.DegCod)"
" ORDER BY S,FullName",
2019-04-03 20:57:04 +02:00
(unsigned) Hie_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_SYS),
(unsigned) Hie_INS,UsrCod,Sco_GetDBStrFromScope (Hie_INS),
(unsigned) Hie_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_CTR),
(unsigned) Hie_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_DEG));
2018-10-30 15:26:20 +01:00
if (NumRows)
2014-12-01 23:55:08 +01:00
/***** Get the list of degrees *****/
for (NumRow = 1;
NumRow <= NumRows;
NumRow++)
{
/***** Indent *****/
fprintf (Gbl.F.Out,"<tr>"
2015-09-03 00:59:03 +02:00
"<td class=\"RIGHT_TOP COLOR%u\">"
2015-07-21 20:07:46 +02:00
"<img src=\"%s/%s20x20.gif\""
" alt=\"\" title=\"\""
2016-11-14 10:05:41 +01:00
" class=\"ICO25x25\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2019-03-20 01:36:36 +01:00
Gbl.RowEvenOdd,Cfg_URL_ICON_PUBLIC,
2014-12-01 23:55:08 +01:00
NumRow == NumRows ? "subend" :
"submid");
2015-11-23 00:44:39 +01:00
/***** Write institution, centre, degree *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td colspan=\"%u\""
2015-09-03 00:59:03 +02:00
" class=\"DAT_SMALL_NOBR LEFT_TOP COLOR%u\">",
ColSpan - 1,Gbl.RowEvenOdd);
2014-12-01 23:55:08 +01:00
2015-11-23 00:44:39 +01:00
/* Get next institution, centre, degree */
2014-12-01 23:55:08 +01:00
row = mysql_fetch_row (mysql_res);
2015-11-23 00:44:39 +01:00
/* Get scope */
switch (Sco_GetScopeFromUnsignedStr (row[0]))
{
2019-04-03 20:57:04 +02:00
case Hie_SYS: // System
2019-01-11 02:55:01 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/swad64x64.png\""
2015-11-23 00:44:39 +01:00
" alt=\"%s\" title=\"%s\""
2019-01-11 02:55:01 +01:00
" class=\"ICO16x16\" />"
2015-11-23 00:44:39 +01:00
"&nbsp;%s",
2019-03-20 01:36:36 +01:00
Cfg_URL_ICON_PUBLIC,
2014-12-01 23:55:08 +01:00
Txt_all_degrees,
2015-07-21 20:07:46 +02:00
Txt_all_degrees,
2014-12-01 23:55:08 +01:00
Txt_all_degrees);
2015-11-23 00:44:39 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_INS: // Institution
2015-11-23 00:44:39 +01:00
Ins.InsCod = Str_ConvertStrCodToLongCod (row[1]);
if (Ins.InsCod > 0)
{
/* Get data of institution */
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2015-11-23 00:44:39 +01:00
/* Write institution logo and name */
Ins_DrawInstitutionLogoAndNameWithLink (&Ins,ActSeeInsInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
2019-04-03 20:57:04 +02:00
case Hie_CTR: // Centre
2015-11-23 00:44:39 +01:00
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[1]);
if (Ctr.CtrCod > 0)
{
/* Get data of centre */
Ctr_GetDataOfCentreByCod (&Ctr);
/* Write centre logo and name */
Ctr_DrawCentreLogoAndNameWithLink (&Ctr,ActSeeCtrInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
2019-04-03 20:57:04 +02:00
case Hie_DEG: // Degree
2015-11-23 00:44:39 +01:00
Deg.DegCod = Str_ConvertStrCodToLongCod (row[1]);
if (Deg.DegCod > 0)
{
/* Get data of degree */
Deg_GetDataOfDegreeByCod (&Deg);
/* Write degree logo and name */
Deg_DrawDegreeLogoAndNameWithLink (&Deg,ActSeeDegInf,
"DAT_SMALL_NOBR","LEFT_TOP");
}
break;
default: // There are no administrators in other scopes
2018-10-24 23:03:11 +02:00
Lay_WrongScopeExit ();
2015-11-23 00:44:39 +01:00
break;
}
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
2018-10-30 17:47:57 +01:00
/**************************** List degrees found *****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2018-10-30 17:47:57 +01:00
void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumDegs)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_degree;
extern const char *Txt_degrees;
MYSQL_ROW row;
unsigned NumDeg;
struct Degree Deg;
/***** Query database *****/
2018-10-30 17:47:57 +01:00
if (NumDegs)
2014-12-01 23:55:08 +01:00
{
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2014-12-01 23:55:08 +01:00
/* Number of degrees found */
2018-10-17 10:32:18 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
"%u %s",
NumDegs,(NumDegs == 1) ? Txt_degree :
Txt_degrees);
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Gbl.Title,NULL,
2017-06-12 15:03:29 +02:00
NULL,Box_NOT_CLOSABLE,2);
2017-06-12 14:16:33 +02:00
/***** Write heading *****/
2014-12-01 23:55:08 +01:00
Deg_PutHeadDegreesForSeeing ();
/***** List the degrees (one row per degree) *****/
for (NumDeg = 1;
NumDeg <= NumDegs;
NumDeg++)
{
/* Get next degree */
2018-10-30 17:47:57 +01:00
row = mysql_fetch_row (*mysql_res);
2014-12-01 23:55:08 +01:00
/* Get degree code (row[0]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get data of degree */
Deg_GetDataOfDegreeByCod (&Deg);
/* Write data of this degree */
Deg_ListOneDegreeForSeeing (&Deg,NumDeg);
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
2018-10-30 17:47:57 +01:00
DB_FreeMySQLResult (mysql_res);
2014-12-01 23:55:08 +01:00
}
2019-04-07 12:17:10 +02:00
/*****************************************************************************/
/************************ Degree constructor/destructor **********************/
/*****************************************************************************/
static void Deg_EditingDegreeConstructor (void)
{
/***** Pointer must be NULL *****/
if (Deg_EditingDeg != NULL)
Lay_ShowErrorAndExit ("Error initializing degree.");
/***** Allocate memory for degree *****/
if ((Deg_EditingDeg = (struct Degree *) malloc (sizeof (struct Degree))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for degree.");
/***** Reset degree *****/
Deg_EditingDeg->DegCod = -1L;
Deg_EditingDeg->DegTypCod = -1L;
Deg_EditingDeg->CtrCod = -1L;
Deg_EditingDeg->Status = 0;
Deg_EditingDeg->RequesterUsrCod = -1L;
Deg_EditingDeg->ShrtName[0] = '\0';
Deg_EditingDeg->FullName[0] = '\0';
Deg_EditingDeg->WWW[0] = '\0';
Deg_EditingDeg->Crss.Num = 0;
Deg_EditingDeg->Crss.Lst = NULL;
}
static void Deg_EditingDegreeDestructor (void)
{
2019-04-07 19:49:53 +02:00
/***** Free memory used for degree *****/
2019-04-07 12:17:10 +02:00
if (Deg_EditingDeg != NULL)
{
free ((void *) Deg_EditingDeg);
Deg_EditingDeg = NULL;
}
}