swad-core/swad_degree.c

3134 lines
109 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.
2016-01-01 20:19:43 +01:00
Copyright (C) 1999-2016 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
2014-12-01 23:55:08 +01:00
#include <stdio.h> // For fprintf, etc.
#include <stdlib.h> // For exit, system, calloc, free, etc.
#include <string.h> // For string functions
#include <mysql/mysql.h> // To access MySQL databases
#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"
#include "swad_global.h"
2015-10-06 20:34:49 +02:00
#include "swad_help.h"
2014-12-01 23:55:08 +01:00
#include "swad_indicator.h"
#include "swad_info.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"
2014-12-01 23:55:08 +01:00
#include "swad_text.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;
/*****************************************************************************/
/**************************** Private constants ******************************/
/*****************************************************************************/
#define Deg_MAX_LENGTH_SHORT_NAME_DEGREE_ON_PAGE_HEAD 20 // Adjust depending on the size of the style used for the degree on the page head
#define Deg_MAX_LENGTH_SHORT_NAME_COURSE_ON_PAGE_HEAD 20 // Adjust depending on the size of the style used for the degree on the page head
/*****************************************************************************/
/**************************** Private prototypes *****************************/
/*****************************************************************************/
static void Deg_Configuration (bool PrintView);
2016-05-05 20:16:28 +02:00
static void Deg_PutIconsToPrintAndUpload (void);
2014-12-01 23:55:08 +01:00
2015-07-25 20:20:07 +02:00
static void Deg_WriteSelectorOfDegree (void);
2016-03-20 13:18:56 +01:00
2014-12-01 23:55:08 +01:00
static void Deg_ListDegreesForEdition (void);
static bool Deg_CheckIfICanEdit (struct Degree *Deg);
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);
static void Deg_CreateDegree (struct Degree *Deg,unsigned Status);
2016-03-20 13:18:56 +01:00
2014-12-01 23:55:08 +01:00
static void Deg_ListDegrees (void);
2016-03-20 13:18:56 +01:00
static void Deg_PutIconToEditDegrees (void);
static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg);
2014-12-01 23:55:08 +01:00
static void Deg_GetListDegsOfCurrentCtr (void);
static void Deg_FreeListDegsOfCurrentCtr (void);
static void Deg_RecFormRequestOrCreateDeg (unsigned Status);
static void Deg_PutParamOtherDegCod (long DegCod);
static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row);
2016-03-01 13:36:48 +01:00
static bool Deg_RenameDegree (struct Degree *Deg,Cns_ShortOrFullName_t ShortOrFullName);
2015-11-04 22:51:41 +01:00
static bool Deg_CheckIfDegreeNameExists (long CtrCod,const char *FieldName,const char *Name,long DegCod);
2014-12-01 23:55:08 +01:00
2016-10-19 23:17:36 +02:00
static void Deg_UpdateDegCentreDB (long DegCod,long CtrCod);
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********** List pending institutions, centres, degrees and courses **********/
/*****************************************************************************/
void Deg_SeePending (void)
{
/***** 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 ();
}
/*****************************************************************************/
/******************* List degrees with pending courses ***********************/
/*****************************************************************************/
void Deg_SeeDegWithPendingCrss (void)
{
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;
char Query[1024];
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 *****/
switch (Gbl.Usrs.Me.LoggedRole)
{
2015-04-07 21:44:24 +02:00
case Rol_DEG_ADM:
2014-12-01 23:55:08 +01:00
sprintf (Query,"SELECT courses.DegCod,COUNT(*)"
2015-01-29 01:03:31 +01:00
" FROM admin,courses,degrees"
" WHERE admin.UsrCod='%ld' AND admin.Scope='Deg'"
" AND admin.Cod=courses.DegCod"
" AND (courses.Status & %u)<>0"
2014-12-01 23:55:08 +01:00
" AND courses.DegCod=degrees.DegCod"
" GROUP BY courses.DegCod ORDER BY degrees.ShortName",
2015-01-29 01:03:31 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod,(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:
2014-12-01 23:55:08 +01:00
sprintf (Query,"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);
break;
default: // Forbidden for other users
return;
}
/***** Get degrees *****/
if ((NumDegs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees with pending courses")))
{
/***** Write heading *****/
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Txt_Degrees_with_pending_courses);
2014-12-01 23:55:08 +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]);
2015-09-04 19:26:08 +02:00
BgColor = (Deg.DegCod == Gbl.CurrentDeg.Deg.DegCod) ? "LIGHT_BLUE" :
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;
}
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
else
Lay_ShowAlert (Lay_INFO,Txt_There_are_no_degrees_with_requests_for_courses_to_be_confirmed);
/***** 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 *****/
Act_FormGoToStart (Action);
Deg_PutParamDegCod (Deg->DegCod);
/***** Link to action *****/
sprintf (Gbl.Title,Txt_Go_to_X,Deg->FullName);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.Title,ClassLink,NULL);
2015-11-19 20:04:41 +01:00
/***** Draw degree logo *****/
2015-12-13 13:53:00 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,Deg->DegCod,Deg->ShortName,20,ClassLogo,true);
2015-11-19 20:04:41 +01:00
/***** End link *****/
fprintf (Gbl.F.Out,"&nbsp;%s</a>",Deg->FullName);
/***** End form *****/
Act_FormEnd ();
}
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
/***** Show help to enroll 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)
{
2015-07-27 21:25:45 +02:00
extern const char *The_ClassForm[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;
2015-12-07 23:13:08 +01:00
extern const char *Txt_STR_LANG_ID[1+Txt_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;
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
2016-10-19 20:43:26 +02:00
unsigned NumCtr;
2014-12-01 23:55:08 +01:00
bool PutLink = !PrintView && Gbl.CurrentDeg.Deg.WWW[0];
if (Gbl.CurrentDeg.Deg.DegCod > 0)
{
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2016-03-18 20:48:24 +01:00
Lay_StartRoundFrame (NULL,NULL,PrintView ? NULL :
2016-05-05 20:16:28 +02:00
Deg_PutIconsToPrintAndUpload);
2014-12-08 17:35:48 +01:00
2014-12-01 23:55:08 +01:00
/***** Title *****/
2016-03-18 20:48:24 +01:00
fprintf (Gbl.F.Out,"<div class=\"TITLE_LOCATION\">");
2014-12-01 23:55:08 +01:00
if (PutLink)
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"TITLE_LOCATION\" title=\"%s\">",
Gbl.CurrentDeg.Deg.WWW,
Gbl.CurrentDeg.Deg.FullName);
2015-02-01 20:17:24 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,Gbl.CurrentDeg.Deg.DegCod,
2015-01-18 11:46:39 +01:00
Gbl.CurrentDeg.Deg.ShortName,64,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<br />%s",
Gbl.CurrentDeg.Deg.FullName);
if (PutLink)
fprintf (Gbl.F.Out,"</a>");
2016-03-18 20:48:24 +01:00
fprintf (Gbl.F.Out,"</div>");
/***** Start table *****/
fprintf (Gbl.F.Out,"<table class=\"FRAME_TABLE CELLS_PAD_2\">");
2014-12-01 23:55:08 +01:00
2016-10-19 20:43:26 +02:00
/***** Centre *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">",
The_ClassForm[Gbl.Prefs.Theme],
Txt_Centre);
if (!PrintView &&
Gbl.Usrs.Me.LoggedRole >= 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.CurrentIns.Ins.InsCod);
/* Put form to select centre */
Act_FormStart (ActChgDegCtrCfg);
fprintf (Gbl.F.Out,"<select name=\"OthCtrCod\""
" class=\"INPUT_CENTRE\""
" onchange=\"document.getElementById('%s').submit();\">",
Gbl.Form.Id);
for (NumCtr = 0;
NumCtr < Gbl.Ctrs.Num;
NumCtr++)
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
Gbl.Ctrs.Lst[NumCtr].CtrCod,
Gbl.Ctrs.Lst[NumCtr].CtrCod == Gbl.CurrentCtr.Ctr.CtrCod ? " selected=\"selected\"" :
"",
Gbl.Ctrs.Lst[NumCtr].ShortName);
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
/* Free list of centres */
Ctr_FreeListCentres ();
}
else // I can not edit centre
fprintf (Gbl.F.Out,"%s",Gbl.CurrentCtr.Ctr.FullName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Degree full name *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT_N LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2014-12-01 23:55:08 +01:00
Txt_Degree);
if (PutLink)
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT_N\" title=\"%s\">",
Gbl.CurrentDeg.Deg.WWW,
Gbl.CurrentDeg.Deg.FullName);
fprintf (Gbl.F.Out,"%s",
Gbl.CurrentDeg.Deg.FullName);
if (PutLink)
fprintf (Gbl.F.Out,"</a>");
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Degree short name *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2015-02-04 20:03:23 +01:00
Txt_Short_name,
2014-12-01 23:55:08 +01:00
Gbl.CurrentDeg.Deg.ShortName);
2015-02-04 20:05:54 +01:00
/***** Degree WWW *****/
if (Gbl.CurrentDeg.Deg.WWW[0])
{
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2015-02-04 20:05:54 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">"
2015-02-04 20:05:54 +01:00
"<a href=\"%s\" target=\"_blank\" class=\"DAT\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2015-02-04 20:05:54 +01:00
Txt_Web,
Gbl.CurrentDeg.Deg.WWW);
Str_LimitLengthHTMLStr (Gbl.CurrentDeg.Deg.WWW,20);
fprintf (Gbl.F.Out,"%s"
"</a>"
"</td>"
"</tr>",
Gbl.CurrentDeg.Deg.WWW);
}
/***** Shortcut to the degree *****/
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\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">"
2015-03-07 21:08:44 +01:00
"<a href=\"%s/%s?deg=%ld\" class=\"DAT\" target=\"_blank\">"
"%s/%s?deg=%ld"
2014-12-22 19:59:27 +01:00
"</a>"
2014-12-01 23:55:08 +01:00
"</td>"
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2015-03-07 18:09:42 +01:00
Txt_Shortcut,
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_CGI,
2015-12-07 23:13:08 +01:00
Txt_STR_LANG_ID[Gbl.Prefs.Language],
2015-11-21 20:23:28 +01:00
Gbl.CurrentDeg.Deg.DegCod,
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_CGI,
2015-12-07 23:13:08 +01:00
Txt_STR_LANG_ID[Gbl.Prefs.Language],
2015-11-21 20:23:28 +01:00
Gbl.CurrentDeg.Deg.DegCod);
2014-12-01 23:55:08 +01:00
if (PrintView)
{
/***** QR code with link to the degree *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2014-12-01 23:55:08 +01:00
Txt_QR_code);
2015-09-28 18:28:29 +02:00
QR_LinkTo (250,"deg",Gbl.CurrentDeg.Deg.DegCod);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else
{
/***** Number of courses *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2016-05-30 19:36:49 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2016-05-30 19:36:49 +02:00
Txt_Courses);
/* Form to go to see courses of this degree */
Act_FormGoToStart (ActSeeCrs);
Deg_PutParamDegCod (Gbl.CurrentDeg.Deg.DegCod);
2016-05-30 19:52:46 +02:00
sprintf (Gbl.Title,Txt_Courses_of_DEGREE_X,
Gbl.CurrentDeg.Deg.ShortName);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.Title,"DAT",NULL);
2016-05-30 19:36:49 +02:00
fprintf (Gbl.F.Out,"%u</a>",
2016-05-30 19:16:43 +02:00
Crs_GetNumCrssInDeg (Gbl.CurrentDeg.Deg.DegCod));
2016-05-30 19:36:49 +02:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Number of teachers *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%u"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2015-04-07 21:44:24 +02:00
Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN],
Usr_GetNumUsrsInCrssOfDeg (Rol_TEACHER,Gbl.CurrentDeg.Deg.DegCod));
2014-12-01 23:55:08 +01:00
/***** Number of students *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"DAT LEFT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%u"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],
2015-04-07 21:44:24 +02:00
Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
Usr_GetNumUsrsInCrssOfDeg (Rol_STUDENT,Gbl.CurrentDeg.Deg.DegCod));
2014-12-01 23:55:08 +01:00
}
2014-12-08 17:35:48 +01:00
2016-03-18 20:48:24 +01:00
/***** End table *****/
fprintf (Gbl.F.Out,"</table>");
2014-12-08 17:35:48 +01:00
/***** End frame *****/
2016-03-18 20:48:24 +01:00
Lay_EndRoundFrame ();
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
{
extern const char *Txt_Print;
2016-05-05 20:16:28 +02:00
/***** Link to print info about degree *****/
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActPrnDegInf,NULL,
"print64x64.png",
Txt_Print,NULL,
NULL);
2016-05-05 20:16:28 +02:00
if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM)
/***** Link to upload logo of degree *****/
Log_PutIconToChangeLogo (Sco_SCOPE_DEG);
2016-03-18 20:48:24 +01:00
}
/*****************************************************************************/
2014-12-01 23:55:08 +01:00
/*** Write menu to select country, institution, centre, degree and course ****/
/*****************************************************************************/
2015-07-25 20:07:38 +02:00
void Deg_WriteMenuAllCourses (void)
2014-12-01 23:55:08 +01:00
{
2015-07-27 21:25:45 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
2015-07-25 20:20:07 +02:00
extern const char *Txt_Course;
2014-12-01 23:55:08 +01:00
/***** Start of table *****/
2014-12-27 19:43:01 +01:00
fprintf (Gbl.F.Out,"<table class=\"CELLS_PAD_2\""
2015-09-28 18:28:29 +02:00
" style=\"margin:0 auto 12px auto;\">");
2014-12-01 23:55:08 +01:00
/***** Write a 1st selector
with all the countries *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_Country);
2015-07-25 20:20:07 +02:00
Cty_WriteSelectorOfCountry ();
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-07-25 20:07:38 +02:00
if (Gbl.CurrentCty.Cty.CtyCod > 0)
2014-12-01 23:55:08 +01:00
{
/***** Write a 2nd selector
with the institutions of selected country *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_Institution);
2015-07-25 20:20:07 +02:00
Ins_WriteSelectorOfInstitution ();
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-07-25 20:07:38 +02:00
if (Gbl.CurrentIns.Ins.InsCod > 0)
2014-12-01 23:55:08 +01:00
{
/***** Write a 3rd selector
with all the centres of selected institution *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_Centre);
2015-07-25 20:20:07 +02:00
Ctr_WriteSelectorOfCentre ();
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-07-25 20:07:38 +02:00
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
2014-12-01 23:55:08 +01:00
{
/***** Write a 4th selector
with all the degrees of selected centre *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2014-12-22 19:59:27 +01:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_Degree);
2015-07-25 20:20:07 +02:00
Deg_WriteSelectorOfDegree ();
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2015-07-25 20:20:07 +02:00
if (Gbl.CurrentDeg.Deg.DegCod > 0)
{
/***** Write a 5th selector
with all the courses of selected degree *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_MIDDLE\">"
2015-07-25 20:20:07 +02:00
"%s:"
"</td>"
2015-07-31 19:49:21 +02:00
"<td class=\"LEFT_MIDDLE\">",
2015-07-27 21:25:45 +02:00
The_ClassForm[Gbl.Prefs.Theme],Txt_Course);
2015-07-25 20:20:07 +02:00
Crs_WriteSelectorOfCourse ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2014-12-01 23:55:08 +01:00
}
}
}
/***** End of table *****/
2014-12-27 19:43:01 +01:00
fprintf (Gbl.F.Out,"</table>");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************************** Write selector of degree ************************/
/*****************************************************************************/
2015-07-25 20:20:07 +02:00
static void Deg_WriteSelectorOfDegree (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Degree;
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDegs;
unsigned NumDeg;
long DegCod;
/***** Start form *****/
2015-07-25 20:20:07 +02:00
Act_FormGoToStart (ActSeeCrs);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"deg\" style=\"width:175px;\"");
2014-12-01 23:55:08 +01:00
if (Gbl.CurrentCtr.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\"");
fprintf (Gbl.F.Out,"><option value=\"\"");
if (Gbl.CurrentDeg.Deg.DegCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\">[%s]</option>",
Txt_Degree);
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
{
/***** Get degrees belonging to the current centre from database *****/
sprintf (Query,"SELECT DegCod,ShortName FROM degrees"
" WHERE CtrCod='%ld'"
" ORDER BY ShortName",
Gbl.CurrentCtr.Ctr.CtrCod);
NumDegs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees of a centre");
/***** 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);
if (Gbl.CurrentDeg.Deg.DegCod > 0 &&
(DegCod == Gbl.CurrentDeg.Deg.DegCod))
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>");
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-03-20 13:18:56 +01:00
/************* Write hierarchy breadcrumb in the top of the page *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-03-20 13:18:56 +01:00
void Deg_WriteHierarchyBreadcrumb (void)
2014-12-01 23:55:08 +01:00
{
2015-11-30 12:58:19 +01:00
extern const char *The_ClassBreadcrumb[The_NUM_THEMES];
2015-02-05 00:55:47 +01:00
extern const char *Txt_System;
2015-12-26 12:40:21 +01:00
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
2014-12-01 23:55:08 +01:00
char DegreeShortName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree
2015-12-26 13:11:55 +01:00
char ClassOn[64];
2015-12-26 14:17:48 +01:00
char ClassSemiOff[64];
2015-12-26 13:11:55 +01:00
char ClassOff[64];
/***** CSS classes *****/
strcpy (ClassOn,The_ClassBreadcrumb[Gbl.Prefs.Theme]);
2015-12-26 14:17:48 +01:00
sprintf (ClassSemiOff,"BC_SEMIOFF %s",The_ClassBreadcrumb[Gbl.Prefs.Theme]);
2015-12-26 13:11:55 +01:00
sprintf (ClassOff,"BC_OFF %s",The_ClassBreadcrumb[Gbl.Prefs.Theme]);
2014-12-01 23:55:08 +01:00
2014-12-29 00:54:56 +01:00
/***** Form to go to the system *****/
2014-12-01 23:55:08 +01:00
Act_FormGoToStart (ActMnu);
Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_System,ClassOn,NULL);
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_System);
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
2015-12-26 13:11:55 +01:00
if (Gbl.CurrentCty.Cty.CtyCod > 0) // Country selected...
2014-12-01 23:55:08 +01:00
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassOn);
2014-12-01 23:55:08 +01:00
2016-03-20 13:18:56 +01:00
/***** Form to go to see institutions of this country *****/
Act_FormGoToStart (ActSeeIns);
2014-12-01 23:55:08 +01:00
Cty_PutParamCtyCod (Gbl.CurrentCty.Cty.CtyCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language],ClassOn,NULL);
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"%s</a>",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-12-26 12:40:21 +01:00
}
else
2015-12-26 13:11:55 +01:00
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassSemiOff);
2014-12-01 23:55:08 +01:00
2015-12-26 13:11:55 +01:00
/***** Form to go to select countries *****/
Act_FormGoToStart (ActSeeCty);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_Country,ClassSemiOff,NULL);
2015-12-26 13:11:55 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Country);
Act_FormEnd ();
}
if (Gbl.CurrentIns.Ins.InsCod > 0) // Institution selected...
2015-12-26 12:40:21 +01:00
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassOn);
2015-12-26 12:40:21 +01:00
2016-03-20 13:18:56 +01:00
/***** Form to see centres of this institution *****/
Act_FormGoToStart (ActSeeCtr);
2015-12-26 12:40:21 +01:00
Ins_PutParamInsCod (Gbl.CurrentIns.Ins.InsCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.CurrentIns.Ins.FullName,ClassOn,NULL);
2015-12-26 12:40:21 +01:00
fprintf (Gbl.F.Out,"%s</a>",
Gbl.CurrentIns.Ins.ShortName);
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
2015-12-26 13:11:55 +01:00
else if (Gbl.CurrentCty.Cty.CtyCod > 0)
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassSemiOff);
2015-12-26 13:11:55 +01:00
/***** Form to go to select institutions *****/
Act_FormGoToStart (ActSeeIns);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_Institution,ClassSemiOff,NULL);
2015-12-26 13:11:55 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Institution);
Act_FormEnd ();
}
2015-12-26 12:40:21 +01:00
else
/***** Separator and hidden institution *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; %s</span>",
2015-12-26 13:11:55 +01:00
ClassOff,Txt_Institution);
2015-12-26 12:40:21 +01:00
2015-12-26 13:11:55 +01:00
if (Gbl.CurrentCtr.Ctr.CtrCod > 0) // Centre selected...
2015-12-26 12:40:21 +01:00
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassOn);
2014-12-01 23:55:08 +01:00
2016-03-20 13:18:56 +01:00
/***** Form to see degrees of this centre *****/
Act_FormGoToStart (ActSeeDeg);
2015-12-26 12:40:21 +01:00
Ctr_PutParamCtrCod (Gbl.CurrentCtr.Ctr.CtrCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.CurrentCtr.Ctr.FullName,ClassOn,NULL);
2015-12-26 12:40:21 +01:00
fprintf (Gbl.F.Out,"%s</a>",
Gbl.CurrentCtr.Ctr.ShortName);
Act_FormEnd ();
}
2015-12-26 13:11:55 +01:00
else if (Gbl.CurrentIns.Ins.InsCod > 0)
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassSemiOff);
2015-12-26 13:11:55 +01:00
/***** Form to go to select centres *****/
Act_FormGoToStart (ActSeeCtr);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_Centre,ClassSemiOff,NULL);
2015-12-26 13:11:55 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Centre);
Act_FormEnd ();
}
2015-12-26 12:40:21 +01:00
else
/***** Separator and hidden centre *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; %s</span>",
2015-12-26 13:11:55 +01:00
ClassOff,Txt_Centre);
2015-12-26 12:40:21 +01:00
2015-12-26 13:11:55 +01:00
if (Gbl.CurrentDeg.Deg.DegCod > 0) // Degree selected...
2015-12-26 12:40:21 +01:00
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassOn);
2015-12-26 12:40:21 +01:00
2016-05-30 19:36:49 +02:00
/***** Form to go to see courses of this degree *****/
2016-03-20 13:18:56 +01:00
Act_FormGoToStart (ActSeeCrs);
2015-12-26 12:40:21 +01:00
Deg_PutParamDegCod (Gbl.CurrentDeg.Deg.DegCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Gbl.CurrentDeg.Deg.FullName,ClassOn,NULL);
2015-12-26 12:40:21 +01:00
strcpy (DegreeShortName,Gbl.CurrentDeg.Deg.ShortName);
Str_LimitLengthHTMLStr (DegreeShortName,
Deg_MAX_LENGTH_SHORT_NAME_DEGREE_ON_PAGE_HEAD);
fprintf (Gbl.F.Out,"%s</a>",
DegreeShortName);
Act_FormEnd ();
}
2015-12-26 13:11:55 +01:00
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
{
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",ClassSemiOff);
2015-12-26 13:11:55 +01:00
/***** Form to go to select degrees *****/
Act_FormGoToStart (ActSeeDeg);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_Degree,ClassSemiOff,NULL);
2015-12-26 13:11:55 +01:00
fprintf (Gbl.F.Out,"%s</a>",Txt_Degree);
Act_FormEnd ();
}
2015-12-26 12:40:21 +01:00
else
/***** Separator and hidden degree *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; %s</span>",
2015-12-26 13:11:55 +01:00
ClassOff,Txt_Degree);
2015-12-26 12:40:21 +01:00
2015-12-26 13:11:55 +01:00
/***** Separator *****/
2016-03-19 02:21:09 +01:00
fprintf (Gbl.F.Out,"<span class=\"%s\"> &gt; </span>",
2015-12-26 14:17:48 +01:00
(Gbl.CurrentCrs.Crs.CrsCod > 0) ? ClassOn :
((Gbl.CurrentDeg.Deg.DegCod > 0) ? ClassSemiOff :
ClassOff));
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-02-04 01:41:59 +01:00
/*************** Write course full name in the top of the page ***************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Deg_WriteBigNameCtyInsCtrDegCrs (void)
{
extern const char *The_ClassCourse[The_NUM_THEMES];
2016-03-20 22:31:57 +01:00
extern const char *Txt_TAGLINE;
2014-12-01 23:55:08 +01:00
2016-02-04 12:37:02 +01:00
fprintf (Gbl.F.Out,"<h1 id=\"main_title\" class=\"%s\">",
2015-12-01 22:31:01 +01:00
The_ClassCourse[Gbl.Prefs.Theme]);
2016-03-19 02:21:09 +01:00
/***** Logo *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0 ||
Gbl.CurrentDeg.Deg.DegCod > 0)
Log_DrawLogo (Sco_SCOPE_DEG,Gbl.CurrentDeg.Deg.DegCod,
Gbl.CurrentDeg.Deg.ShortName,40,"TOP_LOGO",false);
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
Log_DrawLogo (Sco_SCOPE_CTR,Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentCtr.Ctr.ShortName,40,"TOP_LOGO",false);
else if (Gbl.CurrentIns.Ins.InsCod > 0)
Log_DrawLogo (Sco_SCOPE_INS,Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentIns.Ins.ShortName,40,"TOP_LOGO",false);
else if (Gbl.CurrentCty.Cty.CtyCod > 0)
Cty_DrawCountryMap (&Gbl.CurrentCty.Cty,"COUNTRY_MAP_TITLE");
else
fprintf (Gbl.F.Out,"<img src=\"%s/%s\""
" alt=\"%s\" title=\"%s\""
" class=\"TOP_LOGO\" />",
Gbl.Prefs.IconsURL,Cfg_PLATFORM_LOGO_SMALL_FILENAME,
Cfg_PLATFORM_SHORT_NAME,Cfg_PLATFORM_FULL_NAME);
/***** Text *****/
2016-03-20 22:31:57 +01:00
fprintf (Gbl.F.Out,"<div id=\"big_name_container\">");
if (Gbl.CurrentCty.Cty.CtyCod > 0)
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>",
(Gbl.CurrentCrs.Crs.CrsCod > 0) ? Gbl.CurrentCrs.Crs.FullName :
((Gbl.CurrentDeg.Deg.DegCod > 0) ? Gbl.CurrentDeg.Deg.FullName :
((Gbl.CurrentCtr.Ctr.CtrCod > 0) ? Gbl.CurrentCtr.Ctr.FullName :
((Gbl.CurrentIns.Ins.InsCod > 0) ? Gbl.CurrentIns.Ins.FullName :
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]))),
(Gbl.CurrentCrs.Crs.CrsCod > 0) ? Gbl.CurrentCrs.Crs.ShortName :
((Gbl.CurrentDeg.Deg.DegCod > 0) ? Gbl.CurrentDeg.Deg.ShortName :
((Gbl.CurrentCtr.Ctr.CtrCod > 0) ? Gbl.CurrentCtr.Ctr.ShortName :
((Gbl.CurrentIns.Ins.InsCod > 0) ? Gbl.CurrentIns.Ins.ShortName :
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]))));
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>");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Initialize values related to current course ****************/
/*****************************************************************************/
void Deg_InitCurrentCourse (void)
{
/***** If numerical course code is available, get course data *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{
if (Crs_GetDataOfCourseByCod (&Gbl.CurrentCrs.Crs)) // Course found
Gbl.CurrentDeg.Deg.DegCod = Gbl.CurrentCrs.Crs.DegCod;
else
{
Gbl.CurrentIns.Ins.InsCod =
Gbl.CurrentCtr.Ctr.CtrCod =
Gbl.CurrentDeg.Deg.DegCod =
Gbl.CurrentCrs.Crs.CrsCod = -1L;
}
}
/***** If numerical degree code is available, get degree data *****/
if (Gbl.CurrentDeg.Deg.DegCod > 0)
{
2016-04-16 15:05:18 +02:00
if (Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg)) // Degree found
2014-12-01 23:55:08 +01:00
{
Gbl.CurrentCtr.Ctr.CtrCod = Gbl.CurrentDeg.Deg.CtrCod;
Gbl.CurrentDegTyp.DegTyp.DegTypCod = Gbl.CurrentDeg.Deg.DegTypCod;
Gbl.CurrentIns.Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Gbl.CurrentDeg.Deg.DegCod);
/***** Degree type is available, so get degree type data *****/
2016-03-20 22:31:57 +01:00
if (!DT_GetDataOfDegreeTypeByCod (&Gbl.CurrentDegTyp.DegTyp)) // Degree type not found
2014-12-01 23:55:08 +01:00
{
Gbl.CurrentIns.Ins.InsCod =
Gbl.CurrentCtr.Ctr.CtrCod =
Gbl.CurrentDeg.Deg.DegTypCod =
Gbl.CurrentDeg.Deg.DegCod =
Gbl.CurrentCrs.Crs.CrsCod = -1L;
}
}
else
{
Gbl.CurrentIns.Ins.InsCod =
Gbl.CurrentCtr.Ctr.CtrCod =
Gbl.CurrentDeg.Deg.DegCod =
Gbl.CurrentCrs.Crs.CrsCod = -1L;
}
}
/***** If centre code is available, get centre data *****/
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
{
if (Ctr_GetDataOfCentreByCod (&Gbl.CurrentCtr.Ctr)) // Centre found
Gbl.CurrentIns.Ins.InsCod = Gbl.CurrentCtr.Ctr.InsCod;
else
Gbl.CurrentCtr.Ctr.CtrCod = -1L;
}
/***** If numerical institution code is available, get institution data *****/
if (Gbl.CurrentIns.Ins.InsCod > 0)
{
2015-12-09 19:51:17 +01:00
if (Ins_GetDataOfInstitutionByCod (&Gbl.CurrentIns.Ins,Ins_GET_BASIC_DATA)) // Institution found
2014-12-01 23:55:08 +01:00
Gbl.CurrentCty.Cty.CtyCod = Gbl.CurrentIns.Ins.CtyCod;
else
{
Gbl.CurrentCty.Cty.CtyCod =
Gbl.CurrentIns.Ins.InsCod =
Gbl.CurrentCtr.Ctr.CtrCod =
Gbl.CurrentDeg.Deg.DegCod =
Gbl.CurrentCrs.Crs.CrsCod = -1L;
}
}
/***** If numerical country code is available, get country data *****/
if (Gbl.CurrentCty.Cty.CtyCod > 0)
{
2015-12-09 19:51:17 +01:00
if (!Cty_GetDataOfCountryByCod (&Gbl.CurrentCty.Cty,Cty_GET_BASIC_DATA)) // Country not found
2014-12-01 23:55:08 +01:00
{
Gbl.CurrentCty.Cty.CtyCod =
Gbl.CurrentIns.Ins.InsCod =
Gbl.CurrentCtr.Ctr.CtrCod =
Gbl.CurrentDeg.Deg.DegCod =
Gbl.CurrentCrs.Crs.CrsCod = -1L;
}
}
/***** Initialize default fields for edition to current values *****/
Gbl.Inss.EditingIns.CtyCod = Gbl.CurrentCty.Cty.CtyCod;
Gbl.Ctrs.EditingCtr.InsCod =
Gbl.Dpts.EditingDpt.InsCod = Gbl.CurrentIns.Ins.InsCod;
Gbl.Degs.EditingDeg.CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
Gbl.Degs.EditingDeg.DegTypCod = Gbl.CurrentDegTyp.DegTyp.DegTypCod;
/***** Initialize paths *****/
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{
/***** Paths of course directories *****/
sprintf (Gbl.CurrentCrs.PathPriv,"%s/%s/%ld",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
sprintf (Gbl.CurrentCrs.PathRelPubl,"%s/%s/%ld",
Cfg_PATH_SWAD_PUBLIC ,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
sprintf (Gbl.CurrentCrs.PathURLPubl,"%s/%s/%ld",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
/***** If any of the course directories does not exist, create it *****/
if (!Fil_CheckIfPathExists (Gbl.CurrentCrs.PathPriv))
Fil_CreateDirIfNotExists (Gbl.CurrentCrs.PathPriv);
if (!Fil_CheckIfPathExists (Gbl.CurrentCrs.PathRelPubl))
Fil_CreateDirIfNotExists (Gbl.CurrentCrs.PathRelPubl);
/***** Count number of groups in current course (used only in some actions) *****/
Gbl.CurrentCrs.Grps.NumGrps = Grp_CountNumGrpsInCurrentCrs ();
}
}
/*****************************************************************************/
/************* Show the degrees belonging to the current centre **************/
/*****************************************************************************/
void Deg_ShowDegsOfCurrentCtr (void)
{
if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
{
/***** Get list of centres and degrees *****/
Ctr_GetListCentres (Gbl.CurrentIns.Ins.InsCod);
Deg_GetListDegsOfCurrentCtr ();
/***** Write menu to select country, institution and centre *****/
2015-07-25 20:07:38 +02:00
Deg_WriteMenuAllCourses ();
2014-12-01 23:55:08 +01:00
/***** Show list of degrees *****/
Deg_ListDegrees ();
/***** Free list of degrees and centres *****/
Deg_FreeListDegsOfCurrentCtr ();
Ctr_FreeListCentres ();
}
}
/*****************************************************************************/
/********************* List current degrees for edition **********************/
/*****************************************************************************/
#define Deg_MAX_LENGTH_WWW_ON_SCREEN 10
static void Deg_ListDegreesForEdition (void)
{
2014-12-13 20:32:10 +01:00
extern const char *Txt_Degrees_of_CENTRE_X;
2014-12-01 23:55:08 +01:00
extern const char *Txt_DEGREE_STATUS[Deg_NUM_STATUS_TXT];
unsigned NumDeg;
struct DegreeType *DegTyp;
struct Degree *Deg;
unsigned NumCtr;
unsigned NumDegTyp;
char WWW[Deg_MAX_LENGTH_WWW_ON_SCREEN+1];
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 *****/
2014-12-13 20:32:10 +01:00
sprintf (Gbl.Title,Txt_Degrees_of_CENTRE_X,
Gbl.CurrentCtr.Ctr.ShortName);
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Gbl.Title);
2014-12-01 23:55:08 +01:00
Deg_PutHeadDegreesForEdition ();
/***** List the degrees *****/
for (NumDeg = 0;
NumDeg < Gbl.CurrentCtr.Ctr.NumDegs;
NumDeg++)
{
Deg = &(Gbl.CurrentCtr.LstDegs[NumDeg]);
2016-04-16 15:05:18 +02:00
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
2014-12-01 23:55:08 +01:00
ICanEdit = Deg_CheckIfICanEdit (Deg);
/* 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)
2015-07-22 19:20:30 +02:00
Lay_PutIconRemovalNotAllowed ();
2014-12-01 23:55:08 +01:00
else
{
Act_FormStart (ActRemDeg);
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-07-22 19:59:28 +02:00
Lay_PutIconRemove ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
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);
2015-12-13 13:53:00 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,Deg->DegCod,Deg->ShortName,20,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/* Centre */
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">");
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) // I can select centre
2014-12-01 23:55:08 +01:00
{
Act_FormStart (ActChgDegCtr);
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-09-28 18:28:29 +02:00
fprintf (Gbl.F.Out,"<select name=\"OthCtrCod\" 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 (NumCtr = 0;
NumCtr < Gbl.Ctrs.Num;
NumCtr++)
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
Gbl.Ctrs.Lst[NumCtr].CtrCod,
(Gbl.Ctrs.Lst[NumCtr].CtrCod == Deg->CtrCod) ? " selected=\"selected\"" :
"",
Gbl.Ctrs.Lst[NumCtr].ShortName);
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
else
fprintf (Gbl.F.Out,"%s",Gbl.CurrentCtr.Ctr.ShortName);
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)
{
Act_FormStart (ActRenDegSho);
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();\" />",
2016-01-14 10:31:09 +01:00
Deg_MAX_LENGTH_DEGREE_SHORT_NAME,Deg->ShortName,Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
else
fprintf (Gbl.F.Out,"%s",Deg->ShortName);
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)
{
Act_FormStart (ActRenDegFul);
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();\" />",
2016-01-14 10:31:09 +01:00
Deg_MAX_LENGTH_DEGREE_FULL_NAME,Deg->FullName,Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
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)
{
Act_FormStart (ActChgDegTyp);
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;
NumDegTyp < Gbl.Degs.DegTypes.Num;
NumDegTyp++)
{
DegTyp = &Gbl.Degs.DegTypes.Lst[NumDegTyp];
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>");
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
else
for (NumDegTyp = 0;
NumDegTyp < Gbl.Degs.DegTypes.Num;
NumDegTyp++)
if (Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypCod == Deg->DegTypCod)
fprintf (Gbl.F.Out,"%s",Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypName);
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)
{
Act_FormStart (ActChgDegWWW);
Deg_PutParamOtherDegCod (Deg->DegCod);
2015-10-22 14:49:48 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" 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();\" />",
2016-01-14 10:31:09 +01:00
Cns_MAX_LENGTH_WWW,Deg->WWW,Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
else
{
strncpy (WWW,Deg->WWW,Deg_MAX_LENGTH_WWW_ON_SCREEN);
WWW[Deg_MAX_LENGTH_WWW_ON_SCREEN] = '\0';
2015-12-06 01:57:08 +01:00
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\">%s",
2014-12-01 23:55:08 +01:00
Deg->WWW,Deg->WWW,WWW);
if (strlen (Deg->WWW) > Deg_MAX_LENGTH_WWW_ON_SCREEN)
2016-01-15 11:41:45 +01:00
fprintf (Gbl.F.Out,"&hellip;");
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</a>");
}
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
/* Degree status */
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"DAT STATUS\">");
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM &&
2014-12-01 23:55:08 +01:00
StatusTxt == Deg_STATUS_PENDING)
{
Act_FormStart (ActChgDegSta);
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]);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
else
fprintf (Gbl.F.Out,"%s",Txt_DEGREE_STATUS[StatusTxt]);
fprintf (Gbl.F.Out,"</td>");
/* Degree requester */
UsrDat.UsrCod = Deg->RequesterUsrCod;
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"INPUT_REQUESTER LEFT_TOP\">"
"<table class=\"INPUT_REQUESTER CELLS_PAD_2\">"
2014-12-01 23:55:08 +01:00
"<tr>");
2015-12-05 21:15:30 +01:00
Msg_WriteMsgAuthor (&UsrDat,100,6,"DAT",true,NULL);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</tr>"
"</table>"
"</td>"
"</tr>");
}
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
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 *******************/
/*****************************************************************************/
static bool Deg_CheckIfICanEdit (struct Degree *Deg)
{
2015-04-07 21:44:24 +02:00
return (bool) (Gbl.Usrs.Me.LoggedRole >= 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)
{
2014-12-13 20:32:10 +01:00
extern const char *Txt_New_degree_of_CENTRE_X;
2014-12-01 23:55:08 +01:00
extern const char *Txt_DEGREE_STATUS[Deg_NUM_STATUS_TXT];
extern const char *Txt_Create_degree;
struct Degree *Deg;
struct DegreeType *DegTyp;
unsigned NumDegTyp;
/***** Start form *****/
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM)
2014-12-01 23:55:08 +01:00
Act_FormStart (ActNewDeg);
2015-04-07 21:44:24 +02:00
else if (Gbl.Usrs.Me.MaxRole >= Rol__GUEST_)
2014-12-01 23:55:08 +01:00
Act_FormStart (ActReqDeg);
else
Lay_ShowErrorAndExit ("You can not edit degrees.");
/***** Degree data *****/
Deg = &Gbl.Degs.EditingDeg;
/***** Start of frame *****/
2014-12-13 20:32:10 +01:00
sprintf (Gbl.Title,Txt_New_degree_of_CENTRE_X,
Gbl.CurrentCtr.Ctr.ShortName);
2015-04-12 18:01:06 +02:00
Lay_StartRoundFrameTable (NULL,2,Gbl.Title);
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
Deg_PutHeadDegreesForEdition ();
/***** Put disabled icon to remove degree *****/
fprintf (Gbl.F.Out,"<tr>"
2015-07-22 19:20:30 +02:00
"<td class=\"BM\">");
Lay_PutIconRemovalNotAllowed ();
fprintf (Gbl.F.Out,"</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 *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">");
2015-12-13 13:53:00 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,-1L,"",20,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>");
/***** Centre *****/
2015-07-31 19:49:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2015-09-06 19:51:06 +02:00
"<select name=\"OthCtrCod\""
2015-09-28 18:28:29 +02:00
" style=\"width:62px;\" disabled=\"disabled\">"
2014-12-01 23:55:08 +01:00
"<option value=\"%ld\" selected=\"selected\">"
"%s"
"</option>"
"</select>"
"</td>",
Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentCtr.Ctr.ShortName);
/***** 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\""
" class=\"INPUT_SHORT_NAME\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Deg_MAX_LENGTH_DEGREE_SHORT_NAME,Deg->ShortName);
/***** 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\""
" class=\"INPUT_FULL_NAME\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Deg_MAX_LENGTH_DEGREE_FULL_NAME,Deg->FullName);
/***** 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;
NumDegTyp < Gbl.Degs.DegTypes.Num;
NumDegTyp++)
{
DegTyp = &Gbl.Degs.DegTypes.Lst[NumDegTyp];
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s</option>",
DegTyp->DegTypCod,
DegTyp->DegTypCod == Deg->DegTypCod ? " selected=\"selected\"" :
"",
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\">"
2015-10-23 01:31:08 +02:00
"<input type=\"text\" name=\"WWW\""
2015-12-05 21:15:30 +01:00
" maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_WWW\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Cns_MAX_LENGTH_WWW,Deg->WWW);
/***** 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 status *****/
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"DAT STATUS\">"
2014-12-22 19:59:27 +01:00
"%s"
"</td>",
2014-12-01 23:55:08 +01:00
Txt_DEGREE_STATUS[Deg_STATUS_PENDING]);
/***** Degree requester *****/
2015-12-05 21:15:30 +01:00
fprintf (Gbl.F.Out,"<td class=\"INPUT_REQUESTER LEFT_TOP\">"
"<table class=\"INPUT_REQUESTER CELLS_PAD_2\">"
2014-12-01 23:55:08 +01:00
"<tr>");
2015-12-05 21:15:30 +01:00
Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,100,6,"DAT",true,NULL);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</tr>"
"</table>"
"</td>"
"</tr>");
2015-04-11 23:46:21 +02:00
/***** Send button and end frame *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTableWithButton (Lay_CREATE_BUTTON,Txt_Create_degree);
2014-12-01 23:55:08 +01:00
2015-04-11 23:46:21 +02:00
/***** End form *****/
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
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;
extern const char *Txt_Status;
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
"%s"
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Degree,
2015-12-05 21:15:30 +01:00
Txt_Type,
2014-12-01 23:55:08 +01:00
Txt_Courses_ABBREVIATION,
Txt_Status);
}
/*****************************************************************************/
/******************** Write header with fields of a degree *******************/
/*****************************************************************************/
static void Deg_PutHeadDegreesForEdition (void)
{
extern const char *Txt_Code;
extern const char *Txt_Centre;
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_Status;
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=\"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
"%s"
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Code,
Txt_Centre,
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_Status,
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 ***************************/
/*****************************************************************************/
static void Deg_CreateDegree (struct Degree *Deg,unsigned Status)
{
extern const char *Txt_Created_new_degree_X;
char Query[1024];
/***** Create a new degree *****/
2016-03-01 14:18:31 +01:00
sprintf (Query,"INSERT INTO degrees (CtrCod,DegTypCod,Status,"
"RequesterUsrCod,ShortName,FullName,WWW)"
" VALUES ('%ld','%ld','%u',"
"'%ld','%s','%s','%s')",
Deg->CtrCod,Deg->DegTypCod,Status,
Gbl.Usrs.Me.UsrDat.UsrCod,Deg->ShortName,Deg->FullName,Deg->WWW);
Deg->DegCod = DB_QueryINSERTandReturnCode (Query,"can not create a new degree");
2014-12-01 23:55:08 +01:00
/***** Write success message *****/
sprintf (Gbl.Message,Txt_Created_new_degree_X,
Deg->FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
2016-03-01 13:36:48 +01:00
/***** Put button to go to degree created *****/
Deg_PutButtonToGoToDeg (Deg);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** List degrees belonging to the current centre *****************/
/*****************************************************************************/
static void Deg_ListDegrees (void)
{
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;
2015-10-06 01:19:21 +02:00
bool ICanEdit = (Gbl.Usrs.Me.LoggedRole >= Rol__GUEST_);
2014-12-01 23:55:08 +01:00
2016-03-20 13:18:56 +01:00
/***** Start frame *****/
sprintf (Gbl.Title,Txt_Degrees_of_CENTRE_X,Gbl.CurrentCtr.Ctr.ShortName);
Lay_StartRoundFrame (NULL,Gbl.Title,ICanEdit ? Deg_PutIconToEditDegrees :
NULL);
2015-10-06 01:19:21 +02:00
if (Gbl.CurrentCtr.Ctr.NumDegs) // There are degrees in the current centre
2016-03-20 13:18:56 +01:00
{
/***** Start table *****/
2016-03-21 18:37:28 +01:00
fprintf (Gbl.F.Out,"<table class=\"FRAME_TABLE_MARGIN CELLS_PAD_2\">");
2016-03-20 13:18:56 +01:00
Deg_PutHeadDegreesForSeeing ();
/***** List the degrees *****/
for (NumDeg = 0;
NumDeg < Gbl.CurrentCtr.Ctr.NumDegs;
NumDeg++)
Deg_ListOneDegreeForSeeing (&(Gbl.CurrentCtr.LstDegs[NumDeg]),NumDeg + 1);
/***** End table *****/
fprintf (Gbl.F.Out,"</table>");
}
else // No degrees created in the current centre
Lay_ShowAlert (Lay_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-03-16 12:59:57 +01:00
if (ICanEdit)
{
Act_FormStart (ActEdiDeg);
2016-03-16 13:23:10 +01:00
Lay_PutConfirmButton (Gbl.CurrentCtr.Ctr.NumDegs ? Txt_Create_another_degree :
Txt_Create_degree);
2016-03-16 12:59:57 +01:00
Act_FormEnd ();
2015-10-06 01:19:21 +02:00
}
2016-03-20 13:18:56 +01:00
/***** End frame *****/
Lay_EndRoundFrame ();
}
/*****************************************************************************/
/********************** Put link (form) to edit degrees **********************/
/*****************************************************************************/
static void Deg_PutIconToEditDegrees (void)
{
extern const char *Txt_Edit;
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActEdiDeg,NULL,
"edit64x64.png",
Txt_Edit,NULL,
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;
Crs_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";
}
BgColor = (Deg->DegCod == Gbl.CurrentDeg.Deg.DegCod) ? "LIGHT_BLUE" :
Gbl.ColorRows[Gbl.RowEvenOdd];
/***** Put green tip if degree has courses *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"CENTER_MIDDLE %s\">"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</td>",
BgColor,
Gbl.Prefs.IconsURL,
2016-04-16 15:05:18 +02:00
NumCrss ? "ok_green" :
"tr",
NumCrss ? Txt_DEGREE_With_courses :
Txt_DEGREE_Without_courses,
NumCrss ? Txt_DEGREE_With_courses :
Txt_DEGREE_Without_courses);
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);
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">"
"%s"
"</td>"
"</tr>",
TxtClassNormal,BgColor,Txt_DEGREE_STATUS[StatusTxt]);
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************************** Put forms to edit degrees ***********************/
/*****************************************************************************/
void Deg_EditDegrees (void)
{
extern const char *Txt_There_is_no_list_of_centres;
extern const char *Txt_You_must_create_at_least_one_centre_before_creating_degrees;
extern const char *Txt_There_is_no_list_of_types_of_degree;
extern const char *Txt_You_must_create_at_least_one_type_of_degree_before_creating_degrees;
/***** Get list of degrees in the current centre *****/
Deg_GetListDegsOfCurrentCtr ();
/***** Get list of centres of the current institution *****/
Ctr_GetListCentres (Gbl.CurrentIns.Ins.InsCod);
if (Gbl.Ctrs.Num)
{
/***** Get list of degree types *****/
2016-03-20 22:31:57 +01:00
DT_GetListDegreeTypes ();
2014-12-01 23:55:08 +01:00
if (Gbl.Degs.DegTypes.Num)
{
/***** Put a form to create a new degree *****/
Deg_PutFormToCreateDegree ();
/***** Forms to edit current degrees *****/
if (Gbl.CurrentCtr.Ctr.NumDegs)
{
if (Gbl.Ctrs.Num)
Deg_ListDegreesForEdition ();
else
Lay_ShowAlert (Lay_WARNING,Txt_There_is_no_list_of_centres);
}
}
else // No degree types
{
Lay_ShowAlert (Lay_WARNING,Txt_There_is_no_list_of_types_of_degree);
Lay_ShowAlert (Lay_INFO,Txt_You_must_create_at_least_one_type_of_degree_before_creating_degrees);
}
/***** Free list of degree types *****/
2016-03-20 22:31:57 +01:00
DT_FreeListDegreeTypes ();
2014-12-01 23:55:08 +01:00
}
else // No centres
{
Lay_ShowAlert (Lay_WARNING,Txt_There_is_no_list_of_centres);
Lay_ShowAlert (Lay_INFO,Txt_You_must_create_at_least_one_centre_before_creating_degrees);
}
/***** Free list of centres of the current institution *****/
Ctr_FreeListCentres ();
/***** Free list of degrees in the current centre *****/
Deg_FreeListDegsOfCurrentCtr ();
}
/*****************************************************************************/
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
{
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDeg;
/***** Get degrees admin by me from database *****/
2016-04-16 15:05:18 +02:00
sprintf (Query,"SELECT DISTINCTROW degrees.DegCod,degrees.CtrCod,"
"degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod,"
"degrees.ShortName,degrees.FullName,degrees.WWW"
" FROM degrees,courses,crs_usr"
2016-04-16 18:21:06 +02:00
" WHERE degrees.DegCod=courses.DegCod"
2016-04-16 15:05:18 +02:00
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role='%u'"
" ORDER BY degrees.ShortName",
(unsigned) Rol_STUDENT);
Degs->Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by you");
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)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store degrees admin by you.");
/***** 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);
}
/*****************************************************************************/
/*********************** Free list of all the degrees ************************/
/*****************************************************************************/
2016-04-16 15:05:18 +02:00
void Deg_FreeListDegs (struct ListDegrees *Degs)
2014-12-01 23:55:08 +01:00
{
2016-04-16 15:05:18 +02:00
if (Degs->Lst)
2014-12-01 23:55:08 +01:00
{
2016-04-16 15:05:18 +02:00
free ((void *) Degs->Lst);
Degs->Lst = NULL;
Degs->Num = 0;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************ Get a list with the degrees of the current centre **************/
/*****************************************************************************/
static void Deg_GetListDegsOfCurrentCtr (void)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned NumDeg;
/***** Get degrees of the current centre from database *****/
2015-12-06 01:37:22 +01:00
sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod,"
2016-02-29 18:53:26 +01:00
"ShortName,FullName,WWW"
2015-12-06 01:37:22 +01:00
" FROM degrees WHERE CtrCod='%ld' ORDER BY FullName",
Gbl.CurrentCtr.Ctr.CtrCod);
2014-12-01 23:55:08 +01:00
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees of a centre");
/***** Count number of rows in result *****/
if (NumRows) // Degrees found...
{
Gbl.CurrentCtr.Ctr.NumDegs = (unsigned) NumRows;
/***** Create list with degrees of this centre *****/
if ((Gbl.CurrentCtr.LstDegs = (struct Degree *) calloc (Gbl.CurrentCtr.Ctr.NumDegs,sizeof (struct Degree))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store degrees of a centre.");
/***** Get the degrees of this centre *****/
for (NumDeg = 0;
NumDeg < Gbl.CurrentCtr.Ctr.NumDegs;
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
Deg_GetDataOfDegreeFromRow (&(Gbl.CurrentCtr.LstDegs[NumDeg]),row);
}
}
else // Error: degrees should be found, but really they haven't be found. This never should happen.
Gbl.CurrentCtr.Ctr.NumDegs = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/***************** Free list of degrees of the current centre ****************/
/*****************************************************************************/
static void Deg_FreeListDegsOfCurrentCtr (void)
{
if (Gbl.CurrentCtr.LstDegs)
{
free ((void *) Gbl.CurrentCtr.LstDegs);
Gbl.CurrentCtr.LstDegs = NULL;
Gbl.CurrentCtr.Ctr.NumDegs = 0;
}
}
/*****************************************************************************/
/*********** Create a list with the degrees administrated by me **************/
/*****************************************************************************/
void Deg_GetListDegsAdminByMe (void)
{
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDeg;
2016-10-19 01:46:40 +02:00
/***** Set default list *****/
Gbl.Usrs.Me.MyAdminDegs.Num = 0;
Gbl.Usrs.Me.MyAdminDegs.Lst = NULL;
2014-12-01 23:55:08 +01:00
/***** Get degrees admin by me from database *****/
2016-10-19 01:46:40 +02:00
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod,"
"ShortName,FullName,WWW"
" FROM degrees"
" WHERE CtrCod='%ld'"
" ORDER BY ShortName",
Gbl.CurrentCtr.Ctr.CtrCod);
break;
case Rol_DEG_ADM:
sprintf (Query,"SELECT degrees.DegCod,degrees.CtrCod,degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod,"
"degrees.ShortName,degrees.FullName,degrees.WWW"
" FROM admin,degrees"
" WHERE admin.UsrCod='%ld' AND admin.Scope='Deg'"
" AND admin.Cod=degrees.DegCod"
" ORDER BY degrees.ShortName",
Gbl.Usrs.Me.UsrDat.UsrCod);
break;
default:
/* I can not admin any degree */
return;
}
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.MyAdminDegs.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by you");
/***** Count number of rows in result *****/
if (Gbl.Usrs.Me.MyAdminDegs.Num) // Degrees found...
{
/***** Create list with degrees of this type *****/
2016-10-19 01:46:40 +02:00
if ((Gbl.Usrs.Me.MyAdminDegs.Lst = (struct Degree *) calloc (Gbl.Usrs.Me.MyAdminDegs.Num,
sizeof (struct Degree))) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Nout enough memory to store degrees admin by you.");
2016-10-19 01:46:40 +02:00
/***** Get the degrees *****/
2014-12-01 23:55:08 +01:00
for (NumDeg = 0;
NumDeg < Gbl.Usrs.Me.MyAdminDegs.Num;
NumDeg++)
{
/* Get next degree */
row = mysql_fetch_row (mysql_res);
Deg_GetDataOfDegreeFromRow (&(Gbl.Usrs.Me.MyAdminDegs.Lst[NumDeg]),row);
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/***************** Free list of degrees administrated by me ******************/
/*****************************************************************************/
void Deg_FreeListMyAdminDegs (void)
{
if (Gbl.Usrs.Me.MyAdminDegs.Lst)
{
free ((void *) Gbl.Usrs.Me.MyAdminDegs.Lst);
Gbl.Usrs.Me.MyAdminDegs.Lst = NULL;
Gbl.Usrs.Me.MyAdminDegs.Num = 0;
}
}
/*****************************************************************************/
/****************** Receive form to request a new degree *********************/
/*****************************************************************************/
void Deg_RecFormReqDeg (void)
{
Deg_RecFormRequestOrCreateDeg ((unsigned) Deg_STATUS_BIT_PENDING);
}
/*****************************************************************************/
/******************* Receive form to create a new degree *********************/
/*****************************************************************************/
void Deg_RecFormNewDeg (void)
{
Deg_RecFormRequestOrCreateDeg (0);
}
/*****************************************************************************/
/******************* Receive form to create a new degree *********************/
/*****************************************************************************/
static void Deg_RecFormRequestOrCreateDeg (unsigned Status)
{
extern const char *Txt_The_degree_X_already_exists;
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;
struct Degree *Deg;
Deg = &Gbl.Degs.EditingDeg;
/***** Get parameters from form *****/
/* Set degree centre */
Deg->CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
/* Get degree short name */
Par_GetParToText ("ShortName",Deg->ShortName,Deg_MAX_LENGTH_DEGREE_SHORT_NAME);
/* Get degree full name */
Par_GetParToText ("FullName",Deg->FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME);
/* Get degree type */
2016-03-20 22:31:57 +01:00
if ((Deg->DegTypCod = DT_GetParamOtherDegTypCod ()) <= 0)
2014-12-01 23:55:08 +01:00
Lay_ShowAlert (Lay_ERROR,"Wrong type of degree.");
/* Get degree WWW */
Par_GetParToText ("WWW",Deg->WWW,Cns_MAX_LENGTH_WWW);
if (Deg->ShortName[0] && Deg->FullName[0]) // If there's a degree name
{
if (Deg->WWW[0])
{
/***** If name of degree was in database... *****/
2015-11-04 22:51:41 +01:00
if (Deg_CheckIfDegreeNameExists (Deg->CtrCod,"ShortName",Deg->ShortName,-1L))
2014-12-01 23:55:08 +01:00
{
sprintf (Gbl.Message,Txt_The_degree_X_already_exists,
Deg->ShortName);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
2015-11-04 22:51:41 +01:00
else if (Deg_CheckIfDegreeNameExists (Deg->CtrCod,"FullName",Deg->FullName,-1L))
2014-12-01 23:55:08 +01:00
{
sprintf (Gbl.Message,Txt_The_degree_X_already_exists,
Deg->FullName);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
else // Add new degree to database
Deg_CreateDegree (Deg,Status);
}
else // If there is not a degree logo or web
{
sprintf (Gbl.Message,"%s",Txt_You_must_specify_the_web_address_of_the_new_degree);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
}
else // If there is not a degree name
{
sprintf (Gbl.Message,"%s",Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_degree);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
/***** Show the form again *****/
Deg_EditDegrees ();
}
/*****************************************************************************/
/************************ 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;
struct Degree Deg;
/***** Get degree code *****/
if ((Deg.DegCod = Deg_GetParamOtherDegCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of degree is missing.");
2016-03-01 13:36:48 +01:00
/***** Get data of degree *****/
2014-12-01 23:55:08 +01:00
Deg_GetDataOfDegreeByCod (&Deg);
/***** Check if this degree has courses *****/
2016-04-16 15:05:18 +02:00
if (Crs_GetNumCrssInDeg (Deg.DegCod)) // Degree has courses ==> don't remove
2014-12-01 23:55:08 +01:00
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
else // Degree has no courses ==> remove it
{
/***** Remove degree *****/
Deg_RemoveDegreeCompletely (Deg.DegCod);
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_Degree_X_removed,
Deg.FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
/***** Show the form again *****/
Deg_EditDegrees ();
}
/*****************************************************************************/
/******************** 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 *********************/
/*****************************************************************************/
long Deg_GetParamOtherDegCod (void)
{
char LongStr[1+10+1];
/***** Get parameter with code of degree *****/
Par_GetParToText ("OthDegCod",LongStr,1+10);
return Str_ConvertStrCodToLongCod (LongStr);
}
/*****************************************************************************/
/********************* Get data of a degree from its code ********************/
/*****************************************************************************/
// Returns true if degree found
bool Deg_GetDataOfDegreeByCod (struct Degree *Deg)
{
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
bool DegFound = false;
if (Deg->DegCod <= 0)
{
Deg->DegCod = -1L;
Deg->CtrCod = -1L;
Deg->DegTypCod = -1L;
Deg->Status = (Deg_Status_t) 0;
Deg->RequesterUsrCod = -1L;
Deg->ShortName[0] = '\0';
Deg->FullName[0] = '\0';
Deg->WWW[0] = '\0';
Deg->LstCrss = NULL;
return false;
}
/***** Get data of a degree from database *****/
2015-12-06 01:37:22 +01:00
sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod,"
2016-02-29 18:53:26 +01:00
"ShortName,FullName,WWW"
2015-12-06 01:37:22 +01:00
" FROM degrees WHERE DegCod ='%ld'",
Deg->DegCod);
2014-12-01 23:55:08 +01:00
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get data of a degree");
if (NumRows == 1)
{
/***** Get data of degree *****/
row = mysql_fetch_row (mysql_res);
Deg_GetDataOfDegreeFromRow (Deg,row);
DegFound = true;
}
else if (NumRows == 0)
{
Deg->DegCod = -1L;
Deg->CtrCod = -1L;
Deg->DegTypCod = -1L;
Deg->Status = (Deg_Status_t) 0;
Deg->RequesterUsrCod = -1L;
Deg->ShortName[0] = '\0';
Deg->FullName[0] = '\0';
Deg->WWW[0] = '\0';
Deg->LstCrss = NULL;
return false;
}
else if (NumRows > 1)
Lay_ShowErrorAndExit ("Degree repeated in database.");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
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]) *****/
strcpy (Deg->ShortName,row[5]);
/***** Get degree full name (row[6]) *****/
strcpy (Deg->FullName,row[6]);
2016-02-29 18:53:26 +01:00
/***** Get WWW (row[7]) *****/
strcpy (Deg->WWW,row[7]);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Get the short name of a degree from its code ******************/
/*****************************************************************************/
void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
Deg->ShortName[0] = '\0';
if (Deg->DegCod > 0)
{
/***** Get the short name of a degree from database *****/
sprintf (Query,"SELECT ShortName FROM degrees"
" WHERE DegCod ='%ld'",
Deg->DegCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the short name of a degree") == 1)
{
/***** Get the short name of this degree *****/
row = mysql_fetch_row (mysql_res);
strcpy (Deg->ShortName,row[0]);
}
/***** 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)
{
char Query[128];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long CtrCod = -1L;
if (DegCod > 0)
{
/***** Get the centre code of a degree from database *****/
sprintf (Query,"SELECT CtrCod FROM degrees WHERE DegCod ='%ld'",
DegCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the centre of a degree") == 1)
{
/***** 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)
{
2015-02-03 11:34:59 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
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 *****/
2014-12-01 23:55:08 +01:00
sprintf (Query,"SELECT centres.InsCod FROM degrees,centres"
2015-02-04 19:18:09 +01:00
" WHERE degrees.DegCod='%ld' AND degrees.CtrCod=centres.CtrCod",
2014-12-01 23:55:08 +01:00
DegCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get the institution of a degree") == 1)
{
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
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow,NumRows;
long CrsCod;
2015-01-25 18:50:43 +01:00
char PathDeg[PATH_MAX+1];
2014-12-01 23:55:08 +01:00
/***** Get courses of a degree from database *****/
sprintf (Query,"SELECT CrsCod FROM courses"
" WHERE DegCod='%ld'",DegCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get courses of a degree");
/* 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);
/***** Remove surveys of the degree (not including surveys of courses in degree, already removed) *****/
Svy_RemoveDegSurveys (DegCod);
/***** Remove all the threads and posts in degree forums *****/
/* Remove disabled posts */
sprintf (Query,"DELETE FROM forum_disabled_post"
" USING forum_thread,forum_post,forum_disabled_post"
" WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')"
" AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod AND forum_post.PstCod=forum_disabled_post.PstCod",
For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod);
DB_QueryDELETE (Query,"can not remove the disabled posts in forums of a degree");
/* Remove posts */
sprintf (Query,"DELETE FROM forum_post"
" USING forum_thread,forum_post"
" WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')"
" AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod",
For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod);
DB_QueryDELETE (Query,"can not remove posts in forums of a degree");
/* Remove threads read */
sprintf (Query,"DELETE FROM forum_thr_read"
" USING forum_thread,forum_thr_read"
" WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')"
" AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_thr_read.ThrCod",
For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod);
DB_QueryDELETE (Query,"can not remove read threads in forums of a degree");
/* Remove threads */
sprintf (Query,"DELETE FROM forum_thread"
" WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')"
" AND Location='%ld'",
For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod);
DB_QueryDELETE (Query,"can not remove threads in forums of a degree");
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 *****/
sprintf (PathDeg,"%s/%s/%02u/%u",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_DEG,
(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 *****/
2015-01-29 01:03:31 +01:00
sprintf (Query,"DELETE FROM admin WHERE Scope='Deg' AND Cod='%ld'",
2015-01-20 02:00:42 +01:00
DegCod);
2014-12-01 23:55:08 +01:00
DB_QueryDELETE (Query,"can not remove administrators of a degree");
/***** Remove the degree *****/
2015-01-20 02:00:42 +01:00
sprintf (Query,"DELETE FROM degrees WHERE DegCod='%ld'",
DegCod);
2014-12-01 23:55:08 +01:00
DB_QueryDELETE (Query,"can not remove a degree");
/***** Delete all the degrees in sta_degrees table not present in degrees table *****/
Pho_RemoveObsoleteStatDegrees ();
}
/*****************************************************************************/
/********************* Change the short name of a degree *********************/
/*****************************************************************************/
void Deg_RenameDegreeShort (void)
{
2016-03-01 13:36:48 +01:00
struct Degree *Deg;
Deg = &Gbl.Degs.EditingDeg;
if (Deg_RenameDegree (Deg,Cns_SHORT_NAME))
if (Deg->DegCod == Gbl.CurrentDeg.Deg.DegCod) // If renaming current degree...
strcpy (Gbl.CurrentDeg.Deg.ShortName,Deg->ShortName); // Overwrite current degree name in order to show correctly in page title and heading
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Change the full name of a degree **********************/
/*****************************************************************************/
void Deg_RenameDegreeFull (void)
{
2016-03-01 13:36:48 +01:00
struct Degree *Deg;
Deg = &Gbl.Degs.EditingDeg;
if (Deg_RenameDegree (Deg,Cns_FULL_NAME))
if (Deg->DegCod == Gbl.CurrentDeg.Deg.DegCod) // If renaming current degree...
strcpy (Gbl.CurrentDeg.Deg.FullName,Deg->FullName); // Overwrite current degree name in order to show correctly in page title and heading
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Change the name of a degree ************************/
/*****************************************************************************/
2016-03-01 13:36:48 +01:00
// Returns true if the degree is renamed
// Returns false if the degree is not renamed
2014-12-01 23:55:08 +01:00
2016-03-01 13:36:48 +01:00
static bool Deg_RenameDegree (struct Degree *Deg,Cns_ShortOrFullName_t ShortOrFullName)
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;
char Query[512];
const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning
unsigned MaxLength = 0; // Initialized to avoid warning
char *CurrentDegName = NULL; // Initialized to avoid warning
char NewDegName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1];
2016-03-01 13:36:48 +01:00
bool DegreeHasBeenRenamed = false;
2014-12-01 23:55:08 +01:00
switch (ShortOrFullName)
{
case Cns_SHORT_NAME:
ParamName = "ShortName";
FieldName = "ShortName";
MaxLength = Deg_MAX_LENGTH_DEGREE_SHORT_NAME;
CurrentDegName = Deg->ShortName;
break;
case Cns_FULL_NAME:
ParamName = "FullName";
FieldName = "FullName";
MaxLength = Deg_MAX_LENGTH_DEGREE_FULL_NAME;
CurrentDegName = Deg->FullName;
break;
}
/***** Get parameters from form *****/
/* Get the code of the degree */
if ((Deg->DegCod = Deg_GetParamOtherDegCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of degree is missing.");
/* Get the new name for the degree */
Par_GetParToText (ParamName,NewDegName,MaxLength);
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])
{
sprintf (Gbl.Message,Txt_You_can_not_leave_the_name_of_the_degree_X_empty,
CurrentDegName);
2016-03-01 13:36:48 +01:00
Gbl.Error = true;
2014-12-01 23:55:08 +01:00
}
else
{
/***** Check if old and new names are the same (this happens when user press enter with no changes in the form) *****/
if (strcmp (CurrentDegName,NewDegName)) // Different names
{
/***** If degree was in database... *****/
2015-11-04 22:51:41 +01:00
if (Deg_CheckIfDegreeNameExists (Deg->CtrCod,ParamName,NewDegName,Deg->DegCod))
2014-12-01 23:55:08 +01:00
{
sprintf (Gbl.Message,Txt_The_degree_X_already_exists,
NewDegName);
2016-03-01 13:36:48 +01:00
Gbl.Error = true;
2014-12-01 23:55:08 +01:00
}
else
{
/* Update the table changing old name by new name */
sprintf (Query,"UPDATE degrees SET %s='%s' WHERE DegCod='%ld'",
FieldName,NewDegName,Deg->DegCod);
DB_QueryUPDATE (Query,"can not update the name of a degree");
2016-03-01 13:36:48 +01:00
/* Write message to show the change made */
2014-12-01 23:55:08 +01:00
sprintf (Gbl.Message,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 */
strncpy (CurrentDegName,NewDegName,MaxLength);
CurrentDegName[MaxLength] = '\0';
DegreeHasBeenRenamed = true;
2014-12-01 23:55:08 +01:00
}
}
else // The same name
sprintf (Gbl.Message,Txt_The_name_of_the_degree_X_has_not_changed,
CurrentDegName);
}
2016-03-01 13:36:48 +01:00
return DegreeHasBeenRenamed;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************* Check if the name of degree exists ********************/
/*****************************************************************************/
2015-11-04 22:51:41 +01:00
static bool Deg_CheckIfDegreeNameExists (long CtrCod,const char *FieldName,const char *Name,long DegCod)
2014-12-01 23:55:08 +01:00
{
char Query[512];
/***** Get number of degrees with a type and a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM degrees"
2015-11-04 22:51:41 +01:00
" WHERE CtrCod='%ld' AND %s='%s' AND DegCod<>'%ld'",
CtrCod,FieldName,Name,DegCod);
2014-12-01 23:55:08 +01:00
return (DB_QueryCOUNT (Query,"can not check if the name of a degree already existed") != 0);
}
/*****************************************************************************/
/************************ Change the centre of a degree **********************/
/*****************************************************************************/
2016-10-19 20:43:26 +02:00
void Deg_ChangeDegreeCtrInConfig (void)
{
extern const char *Txt_The_degree_X_has_been_moved_to_the_centre_Y;
struct Centre NewCtr;
/***** Get parameters from form *****/
/* Get parameter with centre code */
NewCtr.CtrCod = Ctr_GetParamOtherCtrCod ();
/***** Get data of new centre *****/
Ctr_GetDataOfCentreByCod (&NewCtr);
/***** Update centre in table of degrees *****/
2016-10-19 23:17:36 +02:00
Deg_UpdateDegCentreDB (Gbl.CurrentDeg.Deg.DegCod,NewCtr.CtrCod);
2016-10-19 20:43:26 +02:00
Gbl.CurrentDeg.Deg.CtrCod =
Gbl.CurrentCtr.Ctr.CtrCod = NewCtr.CtrCod;
/***** Initialize again current course, degree, centre... *****/
Deg_InitCurrentCourse ();
/***** Create message to show the change made *****/
sprintf (Gbl.Message,Txt_The_degree_X_has_been_moved_to_the_centre_Y,
Gbl.CurrentDeg.Deg.FullName,
Gbl.CurrentCtr.Ctr.FullName);
}
/*****************************************************************************/
2016-10-19 23:17:36 +02:00
/** Show message of success after changing a degree in course configuration **/
2016-10-19 20:43:26 +02:00
/*****************************************************************************/
void Deg_ContEditAfterChgDegInConfig (void)
{
/***** Write error/success message *****/
Lay_ShowAlert (Gbl.Error ? Lay_WARNING :
Lay_SUCCESS,
Gbl.Message);
/***** Show the form again *****/
Deg_ShowConfiguration ();
}
/*****************************************************************************/
/************************ Change the centre of a degree **********************/
/*****************************************************************************/
2014-12-01 23:55:08 +01:00
void Deg_ChangeDegreeCtr (void)
{
2016-03-01 13:36:48 +01:00
extern const char *Txt_The_degree_X_has_been_moved_to_the_centre_Y;
2014-12-01 23:55:08 +01:00
struct Degree *Deg;
2016-03-01 13:36:48 +01:00
struct Centre NewCtr;
2014-12-01 23:55:08 +01:00
Deg = &Gbl.Degs.EditingDeg;
/***** Get parameters from form *****/
/* Get degree code */
if ((Deg->DegCod = Deg_GetParamOtherDegCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of degree is missing.");
/* Get parameter with centre code */
2016-03-01 13:36:48 +01:00
NewCtr.CtrCod = Ctr_GetParamOtherCtrCod ();
/***** Get data of degree and new centre *****/
Deg_GetDataOfDegreeByCod (Deg);
Ctr_GetDataOfCentreByCod (&NewCtr);
2014-12-01 23:55:08 +01:00
/***** Update centre in table of degrees *****/
2016-10-19 23:17:36 +02:00
Deg_UpdateDegCentreDB (Deg->DegCod,NewCtr.CtrCod);
2016-03-01 13:36:48 +01:00
Deg->CtrCod = NewCtr.CtrCod;
2014-12-01 23:55:08 +01:00
/***** Write message to show the change made *****/
2016-03-01 13:36:48 +01:00
sprintf (Gbl.Message,Txt_The_degree_X_has_been_moved_to_the_centre_Y,
Deg->FullName,NewCtr.FullName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
/***** Put button to go to degree changed *****/
2016-03-01 23:58:48 +01:00
Deg_PutButtonToGoToDeg (Deg);
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
Deg_EditDegrees ();
}
2016-10-19 23:17:36 +02:00
/*****************************************************************************/
/********************** Update centre in table of degrees ********************/
/*****************************************************************************/
static void Deg_UpdateDegCentreDB (long DegCod,long CtrCod)
{
char Query[128];
/***** Update centre in table of degrees *****/
sprintf (Query,"UPDATE degrees SET CtrCod='%ld' WHERE DegCod='%ld'",
CtrCod,DegCod);
DB_QueryUPDATE (Query,"can not update the centre of a degree");
}
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;
struct Degree *Deg;
char Query[256+Cns_MAX_LENGTH_WWW];
char NewWWW[Cns_MAX_LENGTH_WWW+1];
Deg = &Gbl.Degs.EditingDeg;
/***** Get parameters from form *****/
/* Get the code of the degree */
if ((Deg->DegCod = Deg_GetParamOtherDegCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of degree is missing.");
/* Get the new WWW for the degree */
Par_GetParToText ("WWW",NewWWW,Cns_MAX_LENGTH_WWW);
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 WWW is empty *****/
if (NewWWW[0])
{
2016-03-01 13:36:48 +01:00
/***** Update the table changing old WWW by new WWW *****/
2014-12-01 23:55:08 +01:00
sprintf (Query,"UPDATE degrees SET WWW='%s' WHERE DegCod='%ld'",
NewWWW,Deg->DegCod);
DB_QueryUPDATE (Query,"can not update the web of a degree");
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,
NewWWW);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
2016-03-01 13:36:48 +01:00
/***** Put button to go to degree changed *****/
2016-03-01 23:58:48 +01:00
Deg_PutButtonToGoToDeg (Deg);
2014-12-01 23:55:08 +01:00
}
else
{
sprintf (Gbl.Message,"%s",Txt_You_can_not_leave_the_web_address_empty);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
/***** Show the form again *****/
strcpy (Deg->WWW,NewWWW);
Deg_EditDegrees ();
}
/*****************************************************************************/
/*********************** Change the status of a degree ***********************/
/*****************************************************************************/
void Deg_ChangeDegStatus (void)
{
extern const char *Txt_The_status_of_the_degree_X_has_changed;
struct Degree *Deg;
char Query[256];
char UnsignedNum[10+1];
Deg_Status_t Status;
Deg_StatusTxt_t StatusTxt;
Deg = &Gbl.Degs.EditingDeg;
/***** Get parameters from form *****/
/* Get degree code */
if ((Deg->DegCod = Deg_GetParamOtherDegCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of degree is missing.");
/* Get parameter with status */
Par_GetParToText ("Status",UnsignedNum,1);
if (sscanf (UnsignedNum,"%u",&Status) != 1)
Lay_ShowErrorAndExit ("Wrong status.");
StatusTxt = Deg_GetStatusTxtFromStatusBits (Status);
Status = Deg_GetStatusBitsFromStatusTxt (StatusTxt); // New status
/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (Deg);
/***** Update status in table of degrees *****/
sprintf (Query,"UPDATE degrees SET Status='%u' WHERE DegCod='%ld'",
(unsigned) Status,Deg->DegCod);
DB_QueryUPDATE (Query,"can not update the status of a degree");
Deg->Status = Status;
/***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_status_of_the_degree_X_has_changed,
Deg->ShortName);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
2016-03-01 13:36:48 +01:00
/***** Put button to go to degree changed *****/
2016-03-01 23:58:48 +01:00
Deg_PutButtonToGoToDeg (Deg);
2016-03-01 13:36:48 +01:00
/***** Show the form again *****/
Deg_EditDegrees ();
}
/*****************************************************************************/
/************* Show message of success after changing a degree ***************/
/*****************************************************************************/
void Deg_ContEditAfterChgDeg (void)
{
if (Gbl.Error)
/***** Write error message *****/
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
else
{
/***** Write success message showing the change made *****/
Lay_ShowAlert (Lay_INFO,Gbl.Message);
/***** Put button to go to degree changed *****/
2016-03-01 23:58:48 +01:00
Deg_PutButtonToGoToDeg (&Gbl.Degs.EditingDeg);
2016-03-01 13:36:48 +01:00
}
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
Deg_EditDegrees ();
}
2016-03-01 13:36:48 +01:00
/*****************************************************************************/
/************************ Put button to go to degree *************************/
/*****************************************************************************/
2016-03-20 16:30:52 +01:00
void Deg_PutButtonToGoToDeg (struct Degree *Deg)
2016-03-01 13:36:48 +01:00
{
extern const char *Txt_Go_to_X;
2016-03-01 23:58:48 +01:00
// If the degree is different to the current one...
if (Deg->DegCod != Gbl.CurrentDeg.Deg.DegCod)
{
2016-03-24 20:54:32 +01:00
fprintf (Gbl.F.Out,"<div class=\"BUTTONS_AFTER_ALERT\">");
2016-03-02 00:15:51 +01:00
Act_FormStart (ActSeeCrs);
2016-03-01 23:58:48 +01:00
Deg_PutParamDegCod (Deg->DegCod);
sprintf (Gbl.Title,Txt_Go_to_X,Deg->ShortName);
2016-03-24 20:54:32 +01:00
Lay_PutConfirmButtonInline (Gbl.Title);
2016-03-01 23:58:48 +01:00
Act_FormEnd ();
2016-03-24 20:54:32 +01:00
fprintf (Gbl.F.Out,"</div>");
2016-03-01 23:58:48 +01:00
}
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)
{
2015-02-01 20:17:24 +01:00
Log_RequestLogo (Sco_SCOPE_DEG);
2015-01-17 19:31:21 +01:00
}
/*****************************************************************************/
/***************** Receive the logo of the current degree ********************/
/*****************************************************************************/
void Deg_ReceiveLogo (void)
{
2015-02-01 20:17:24 +01:00
Log_ReceiveLogo (Sco_SCOPE_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)
{
Log_RemoveLogo (Sco_SCOPE_DEG);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*********************** Get total number of degrees *************************/
/*****************************************************************************/
unsigned Deg_GetNumDegsTotal (void)
{
char Query[256];
/***** Get total number of degrees from database *****/
sprintf (Query,"SELECT COUNT(*) FROM degrees");
return (unsigned) DB_QueryCOUNT (Query,"can not get the total number of degrees");
}
/*****************************************************************************/
/********************* Get number of degrees in a country ********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInCty (long InsCod)
{
char Query[512];
/***** Get number of degrees in a country from database *****/
sprintf (Query,"SELECT COUNT(*) FROM institutions,centres,degrees"
" WHERE institutions.CtyCod='%ld'"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of degrees in a country");
}
/*****************************************************************************/
/****************** Get number of degrees in an institution ******************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInIns (long InsCod)
{
char Query[512];
/***** Get number of degrees in an institution from database *****/
sprintf (Query,"SELECT COUNT(*) FROM centres,degrees"
" WHERE centres.InsCod='%ld'"
" AND centres.CtrCod=degrees.CtrCod",
InsCod);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of degrees in an institution");
}
/*****************************************************************************/
/******************** Get number of degrees in a centre **********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsInCtr (long CtrCod)
{
char Query[512];
/***** Get number of degrees in a centre from database *****/
sprintf (Query,"SELECT COUNT(*) FROM degrees"
" WHERE CtrCod='%ld'",
CtrCod);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of degrees in a centre");
}
/*****************************************************************************/
/********************* Get number of centres with courses ********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsWithCrss (const char *SubQuery)
{
char Query[512];
/***** Get number of degrees with courses from database *****/
sprintf (Query,"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);
return (unsigned) DB_QueryCOUNT (Query,"can not get number of degrees with courses");
}
/*****************************************************************************/
/********************* Get number of degrees with users **********************/
/*****************************************************************************/
unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
{
char Query[512];
/***** Get number of degrees with users from database *****/
sprintf (Query,"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);
return (unsigned) DB_QueryCOUNT (Query,"can not get number of degrees with users");
}
/*****************************************************************************/
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
/*****************************************************************************/
2015-11-23 00:44:39 +01:00
void Deg_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_all_degrees;
2015-11-23 13:14:13 +01:00
char Query[1024];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2015-11-23 00:44:39 +01:00
unsigned NumRow;
unsigned NumRows;
struct Institution Ins;
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 *****/
2015-11-23 13:14:13 +01:00
sprintf (Query,"(SELECT '%u' AS S,'-1' AS Cod,'' AS FullName"
2015-01-29 01:03:31 +01:00
" FROM admin"
2015-11-23 00:44:39 +01:00
" WHERE UsrCod='%ld'"
" AND Scope='Sys')"
" UNION "
2015-11-23 13:14:13 +01:00
"(SELECT '%u' AS S,admin.Cod,institutions.FullName"
2015-11-23 00:44:39 +01:00
" FROM admin,institutions"
" WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Ins'"
" AND admin.Cod=institutions.InsCod)"
" UNION "
2015-11-23 13:14:13 +01:00
"(SELECT '%u' AS S,admin.Cod,centres.FullName"
2015-11-23 00:44:39 +01:00
" FROM admin,centres"
" WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Ctr'"
" AND admin.Cod=centres.CtrCod)"
2014-12-01 23:55:08 +01:00
" UNION "
2015-11-23 13:14:13 +01:00
"(SELECT '%u' AS S,admin.Cod,degrees.FullName"
2015-01-29 01:03:31 +01:00
" FROM admin,degrees"
2015-11-23 00:44:39 +01:00
" WHERE admin.UsrCod='%ld'"
" AND admin.Scope='Deg'"
2015-01-29 01:03:31 +01:00
" AND admin.Cod=degrees.DegCod)"
2015-11-23 13:14:13 +01:00
" ORDER BY S,FullName",
2015-11-23 00:44:39 +01:00
(unsigned) Sco_SCOPE_SYS,UsrCod,
(unsigned) Sco_SCOPE_INS,UsrCod,
(unsigned) Sco_SCOPE_CTR,UsrCod,
(unsigned) Sco_SCOPE_DEG,UsrCod);
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get institutions, centres, degrees admin by a user")))
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=\"\""
2015-12-13 12:51:41 +01:00
" class=\"ICON25x25\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2015-09-03 00:59:03 +02:00
Gbl.RowEvenOdd,Gbl.Prefs.IconsURL,
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]))
{
case Sco_SCOPE_SYS: // System
2015-12-12 19:47:10 +01:00
fprintf (Gbl.F.Out,"<img src=\"%s/swad64x64.gif\""
2015-11-23 00:44:39 +01:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
2015-11-23 00:44:39 +01:00
"&nbsp;%s",
2014-12-01 23:55:08 +01:00
Gbl.Prefs.IconsURL,
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;
case Sco_SCOPE_INS: // Institution
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;
case Sco_SCOPE_CTR: // Centre
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;
case Sco_SCOPE_DEG: // Degree
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
Lay_ShowErrorAndExit ("Wrong scope.");
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);
}
/*****************************************************************************/
/****************************** List degrees found ***************************/
/*****************************************************************************/
// Returns number of degrees found
unsigned Deg_ListDegsFound (const char *Query)
{
extern const char *Txt_degree;
extern const char *Txt_degrees;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumDegs;
unsigned NumDeg;
struct Degree Deg;
/***** Query database *****/
if ((NumDegs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees")))
{
/***** Write heading *****/
/* Number of degrees found */
2016-04-17 23:28:38 +02:00
sprintf (Gbl.Title,"%u %s",
NumDegs,(NumDegs == 1) ? Txt_degree :
Txt_degrees);
Lay_StartRoundFrameTable (NULL,2,Gbl.Title);
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 */
row = mysql_fetch_row (mysql_res);
/* 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);
}
2016-03-20 13:47:46 +01:00
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumDegs;
}