swad-core/swad_hierarchy.c

634 lines
21 KiB
C
Raw Normal View History

2016-12-10 22:21:04 +01:00
// swad_hierarchy.c: hierarchy (system, institution, centre, degree, course)
/*
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
2016-12-10 22:21:04 +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 <stdio.h> // For fprintf, etc.
#include <string.h> // For string functions
#include "swad_config.h"
#include "swad_degree.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2016-12-10 22:21:04 +01:00
#include "swad_global.h"
#include "swad_logo.h"
2017-06-11 20:09:59 +02:00
#include "swad_table.h"
2016-12-10 22:21:04 +01:00
#include "swad_theme.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/*************************** Public constants ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private types *********************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Private constants ******************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Private prototypes *****************************/
/*****************************************************************************/
2017-03-27 01:14:38 +02:00
/*****************************************************************************/
/********** List pending institutions, centres, degrees and courses **********/
/*****************************************************************************/
void Hie_SeePending (void)
{
/***** Put contextual links *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
/* Put link to remove old courses */
Crs_PutLinkToRemoveOldCrss ();
fprintf (Gbl.F.Out,"</div>");
/***** List countries with pending institutions *****/
Cty_SeeCtyWithPendingInss ();
/***** List institutions with pending centres *****/
Ins_SeeInsWithPendingCtrs ();
/***** List centres with pending degrees *****/
Ctr_SeeCtrWithPendingDegs ();
/***** List degrees with pending courses *****/
Deg_SeeDegWithPendingCrss ();
}
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
/*** Write menu to select country, institution, centre, degree and course ****/
/*****************************************************************************/
void Hie_WriteMenuHierarchy (void)
{
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2016-12-10 22:21:04 +01:00
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
extern const char *Txt_Course;
2017-06-12 14:16:33 +02:00
/***** Start table *****/
2017-06-11 20:09:59 +02:00
Tbl_StartTableCenter (2);
2016-12-10 22:21:04 +01:00
/***** Write a 1st selector
with all the countries *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 10:03:00 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"cty\" class=\"%s\">%s:</label>"
2016-12-10 22:21:04 +01:00
"</td>"
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Country);
2016-12-10 22:21:04 +01:00
Cty_WriteSelectorOfCountry ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 2nd selector
with the institutions of selected country *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 10:03:00 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"ins\" class=\"%s\">%s:</label>"
2016-12-10 22:21:04 +01:00
"</td>"
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Institution);
2016-12-10 22:21:04 +01:00
Ins_WriteSelectorOfInstitution ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 3rd selector
with all the centres of selected institution *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 10:03:00 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"ctr\" class=\"%s\">%s:</label>"
2016-12-10 22:21:04 +01:00
"</td>"
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Centre);
2016-12-10 22:21:04 +01:00
Ctr_WriteSelectorOfCentre ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 4th selector
with all the degrees of selected centre *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 10:03:00 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"deg\" class=\"%s\">%s:</label>"
2016-12-10 22:21:04 +01:00
"</td>"
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Degree);
2016-12-10 22:21:04 +01:00
Deg_WriteSelectorOfDegree ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0)
2016-12-10 22:21:04 +01:00
{
/***** Write a 5th selector
with all the courses of selected degree *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 10:03:00 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"crs\" class=\"%s\">%s:</label>"
2016-12-10 22:21:04 +01:00
"</td>"
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Course);
2016-12-10 22:21:04 +01:00
Crs_WriteSelectorOfCourse ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
}
}
}
2017-06-12 14:16:33 +02:00
/***** End table *****/
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2016-12-10 22:21:04 +01:00
}
/*****************************************************************************/
/************* Write hierarchy breadcrumb in the top of the page *************/
/*****************************************************************************/
2018-10-09 17:56:18 +02:00
void Hie_WriteHierarchyInBreadcrumb (void)
2016-12-10 22:21:04 +01:00
{
extern const char *The_ClassBreadcrumb[The_NUM_THEMES];
extern const char *Txt_System;
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
const char *ClassTxt = The_ClassBreadcrumb[Gbl.Prefs.Theme];
/***** Form to go to the system *****/
2018-10-09 17:56:18 +02:00
fprintf (Gbl.F.Out,"<div class=\"BC %s\">&nbsp;",ClassTxt);
2016-12-10 22:21:04 +01:00
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActMnu);
2016-12-10 22:21:04 +01:00
Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys);
2018-11-09 20:47:39 +01:00
Frm_LinkFormSubmit (Txt_System,ClassTxt,NULL);
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_System);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected...
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to see institutions of this country *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeIns);
2019-04-03 20:57:04 +02:00
Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod);
Frm_LinkFormSubmit (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language],ClassTxt,NULL);
fprintf (Gbl.F.Out,"%s</a>",Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
else
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_SEMIOFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to select countries *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeCty);
Frm_LinkFormSubmit (Txt_Country,ClassTxt,NULL);
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Country);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected...
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to see centres of this institution *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeCtr);
2019-04-03 20:57:04 +02:00
Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod);
Frm_LinkFormSubmit (Gbl.Hierarchy.Ins.FullName,ClassTxt,NULL);
fprintf (Gbl.F.Out,"%s</a>",Gbl.Hierarchy.Ins.ShrtName);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_SEMIOFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to select institutions *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeIns);
Frm_LinkFormSubmit (Txt_Institution,ClassTxt,NULL);
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Institution);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
else
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_OFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Hidden institution *****/
fprintf (Gbl.F.Out,"%s",Txt_Institution);
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected...
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to see degrees of this centre *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeDeg);
2019-04-03 20:57:04 +02:00
Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod);
Frm_LinkFormSubmit (Gbl.Hierarchy.Ctr.FullName,ClassTxt,NULL);
fprintf (Gbl.F.Out,"%s</a>",Gbl.Hierarchy.Ctr.ShrtName);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_SEMIOFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to select centres *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeCtr);
Frm_LinkFormSubmit (Txt_Centre,ClassTxt,NULL);
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Centre);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
else
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_OFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Hidden centre *****/
fprintf (Gbl.F.Out,"%s",Txt_Centre);
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected...
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to see courses of this degree *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeCrs);
2019-04-03 20:57:04 +02:00
Deg_PutParamDegCod (Gbl.Hierarchy.Deg.DegCod);
Frm_LinkFormSubmit (Gbl.Hierarchy.Deg.FullName,ClassTxt,NULL);
fprintf (Gbl.F.Out,"%s</a>",Gbl.Hierarchy.Deg.ShrtName);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_SEMIOFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Form to go to select degrees *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormGoTo (ActSeeDeg);
Frm_LinkFormSubmit (Txt_Degree,ClassTxt,NULL);
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Degree);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"</div>");
}
else
{
fprintf (Gbl.F.Out,"<div class=\"BC BC_OFF %s\">",ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
/***** Hidden degree *****/
fprintf (Gbl.F.Out,"%s",Txt_Degree);
fprintf (Gbl.F.Out,"</div>");
}
fprintf (Gbl.F.Out,"<div class=\"BC%s %s\">",
2019-04-03 20:57:04 +02:00
(Gbl.Hierarchy.Level == Hie_CRS) ? "" :
((Gbl.Hierarchy.Deg.DegCod > 0) ? " BC_SEMIOFF" :
" BC_OFF"),
2016-12-10 22:21:04 +01:00
ClassTxt);
/***** Separator *****/
fprintf (Gbl.F.Out,"&nbsp;&gt;&nbsp;");
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/*************** Write course full name in the top of the page ***************/
/*****************************************************************************/
void Hie_WriteBigNameCtyInsCtrDegCrs (void)
{
extern const char *The_ClassCourse[The_NUM_THEMES];
extern const char *Txt_TAGLINE;
fprintf (Gbl.F.Out,"<h1 id=\"main_title\" class=\"%s\">",
The_ClassCourse[Gbl.Prefs.Theme]);
/***** Logo *****/
2019-04-03 20:57:04 +02:00
switch (Gbl.Hierarchy.Level)
{
case Hie_SYS: // System
fprintf (Gbl.F.Out,"<img src=\"%s/swad64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICO40x40 TOP_LOGO\" />",
Cfg_URL_ICON_PUBLIC,
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_FULL_NAME);
break;
case Hie_CTY: // Country
Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TITLE");
break;
case Hie_INS: // Institution
Log_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.ShrtName,40,"TOP_LOGO",false);
break;
case Hie_CTR: // Centre
Log_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Ctr.ShrtName,40,"TOP_LOGO",false);
break;
case Hie_DEG: // Degree
case Hie_CRS: // Course
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,40,"TOP_LOGO",false);
break;
default:
break;
}
2016-12-10 22:21:04 +01:00
/***** Text *****/
fprintf (Gbl.F.Out,"<div id=\"big_name_container\">");
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
fprintf (Gbl.F.Out,"<div id=\"big_full_name\">"
"%s" // Full name
"</div>"
"<div class=\"NOT_SHOWN\">"
" / " // To separate
"</div>"
"<div id=\"big_short_name\">"
"%s" // Short name
"</div>",
2019-04-04 10:45:15 +02:00
(Gbl.Hierarchy.Level == Hie_CRS) ? Gbl.Hierarchy.Crs.FullName :
2019-04-03 20:57:04 +02:00
((Gbl.Hierarchy.Level == Hie_DEG) ? Gbl.Hierarchy.Deg.FullName :
((Gbl.Hierarchy.Level == Hie_CTR) ? Gbl.Hierarchy.Ctr.FullName :
((Gbl.Hierarchy.Level == Hie_INS) ? Gbl.Hierarchy.Ins.FullName :
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]))),
2019-04-04 10:45:15 +02:00
(Gbl.Hierarchy.Level == Hie_CRS) ? Gbl.Hierarchy.Crs.ShrtName :
2019-04-03 20:57:04 +02:00
((Gbl.Hierarchy.Level == Hie_DEG) ? Gbl.Hierarchy.Deg.ShrtName :
((Gbl.Hierarchy.Level == Hie_CTR) ? Gbl.Hierarchy.Ctr.ShrtName :
((Gbl.Hierarchy.Level == Hie_INS) ? Gbl.Hierarchy.Ins.ShrtName :
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]))));
2016-12-10 22:21:04 +01:00
else // No country specified ==> home page
fprintf (Gbl.F.Out,"<div id=\"big_full_name\">"
"%s: %s" // Full name
"</div>"
"<div class=\"NOT_SHOWN\">"
" / " // To separate
"</div>"
"<div id=\"big_short_name\">"
"%s" // Short name
"</div>",
Cfg_PLATFORM_SHORT_NAME,Txt_TAGLINE,
Cfg_PLATFORM_SHORT_NAME);
fprintf (Gbl.F.Out,"</div>"
"</h1>");
}
2019-04-01 23:15:17 +02:00
/*****************************************************************************/
/**************** Copy last hierarchy to current hierarchy *******************/
/*****************************************************************************/
void Hie_SetHierarchyFromUsrLastHierarchy (void)
{
/***** Initialize all codes to -1 *****/
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2019-04-01 23:15:17 +02:00
/***** Copy last hierarchy scope and code to current hierarchy *****/
switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope)
{
2019-04-03 20:57:04 +02:00
case Hie_CTY: // Country
Gbl.Hierarchy.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2019-04-03 20:57:04 +02:00
case Hie_INS: // Institution
Gbl.Hierarchy.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CTR: // Centre
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2019-04-03 20:57:04 +02:00
case Hie_DEG: // Degree
Gbl.Hierarchy.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CRS: // Course
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
2019-04-01 23:15:17 +02:00
break;
default:
break;
}
/****** Initialize again current course, degree, centre... ******/
Hie_InitHierarchy ();
}
2016-12-10 22:21:04 +01:00
/*****************************************************************************/
/**** Initialize current country, institution, centre, degree and course *****/
/*****************************************************************************/
void Hie_InitHierarchy (void)
{
/***** If course code is available, get course data *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Crs.CrsCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-04-04 10:45:15 +02:00
if (Crs_GetDataOfCourseByCod (&Gbl.Hierarchy.Crs)) // Course found
Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.DegCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If degree code is available, get degree data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-04-03 20:57:04 +02:00
if (Deg_GetDataOfDegreeByCod (&Gbl.Hierarchy.Deg)) // Degree found
2016-12-10 22:21:04 +01:00
{
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.CtrCod;
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Gbl.Hierarchy.Deg.DegCod);
2016-12-10 22:21:04 +01:00
}
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If centre code is available, get centre data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-04-03 20:57:04 +02:00
if (Ctr_GetDataOfCentreByCod (&Gbl.Hierarchy.Ctr)) // Centre found
Gbl.Hierarchy.Ins.InsCod = Gbl.Hierarchy.Ctr.InsCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If institution code is available, get institution data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Ins.InsCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-04-03 20:57:04 +02:00
if (Ins_GetDataOfInstitutionByCod (&Gbl.Hierarchy.Ins,Ins_GET_BASIC_DATA)) // Institution found
Gbl.Hierarchy.Cty.CtyCod = Gbl.Hierarchy.Ins.CtyCod;
2016-12-10 22:21:04 +01:00
else
2019-04-03 20:57:04 +02:00
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
/***** If country code is available, get country data *****/
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Cty.CtyCod > 0)
2016-12-10 22:21:04 +01:00
{
2019-04-03 20:57:04 +02:00
if (!Cty_GetDataOfCountryByCod (&Gbl.Hierarchy.Cty,Cty_GET_BASIC_DATA)) // Country not found
Hie_ResetHierarchy ();
2016-12-10 22:21:04 +01:00
}
2019-04-03 20:57:04 +02:00
/***** Set current hierarchy level and code
depending on course code, degree code, etc. *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Crs.CrsCod > 0) // Course selected
2019-04-03 20:57:04 +02:00
{
Gbl.Hierarchy.Level = Hie_CRS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Crs.CrsCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected
{
Gbl.Hierarchy.Level = Hie_DEG;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Deg.DegCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected
{
Gbl.Hierarchy.Level = Hie_CTR;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ctr.CtrCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
{
Gbl.Hierarchy.Level = Hie_INS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Ins.InsCod;
2019-04-03 20:57:04 +02:00
}
else if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
{
Gbl.Hierarchy.Level = Hie_CTY;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = Gbl.Hierarchy.Cty.CtyCod;
2019-04-03 20:57:04 +02:00
}
else
{
Gbl.Hierarchy.Level = Hie_SYS;
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Cod = -1L;
2019-04-03 20:57:04 +02:00
}
2019-04-01 23:15:17 +02:00
2016-12-10 22:21:04 +01:00
/***** Initialize paths *****/
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
2016-12-10 22:21:04 +01:00
{
/***** Paths of course directories *****/
2019-04-04 10:45:15 +02:00
snprintf (Gbl.Crs.PathPriv,sizeof (Gbl.Crs.PathPriv),
2019-03-20 01:36:36 +01:00
"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathRelPubl,sizeof (Gbl.Crs.PathRelPubl),
2019-03-20 01:36:36 +01:00
"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_PATH_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
snprintf (Gbl.Crs.PathURLPubl,sizeof (Gbl.Crs.PathURLPubl),
2019-03-20 01:36:36 +01:00
"%s/%ld",
2019-04-04 10:45:15 +02:00
Cfg_URL_CRS_PUBLIC,Gbl.Hierarchy.Crs.CrsCod);
2016-12-10 22:21:04 +01:00
/***** If any of the course directories does not exist, create it *****/
2019-04-04 10:45:15 +02:00
if (!Fil_CheckIfPathExists (Gbl.Crs.PathPriv))
Fil_CreateDirIfNotExists (Gbl.Crs.PathPriv);
if (!Fil_CheckIfPathExists (Gbl.Crs.PathRelPubl))
Fil_CreateDirIfNotExists (Gbl.Crs.PathRelPubl);
2016-12-10 22:21:04 +01:00
/***** Count number of groups in current course
(used in some actions) *****/
2019-04-04 10:45:15 +02:00
Gbl.Crs.Grps.NumGrps = Grp_CountNumGrpsInCurrentCrs ();
2016-12-10 22:21:04 +01:00
}
}
2019-04-03 20:57:04 +02:00
/*****************************************************************************/
/******* Reset current country, institution, centre, degree and course *******/
/*****************************************************************************/
void Hie_ResetHierarchy (void)
{
/***** Country *****/
Gbl.Hierarchy.Cty.CtyCod = -1L;
/***** Institution *****/
Gbl.Hierarchy.Ins.InsCod = -1L;
/***** Centre *****/
Gbl.Hierarchy.Ctr.CtrCod = -1L;
Gbl.Hierarchy.Ctr.InsCod = -1L;
Gbl.Hierarchy.Ctr.PlcCod = -1L;
/***** Degree *****/
Gbl.Hierarchy.Deg.DegCod = -1L;
/***** Course *****/
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod = -1L;
2019-04-03 20:57:04 +02:00
/***** Hierarchy level and code *****/
Gbl.Hierarchy.Level = Hie_UNK;
Gbl.Hierarchy.Cod = -1L;
}