swad-core/swad_record.c

4258 lines
158 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_record.c: users' record cards
/*
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.
2017-01-13 01:51:23 +01:00
Copyright (C) 1999-2017 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 <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdlib.h> // For calloc
#include <string.h>
#include "swad_action.h"
#include "swad_config.h"
#include "swad_database.h"
2017-03-30 11:20:06 +02:00
#include "swad_enrolment.h"
2015-03-18 01:06:43 +01:00
#include "swad_follow.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
#include "swad_ID.h"
2015-01-17 20:06:25 +01:00
#include "swad_logo.h"
2014-12-01 23:55:08 +01:00
#include "swad_network.h"
#include "swad_parameter.h"
#include "swad_photo.h"
#include "swad_preference.h"
2016-12-09 13:59:33 +01:00
#include "swad_privacy.h"
2014-12-01 23:55:08 +01:00
#include "swad_QR.h"
#include "swad_record.h"
2016-12-13 13:32:19 +01:00
#include "swad_role.h"
2014-12-01 23:55:08 +01:00
#include "swad_user.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
2015-12-13 13:53:00 +01:00
#define Rec_INSTITUTION_LOGO_SIZE 64
#define Rec_DEGREE_LOGO_SIZE 64
2015-12-22 09:38:32 +01:00
2016-04-22 12:24:02 +02:00
#define Rec_USR_MIN_AGE 12 // years old
2015-12-22 09:38:32 +01:00
#define Rec_USR_MAX_AGE 120 // years old
2014-12-01 23:55:08 +01:00
#define Rec_SHOW_OFFICE_HOURS_DEFAULT true
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Rec_WriteHeadingRecordFields (void);
2017-04-28 11:38:21 +02:00
static void Rec_PutParamFielCod (void);
2017-03-08 01:21:21 +01:00
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
2017-01-15 22:58:26 +01:00
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility);
2014-12-01 23:55:08 +01:00
2017-05-09 20:56:02 +02:00
static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView);
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneStdCrs (void);
2016-11-18 00:17:53 +01:00
static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Rec_CourseRecordViewType_t CrsTypeOfView);
2017-05-09 20:56:02 +02:00
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneTchCrs (void);
2017-05-09 20:56:02 +02:00
static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView);
2015-03-05 18:58:59 +01:00
2015-10-03 21:10:47 +02:00
static void Rec_ShowLinkToPrintPreviewOfRecords (void);
2014-12-01 23:55:08 +01:00
static void Rec_GetParamRecordsPerPage (void);
2016-11-27 17:30:10 +01:00
static void Rec_WriteFormShowOfficeHoursOneTch (bool ShowOfficeHours);
static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours);
static void Rec_PutParamsShowOfficeHoursOneTch (void);
static void Rec_PutParamsShowOfficeHoursSeveralTchs (void);
2014-12-01 23:55:08 +01:00
static bool Rec_GetParamShowOfficeHours (void);
2016-11-18 00:17:53 +01:00
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
struct UsrData *UsrDat,const char *Anchor);
2015-03-30 13:59:32 +02:00
static void Rec_ShowMyCrsRecordUpdated (void);
2016-04-22 12:24:02 +02:00
2016-05-05 14:20:38 +02:00
static void Rec_PutIconsCommands (void);
static void Rec_PutParamUsrCodEncrypted (void);
static void Rec_PutParamsWorks (void);
static void Rec_PutParamsStudent (void);
static void Rec_PutParamsMsgUsr (void);
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks);
2016-04-22 12:39:36 +02:00
static void Rec_ShowPhoto (struct UsrData *UsrDat);
2016-04-22 12:44:56 +02:00
static void Rec_ShowFullName (struct UsrData *UsrDat);
2016-04-22 19:50:59 +02:00
static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks);
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountryInHead (struct UsrData *UsrDat,bool ShowData);
2016-04-22 20:00:26 +02:00
static void Rec_ShowWebsAndSocialNets (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView);
2016-04-23 13:30:59 +02:00
static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm);
2017-05-10 10:09:19 +02:00
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm,
const char *Anchor);
2016-04-23 13:23:09 +02:00
static void Rec_ShowRole (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:23:09 +02:00
const char *ClassForm);
2016-04-23 13:37:43 +02:00
static void Rec_ShowSurname1 (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:37:43 +02:00
const char *ClassForm);
2016-04-23 13:45:03 +02:00
static void Rec_ShowSurname2 (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:45:03 +02:00
const char *ClassForm);
2016-04-23 13:49:38 +02:00
static void Rec_ShowFirstName (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:49:38 +02:00
const char *ClassForm);
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountry (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:58:20 +02:00
const char *ClassForm);
2016-04-23 14:03:56 +02:00
static void Rec_ShowOriginPlace (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:03:56 +02:00
const char *ClassForm);
2016-04-23 14:06:49 +02:00
static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:06:49 +02:00
const char *ClassForm);
2016-04-23 14:12:52 +02:00
static void Rec_ShowLocalAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:12:52 +02:00
const char *ClassForm);
2016-04-23 14:18:09 +02:00
static void Rec_ShowLocalPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:18:09 +02:00
const char *ClassForm);
2016-04-23 14:31:57 +02:00
static void Rec_ShowFamilyAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:31:57 +02:00
const char *ClassForm);
2016-04-23 14:36:02 +02:00
static void Rec_ShowFamilyPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:36:02 +02:00
const char *ClassForm);
2016-04-23 14:43:53 +02:00
static void Rec_ShowComments (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:43:53 +02:00
const char *ClassForm);
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitution (struct Instit *Ins,
2016-04-23 14:51:12 +02:00
bool ShowData,const char *ClassForm);
2016-04-23 15:00:07 +02:00
static void Rec_ShowCentre (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:08:32 +02:00
static void Rec_ShowDepartment (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:15:06 +02:00
static void Rec_ShowOffice (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-23 15:20:37 +02:00
static void Rec_ShowOfficePhone (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm);
2016-04-22 12:24:02 +02:00
2014-12-01 23:55:08 +01:00
static void Rec_WriteLinkToDataProtectionClause (void);
2015-12-07 23:13:08 +01:00
static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat);
2014-12-01 23:55:08 +01:00
static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat);
/*****************************************************************************/
/*************** Create, edit and remove fields of records *******************/
/*****************************************************************************/
void Rec_ReqEditRecordFields (void)
{
2017-03-20 11:30:19 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2014-12-01 23:55:08 +01:00
extern const char *Txt_There_are_no_record_fields_in_the_course_X;
2015-03-24 17:47:26 +01:00
extern const char *Txt_Record_fields;
2014-12-01 23:55:08 +01:00
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** List the current fields of records for edit them *****/
if (Gbl.CurrentCrs.Records.LstFields.Num) // Fields found...
{
2017-03-20 11:30:19 +01:00
Lay_StartRoundFrameTable (NULL,Txt_Record_fields,NULL,
Hlp_USERS_Students_course_record_card,2);
2014-12-01 23:55:08 +01:00
Rec_ListFieldsRecordsForEdition ();
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
else // No fields of records found for current course in the database
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_There_are_no_record_fields_in_the_course_X,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Crs.FullName);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
/***** Put a form to create a new record field *****/
Rec_ShowFormCreateRecordField ();
/* Free list of fields of records */
Rec_FreeListFields ();
}
/*****************************************************************************/
/****** Create a list with the fields of records from current course *********/
/*****************************************************************************/
void Rec_GetListRecordFieldsInCurrentCrs (void)
{
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
unsigned Vis;
if (++Gbl.CurrentCrs.Records.LstFields.NestedCalls > 1) // If the list is already created, don't do anything
return;
/***** Get fields of cards of a course from database *****/
sprintf (Query,"SELECT FieldCod,FieldName,NumLines,Visibility"
" FROM crs_record_fields"
2017-03-24 01:09:27 +01:00
" WHERE CrsCod=%ld ORDER BY FieldName",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Crs.CrsCod);
Gbl.CurrentCrs.Records.LstFields.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get fields of cards of a course");
/***** Get the fields of records *****/
if (Gbl.CurrentCrs.Records.LstFields.Num)
{
/***** Create a list of fields *****/
if ((Gbl.CurrentCrs.Records.LstFields.Lst = (struct RecordField *) calloc (Gbl.CurrentCrs.Records.LstFields.Num,sizeof (struct RecordField))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store fields of records in current course.");
/***** Get the fields *****/
for (NumRow = 0;
NumRow < Gbl.CurrentCrs.Records.LstFields.Num;
NumRow++)
{
/* Get next field */
row = mysql_fetch_row (mysql_res);
/* Get the code of field (row[0]) */
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of field.");
/* Name of the field (row[1]) */
2017-01-15 18:02:52 +01:00
Str_Copy (Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Name,row[1],
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* Number of lines (row[2]) */
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].NumLines = Rec_ConvertToNumLinesField (row[2]);
/* Visible or editable by students? (row[3]) */
if (sscanf (row[3],"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Error when getting field of record in current course.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Visibility = (Rec_VisibilityRecordFields_t) Vis;
else
2017-01-29 12:42:19 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumRow].Visibility = Rec_VISIBILITY_DEFAULT;
2014-12-01 23:55:08 +01:00
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/********* List the fields of records already present in database ************/
/*****************************************************************************/
void Rec_ListFieldsRecordsForEdition (void)
{
extern const char *Txt_RECORD_FIELD_VISIBILITY_MENU[Rec_NUM_TYPES_VISIBILITY];
unsigned NumField;
Rec_VisibilityRecordFields_t Vis;
/***** Write heading *****/
Rec_WriteHeadingRecordFields ();
/***** List the fields *****/
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
{
fprintf (Gbl.F.Out,"<tr>");
/* Write icon to remove the field */
2017-04-28 11:38:21 +02:00
fprintf (Gbl.F.Out,"<td class=\"BM\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActReqRemFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
2015-07-22 19:59:28 +02:00
Lay_PutIconRemove ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Name of the field */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActRenFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FieldName\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 01:21:21 +01:00
Rec_MAX_CHARS_NAME_FIELD,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Name,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Number of lines in the form */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActChgRowFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
2015-10-23 01:31:08 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"NumLines\""
" size=\"2\" maxlength=\"2\" value=\"%u\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].NumLines,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
2014-12-01 23:55:08 +01:00
/* Visibility of a field */
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
Act_FormStart (ActChgVisFie);
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
fprintf (Gbl.F.Out,"<select name=\"Visibility\""
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 (Vis = (Rec_VisibilityRecordFields_t) 0;
Vis < (Rec_VisibilityRecordFields_t) Rec_NUM_TYPES_VISIBILITY;
Vis++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Vis);
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Vis)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_RECORD_FIELD_VISIBILITY_MENU[Vis]);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
}
}
/*****************************************************************************/
/******************* Show form to create a new record field ******************/
/*****************************************************************************/
void Rec_ShowFormCreateRecordField (void)
{
2017-03-20 11:30:19 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2014-12-01 23:55:08 +01:00
extern const char *Txt_New_record_field;
extern const char *Txt_RECORD_FIELD_VISIBILITY_MENU[Rec_NUM_TYPES_VISIBILITY];
extern const char *Txt_Create_record_field;
Rec_VisibilityRecordFields_t Vis;
/***** Start form *****/
Act_FormStart (ActNewFie);
/***** Start of frame *****/
2017-03-20 11:30:19 +01:00
Lay_StartRoundFrameTable (NULL,Txt_New_record_field,NULL,
Hlp_USERS_Students_course_record_card,2);
2014-12-01 23:55:08 +01:00
/***** Write heading *****/
Rec_WriteHeadingRecordFields ();
/***** Write disabled icon to remove the field *****/
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
/***** Field name *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"<input type=\"text\" name=\"FieldName\""
2016-11-19 20:09:52 +01:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
2017-03-08 01:21:21 +01:00
Rec_MAX_CHARS_NAME_FIELD,Gbl.CurrentCrs.Records.Field.Name);
2014-12-01 23:55:08 +01:00
/***** Number of lines in form ******/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
2015-10-23 01:31:08 +02:00
"<input type=\"text\" name=\"NumLines\""
2016-11-19 20:09:52 +01:00
" size=\"2\" maxlength=\"2\" value=\"%u\""
" required=\"required\" />"
2014-12-01 23:55:08 +01:00
"</td>",
Gbl.CurrentCrs.Records.Field.NumLines);
/***** Visibility to students *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"<select name=\"Visibility\">");
for (Vis = (Rec_VisibilityRecordFields_t) 0;
Vis < (Rec_VisibilityRecordFields_t) Rec_NUM_TYPES_VISIBILITY;
Vis++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Vis);
if (Gbl.CurrentCrs.Records.Field.Visibility == Vis)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_RECORD_FIELD_VISIBILITY_MENU[Vis]);
}
fprintf (Gbl.F.Out,"</select>"
"</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_record_field);
2015-03-24 17:47:26 +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 heading of groups **************************/
/*****************************************************************************/
static void Rec_WriteHeadingRecordFields (void)
{
extern const char *Txt_Field_BR_name;
extern const char *Txt_No_of_BR_lines;
extern const char *Txt_Visible_by_BR_the_student;
fprintf (Gbl.F.Out,"<tr>"
2014-12-27 00:28:19 +01:00
"<th></th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2015-09-06 20:02:14 +02:00
"<th class=\"CENTER_MIDDLE\">"
2014-12-27 00:28:19 +01:00
"%s"
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
Txt_Field_BR_name,
Txt_No_of_BR_lines,
Txt_Visible_by_BR_the_student);
}
/*****************************************************************************/
/*************** Receive data from a form of record fields *******************/
/*****************************************************************************/
void Rec_ReceiveFormField (void)
{
extern const char *Txt_The_record_field_X_already_exists;
extern const char *Txt_You_must_specify_the_name_of_the_new_record_field;
/***** Get parameters from the form *****/
/* Get the name of the field */
2017-03-11 18:59:13 +01:00
Par_GetParToText ("FieldName",Gbl.CurrentCrs.Records.Field.Name,
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* Get the number of lines */
2017-01-29 21:41:08 +01:00
Gbl.CurrentCrs.Records.Field.NumLines = (unsigned)
Par_GetParToUnsignedLong ("NumLines",
Rec_MIN_LINES_IN_EDITION_FIELD,
Rec_MAX_LINES_IN_EDITION_FIELD,
Rec_DEF_LINES_IN_EDITION_FIELD);
2014-12-01 23:55:08 +01:00
/* Get the field visibility by students */
2017-01-29 12:42:19 +01:00
Gbl.CurrentCrs.Records.Field.Visibility = (Rec_VisibilityRecordFields_t)
2017-01-29 21:41:08 +01:00
Par_GetParToUnsignedLong ("Visibility",
0,
Rec_NUM_TYPES_VISIBILITY - 1,
(unsigned long) Rec_VISIBILITY_DEFAULT);
2014-12-01 23:55:08 +01:00
if (Gbl.CurrentCrs.Records.Field.Name[0]) // If there's a name
{
/***** If the field already was in the database... *****/
if (Rec_CheckIfRecordFieldIsRepeated (Gbl.CurrentCrs.Records.Field.Name))
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_already_exists,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
else // Add the new field to the database
Rec_CreateRecordField ();
}
else // If there is not name
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_ERROR,Txt_You_must_specify_the_name_of_the_new_record_field);
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********* Get number of lines of the form to edit a record field ************/
/*****************************************************************************/
unsigned Rec_ConvertToNumLinesField (const char *StrNumLines)
{
int NumLines;
if (sscanf (StrNumLines,"%d",&NumLines) != 1)
2017-01-29 12:42:19 +01:00
return Rec_DEF_LINES_IN_EDITION_FIELD;
2014-12-01 23:55:08 +01:00
else if (NumLines < Rec_MIN_LINES_IN_EDITION_FIELD)
return Rec_MIN_LINES_IN_EDITION_FIELD;
else if (NumLines > Rec_MAX_LINES_IN_EDITION_FIELD)
return Rec_MAX_LINES_IN_EDITION_FIELD;
return (unsigned) NumLines;
}
/*****************************************************************************/
/* Check if the name of the field of record equals any of the existing ones **/
/*****************************************************************************/
bool Rec_CheckIfRecordFieldIsRepeated (const char *FieldName)
{
bool FieldIsRepeated = false;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow,NumRows;
/* Query database */
if ((NumRows = Rec_GetAllFieldsInCurrCrs (&mysql_res)) > 0) // If se han encontrado groups...
/* Compare with all the tipos of group from the database */
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next type of group */
row = mysql_fetch_row (mysql_res);
/* The name of the field is in row[1] */
if (!strcasecmp (FieldName,row[1]))
{
FieldIsRepeated = true;
break;
}
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
return FieldIsRepeated;
}
/*****************************************************************************/
/******* Get the fields of records already present in current course *********/
/*****************************************************************************/
unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
{
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
/***** Get fields of cards of current course from database *****/
2014-12-27 19:43:01 +01:00
sprintf (Query,"SELECT FieldCod,FieldName,Visibility"
" FROM crs_record_fields"
2017-03-24 01:09:27 +01:00
" WHERE CrsCod=%ld ORDER BY FieldName",
2014-12-27 19:43:01 +01:00
Gbl.CurrentCrs.Crs.CrsCod);
return DB_QuerySELECT (Query,mysql_res,
"can not get fields of cards of a course");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************* Create a field of record **************************/
/*****************************************************************************/
void Rec_CreateRecordField (void)
{
extern const char *Txt_Created_new_record_field_X;
2017-03-11 18:59:13 +01:00
char Query[256 + Rec_MAX_BYTES_NAME_FIELD];
2014-12-01 23:55:08 +01:00
/***** Create the new field *****/
2014-12-27 13:49:17 +01:00
sprintf (Query,"INSERT INTO crs_record_fields"
" (CrsCod,FieldName,NumLines,Visibility)"
2017-03-13 13:17:53 +01:00
" VALUES"
2017-03-24 01:09:27 +01:00
" (%ld,'%s',%u,%u)",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Crs.CrsCod,
2014-12-27 13:49:17 +01:00
Gbl.CurrentCrs.Records.Field.Name,
Gbl.CurrentCrs.Records.Field.NumLines,
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
DB_QueryINSERT (Query,"can not create field of record");
2014-12-27 19:43:01 +01:00
/***** Write message of success *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_Created_new_record_field_X,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Request the removing of a field of records *****************/
/*****************************************************************************/
void Rec_ReqRemField (void)
{
unsigned NumRecords;
/***** Get the code of field *****/
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/***** Check if exists any record with that field filled *****/
if ((NumRecords = Rec_CountNumRecordsInCurrCrsWithField (Gbl.CurrentCrs.Records.Field.FieldCod))) // There are records with that field filled
Rec_AskConfirmRemFieldWithRecords (NumRecords);
else // There are no records with that field filled
Rec_RemoveFieldFromDB ();
}
/*****************************************************************************/
/************ Get a parameter with a code of field of records ****************/
/*****************************************************************************/
long Rec_GetFieldCod (void)
{
/***** Get the code of the field *****/
2017-01-28 20:32:50 +01:00
return Par_GetParToLong ("FieldCod");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Get the number of records with a field filled ***************/
/*****************************************************************************/
unsigned Rec_CountNumRecordsInCurrCrsWithField (long FieldCod)
{
2015-03-18 01:06:43 +01:00
char Query[128];
2014-12-01 23:55:08 +01:00
/***** Get number of cards with a given field in a course from database *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"SELECT COUNT(*) FROM crs_records WHERE FieldCod=%ld",
2015-03-18 01:06:43 +01:00
FieldCod);
2017-04-28 11:38:21 +02:00
return (unsigned) DB_QueryCOUNT (Query,"can not get number of cards"
" with a given field not empty"
" in a course");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******* Request confirmation for the removing of a field with records *******/
/*****************************************************************************/
void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
{
extern const char *Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X;
extern const char *Txt_this_field_is_filled_in_the_record_of_one_student;
extern const char *Txt_this_field_is_filled_in_the_records_of_X_students;
extern const char *Txt_Remove_record_field;
char Message_part2[512];
/***** Get from the database the name of the field *****/
2017-01-17 03:10:43 +01:00
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,
Gbl.CurrentCrs.Records.Field.Name,
&Gbl.CurrentCrs.Records.Field.NumLines,
&Gbl.CurrentCrs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
2017-04-28 11:38:21 +02:00
/***** Show question and button to remove my photo *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name,Gbl.CurrentCrs.Crs.FullName);
if (NumRecords == 1)
2017-05-10 10:25:01 +02:00
Str_Concat (Gbl.Alert.Txt,Txt_this_field_is_filled_in_the_record_of_one_student,
2017-05-11 23:45:46 +02:00
Ale_MAX_BYTES_ALERT);
2014-12-01 23:55:08 +01:00
else
{
sprintf (Message_part2,Txt_this_field_is_filled_in_the_records_of_X_students,
NumRecords);
2017-05-10 10:25:01 +02:00
Str_Concat (Gbl.Alert.Txt,Message_part2,
2017-05-11 23:45:46 +02:00
Ale_MAX_BYTES_ALERT);
2014-12-01 23:55:08 +01:00
}
2017-05-11 23:45:46 +02:00
Ale_ShowAlertAndButton (Ale_QUESTION,Gbl.Alert.Txt,
2017-05-11 21:53:37 +02:00
ActRemFie,NULL,Rec_PutParamFielCod,
Lay_REMOVE_BUTTON,Txt_Remove_record_field);
2017-04-28 11:38:21 +02:00
/***** List record fields again *****/
Rec_ReqEditRecordFields ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Remove from the database a field of records ******************/
/*****************************************************************************/
void Rec_RemoveFieldFromDB (void)
{
extern const char *Txt_Record_field_X_removed;
2017-03-11 18:59:13 +01:00
char Query[128];
2014-12-01 23:55:08 +01:00
/***** Get from the database the name of the field *****/
2017-03-11 18:59:13 +01:00
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,
Gbl.CurrentCrs.Records.Field.Name,
&Gbl.CurrentCrs.Records.Field.NumLines,
&Gbl.CurrentCrs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
/***** Remove field from all records *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"DELETE FROM crs_records WHERE FieldCod=%ld",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryDELETE (Query,"can not remove field from all students' records");
/***** Remove the field *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"DELETE FROM crs_record_fields WHERE FieldCod=%ld",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryDELETE (Query,"can not remove field of record");
/***** Write message to show the change made *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_Record_field_X_removed,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
/***** Show the form again *****/
Rec_ReqEditRecordFields ();
}
2017-04-28 11:38:21 +02:00
/*****************************************************************************/
/********************** Put parameter with field code ************************/
/*****************************************************************************/
static void Rec_PutParamFielCod (void)
{
Par_PutHiddenParamLong ("FieldCod",Gbl.CurrentCrs.Records.Field.FieldCod);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** Get the data of a field of records from its code *************/
/*****************************************************************************/
2017-03-08 01:21:21 +01:00
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
2017-01-15 22:58:26 +01:00
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility)
2014-12-01 23:55:08 +01:00
{
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned Vis;
/***** Get a field of a record in a course from database *****/
sprintf (Query,"SELECT FieldName,NumLines,Visibility FROM crs_record_fields"
2017-03-24 01:09:27 +01:00
" WHERE CrsCod=%ld AND FieldCod=%ld",
2017-03-11 18:59:13 +01:00
Gbl.CurrentCrs.Crs.CrsCod,FieldCod);
2014-12-01 23:55:08 +01:00
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get a field of a record in a course");
/***** Count number of rows in result *****/
if (NumRows != 1)
Lay_ShowErrorAndExit ("Error when getting a field of a record in a course.");
/***** Get the field *****/
row = mysql_fetch_row (mysql_res);
/* Name of the field */
2017-01-17 03:10:43 +01:00
Str_Copy (Name,row[0],
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/* Number of lines of the field (row[1]) */
*NumLines = Rec_ConvertToNumLinesField (row[1]);
/* Visible or editable by students? (row[2]) */
if (sscanf (row[2],"%u",&Vis) != 1)
Lay_ShowErrorAndExit ("Error when getting a field of a record in a course.");
if (Vis < Rec_NUM_TYPES_VISIBILITY)
*Visibility = (Rec_VisibilityRecordFields_t) Vis;
else
2017-01-29 12:42:19 +01:00
*Visibility = Rec_VISIBILITY_DEFAULT;
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/************************* Remove a field of records *************************/
/*****************************************************************************/
void Rec_RemoveField (void)
{
/***** Get the code of the field *****/
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/***** Borrarlo from the database *****/
Rec_RemoveFieldFromDB ();
}
/*****************************************************************************/
/************************** Rename a field of records ************************/
/*****************************************************************************/
void Rec_RenameField (void)
{
extern const char *Txt_You_can_not_leave_the_name_of_the_field_X_empty;
extern const char *Txt_The_record_field_X_already_exists;
extern const char *Txt_The_record_field_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_field_X_has_not_changed;
2017-03-11 18:59:13 +01:00
char Query[256 + Rec_MAX_BYTES_NAME_FIELD];
2017-03-08 01:21:21 +01:00
char NewFieldName[Rec_MAX_BYTES_NAME_FIELD + 1];
2014-12-01 23:55:08 +01:00
/***** Get parameters of the form *****/
/* Get the code of the field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new group name */
2017-03-08 01:21:21 +01:00
Par_GetParToText ("FieldName",NewFieldName,Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
/***** Get from the database the antiguo group name *****/
2017-03-11 18:59:13 +01:00
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,
Gbl.CurrentCrs.Records.Field.Name,
&Gbl.CurrentCrs.Records.Field.NumLines,
&Gbl.CurrentCrs.Records.Field.Visibility);
2014-12-01 23:55:08 +01:00
/***** Check if new name is empty *****/
if (!NewFieldName[0])
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_You_can_not_leave_the_name_of_the_field_X_empty,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
else
{
/***** Check if the name of the olde field match the new one
(this happens when return is pressed without changes) *****/
if (strcmp (Gbl.CurrentCrs.Records.Field.Name,NewFieldName)) // Different names
{
/***** If the group ya estaba in the database... *****/
if (Rec_CheckIfRecordFieldIsRepeated (NewFieldName))
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_already_exists,
2014-12-01 23:55:08 +01:00
NewFieldName);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
else
{
/* Update the table of fields changing then old name by the new one */
2017-03-11 18:59:13 +01:00
sprintf (Query,"UPDATE crs_record_fields SET FieldName='%s'"
2017-03-24 01:09:27 +01:00
" WHERE FieldCod=%ld",
2014-12-01 23:55:08 +01:00
NewFieldName,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update name of field of record");
/***** Write message to show the change made *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_record_field_X_has_been_renamed_as_Y,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name,NewFieldName);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
}
else // The same name
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_name_of_the_field_X_has_not_changed,
2014-12-01 23:55:08 +01:00
NewFieldName);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
}
/***** Show the form again *****/
2017-01-15 22:58:26 +01:00
Str_Copy (Gbl.CurrentCrs.Records.Field.Name,NewFieldName,
2017-03-08 01:21:21 +01:00
Rec_MAX_BYTES_NAME_FIELD);
2014-12-01 23:55:08 +01:00
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********* Change number of lines of the form of a field of records **********/
/*****************************************************************************/
void Rec_ChangeLinesField (void)
{
extern const char *Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed;
extern const char *Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y;
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
unsigned NewNumLines;
/***** Get parameters of the form *****/
/* Get the code of field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new number of lines */
2017-01-29 21:41:08 +01:00
NewNumLines = (unsigned)
Par_GetParToUnsignedLong ("NumLines",
Rec_MIN_LINES_IN_EDITION_FIELD,
Rec_MAX_LINES_IN_EDITION_FIELD,
Rec_DEF_LINES_IN_EDITION_FIELD);
2014-12-01 23:55:08 +01:00
/* Get from the database the number of lines of the field */
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Check if the old number of rows antiguo match the new one
(this happens when return is pressed without changes) *****/
if (Gbl.CurrentCrs.Records.Field.NumLines == NewNumLines)
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
else
{
/***** Update of the table of fields changing the old maximum of students by the new one *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"UPDATE crs_record_fields SET NumLines=%u"
" WHERE FieldCod=%ld",
2014-12-01 23:55:08 +01:00
NewNumLines,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update the number of lines of a field of record");
/***** Write message to show the change made *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name,NewNumLines);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
/***** Show the form again *****/
Gbl.CurrentCrs.Records.Field.NumLines = NewNumLines;
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/************ Change wisibility by students of a field of records ************/
/*****************************************************************************/
void Rec_ChangeVisibilityField (void)
{
extern const char *Txt_The_visibility_of_the_record_field_X_has_not_changed;
extern const char *Txt_RECORD_FIELD_VISIBILITY_MSG[Rec_NUM_TYPES_VISIBILITY];
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
Rec_VisibilityRecordFields_t NewVisibility;
/***** Get parameters of the form *****/
/* Get the code of field */
if ((Gbl.CurrentCrs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1)
Lay_ShowErrorAndExit ("Code of field is missing.");
/* Get the new visibility of the field */
2017-01-29 12:42:19 +01:00
NewVisibility = (Rec_VisibilityRecordFields_t)
2017-01-29 21:41:08 +01:00
Par_GetParToUnsignedLong ("Visibility",
0,
Rec_NUM_TYPES_VISIBILITY - 1,
(unsigned long) Rec_VISIBILITY_DEFAULT);
2014-12-01 23:55:08 +01:00
/* Get from the database the visibility of the field */
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Check if the old visibility matches the new one
(this happens whe return is pressed without changes in the form) *****/
if (Gbl.CurrentCrs.Records.Field.Visibility == NewVisibility)
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_The_visibility_of_the_record_field_X_has_not_changed,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
else
{
/***** Update of the table of fields changing the old visibility by the new *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"UPDATE crs_record_fields SET Visibility=%u"
" WHERE FieldCod=%ld",
2014-12-01 23:55:08 +01:00
(unsigned) NewVisibility,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE (Query,"can not update the visibility of a field of record");
/***** Write message to show the change made *****/
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_RECORD_FIELD_VISIBILITY_MSG[NewVisibility],
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.Field.Name);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
/***** Show the form again *****/
Gbl.CurrentCrs.Records.Field.Visibility = NewVisibility;
Rec_ReqEditRecordFields ();
}
/*****************************************************************************/
/********************** Liberar list of fields of records ********************/
/*****************************************************************************/
void Rec_FreeListFields (void)
{
if (Gbl.CurrentCrs.Records.LstFields.NestedCalls > 0)
if (--Gbl.CurrentCrs.Records.LstFields.NestedCalls == 0)
if (Gbl.CurrentCrs.Records.LstFields.Lst)
{
free ((void *) Gbl.CurrentCrs.Records.LstFields.Lst);
Gbl.CurrentCrs.Records.LstFields.Lst = NULL;
Gbl.CurrentCrs.Records.LstFields.Num = 0;
}
}
/*****************************************************************************/
/******************* Put a link to list official students ********************/
/*****************************************************************************/
void Rec_PutLinkToEditRecordFields (void)
{
extern const char *Txt_Edit_record_fields;
/***** Link to edit record fields *****/
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActEdiRecFie,NULL,NULL,
2016-07-01 16:32:42 +02:00
"edit64x64.png",
Txt_Edit_record_fields,Txt_Edit_record_fields,
NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Draw records of several guests **********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsGstsShow (void)
{
2017-05-10 10:09:19 +02:00
Gbl.Action.Original = ActSeeRecSevGst; // Used to know where to go when confirming ID
2017-05-09 20:56:02 +02:00
Rec_ListRecordsGsts (Rec_SHA_RECORD_LIST);
}
void Rec_ListRecordsGstsPrint (void)
{
Rec_ListRecordsGsts (Rec_SHA_RECORD_PRINT);
}
static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_must_select_one_ore_more_users;
2017-05-10 09:39:38 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2017-05-10 10:09:19 +02:00
char Anchor[32];
2014-12-01 23:55:08 +01:00
/***** Assign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_GUESTS;
/***** Get parameter with number of user records per page (only for printing) *****/
2017-05-09 20:56:02 +02:00
if (TypeOfView == Rec_SHA_RECORD_PRINT)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected users *****/
2016-07-04 14:03:04 +02:00
Usr_GetListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
/* Check the number of students to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no students selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_users);
2014-12-01 23:55:08 +01:00
Usr_SeeGuests (); // ...show again the form
return;
}
2017-05-09 20:56:02 +02:00
if (TypeOfView == Rec_SHA_RECORD_LIST) // Listing several records
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Link to print view */
2015-09-17 16:54:02 +02:00
Act_FormStart (ActPrnRecSevGst);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevGst,Gbl.Usrs.Select.All);
2014-12-01 23:55:08 +01:00
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
UsrDat.Accepted = false; // Guests have no courses,...
// ...so they have not accepted...
// ...inscription in any course
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
{
2017-05-10 09:39:38 +02:00
/* Start container for this user */
2017-05-10 10:09:19 +02:00
sprintf (Anchor,"record_%u",NumUsr);
fprintf (Gbl.F.Out,"<section id=\"%s\" class=\"REC_USR\"",
Anchor);
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevGst &&
2017-05-10 09:39:38 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2017-05-11 23:45:46 +02:00
Ale_ShowPendingAlert ();
2017-05-10 10:09:19 +02:00
2016-11-18 01:07:00 +01:00
/* Shared record */
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_SHA\">");
2017-05-10 10:09:19 +02:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,Anchor);
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* End container for this user */
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
2016-07-04 14:03:04 +02:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
}
2015-03-05 01:55:46 +01:00
/*****************************************************************************/
/********** Get user's data and draw record of one unique student ************/
/*****************************************************************************/
void Rec_GetUsrAndShowRecordOneStdCrs (void)
{
/***** Get the selected student *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2015-03-05 01:55:46 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the student
2016-12-09 13:59:33 +01:00
if (Usr_CheckIfICanViewRecordStd (&Gbl.Usrs.Other.UsrDat))
2015-03-05 01:55:46 +01:00
Rec_ShowRecordOneStdCrs ();
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************** Draw record of one unique student **********************/
/*****************************************************************************/
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneStdCrs (void)
2014-12-01 23:55:08 +01:00
{
2017-03-30 11:20:06 +02:00
/***** Get if student has accepted enrolment in current course *****/
2015-09-17 11:21:49 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2015-03-05 01:55:46 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
2017-05-10 10:09:19 +02:00
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
2017-05-09 10:32:54 +02:00
/***** Put contextual links *****/
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
2017-05-09 10:32:54 +02:00
/* Link to edit record fields */
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
2017-05-09 10:32:54 +02:00
/* Link to print view */
2014-12-01 23:55:08 +01:00
Act_FormStart (ActPrnRecSevStd);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Show optional alert (result of editing data in course record) *****/
2017-05-11 23:45:46 +02:00
Ale_ShowPendingAlert ();
2017-05-09 10:32:54 +02:00
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
fprintf (Gbl.F.Out,"<section class=\"REC_USR\">");
2016-11-18 01:07:00 +01:00
/***** Shared record *****/
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_SHA\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2015-03-29 22:36:21 +02:00
/***** Record of the student in the course *****/
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
{
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
2017-05-10 10:09:19 +02:00
{
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
2017-05-08 20:48:27 +02:00
Rec_ShowCrsRecord (Rec_CRS_LIST_ONE_RECORD,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"</section>");
}
2015-10-03 21:10:47 +02:00
else if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT &&
Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // It's me
2017-05-10 10:09:19 +02:00
{
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
2016-11-18 00:17:53 +01:00
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_FORM,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"</section>");
}
2015-03-29 22:36:21 +02:00
}
2017-05-10 10:09:19 +02:00
/***** End container for this user *****/
fprintf (Gbl.F.Out,"</section>");
/***** Free list of fields of records *****/
2015-03-29 22:36:21 +02:00
Rec_FreeListFields ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several students ***********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsStdsShow (void)
2015-10-03 21:10:47 +02:00
{
2017-05-10 10:09:19 +02:00
Gbl.Action.Original = ActSeeRecSevStd; // Used to know where to go when confirming ID...
// ...or changing course record
2016-11-18 00:17:53 +01:00
Rec_ListRecordsStds (Rec_SHA_RECORD_LIST,
2017-05-08 20:48:27 +02:00
Rec_CRS_LIST_SEVERAL_RECORDS);
2015-10-03 21:10:47 +02:00
}
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsStdsPrint (void)
2015-10-03 21:10:47 +02:00
{
2016-11-18 00:17:53 +01:00
Rec_ListRecordsStds (Rec_SHA_RECORD_PRINT,
2017-05-08 20:48:27 +02:00
Rec_CRS_PRINT_SEVERAL_RECORDS);
2015-10-03 21:10:47 +02:00
}
2016-11-18 00:17:53 +01:00
static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
Rec_CourseRecordViewType_t CrsTypeOfView)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_You_must_select_one_ore_more_students;
2015-10-03 21:10:47 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2017-05-10 10:09:19 +02:00
char Anchor[32];
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS;
/***** Get parameter with number of user records per page (only for printing) *****/
2016-11-18 00:17:53 +01:00
if (ShaTypeOfView == Rec_SHA_RECORD_PRINT)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected students *****/
2016-07-04 14:03:04 +02:00
Usr_GetListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
/* Check the number of students to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no students selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_students);
2014-12-01 23:55:08 +01:00
Usr_SeeStudents (); // ...show again the form
return;
}
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
2016-11-18 00:17:53 +01:00
if (ShaTypeOfView == Rec_SHA_RECORD_LIST)
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Link to edit record fields */
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
2014-12-01 23:55:08 +01:00
Rec_PutLinkToEditRecordFields ();
/* Link to print view */
Act_FormStart (ActPrnRecSevStd);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevStd,Gbl.Usrs.Select.All);
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
2015-09-17 11:21:49 +02:00
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
false))
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
/* Check if this user has accepted
2015-10-03 21:10:47 +02:00
his/her inscription in the current course */
2015-09-17 11:21:49 +02:00
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* Start container for this user */
2017-05-09 12:29:25 +02:00
sprintf (Anchor,"record_%u",NumUsr);
fprintf (Gbl.F.Out,"<section id=\"%s\" class=\"REC_USR\"",
Anchor);
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevStd &&
2015-10-03 21:10:47 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
2017-05-09 12:29:25 +02:00
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-09 12:29:25 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2017-05-11 23:45:46 +02:00
Ale_ShowPendingAlert ();
2017-05-08 20:13:27 +02:00
2016-11-18 01:07:00 +01:00
/* Shared record */
2017-05-09 12:29:25 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_SHA\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (ShaTypeOfView,&UsrDat,Anchor);
2017-05-09 12:29:25 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
/* Record of the student in the course */
2015-07-17 13:06:32 +02:00
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
2015-10-03 21:10:47 +02:00
if ( Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
(Gbl.Usrs.Me.LoggedRole == Rol_STUDENT && // I am student in this course...
2017-05-08 20:13:27 +02:00
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)) // ...and it's me
2017-05-09 12:29:25 +02:00
{
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
2016-11-18 00:17:53 +01:00
Rec_ShowCrsRecord (CrsTypeOfView,&UsrDat,Anchor);
2017-05-09 12:29:25 +02:00
fprintf (Gbl.F.Out,"</section>");
}
2017-05-10 09:39:38 +02:00
/* End container for this user */
2015-10-03 21:10:47 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2015-10-03 21:10:47 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
2015-09-17 11:21:49 +02:00
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
/***** Free list of fields of records *****/
2016-11-18 00:17:53 +01:00
Rec_FreeListFields ();
2014-12-01 23:55:08 +01:00
2016-07-04 14:03:04 +02:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
}
2015-03-05 01:55:46 +01:00
/*****************************************************************************/
/********** Get user's data and draw record of one unique teacher ************/
/*****************************************************************************/
void Rec_GetUsrAndShowRecordOneTchCrs (void)
{
/***** Get the selected teacher *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2015-03-05 01:55:46 +01:00
/***** Show the record *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the teacher
2016-12-09 13:59:33 +01:00
if (Usr_CheckIfICanViewRecordTch (&Gbl.Usrs.Other.UsrDat))
2015-03-05 01:55:46 +01:00
Rec_ShowRecordOneTchCrs ();
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************** Draw record of one unique teacher **********************/
/*****************************************************************************/
2015-03-05 18:58:59 +01:00
static void Rec_ShowRecordOneTchCrs (void)
2014-12-01 23:55:08 +01:00
{
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_timetable;
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2017-01-28 15:58:46 +01:00
char Width[10 + 2 + 1];
2016-11-27 17:30:10 +01:00
bool ShowOfficeHours;
2015-12-01 01:09:55 +01:00
/***** Width for office hours *****/
2015-12-13 17:49:53 +01:00
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
2017-03-30 11:20:06 +02:00
/***** Get if teacher has accepted enrolment in current course *****/
2015-09-17 11:21:49 +02:00
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2015-03-05 01:55:46 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
2016-11-27 17:30:10 +01:00
/***** Get if I want to see teachers' office hours in teachers' records *****/
ShowOfficeHours = Rec_GetParamShowOfficeHours ();
2015-04-02 14:22:21 +02:00
/***** Show contextual menu *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
2015-04-02 14:22:21 +02:00
/* Show office hours? */
2016-11-27 17:30:10 +01:00
Rec_WriteFormShowOfficeHoursOneTch (ShowOfficeHours);
2014-12-01 23:55:08 +01:00
2015-04-02 14:22:21 +02:00
/* Link to print view */
2014-12-01 23:55:08 +01:00
Act_FormStart (ActPrnRecSevTch);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",'Y');
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-04-02 14:22:21 +02:00
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
fprintf (Gbl.F.Out,"<section class=\"REC_USR\">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Shared record *****/
fprintf (Gbl.F.Out,"<section class=\"REC_SHA\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Other.UsrDat,NULL);
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Office hours *****/
2016-11-27 17:30:10 +01:00
if (ShowOfficeHours)
{
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_TT\">");
2017-04-24 13:00:59 +02:00
Gbl.TimeTable.Type = TT_TUTORING_TIMETABLE;
2016-11-27 17:30:10 +01:00
Lay_StartRoundFrame (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],
NULL,Hlp_USERS_Teachers_timetable);
TT_ShowTimeTable (Gbl.Usrs.Other.UsrDat.UsrCod);
Lay_EndRoundFrame ();
2017-05-10 10:09:19 +02:00
fprintf (Gbl.F.Out,"</section>");
2016-11-27 17:30:10 +01:00
}
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Start container for this user *****/
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Draw records of several teachers ***********************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
void Rec_ListRecordsTchsShow (void)
{
2017-05-10 10:09:19 +02:00
Gbl.Action.Original = ActSeeRecSevTch; // Used to know where to go when confirming ID
2017-05-09 20:56:02 +02:00
Rec_ListRecordsTchs (Rec_SHA_RECORD_LIST);
}
void Rec_ListRecordsTchsPrint (void)
{
Rec_ListRecordsTchs (Rec_SHA_RECORD_PRINT);
}
static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
2014-12-01 23:55:08 +01:00
{
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_timetable;
2014-12-01 23:55:08 +01:00
extern const char *Txt_You_must_select_one_ore_more_teachers;
2015-01-02 12:57:26 +01:00
extern const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES];
2017-05-10 09:39:38 +02:00
unsigned NumUsr = 0;
2014-12-01 23:55:08 +01:00
const char *Ptr;
struct UsrData UsrDat;
2017-05-10 10:09:19 +02:00
char Anchor[32];
2014-12-01 23:55:08 +01:00
bool ShowOfficeHours;
2017-01-28 15:58:46 +01:00
char Width[10 + 2 + 1];
2015-12-01 01:09:55 +01:00
/***** Width for office hours *****/
2015-12-13 17:49:53 +01:00
sprintf (Width,"%upx",Rec_RECORD_WIDTH);
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/***** Assign users listing type depending on current action *****/
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
/***** Get if I want to see teachers' office hours in teachers' records *****/
ShowOfficeHours = Rec_GetParamShowOfficeHours ();
/***** Get parameter with number of user records per page (only for printing) *****/
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevTch)
2014-12-01 23:55:08 +01:00
Rec_GetParamRecordsPerPage ();
/***** Get list of selected teachers *****/
2016-07-04 14:03:04 +02:00
Usr_GetListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
/* Check the number of teachers to show */
2015-09-30 23:10:15 +02:00
if (!Usr_CountNumUsrsInListOfSelectedUsrs ()) // If no teachers selected...
2014-12-01 23:55:08 +01:00
{ // ...write warning notice
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_teachers);
2014-12-01 23:55:08 +01:00
Usr_SeeTeachers (); // ...show again the form
return;
}
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActSeeRecSevTch)
2014-12-01 23:55:08 +01:00
{
2015-04-02 14:22:21 +02:00
/***** Show contextual menu *****/
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
/* Show office hours? */
2016-11-27 17:30:10 +01:00
Rec_WriteFormShowOfficeHoursSeveralTchs (ShowOfficeHours);
2014-12-01 23:55:08 +01:00
/* Link to print view */
Act_FormStart (ActPrnRecSevTch);
Usr_PutHiddenParUsrCodAll (ActPrnRecSevTch,Gbl.Usrs.Select.All);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
Par_PutHiddenParamChar ("ShowOfficeHours",
ShowOfficeHours ? 'Y' :
'N');
Rec_ShowLinkToPrintPreviewOfRecords ();
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2015-04-02 14:22:21 +02:00
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
}
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** List the records *****/
Ptr = Gbl.Usrs.Select.All;
while (*Ptr)
{
2017-03-13 14:22:36 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
2014-12-01 23:55:08 +01:00
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
2015-09-17 11:21:49 +02:00
if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
false))
2014-12-01 23:55:08 +01:00
{
2017-05-10 09:39:38 +02:00
/* Check if this user has accepted
his/her inscription in the current course */
2015-09-17 11:21:49 +02:00
UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
/* Start container for this user */
sprintf (Anchor,"record_%u",NumUsr);
fprintf (Gbl.F.Out,"<section id=\"%s\" class=\"REC_USR\"",
Anchor);
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act == ActPrnRecSevTch &&
2017-05-10 09:39:38 +02:00
NumUsr != 0 &&
(NumUsr % Gbl.Usrs.Listing.RecsPerPag) == 0)
fprintf (Gbl.F.Out," style=\"page-break-before:always;\"");
fprintf (Gbl.F.Out,">");
2014-12-01 23:55:08 +01:00
2017-05-10 10:09:19 +02:00
/* Show optional alert */
if (UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod) // Selected user
2017-05-11 23:45:46 +02:00
Ale_ShowPendingAlert ();
2017-05-10 10:09:19 +02:00
/* Shared record */
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_SHA\">");
2017-05-10 10:09:19 +02:00
Rec_ShowSharedUsrRecord (TypeOfView,&UsrDat,Anchor);
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
/* Office hours */
if (ShowOfficeHours)
{
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"<section class=\"REC_TT\">");
2017-04-24 13:00:59 +02:00
Gbl.TimeTable.Type = TT_TUTORING_TIMETABLE;
2016-11-12 22:00:50 +01:00
Lay_StartRoundFrame (Width,Txt_TIMETABLE_TYPES[Gbl.TimeTable.Type],
2016-11-18 10:08:01 +01:00
NULL,Hlp_USERS_Teachers_timetable);
2016-03-18 14:07:21 +01:00
TT_ShowTimeTable (UsrDat.UsrCod);
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrame ();
2017-05-10 09:39:38 +02:00
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
}
2017-05-10 09:39:38 +02:00
/* End container for this user */
fprintf (Gbl.F.Out,"</section>");
2014-12-01 23:55:08 +01:00
2017-05-10 09:39:38 +02:00
NumUsr++;
2014-12-01 23:55:08 +01:00
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
2016-07-04 14:03:04 +02:00
/***** Free memory used by list of selected users' codes *****/
Usr_FreeListsSelectedUsrsCods ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Show a link to print preview of users' records **************/
/*****************************************************************************/
2015-10-03 21:10:47 +02:00
static void Rec_ShowLinkToPrintPreviewOfRecords (void)
2014-12-01 23:55:08 +01:00
{
2015-07-27 21:25:45 +02:00
extern const char *The_ClassFormBold[The_NUM_THEMES];
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-01-28 01:14:14 +01:00
extern const char *Txt_Print;
2014-12-01 23:55:08 +01:00
extern const char *Txt_record_cards_per_page;
unsigned i;
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Txt_Print,The_ClassFormBold[Gbl.Prefs.Theme],NULL);
2015-12-08 22:20:44 +01:00
Lay_PutIconWithText ("print64x64.png",Txt_Print,Txt_Print);
2015-12-13 18:32:37 +01:00
fprintf (Gbl.F.Out,"</a>"
2016-12-27 16:45:37 +01:00
"<label class=\"%s\">"
"(<select name=\"RecsPerPag\">",
2015-07-28 00:16:09 +02:00
The_ClassForm[Gbl.Prefs.Theme]);
2017-01-29 12:42:19 +01:00
for (i = Rec_MIN_RECORDS_PER_PAGE;
i <= Rec_MAX_RECORDS_PER_PAGE;
2014-12-01 23:55:08 +01:00
i++)
{
fprintf (Gbl.F.Out,"<option");
if (i == Gbl.Usrs.Listing.RecsPerPag)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%u</option>",i);
}
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"</select> %s)"
"</label>",
2016-12-20 02:18:50 +01:00
Txt_record_cards_per_page);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/** Get parameter with number of user records per page (only for printing) ***/
/*****************************************************************************/
static void Rec_GetParamRecordsPerPage (void)
{
2017-01-29 21:41:08 +01:00
Gbl.Usrs.Listing.RecsPerPag = (unsigned)
Par_GetParToUnsignedLong ("RecsPerPag",
Rec_MIN_RECORDS_PER_PAGE,
Rec_MAX_RECORDS_PER_PAGE,
Rec_DEF_RECORDS_PER_PAGE);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-27 17:30:10 +01:00
/*********** Write a form to select whether show all office hours ************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-27 17:30:10 +01:00
static void Rec_WriteFormShowOfficeHoursOneTch (bool ShowOfficeHours)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Show_office_hours;
2016-11-27 17:30:10 +01:00
Lay_PutContextualCheckbox (ActSeeRecOneTch,Rec_PutParamsShowOfficeHoursOneTch,
"ShowOfficeHours",ShowOfficeHours,
Txt_Show_office_hours,
Txt_Show_office_hours);
}
static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours)
{
extern const char *Txt_Show_office_hours;
Lay_PutContextualCheckbox (ActSeeRecSevTch,Rec_PutParamsShowOfficeHoursSeveralTchs,
"ShowOfficeHours",ShowOfficeHours,
Txt_Show_office_hours,
Txt_Show_office_hours);
}
static void Rec_PutParamsShowOfficeHoursOneTch (void)
{
2017-05-08 19:54:05 +02:00
Usr_PutParamOtherUsrCodEncrypted ();
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
2016-11-27 17:30:10 +01:00
}
2014-12-01 23:55:08 +01:00
2016-11-27 17:30:10 +01:00
static void Rec_PutParamsShowOfficeHoursSeveralTchs (void)
{
Usr_PutHiddenParUsrCodAll (ActSeeRecSevTch,Gbl.Usrs.Select.All);
Par_PutHiddenParamChar ("ParamOfficeHours",'Y');
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********** Get parameter to show (or not) teachers' office hours ************/
/*****************************************************************************/
// Returns true if office hours must be shown
static bool Rec_GetParamShowOfficeHours (void)
{
2017-01-28 20:32:50 +01:00
if (Par_GetParToBool ("ParamOfficeHours"))
return Par_GetParToBool ("ShowOfficeHours");
2014-12-01 23:55:08 +01:00
return Rec_SHOW_OFFICE_HOURS_DEFAULT;
}
/*****************************************************************************/
/*************** Update my record in the course and show it ******************/
/*****************************************************************************/
void Rec_UpdateAndShowMyCrsRecord (void)
{
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** Allocate memory for the texts of the fields *****/
Rec_AllocMemFieldsRecordsCrs ();
/***** Get data of the record from the form *****/
Rec_GetFieldsCrsRecordFromForm ();
/***** Update the record *****/
Rec_UpdateCrsRecord (Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Show updated record *****/
Rec_ShowMyCrsRecordUpdated ();
/***** Free memory used for some fields *****/
Rec_FreeMemFieldsRecordsCrs ();
}
/*****************************************************************************/
2015-10-03 21:10:47 +02:00
/***** Update record in the course of one student and show records again *****/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Rec_UpdateAndShowOtherCrsRecord (void)
{
2015-10-03 21:10:47 +02:00
extern const char *Txt_Student_record_card_in_this_course_has_been_updated;
2017-05-09 20:56:02 +02:00
long OriginalActCod;
2014-12-01 23:55:08 +01:00
2017-05-08 20:13:27 +02:00
/***** Initialize alert type and message *****/
2017-05-11 23:45:46 +02:00
Gbl.Alert.Type = Ale_NONE; // Do not show alert
2017-05-08 20:13:27 +02:00
2017-05-09 20:56:02 +02:00
/***** Get where we came from *****/
OriginalActCod = Par_GetParToLong ("OriginalActCod");
Gbl.Action.Original = Act_GetActionFromActCod (OriginalActCod);
2017-05-09 10:32:54 +02:00
2015-10-03 21:10:47 +02:00
/***** Get the user whose record we want to modify *****/
2016-01-25 14:40:57 +01:00
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
2014-12-01 23:55:08 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat);
/***** Get list of fields of records in current course *****/
Rec_GetListRecordFieldsInCurrentCrs ();
/***** Allocate memory for the texts of the fields *****/
Rec_AllocMemFieldsRecordsCrs ();
/***** Get data of the record from the form *****/
Rec_GetFieldsCrsRecordFromForm ();
/***** Update the record *****/
Rec_UpdateCrsRecord (Gbl.Usrs.Other.UsrDat.UsrCod);
2017-05-11 23:45:46 +02:00
Gbl.Alert.Type = Ale_SUCCESS;
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,"%s",
2017-05-09 11:39:08 +02:00
Txt_Student_record_card_in_this_course_has_been_updated);
2017-05-09 10:32:54 +02:00
/***** Show one or multiple records *****/
2017-05-09 20:56:02 +02:00
switch (Gbl.Action.Original)
{
case ActSeeRecSevStd:
/* Show multiple records again (including the updated one) */
Rec_ListRecordsStdsShow ();
break;
default:
/* Show only the updated record of one student */
Rec_ShowRecordOneStdCrs ();
break;
}
2014-12-01 23:55:08 +01:00
/***** Free memory used for some fields *****/
Rec_FreeMemFieldsRecordsCrs ();
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/************************* Show shared record card ***************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2016-11-18 00:17:53 +01:00
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
struct UsrData *UsrDat,const char *Anchor)
2014-12-01 23:55:08 +01:00
{
2017-05-09 20:56:02 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2016-11-18 00:17:53 +01:00
extern const char *Hlp_USERS_Students_course_record_card;
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-07-17 13:06:32 +02:00
extern const char *Txt_You_dont_have_permission_to_perform_this_action;
2014-12-01 23:55:08 +01:00
extern const char *Txt_RECORD_FIELD_VISIBILITY_RECORD[Rec_NUM_TYPES_VISIBILITY];
2015-03-24 17:47:26 +01:00
extern const char *Txt_Save;
2016-11-18 00:17:53 +01:00
const char *Rec_RecordHelp[Rec_COURSE_NUM_VIEW_TYPES] =
{
Hlp_USERS_Students_course_record_card, // Rec_CRS_MY_RECORD_AS_STUDENT_FORM
Hlp_USERS_Students_course_record_card, // Rec_CRS_MY_RECORD_AS_STUDENT_CHECK
2017-05-08 20:48:27 +02:00
Hlp_USERS_Students_course_record_card, // Rec_CRS_LIST_ONE_RECORD
Hlp_USERS_Students_course_record_card, // Rec_CRS_LIST_SEVERAL_RECORDS
NULL, // Rec_CRS_PRINT_ONE_RECORD
NULL, // Rec_CRS_PRINT_SEVERAL_RECORDS
// Rec_CRS_RECORD_PRINT
2016-11-18 00:17:53 +01:00
};
2017-01-28 15:58:46 +01:00
char StrRecordWidth[10 + 1];
2015-07-17 13:06:32 +02:00
bool ItsMe;
2017-01-25 18:48:41 +01:00
bool ICanEdit = false;
2014-12-01 23:55:08 +01:00
unsigned NumField;
MYSQL_RES *mysql_res;
MYSQL_ROW row = NULL; // Initialized to avoid warning
2015-07-17 13:06:32 +02:00
bool ShowField;
2014-12-01 23:55:08 +01:00
bool ThisFieldHasText;
2017-01-25 18:48:41 +01:00
bool ICanEditThisField;
2017-01-15 22:58:26 +01:00
char Text[Cns_MAX_BYTES_TEXT + 1];
2014-12-01 23:55:08 +01:00
2015-07-17 13:06:32 +02:00
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) // I am a student
{
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod); // It's me
if (ItsMe) // It's me
switch (TypeOfView)
{
2017-05-08 20:48:27 +02:00
case Rec_CRS_LIST_ONE_RECORD:
case Rec_CRS_LIST_SEVERAL_RECORDS:
// When listing records, I can see only my record as student
2016-11-18 00:17:53 +01:00
TypeOfView = Rec_CRS_MY_RECORD_AS_STUDENT_FORM;
2015-07-17 13:06:32 +02:00
break;
2016-11-18 00:17:53 +01:00
case Rec_CRS_MY_RECORD_AS_STUDENT_FORM:
case Rec_CRS_MY_RECORD_AS_STUDENT_CHECK:
2017-05-08 20:48:27 +02:00
case Rec_CRS_PRINT_ONE_RECORD:
case Rec_CRS_PRINT_SEVERAL_RECORDS:
2015-07-17 13:06:32 +02:00
break;
default:
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
break;
}
else // It's not me ==> i am a student trying to do something forbidden
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
}
2014-12-01 23:55:08 +01:00
switch (TypeOfView)
{
2016-11-18 00:17:53 +01:00
case Rec_CRS_MY_RECORD_AS_STUDENT_FORM:
2014-12-01 23:55:08 +01:00
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
2017-01-25 18:48:41 +01:00
ICanEdit = true;
2014-12-01 23:55:08 +01:00
Act_FormStart (ActRcvRecCrs);
break;
}
break;
2016-11-18 00:17:53 +01:00
case Rec_CRS_MY_RECORD_AS_STUDENT_CHECK:
2014-12-01 23:55:08 +01:00
break;
2017-05-08 20:48:27 +02:00
case Rec_CRS_LIST_ONE_RECORD:
ICanEdit = true;
Act_FormStartAnchor (ActRcvRecOthUsr,Anchor);
2017-05-09 20:56:02 +02:00
Par_PutHiddenParamLong ("OriginalActCod",
Act_Actions[ActSeeRecOneStd].ActCod); // Original action, used to know where we came from
2017-05-08 20:48:27 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
break;
case Rec_CRS_LIST_SEVERAL_RECORDS:
2017-01-25 18:48:41 +01:00
ICanEdit = true;
2015-10-03 21:10:47 +02:00
Act_FormStartAnchor (ActRcvRecOthUsr,Anchor);
2017-05-09 20:56:02 +02:00
Par_PutHiddenParamLong ("OriginalActCod",
Act_Actions[ActSeeRecSevStd].ActCod); // Original action, used to know where we came from
2015-10-03 21:10:47 +02:00
Usr_PutHiddenParUsrCodAll (ActRcvRecOthUsr,Gbl.Usrs.Select.All);
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2014-12-01 23:55:08 +01:00
break;
2017-05-08 20:48:27 +02:00
case Rec_CRS_PRINT_ONE_RECORD:
case Rec_CRS_PRINT_SEVERAL_RECORDS:
2014-12-01 23:55:08 +01:00
break;
default:
break;
}
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2015-12-13 17:49:53 +01:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
2016-11-18 00:17:53 +01:00
Lay_StartRoundFrameTable (StrRecordWidth,NULL,
NULL,Rec_RecordHelp[TypeOfView],2);
2014-12-01 23:55:08 +01:00
/***** Header *****/
fprintf (Gbl.F.Out,"<tr>"
2017-05-01 12:36:24 +02:00
"<td colspan=\"2\" class=\"LEFT_TOP\">");
Lay_StartTableWide (0);
fprintf (Gbl.F.Out,"<tr>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2014-12-01 23:55:08 +01:00
Rec_DEGREE_LOGO_SIZE);
2015-02-01 20:17:24 +01:00
Log_DrawLogo (Sco_SCOPE_DEG,Gbl.CurrentDeg.Deg.DegCod,
2016-10-28 10:03:37 +02:00
Gbl.CurrentDeg.Deg.ShrtName,Rec_DEGREE_LOGO_SIZE,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
2015-12-13 17:49:53 +01:00
"<td class=\"REC_HEAD CENTER_MIDDLE\">"
2014-12-01 23:55:08 +01:00
"%s<br />%s<br />%s"
"</td>"
"</tr>",
Gbl.CurrentDeg.Deg.FullName,Gbl.CurrentCrs.Crs.FullName,
UsrDat->FullName);
2017-05-01 12:36:24 +02:00
Lay_EndTable ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Fields of the record that depends on the course *****/
for (NumField = 0, Gbl.RowEvenOdd = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
2015-07-17 13:06:32 +02:00
{
2016-11-18 00:17:53 +01:00
ShowField = !(TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM ||
TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_CHECK) ||
2015-07-17 13:06:32 +02:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility != Rec_HIDDEN_FIELD;
// If the field must be shown...
if (ShowField)
2014-12-01 23:55:08 +01:00
{
2017-05-08 20:48:27 +02:00
ICanEditThisField = TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS ||
2017-01-25 18:48:41 +01:00
(TypeOfView == Rec_CRS_MY_RECORD_AS_STUDENT_FORM &&
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD);
2014-12-01 23:55:08 +01:00
/* Name of the field */
fprintf (Gbl.F.Out,"<tr>"
2017-05-09 11:39:08 +02:00
"<td class=\"REC_C1_BOT %s RIGHT_TOP COLOR%u\">"
2014-12-24 19:11:42 +01:00
"%s:",
2017-01-25 18:48:41 +01:00
ICanEditThisField ? The_ClassForm[Gbl.Prefs.Theme] :
"REC_DAT_SMALL",
2017-05-09 11:39:08 +02:00
Gbl.RowEvenOdd,
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Name);
2017-05-08 20:48:27 +02:00
if (TypeOfView == Rec_CRS_LIST_ONE_RECORD ||
TypeOfView == Rec_CRS_LIST_SEVERAL_RECORDS)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<span class=\"DAT_SMALL\"> (%s)</span>",
Txt_RECORD_FIELD_VISIBILITY_RECORD[Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility]);
fprintf (Gbl.F.Out,"</td>");
/***** Get the text of the field *****/
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res))
{
ThisFieldHasText = true;
row = mysql_fetch_row (mysql_res);
}
else
ThisFieldHasText = false;
2015-12-13 17:49:53 +01:00
/***** Write form, text, or nothing depending on
the user's role and the visibility of the field *****/
2017-05-09 11:39:08 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP COLOR%u\">",
Gbl.RowEvenOdd);
2017-01-25 18:48:41 +01:00
if (ICanEditThisField) // Show with form
2014-12-01 23:55:08 +01:00
{
fprintf (Gbl.F.Out,"<textarea name=\"Field%ld\" rows=\"%u\""
2017-05-09 11:39:08 +02:00
" class=\"REC_C2_BOT_INPUT\">",
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].NumLines);
if (ThisFieldHasText)
fprintf (Gbl.F.Out,"%s",row[0]);
fprintf (Gbl.F.Out,"</textarea>");
}
else // Show without form
{
if (ThisFieldHasText)
{
2017-01-17 03:10:43 +01:00
Str_Copy (Text,row[0],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Text,Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Text);
}
else
fprintf (Gbl.F.Out,"-");
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2015-07-17 13:06:32 +02:00
}
2014-12-01 23:55:08 +01:00
2015-04-11 23:46:21 +02:00
/***** Button to save changes and end frame *****/
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2014-12-01 23:55:08 +01:00
{
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTableWithButton (Lay_CONFIRM_BUTTON,Txt_Save);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
2015-04-11 23:46:21 +02:00
else
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Get the text of a field of a record of course ****************/
/*****************************************************************************/
unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res)
{
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
/***** Get the text of a field of a record from database *****/
sprintf (Query,"SELECT Txt FROM crs_records"
2017-03-24 01:09:27 +01:00
" WHERE FieldCod=%ld AND UsrCod=%ld",
2014-12-01 23:55:08 +01:00
FieldCod,UsrCod);
return DB_QuerySELECT (Query,mysql_res,"can not get the text of a field of a record.");
}
/*****************************************************************************/
/****************** Get the fields of the record from form *******************/
/*****************************************************************************/
void Rec_GetFieldsCrsRecordFromForm (void)
{
unsigned NumField;
2017-01-28 15:58:46 +01:00
char FieldParamName[5 + 10 + 1];
2014-12-01 23:55:08 +01:00
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
/* Get text of the form */
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
Par_GetParToHTML (FieldParamName,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
}
}
/*****************************************************************************/
/*************************** Update record of a user *************************/
/*****************************************************************************/
void Rec_UpdateCrsRecord (long UsrCod)
{
unsigned NumField;
2017-01-28 15:58:46 +01:00
char Query[256 + Cns_MAX_BYTES_TEXT];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
bool FieldAlreadyExists;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
{
/***** Check if already exists this field for this user in database *****/
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
DB_FreeMySQLResult (&mysql_res);
if (FieldAlreadyExists)
{
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Update text of the field of record course *****/
sprintf (Query,"UPDATE crs_records SET Txt='%s'"
2017-03-24 01:09:27 +01:00
" WHERE UsrCod=%ld AND FieldCod=%ld",
2017-03-11 18:59:13 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
2014-12-01 23:55:08 +01:00
DB_QueryUPDATE (Query,"can not update field of record");
}
else
{
/***** Remove text of the field of record course *****/
sprintf (Query,"DELETE FROM crs_records"
2017-03-24 01:09:27 +01:00
" WHERE UsrCod=%ld AND FieldCod=%ld",
2014-12-01 23:55:08 +01:00
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
DB_QueryDELETE (Query,"can not remove field of record");
}
}
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Insert text field of record course *****/
2017-03-13 13:17:53 +01:00
sprintf (Query,"INSERT INTO crs_records"
" (FieldCod,UsrCod,Txt)"
" VALUES"
2017-03-24 01:09:27 +01:00
" (%ld,%ld,'%s')",
2014-12-27 13:49:17 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
UsrCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
2014-12-01 23:55:08 +01:00
DB_QueryINSERT (Query,"can not create field of record");
}
}
}
/*****************************************************************************/
/************ Remove fields of record of a user in current course ************/
/*****************************************************************************/
void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_User_record_card_in_the_course_X_has_been_removed;
2017-03-11 18:59:13 +01:00
char Query[256];
2014-12-01 23:55:08 +01:00
/***** Remove text of the field of record course *****/
2017-03-11 18:59:13 +01:00
sprintf (Query,"DELETE FROM crs_records"
2017-03-24 01:09:27 +01:00
" WHERE UsrCod=%ld AND FieldCod IN"
" (SELECT FieldCod FROM crs_record_fields WHERE CrsCod=%ld)",
2014-12-01 23:55:08 +01:00
UsrCod,Crs->CrsCod);
DB_QueryDELETE (Query,"can not remove user's record in a course");
/***** Write mensaje *****/
if (QuietOrVerbose == Cns_VERBOSE)
{
2017-05-10 10:25:01 +02:00
sprintf (Gbl.Alert.Txt,Txt_User_record_card_in_the_course_X_has_been_removed,
2014-12-01 23:55:08 +01:00
Crs->FullName);
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************* Remove fields of record of a user in all courses **************/
/*****************************************************************************/
void Rec_RemoveFieldsCrsRecordAll (long UsrCod,Cns_QuietOrVerbose_t QuietOrVerbose)
{
extern const char *Txt_User_record_cards_in_all_courses_have_been_removed;
char Query[128];
/***** Remove text of the field of record course *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"DELETE FROM crs_records WHERE UsrCod=%ld",UsrCod);
2014-12-01 23:55:08 +01:00
DB_QueryDELETE (Query,"can not remove user's records in all courses");
/***** Write mensaje *****/
if (QuietOrVerbose == Cns_VERBOSE)
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Txt_User_record_cards_in_all_courses_have_been_removed);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** Show my record in the course already updated ****************/
/*****************************************************************************/
2015-03-30 13:59:32 +02:00
static void Rec_ShowMyCrsRecordUpdated (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Your_record_card_in_this_course_has_been_updated;
2015-03-30 14:51:32 +02:00
/***** Write mensaje of success *****/
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_record_card_in_this_course_has_been_updated);
2014-12-01 23:55:08 +01:00
2016-11-18 01:07:00 +01:00
/***** Shared record *****/
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,&Gbl.Usrs.Me.UsrDat,NULL);
2015-03-30 14:51:32 +02:00
/***** Show updated user's record *****/
2016-11-18 00:17:53 +01:00
Rec_ShowCrsRecord (Rec_CRS_MY_RECORD_AS_STUDENT_CHECK,&Gbl.Usrs.Me.UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***** Allocate memory for the text of the field of the record in course *****/
/*****************************************************************************/
void Rec_AllocMemFieldsRecordsCrs (void)
{
unsigned NumField;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
/* Allocate memory for the texts of the fields */
2017-01-28 15:58:46 +01:00
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
}
/*****************************************************************************/
/**** Free memory used by the texts of the field of the record in course *****/
/*****************************************************************************/
void Rec_FreeMemFieldsRecordsCrs (void)
{
unsigned NumField;
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
2015-04-07 21:44:24 +02:00
if (Gbl.Usrs.Me.LoggedRole > Rol_STUDENT ||
2014-12-01 23:55:08 +01:00
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
/* Free memory of the text of the field */
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text)
{
free ((void *) Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = NULL;
}
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/*********** Show form to sign up and edit my shared record card *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowFormSignUpWithMySharedRecord (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Sign_up;
/***** Show the form *****/
Act_FormStart (ActSignUp);
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_SIGN_UP_FORM,&Gbl.Usrs.Me.UsrDat,NULL);
2015-03-24 17:47:26 +01:00
Lay_PutConfirmButton (Txt_Sign_up);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/***************** Show form to edit my shared record card *******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowFormMySharedRecord (void)
2014-12-01 23:55:08 +01:00
{
2015-03-28 18:34:08 +01:00
extern const char *Txt_Please_fill_in_your_record_card_including_your_country_nationality;
extern const char *Txt_Please_fill_in_your_record_card_including_your_sex;
extern const char *Txt_Please_fill_in_your_record_card_including_your_name;
2014-12-01 23:55:08 +01:00
/***** If user has no sex, name and surname... *****/
2015-03-28 18:34:08 +01:00
if (Gbl.Usrs.Me.UsrDat.CtyCod < 0)
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_country_nationality);
2015-03-28 18:34:08 +01:00
else if (Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN)
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_sex);
2015-03-28 18:34:08 +01:00
else if (!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1[0])
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_record_card_including_your_name);
2014-12-01 23:55:08 +01:00
2016-01-04 16:45:43 +01:00
/***** Contextual links *****/
2015-04-02 14:22:21 +02:00
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
2014-12-01 23:55:08 +01:00
Rec_PutLinkToChangeMyInsCtrDpt (); // Put link (form) to change my institution, centre, department...
2016-01-04 16:45:43 +01:00
Net_PutLinkToChangeMySocialNetworks (); // Put link (form) to change my social networks
2015-04-02 18:39:49 +02:00
Pho_PutLinkToChangeMyPhoto (); // Put link (form) to change my photo
2015-03-06 22:36:29 +01:00
Pri_PutLinkToChangeMyPrivacy (); // Put link (form) to change my privacy
2015-04-02 13:38:05 +02:00
fprintf (Gbl.F.Out,"</div>");
2014-12-01 23:55:08 +01:00
/***** My record *****/
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_FORM,&Gbl.Usrs.Me.UsrDat,NULL);
2014-12-01 23:55:08 +01:00
Rec_WriteLinkToDataProtectionClause ();
}
/*****************************************************************************/
/*************** Show form to edit the record of a new user ******************/
/*****************************************************************************/
2017-01-27 12:57:31 +01:00
void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t DefaultRole)
2014-12-01 23:55:08 +01:00
{
/***** Show the form *****/
2017-01-27 12:57:31 +01:00
/* In this case UsrDat->RoleInCurrentCrsDB
is not the current role in current course.
Instead it is initialized with the preferred role. */
UsrDat->RoleInCurrentCrsDB = (Gbl.CurrentCrs.Crs.CrsCod > 0) ? DefaultRole : // Course selected
Rol__GUEST_; // No course selected
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********************** Show my record after update *************************/
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowMySharedRecordUpd (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Your_personal_data_have_been_updated;
/***** Write alert *****/
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_personal_data_have_been_updated);
2014-12-01 23:55:08 +01:00
/***** Show my record for checking *****/
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_MY_RECORD_CHECK,&Gbl.Usrs.Me.UsrDat,NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************** Show user's record for check *************************/
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
void Rec_ShowSharedRecordUnmodifiable (struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
/***** Get password, user type and user's data from database *****/
Usr_GetAllUsrDataFromUsrCod (UsrDat);
2015-09-17 11:21:49 +02:00
UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
2014-12-01 23:55:08 +01:00
/***** Show user's record *****/
2015-08-24 11:25:20 +02:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
2017-05-09 20:56:02 +02:00
Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_USR_CHECK,UsrDat,NULL);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/************************** Show shared record card **************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
// Show form or only data depending on TypeOfView
2016-11-18 00:17:53 +01:00
void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
2017-05-09 20:56:02 +02:00
struct UsrData *UsrDat,const char *Anchor)
2014-12-01 23:55:08 +01:00
{
2016-04-23 23:39:07 +02:00
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2017-03-02 21:18:52 +01:00
extern const char *Hlp_USERS_SignUp;
2016-11-13 13:31:39 +01:00
extern const char *Hlp_PROFILE_Record;
2016-12-09 14:54:19 +01:00
extern const char *Hlp_SOCIAL_Profiles_view_public_profile;
2016-11-20 20:03:47 +01:00
extern const char *Hlp_USERS_Guests;
2016-11-18 00:17:53 +01:00
extern const char *Hlp_USERS_Students_shared_record_card;
2016-11-18 10:08:01 +01:00
extern const char *Hlp_USERS_Teachers_shared_record_card;
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2015-03-29 14:09:23 +02:00
extern const char *Txt_Save_changes;
2015-03-29 21:43:33 +02:00
extern const char *Txt_Register;
extern const char *Txt_Confirm;
2016-11-18 00:17:53 +01:00
const char *Rec_RecordHelp[Rec_SHARED_NUM_VIEW_TYPES] =
{
2017-03-02 21:18:52 +01:00
Hlp_USERS_SignUp, // Rec_SHA_SIGN_UP_FORM
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
Hlp_PROFILE_Record, // Rec_SHA_MY_RECORD_FORM
Hlp_PROFILE_Record, // Rec_SHA_MY_RECORD_CHECK
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
NULL, // Rec_SHA_OTHER_EXISTING_USR_FORM
NULL, // Rec_SHA_OTHER_NEW_USR_FORM
NULL, // Rec_SHA_OTHER_USR_CHECK
2016-11-18 00:17:53 +01:00
2016-12-09 14:54:19 +01:00
NULL, // Rec_SHA_RECORD_LIST
NULL, // Rec_SHA_RECORD_PRINT
Hlp_SOCIAL_Profiles_view_public_profile, // Rec_SHA_RECORD_PUBLIC
2016-11-18 00:17:53 +01:00
};
const char *Rec_RecordListHelp[Rol_NUM_ROLES] =
{
NULL, // Rol_UNKNOWN
2016-12-09 14:54:19 +01:00
Hlp_USERS_Guests, // Rol__GUEST_
2016-11-18 00:17:53 +01:00
NULL, // Rol_VISITOR
Hlp_USERS_Students_shared_record_card, // Rol_STUDENT
2016-11-18 10:08:01 +01:00
Hlp_USERS_Teachers_shared_record_card, // Rol_TEACHER
2016-11-18 00:17:53 +01:00
NULL, // Rol_DEG_ADM
NULL, // Rol_CTR_ADM
NULL, // Rol_INS_ADM
NULL, // Rol_SYS_ADM
};
2017-01-28 15:58:46 +01:00
char StrRecordWidth[10 + 1];
2015-12-16 00:16:32 +01:00
const char *ClassForm = "REC_DAT";
2016-12-13 13:32:19 +01:00
bool ItsMe;
bool IAmLoggedAsTeacher;
bool IAmLoggedAsSysAdm;
bool CountryForm;
2017-01-25 18:48:41 +01:00
bool ICanEdit;
2015-03-24 10:11:17 +01:00
bool PutFormLinks; // Put links (forms) inside record card
2016-12-13 13:32:19 +01:00
bool ShowData;
bool ShowIDRows;
bool ShowAddressRows;
bool ShowTeacherRows;
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
2016-04-22 12:44:56 +02:00
/***** Initializations *****/
2016-12-13 13:32:19 +01:00
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
CountryForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
ShowData = (ItsMe ||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
UsrDat->Accepted);
ShowIDRows = (TypeOfView != Rec_SHA_RECORD_PUBLIC);
ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM ||
TypeOfView == Rec_SHA_MY_RECORD_CHECK ||
((TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
(IAmLoggedAsTeacher || IAmLoggedAsSysAdm) &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT));
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got
ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_FORM ||
TypeOfView == Rec_SHA_MY_RECORD_CHECK) &&
(UsrDat->Roles & (1 << Rol_TEACHER))) || // He/she (me, really) is a teacher in any course
((TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course
2017-01-25 18:35:42 +01:00
/* Data form = I can edit fields like surnames and name */
switch (TypeOfView)
{
case Rec_SHA_MY_RECORD_FORM:
case Rec_SHA_OTHER_NEW_USR_FORM:
2017-01-25 18:48:41 +01:00
ICanEdit = true;
2017-01-25 18:35:42 +01:00
break;
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2017-01-27 10:42:20 +01:00
ICanEdit = Usr_ICanChangeOtherUsrData (UsrDat);
2017-01-25 18:35:42 +01:00
break;
default: // In other options, I can not edit another user's data
2017-01-25 18:48:41 +01:00
ICanEdit = false;
2017-01-25 18:35:42 +01:00
break;
}
/* Class for labels */
2014-12-01 23:55:08 +01:00
switch (TypeOfView)
{
2016-11-18 00:17:53 +01:00
case Rec_SHA_SIGN_UP_FORM:
case Rec_SHA_MY_RECORD_FORM:
case Rec_SHA_OTHER_NEW_USR_FORM:
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2015-07-28 00:16:09 +02:00
ClassForm = The_ClassForm[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_CHECK:
case Rec_SHA_OTHER_USR_CHECK:
case Rec_SHA_RECORD_LIST:
case Rec_SHA_RECORD_PUBLIC:
case Rec_SHA_RECORD_PRINT:
2015-12-13 17:49:53 +01:00
ClassForm = "REC_DAT";
2014-12-01 23:55:08 +01:00
break;
2015-03-29 21:43:33 +02:00
}
2014-12-01 23:55:08 +01:00
2016-11-18 00:17:53 +01:00
Rec_RecordHelp[Rec_SHA_RECORD_LIST] = Rec_RecordListHelp[UsrDat->RoleInCurrentCrsDB];
2016-01-14 10:31:09 +01:00
PutFormLinks = !Gbl.Form.Inside && // Only if not inside another form
2016-10-21 00:38:34 +02:00
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW; // Only in main window
2015-03-24 10:11:17 +01:00
2016-04-22 12:44:56 +02:00
Ins.InsCod = UsrDat->InsCod;
if (Ins.InsCod > 0)
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2015-12-13 17:49:53 +01:00
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
2016-05-05 14:20:38 +02:00
Gbl.Record.UsrDat = UsrDat;
Gbl.Record.TypeOfView = TypeOfView;
2016-11-14 10:05:41 +01:00
Lay_StartRoundFrameTable (StrRecordWidth,NULL,
2017-01-27 13:10:03 +01:00
TypeOfView == Rec_SHA_OTHER_NEW_USR_FORM ? NULL : // New user ==> don't put icons
Rec_PutIconsCommands,
Rec_RecordHelp[TypeOfView],
2016-11-14 10:05:41 +01:00
2);
2014-12-01 23:55:08 +01:00
2016-04-22 12:39:36 +02:00
/***** Institution and user's photo *****/
2016-04-22 12:24:02 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-23 14:51:12 +02:00
Rec_ShowInstitutionInHead (&Ins,PutFormLinks);
2016-04-22 12:39:36 +02:00
Rec_ShowPhoto (UsrDat);
fprintf (Gbl.F.Out,"</tr>");
2014-12-01 23:55:08 +01:00
2016-04-22 12:39:36 +02:00
/***** Commands and full name *****/
fprintf (Gbl.F.Out,"<tr>");
2016-04-22 12:44:56 +02:00
Rec_ShowFullName (UsrDat);
fprintf (Gbl.F.Out,"</tr>");
2014-12-01 23:55:08 +01:00
/***** User's nickname *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-22 19:50:59 +02:00
Rec_ShowNickname (UsrDat,PutFormLinks);
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"</tr>");
2015-03-05 21:42:02 +01:00
2016-04-22 20:00:26 +02:00
/***** User's country, web and social networks *****/
2016-04-22 19:55:41 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-04-23 13:58:20 +02:00
Rec_ShowCountryInHead (UsrDat,ShowData);
2016-04-22 20:00:26 +02:00
Rec_ShowWebsAndSocialNets (UsrDat,TypeOfView);
fprintf (Gbl.F.Out,"</tr>");
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
if (ShowIDRows ||
ShowAddressRows ||
ShowTeacherRows)
2014-12-01 23:55:08 +01:00
{
fprintf (Gbl.F.Out,"<tr>"
2015-03-29 15:03:35 +02:00
"<td colspan=\"3\">");
2017-05-09 20:56:02 +02:00
/***** Show email and user's IDs *****/
2016-04-23 19:34:29 +02:00
if (ShowIDRows)
{
2017-05-01 10:22:16 +02:00
Lay_StartTableWide (2);
2017-05-09 20:56:02 +02:00
/* Show email */
2016-04-23 19:34:29 +02:00
Rec_ShowEmail (UsrDat,ClassForm);
2017-05-09 20:56:02 +02:00
/* Show user's IDs */
2017-05-10 10:09:19 +02:00
Rec_ShowUsrIDs (UsrDat,ClassForm,Anchor);
2017-05-09 20:56:02 +02:00
2017-05-01 10:22:16 +02:00
Lay_EndTable ();
2016-04-23 19:34:29 +02:00
}
/***** Start form *****/
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_FORM:
2015-03-29 21:43:33 +02:00
Act_FormStart (ActChgMyData);
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_NEW_USR_FORM:
2016-01-17 15:10:54 +01:00
Act_FormStart ( Gbl.Action.Act == ActReqMdfStd ? ActCreStd :
(Gbl.Action.Act == ActReqMdfTch ? ActCreTch :
2015-09-17 16:54:02 +02:00
ActCreOth));
2015-03-29 21:43:33 +02:00
ID_PutParamOtherUsrIDPlain (); // New user
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2015-09-17 16:54:02 +02:00
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActUpdStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActUpdTch :
ActUpdOth));
2015-04-02 18:39:49 +02:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
2015-03-29 21:43:33 +02:00
break;
default:
break;
}
2015-03-29 15:03:35 +02:00
2017-05-01 10:22:16 +02:00
Lay_StartTableWide (2);
2015-03-29 13:57:24 +02:00
if (ShowIDRows)
2015-03-05 23:18:43 +01:00
{
2016-04-23 13:58:20 +02:00
/***** Role or sex *****/
2016-04-23 13:23:09 +02:00
Rec_ShowRole (UsrDat,TypeOfView,ClassForm);
2015-03-29 13:57:24 +02:00
/***** Name *****/
2017-01-25 18:48:41 +01:00
Rec_ShowSurname1 (UsrDat,TypeOfView,ICanEdit,ClassForm);
Rec_ShowSurname2 (UsrDat,ICanEdit,ClassForm);
Rec_ShowFirstName (UsrDat,TypeOfView,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
2016-04-23 13:58:20 +02:00
/***** Country *****/
2015-03-29 13:57:24 +02:00
if (CountryForm)
2016-04-23 13:58:20 +02:00
Rec_ShowCountry (UsrDat,TypeOfView,ClassForm);
2015-03-05 23:18:43 +01:00
}
2015-03-29 13:57:24 +02:00
if (ShowAddressRows)
2015-03-25 16:25:50 +01:00
{
2016-04-23 14:03:56 +02:00
/***** Origin place *****/
2017-01-25 18:48:41 +01:00
Rec_ShowOriginPlace (UsrDat,ShowData,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
2016-04-23 14:06:49 +02:00
/***** Date of birth *****/
2017-01-25 18:48:41 +01:00
Rec_ShowDateOfBirth (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:12:52 +02:00
/***** Local address *****/
2017-01-25 18:48:41 +01:00
Rec_ShowLocalAddress (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:18:09 +02:00
/***** Local phone *****/
2017-01-25 18:48:41 +01:00
Rec_ShowLocalPhone (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:31:57 +02:00
/***** Family address *****/
2017-01-25 18:48:41 +01:00
Rec_ShowFamilyAddress (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:36:02 +02:00
/***** Family phone *****/
2017-01-25 18:48:41 +01:00
Rec_ShowFamilyPhone (UsrDat,ShowData,ICanEdit,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 14:43:53 +02:00
/***** User's comments *****/
2017-01-25 18:48:41 +01:00
Rec_ShowComments (UsrDat,ShowData,ICanEdit,ClassForm);
2015-03-29 13:57:24 +02:00
}
2014-12-01 23:55:08 +01:00
2015-03-29 13:57:24 +02:00
if (ShowTeacherRows)
2014-12-01 23:55:08 +01:00
{
2016-04-23 14:43:53 +02:00
/***** Institution *****/
2016-04-23 14:51:12 +02:00
Rec_ShowInstitution (&Ins,ShowData,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 15:00:07 +02:00
/***** Centre *****/
Rec_ShowCentre (UsrDat,ShowData,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 15:08:32 +02:00
/***** Department *****/
Rec_ShowDepartment (UsrDat,ShowData,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 15:15:06 +02:00
/***** Office *****/
Rec_ShowOffice (UsrDat,ShowData,ClassForm);
2014-12-01 23:55:08 +01:00
2016-04-23 15:20:37 +02:00
/***** Office phone *****/
Rec_ShowOfficePhone (UsrDat,ShowData,ClassForm);
2015-03-29 13:57:24 +02:00
}
2016-04-23 16:37:16 +02:00
2017-05-01 10:22:16 +02:00
Lay_EndTable ();
2015-03-29 13:57:24 +02:00
2016-04-23 19:34:29 +02:00
/***** Button and end form *****/
2015-03-29 21:43:33 +02:00
switch (TypeOfView)
{
2016-11-18 00:17:53 +01:00
case Rec_SHA_MY_RECORD_FORM:
2015-03-29 21:43:33 +02:00
Lay_PutConfirmButton (Txt_Save_changes);
Act_FormEnd ();
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_NEW_USR_FORM:
2015-03-29 21:43:33 +02:00
if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups?
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
Lay_PutConfirmButton (Txt_Register);
Act_FormEnd ();
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_EXISTING_USR_FORM:
2015-03-29 21:43:33 +02:00
/***** Show list of groups to register/remove me/user *****/
if (Gbl.CurrentCrs.Grps.NumGrps) // This course has groups?
{
if (ItsMe)
{
// Don't show groups if I don't belong to course
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
2015-04-07 21:44:24 +02:00
Grp_ShowLstGrpsToChgMyGrps ((Gbl.Usrs.Me.LoggedRole == Rol_STUDENT));
2015-03-29 21:43:33 +02:00
}
else
Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);
}
/***** Which action, register or removing? *****/
if (Enr_PutActionsRegRemOneUsr (ItsMe))
Lay_PutConfirmButton (Txt_Confirm);
Act_FormEnd ();
break;
default:
break;
}
2014-12-01 23:55:08 +01:00
2015-03-29 14:09:23 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2014-12-08 17:35:48 +01:00
/***** End frame *****/
2016-11-14 10:05:41 +01:00
Lay_EndRoundFrameTable ();
2016-05-05 14:20:38 +02:00
}
/*****************************************************************************/
/*********** Show commands (icon to make actions) in record card *************/
/*****************************************************************************/
static void Rec_PutIconsCommands (void)
{
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
2016-05-05 14:32:58 +02:00
extern const char *Txt_Edit_my_personal_data;
2017-02-17 01:59:58 +01:00
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
2016-05-05 14:20:38 +02:00
extern const char *Txt_View_record_for_this_course;
2016-12-09 13:59:33 +01:00
extern const char *Txt_View_record_and_office_hours;
2017-01-20 09:26:35 +01:00
extern const char *Txt_Show_agenda;
2017-01-31 00:25:10 +01:00
extern const char *Txt_Administer_user;
2017-03-01 12:59:49 +01:00
extern const char *Txt_QR_code;
2016-05-05 14:20:38 +02:00
extern const char *Txt_Write_a_message;
2016-11-24 22:08:04 +01:00
extern const char *Txt_View_homework;
2016-11-21 13:15:08 +01:00
extern const char *Txt_View_test_results;
2016-11-18 00:49:16 +01:00
extern const char *Txt_View_attendance;
2016-05-05 14:20:38 +02:00
extern const char *Txt_Following_unfollow;
extern const char *Txt_Follow;
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Record.UsrDat->UsrCod);
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT); // My current role is student
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
2016-12-09 14:17:32 +01:00
bool ICanViewUsrProfile;
2016-05-05 14:20:38 +02:00
if (!Gbl.Form.Inside && // Only if not inside another form
2016-10-21 00:38:34 +02:00
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW && // Only in main window
2016-05-05 14:20:38 +02:00
Gbl.Usrs.Me.Logged) // Only if I am logged
{
2017-01-28 15:58:46 +01:00
ICanViewUsrProfile = Pri_ShowingIsAllowed (Gbl.Record.UsrDat->ProfileVisibility,
2017-02-17 01:59:58 +01:00
Gbl.Record.UsrDat);
2016-12-09 14:17:32 +01:00
2016-12-09 13:59:33 +01:00
/***** Start container *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<div class=\"FRAME_ICO\">");
2016-05-05 14:20:38 +02:00
if (ItsMe)
2017-02-17 06:32:57 +01:00
/***** Button to edit my record card *****/
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActReqEdiRecCom,NULL,NULL,
2016-07-01 16:32:42 +02:00
"edit64x64.png",
Txt_Edit_my_personal_data,NULL,
NULL);
2017-02-17 06:32:57 +01:00
if (ICanViewUsrProfile)
/***** Button to view user's profile *****/
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeOthPubPrf,NULL,
2016-12-09 14:17:32 +01:00
Rec_PutParamUsrCodEncrypted,
"usr64x64.gif",
2017-02-17 06:32:57 +01:00
ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,NULL,
2016-12-09 14:17:32 +01:00
NULL);
2016-12-09 13:59:33 +01:00
/***** Button to view user's record card *****/
if (Usr_CheckIfICanViewRecordStd (Gbl.Record.UsrDat))
/* View student's records: common record card and course record card */
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeRecOneStd,NULL,
2016-12-09 13:59:33 +01:00
Rec_PutParamUsrCodEncrypted,
"card64x64.gif",
Txt_View_record_for_this_course,NULL,
NULL);
else if (Usr_CheckIfICanViewRecordTch (Gbl.Record.UsrDat))
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeRecOneTch,NULL,
2016-05-05 14:20:38 +02:00
Rec_PutParamUsrCodEncrypted,
"card64x64.gif",
2016-12-09 13:59:33 +01:00
Txt_View_record_and_office_hours,NULL,
NULL);
2016-05-05 14:20:38 +02:00
2016-12-09 13:59:33 +01:00
/***** Button to view user's agenda *****/
2016-12-07 10:16:39 +01:00
if (ItsMe)
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeMyAgd,NULL,NULL,
2017-03-25 20:46:14 +01:00
"calendar64x64.png",
2017-01-20 09:26:35 +01:00
Txt_Show_agenda,NULL,
2016-12-07 10:16:39 +01:00
NULL);
2016-12-09 13:59:33 +01:00
else if (Usr_CheckIfICanViewUsrAgenda (Gbl.Record.UsrDat))
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeUsrAgd,NULL,Rec_PutParamUsrCodEncrypted,
2017-03-25 20:46:14 +01:00
"calendar64x64.png",
2017-01-20 09:26:35 +01:00
Txt_Show_agenda,NULL,
2016-12-09 13:59:33 +01:00
NULL);
2016-12-01 20:24:14 +01:00
2016-05-05 14:20:38 +02:00
/***** Button to admin user *****/
if (ItsMe ||
(Gbl.CurrentCrs.Crs.CrsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_TEACHER) ||
(Gbl.CurrentDeg.Deg.DegCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM) ||
(Gbl.CurrentCtr.Ctr.CtrCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_CTR_ADM) ||
(Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
Lay_PutContextualLink ( Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActReqMdfStd :
(Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActReqMdfTch :
ActReqMdfOth),
2017-04-17 19:03:21 +02:00
NULL,Rec_PutParamUsrCodEncrypted,
2016-05-05 14:20:38 +02:00
"config64x64.gif",
2017-01-31 00:25:10 +01:00
Txt_Administer_user,NULL,
2016-07-01 16:32:42 +02:00
NULL);
2016-05-05 14:20:38 +02:00
2016-12-09 13:59:33 +01:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
2016-05-05 14:20:38 +02:00
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && // He/she is a student in the current course
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
{
/***** Button to view user's assignments and works *****/
if (ItsMe) // I am a student
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActAdmAsgWrkUsr,NULL,NULL,
2016-05-05 14:20:38 +02:00
"folder64x64.gif",
2016-11-24 22:08:04 +01:00
Txt_View_homework,NULL,
2016-07-01 16:32:42 +02:00
NULL);
2016-05-05 14:20:38 +02:00
else // I am a teacher or superuser
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActAdmAsgWrkCrs,NULL,Rec_PutParamsWorks,
2016-05-05 14:20:38 +02:00
"folder64x64.gif",
2016-11-24 22:08:04 +01:00
Txt_View_homework,NULL,
2016-07-01 16:32:42 +02:00
NULL);
2016-05-05 14:20:38 +02:00
/***** Button to view user's test exams *****/
if (ItsMe)
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeMyTstRes,NULL,NULL,
2016-11-21 01:20:19 +01:00
"exam64x64.png",
2016-11-21 13:15:08 +01:00
Txt_View_test_results,NULL,
2016-07-01 16:32:42 +02:00
NULL);
2016-05-05 14:20:38 +02:00
else
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeUsrTstRes,NULL,Rec_PutParamsStudent,
2016-11-21 01:20:19 +01:00
"exam64x64.png",
2016-11-21 13:15:08 +01:00
Txt_View_test_results,NULL,
2016-07-01 16:32:42 +02:00
NULL);
2016-05-05 14:20:38 +02:00
/***** Button to view user's attendance *****/
2016-12-01 20:24:14 +01:00
if (ItsMe && IAmLoggedAsStudent)
// As student, I can see my attendance
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeLstMyAtt,NULL,NULL,
2016-12-01 20:24:14 +01:00
"rollcall64x64.png",
Txt_View_attendance,NULL,
NULL);
else if (IAmLoggedAsTeacher || IAmLoggedAsSysAdm)
// As teacher, I can see attendance of the student
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActSeeLstStdAtt,NULL,Rec_PutParamsStudent,
2016-12-01 20:24:14 +01:00
"rollcall64x64.png",
Txt_View_attendance,NULL,
NULL);
2016-05-05 14:20:38 +02:00
}
2017-03-01 12:59:49 +01:00
/***** Button to print QR code *****/
if (ItsMe || IAmLoggedAsSysAdm ||
(Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && // He/she is a student in the current course
IAmLoggedAsTeacher)) // I am a teacher in the current course
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActPrnUsrQR,NULL,Rec_PutParamUsrCodEncrypted,
2017-03-01 12:59:49 +01:00
"qr64x64.gif",
Txt_QR_code,NULL,
NULL);
2016-05-05 14:20:38 +02:00
/***** Button to send a message *****/
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActReqMsgUsr,NULL,Rec_PutParamsMsgUsr,
2016-05-05 14:20:38 +02:00
"msg64x64.gif",
2016-07-01 16:32:42 +02:00
Txt_Write_a_message,NULL,
NULL);
2016-05-05 14:20:38 +02:00
/***** Button to follow / unfollow *****/
2016-09-28 13:12:11 +02:00
if (!ItsMe)
2016-05-05 14:20:38 +02:00
{
2016-09-28 13:12:11 +02:00
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Record.UsrDat->UsrCod))
// I follow user
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActUnfUsr,NULL,Rec_PutParamUsrCodEncrypted,
2016-05-05 14:20:38 +02:00
"following64x64.png",
2016-07-01 16:32:42 +02:00
Txt_Following_unfollow,NULL,
2016-09-28 13:12:11 +02:00
NULL); // Put button to unfollow, even if I can not view user's profile
2016-12-09 14:17:32 +01:00
else if (ICanViewUsrProfile)
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActFolUsr,NULL,Rec_PutParamUsrCodEncrypted,
2016-12-09 14:17:32 +01:00
"follow64x64.png",
Txt_Follow,NULL,
NULL); // Put button to follow
2016-05-05 14:20:38 +02:00
}
2016-12-09 13:59:33 +01:00
/***** End container *****/
2016-05-05 14:20:38 +02:00
fprintf (Gbl.F.Out,"</div>");
}
}
static void Rec_PutParamUsrCodEncrypted (void)
{
Usr_PutParamUsrCodEncrypted (Gbl.Record.UsrDat->EncryptedUsrCod);
}
static void Rec_PutParamsWorks (void)
{
Rec_PutParamsStudent ();
Par_PutHiddenParamChar ("FullTree",'Y'); // By default, show all files
}
static void Rec_PutParamsStudent (void)
{
Par_PutHiddenParamString ("UsrCodStd",Gbl.Record.UsrDat->EncryptedUsrCod);
Grp_PutParamAllGroups ();
}
static void Rec_PutParamsMsgUsr (void)
{
Rec_PutParamUsrCodEncrypted ();
Grp_PutParamAllGroups ();
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
2015-03-05 23:18:43 +01:00
}
2014-12-01 23:55:08 +01:00
2016-04-22 12:24:02 +02:00
/*****************************************************************************/
/*********************** Show institution in record card *********************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks)
2016-04-22 12:24:02 +02:00
{
2016-04-22 12:39:36 +02:00
/***** Institution logo *****/
2016-05-05 14:32:58 +02:00
fprintf (Gbl.F.Out,"<td rowspan=\"4\" class=\"REC_C1_TOP CENTER_MIDDLE\">");
2016-04-22 12:24:02 +02:00
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
Act_FormGoToStart (ActSeeInsInf);
Ins_PutParamInsCod (Ins->InsCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Ins->FullName,NULL,NULL);
2016-04-22 12:24:02 +02:00
}
2016-10-28 10:03:37 +02:00
Log_DrawLogo (Sco_SCOPE_INS,Ins->InsCod,Ins->ShrtName,
2016-04-22 12:24:02 +02:00
Rec_INSTITUTION_LOGO_SIZE,NULL,true);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
}
}
2016-04-22 12:39:36 +02:00
fprintf (Gbl.F.Out,"</td>");
/***** Institution name *****/
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_TOP REC_HEAD LEFT_MIDDLE\">");
2016-04-22 12:24:02 +02:00
if (Ins->InsCod > 0)
{
/* Form to go to the institution */
if (PutFormLinks)
{
Act_FormGoToStart (ActSeeInsInf);
Ins_PutParamInsCod (Ins->InsCod);
2016-07-01 17:13:41 +02:00
Act_LinkFormSubmit (Ins->FullName,"REC_HEAD",NULL);
2016-04-22 12:24:02 +02:00
}
fprintf (Gbl.F.Out,"%s",Ins->FullName);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
}
}
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 12:39:36 +02:00
/*****************************************************************************/
/********************** Show user's photo in record card *********************/
/*****************************************************************************/
static void Rec_ShowPhoto (struct UsrData *UsrDat)
{
2017-01-28 15:58:46 +01:00
char PhotoURL[PATH_MAX + 1];
bool ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
2016-04-22 12:39:36 +02:00
/***** User's photo *****/
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td rowspan=\"3\" class=\"REC_C3_TOP CENTER_TOP\">");
2016-04-22 12:39:36 +02:00
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
NULL,
"PHOTO186x248",Pho_NO_ZOOM,false);
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 12:44:56 +02:00
/*****************************************************************************/
/*************************** Show user's full name ***************************/
/*****************************************************************************/
static void Rec_ShowFullName (struct UsrData *UsrDat)
{
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID LEFT_TOP\">"
"<div class=\"REC_NAME\">");
2016-04-22 12:44:56 +02:00
/***** First name *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s<br />",UsrDat->FirstName);
2016-04-22 12:44:56 +02:00
/***** Surname 1 *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s<br />",UsrDat->Surname1);
2016-04-22 12:44:56 +02:00
/***** Surname 2 *****/
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"%s",UsrDat->Surname2);
2016-04-22 12:44:56 +02:00
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"</div>"
"</td>");
2016-04-22 12:44:56 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-22 19:55:41 +02:00
/*************************** Show user's nickname ****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-04-22 19:50:59 +02:00
static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
{
2017-02-17 01:59:58 +01:00
extern const char *Txt_My_public_profile;
extern const char *Txt_Another_user_s_profile;
bool ItsMe;
2016-04-22 19:50:59 +02:00
2017-03-05 17:12:00 +01:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID LEFT_BOTTOM\">"
2016-04-23 19:34:29 +02:00
"<div class=\"REC_NICK\">");
2016-04-22 19:50:59 +02:00
if (UsrDat->Nickname[0])
{
if (PutFormLinks)
{
/* Put form to go to public profile */
2017-02-17 01:59:58 +01:00
ItsMe = (Gbl.Usrs.Me.Logged &&
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
2017-02-17 06:32:57 +01:00
Act_FormStart (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Act_LinkFormSubmit (ItsMe ? Txt_My_public_profile :
Txt_Another_user_s_profile,
"REC_NICK",NULL);
2016-04-22 19:50:59 +02:00
}
fprintf (Gbl.F.Out,"@%s",UsrDat->Nickname);
if (PutFormLinks)
{
fprintf (Gbl.F.Out,"</a>");
Act_FormEnd ();
}
}
fprintf (Gbl.F.Out,"</div>"
2017-03-05 17:12:00 +01:00
"</td>");
2016-04-22 19:50:59 +02:00
}
2016-04-22 19:55:41 +02:00
/*****************************************************************************/
/**************************** Show user's country ****************************/
/*****************************************************************************/
2016-04-23 13:58:20 +02:00
static void Rec_ShowCountryInHead (struct UsrData *UsrDat,bool ShowData)
2016-04-22 19:55:41 +02:00
{
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_DAT_BOLD LEFT_TOP\">");
2016-04-22 19:55:41 +02:00
if (ShowData && UsrDat->CtyCod > 0)
/* Link to see country information */
2017-03-01 14:53:18 +01:00
Cty_WriteCountryName (UsrDat->CtyCod,
"REC_DAT_BOLD"); // Put link to country
2016-04-22 19:55:41 +02:00
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 20:00:26 +02:00
/*****************************************************************************/
/******************* Show user's webs and social networks ********************/
/*****************************************************************************/
static void Rec_ShowWebsAndSocialNets (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView)
2016-04-22 20:00:26 +02:00
{
2016-04-23 19:34:29 +02:00
fprintf (Gbl.F.Out,"<td class=\"REC_C3_MID CENTER_TOP\">");
2016-11-18 00:17:53 +01:00
if (TypeOfView != Rec_SHA_RECORD_PRINT)
2016-04-22 20:00:26 +02:00
Net_ShowWebsAndSocialNets (UsrDat);
fprintf (Gbl.F.Out,"</td>");
}
2016-04-22 20:31:10 +02:00
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/***************************** Show user's email *****************************/
2016-04-22 20:31:10 +02:00
/*****************************************************************************/
2016-04-23 13:30:59 +02:00
static void Rec_ShowEmail (struct UsrData *UsrDat,const char *ClassForm)
2016-04-22 20:31:10 +02:00
{
extern const char *Txt_Email;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-22 20:31:10 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Email);
2016-04-22 20:31:10 +02:00
if (UsrDat->Email[0])
{
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"<div class=\"REC_EMAIL\">"); // Limited width
2017-01-27 15:21:01 +01:00
if (Mai_ICanSeeOtherUsrEmail (UsrDat))
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"<a href=\"mailto:%s\" class=\"REC_DAT_BOLD\">"
"%s"
"</a>",
UsrDat->Email,
2016-04-22 20:31:10 +02:00
UsrDat->Email);
else
fprintf (Gbl.F.Out,"********");
2017-03-05 17:23:10 +01:00
fprintf (Gbl.F.Out,"</div>");
2016-04-22 20:31:10 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-22 20:47:11 +02:00
/*****************************************************************************/
/******************************* Show user's IDs *****************************/
/*****************************************************************************/
2017-05-10 10:09:19 +02:00
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm,
const char *Anchor)
2016-04-22 20:47:11 +02:00
{
extern const char *Txt_ID;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_TOP %s\">"
2016-04-22 20:47:11 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP\">",
ClassForm,Txt_ID);
2017-05-09 20:56:02 +02:00
ID_WriteUsrIDs (UsrDat,Anchor);
2016-04-22 20:47:11 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:23:09 +02:00
/*****************************************************************************/
/************************** Show user's role / sex ***************************/
/*****************************************************************************/
static void Rec_ShowRole (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:23:09 +02:00
const char *ClassForm)
{
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
extern const char *Txt_Role;
extern const char *Txt_Sex;
extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS];
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
2016-11-18 00:17:53 +01:00
bool RoleForm = (TypeOfView == Rec_SHA_SIGN_UP_FORM ||
TypeOfView == Rec_SHA_OTHER_NEW_USR_FORM ||
TypeOfView == Rec_SHA_OTHER_EXISTING_USR_FORM);
bool SexForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
2016-04-23 13:23:09 +02:00
Rol_Role_t DefaultRoleInCurrentCrs;
Rol_Role_t Role;
Usr_Sex_t Sex;
if (RoleForm)
{
2016-12-13 13:32:19 +01:00
/* Get user's roles if not got */
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat);
2016-04-23 13:23:09 +02:00
fprintf (Gbl.F.Out,"<tr>"
2016-12-27 16:45:37 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Role\" class=\"%s\">%s:</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Role);
2016-04-23 13:23:09 +02:00
switch (TypeOfView)
{
2017-03-30 11:20:06 +02:00
case Rec_SHA_SIGN_UP_FORM: // I want to apply for enrolment
2016-04-23 13:23:09 +02:00
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
Rol_TEACHER :
Rol_STUDENT;
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2016-04-23 13:23:09 +02:00
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_EXISTING_USR_FORM: // The other user already exists in the platform
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2016-04-23 13:23:09 +02:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
{
if (UsrDat->RoleInCurrentCrsDB < Rol_STUDENT) // The other user does not belong to current course
{
/* If there is a request of this user, default role is the requested role */
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNKNOWN)
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TEACHER)) ? Rol_TEACHER :
Rol_STUDENT;
}
else
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol__GUEST_:
case Rol_VISITOR:
case Rol_STUDENT:
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<option value=\"%u\""
" selected=\"selected\""
" disabled=\"disabled\">"
"%s</option>",
2016-04-23 13:23:09 +02:00
(unsigned) Gbl.Usrs.Me.LoggedRole,
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.LoggedRole][UsrDat->Sex]);
break;
2017-01-19 18:32:28 +01:00
case Rol_TEACHER:
2016-04-23 13:23:09 +02:00
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
default: // The rest of users can not register other users
break;
}
}
else // No course selected
{
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STUDENT) |
(1 << Rol_TEACHER))) ? Rol_VISITOR :
Rol__GUEST_;
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\""
" disabled=\"disabled\">%s</option>",
2016-04-23 13:23:09 +02:00
(unsigned) DefaultRoleInCurrentCrs,
Txt_ROLES_SINGUL_Abc[DefaultRoleInCurrentCrs][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
2016-11-18 00:17:53 +01:00
case Rec_SHA_OTHER_NEW_USR_FORM: // The other user does not exist in platform
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
2016-04-23 13:23:09 +02:00
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
2017-01-27 12:57:31 +01:00
case Rol_TEACHER:
case Rol_DEG_ADM:
2016-04-23 13:23:09 +02:00
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
2017-01-27 12:57:31 +01:00
/* In this case UsrDat->RoleInCurrentCrsDB
is not the current role in current course.
Instead it is initialized with the preferred role. */
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][Usr_SEX_UNKNOWN]);
}
2016-04-23 13:23:09 +02:00
break;
default: // The rest of users can not register other users
break;
}
else // No course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_SYS_ADM:
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,"<option value=\"%u\""
" selected=\"selected\">%s</option>",
2016-04-23 13:23:09 +02:00
(unsigned) Rol__GUEST_,Txt_ROLES_SINGUL_Abc[Rol__GUEST_][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
fprintf (Gbl.F.Out,"</select>");
break;
default:
break;
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else if (SexForm)
{
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 13:23:09 +02:00
"%s*:</td>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C2_BOT LEFT_MIDDLE\">",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Sex);
2016-04-23 13:23:09 +02:00
for (Sex = Usr_SEX_FEMALE;
Sex <= Usr_SEX_MALE;
Sex++)
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<label class=\"REC_DAT_BOLD\">"
"<input type=\"radio\" name=\"Sex\" value=\"%u\"",
(unsigned) Sex);
2016-04-23 13:23:09 +02:00
if (Sex == Gbl.Usrs.Me.UsrDat.Sex)
fprintf (Gbl.F.Out," checked=\"checked\"");
2016-11-18 21:00:55 +01:00
fprintf (Gbl.F.Out," required=\"required\" />"
2016-04-23 13:23:09 +02:00
"<img src=\"%s/%s16x16.gif\""
2016-12-25 20:51:53 +01:00
" alt=\"%s\" title=\"%s\" class=\"ICO20x20\" />"
"%s"
"</label>",
2016-04-23 13:23:09 +02:00
Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex]);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else // RoleForm == false, SexForm == false
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 13:23:09 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">"
2016-04-23 13:23:09 +02:00
"%s"
"</td>"
"</tr>",
2016-04-23 19:34:29 +02:00
ClassForm,
2016-11-18 00:17:53 +01:00
TypeOfView == Rec_SHA_MY_RECORD_CHECK ? Txt_Sex :
Txt_Role,
TypeOfView == Rec_SHA_MY_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] :
Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]);
2016-04-23 13:23:09 +02:00
}
2016-04-23 13:37:43 +02:00
/*****************************************************************************/
/*************************** Show user's surname 1 ***************************/
/*****************************************************************************/
static void Rec_ShowSurname1 (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:37:43 +02:00
const char *ClassForm)
{
extern const char *Txt_Surname_1;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Surname1\" class=\"%s\">"
2016-04-23 13:37:43 +02:00
"%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Surname_1);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:37:43 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,":"
"</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">");
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2017-01-27 15:21:01 +01:00
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"Surname1\" name=\"Surname1\""
2016-04-23 13:37:43 +02:00
" maxlength=\"%u\" value=\"%s\""
2017-01-27 15:21:01 +01:00
" class=\"REC_C2_BOT_INPUT\"",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->Surname1);
2017-01-27 15:21:01 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
fprintf (Gbl.F.Out," required=\"required\"");
fprintf (Gbl.F.Out," />");
}
2016-04-23 13:37:43 +02:00
else if (UsrDat->Surname1[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->Surname1);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:45:03 +02:00
/*****************************************************************************/
2016-04-23 13:49:38 +02:00
/*************************** Show user's surname 2 ***************************/
2016-04-23 13:45:03 +02:00
/*****************************************************************************/
static void Rec_ShowSurname2 (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:45:03 +02:00
const char *ClassForm)
{
extern const char *Txt_Surname_2;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"Surname2\" class=\"%s\">"
2016-04-23 13:45:03 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 13:45:03 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Surname_2);
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"Surname2\" name=\"Surname2\""
2016-04-23 13:45:03 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->Surname2);
2016-04-23 13:45:03 +02:00
else if (UsrDat->Surname2[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->Surname2);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:49:38 +02:00
/*****************************************************************************/
/************************** Show user's first name ***************************/
/*****************************************************************************/
static void Rec_ShowFirstName (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2017-01-25 18:48:41 +01:00
bool ICanEdit,
2016-04-23 13:49:38 +02:00
const char *ClassForm)
{
extern const char *Txt_First_name;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FirstName\" class=\"%s\">"
2016-04-23 13:49:38 +02:00
"%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_First_name);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:49:38 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,":"
"</label>"
"</td>"
2016-04-23 19:34:29 +02:00
"<td colspan=\"2\""
" class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">");
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2017-01-27 15:21:01 +01:00
{
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"FirstName\" name=\"FirstName\""
2016-11-18 21:00:55 +01:00
" maxlength=\"%u\" value=\"%s\""
2017-01-27 15:21:01 +01:00
" class=\"REC_C2_BOT_INPUT\"",
2017-03-07 19:55:29 +01:00
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
2016-04-23 19:34:29 +02:00
UsrDat->FirstName);
2017-01-27 15:21:01 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
fprintf (Gbl.F.Out," required=\"required\"");
fprintf (Gbl.F.Out," />");
}
2016-04-23 13:49:38 +02:00
else if (UsrDat->FirstName[0])
fprintf (Gbl.F.Out,"<strong>%s</strong>",UsrDat->FirstName);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 13:58:20 +02:00
/*****************************************************************************/
/**************************** Show user's country ****************************/
/*****************************************************************************/
static void Rec_ShowCountry (struct UsrData *UsrDat,
2016-11-18 00:17:53 +01:00
Rec_SharedRecordViewType_t TypeOfView,
2016-04-23 13:58:20 +02:00
const char *ClassForm)
{
extern const char *Txt_Country;
extern const char *Txt_Another_country;
unsigned NumCty;
/***** If list of countries is empty, try to get it *****/
if (!Gbl.Ctys.Num)
{
2017-01-29 12:42:19 +01:00
Gbl.Ctys.SelectedOrder = Cty_ORDER_BY_COUNTRY;
2016-04-23 13:58:20 +02:00
Cty_GetListCountries (Cty_GET_BASIC_DATA);
}
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"OthCtyCod\" class=\"%s\">%s",
2016-04-23 19:34:29 +02:00
ClassForm,Txt_Country);
2016-11-18 00:17:53 +01:00
if (TypeOfView == Rec_SHA_MY_RECORD_FORM)
2016-04-23 13:58:20 +02:00
fprintf (Gbl.F.Out,"*");
2016-12-27 16:45:37 +01:00
fprintf (Gbl.F.Out,":</label>"
2016-12-25 20:51:53 +01:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td colspan=\"2\""
2016-12-25 20:51:53 +01:00
" class=\"REC_C2_BOT LEFT_MIDDLE\">");
2016-04-23 13:58:20 +02:00
/***** Selector of country *****/
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtyCod\" name=\"OthCtyCod\""
" class=\"REC_C2_BOT_INPUT\" required=\"required\">"
2016-11-18 21:00:55 +01:00
"<option value=\"\">%s</option>"
2016-04-23 13:58:20 +02:00
"<option value=\"0\"",
Txt_Country);
if (UsrDat->CtyCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",Txt_Another_country);
for (NumCty = 0;
NumCty < Gbl.Ctys.Num;
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Ctys.Lst[NumCty].CtyCod == UsrDat->CtyCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
}
fprintf (Gbl.F.Out,"</select>"
"</td>"
"</tr>");
}
2016-04-23 14:03:56 +02:00
/*****************************************************************************/
2016-04-23 14:12:52 +02:00
/************************ Show user's place of origin ************************/
2016-04-23 14:03:56 +02:00
/*****************************************************************************/
static void Rec_ShowOriginPlace (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:03:56 +02:00
const char *ClassForm)
{
extern const char *Txt_Place_of_origin;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"OriginPlace\" class=\"%s\">"
2016-04-23 14:03:56 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:03:56 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Place_of_origin);
2016-04-23 14:03:56 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"OriginPlace\" name=\"OriginPlace\""
2016-04-23 14:03:56 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->OriginPlace);
2016-04-23 14:03:56 +02:00
else if (UsrDat->OriginPlace[0])
fprintf (Gbl.F.Out,"%s",UsrDat->OriginPlace);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:06:49 +02:00
/*****************************************************************************/
2016-04-23 14:12:52 +02:00
/************************ Show user's date of birth **************************/
2016-04-23 14:06:49 +02:00
/*****************************************************************************/
static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:06:49 +02:00
const char *ClassForm)
{
extern const char *Txt_Date_of_birth;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 14:06:49 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Date_of_birth);
2016-04-23 14:06:49 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-04-23 14:06:49 +02:00
Dat_WriteFormDate (Gbl.Now.Date.Year - Rec_USR_MAX_AGE,
Gbl.Now.Date.Year - Rec_USR_MIN_AGE,
"Birth",
&(UsrDat->Birthday),
false,false);
else if (UsrDat->StrBirthday[0])
fprintf (Gbl.F.Out,"%s",UsrDat->StrBirthday);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:12:52 +02:00
/*****************************************************************************/
/************************ Show user's local address **************************/
/*****************************************************************************/
static void Rec_ShowLocalAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:12:52 +02:00
const char *ClassForm)
{
extern const char *Txt_Local_address;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"LocalAddress\" class=\"%s\">"
2016-04-23 14:12:52 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:12:52 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Local_address);
2016-04-23 14:12:52 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"LocalAddress\" name=\"LocalAddress\""
2016-04-23 14:12:52 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->LocalAddress);
2016-04-23 14:12:52 +02:00
else if (UsrDat->LocalAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->LocalAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:18:09 +02:00
/*****************************************************************************/
/************************* Show user's local phone ***************************/
/*****************************************************************************/
static void Rec_ShowLocalPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:18:09 +02:00
const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"LocalPhone\" class=\"%s\">"
2016-04-23 14:18:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:18:09 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 14:18:09 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"LocalPhone\" name=\"LocalPhone\""
2016-04-23 14:18:09 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2016-04-23 19:34:29 +02:00
UsrDat->LocalPhone);
2016-04-23 14:18:09 +02:00
else if (UsrDat->LocalPhone[0])
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->LocalPhone,
UsrDat->LocalPhone);
2016-04-23 14:18:09 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:31:57 +02:00
/*****************************************************************************/
/*********************** Show user's family address **************************/
/*****************************************************************************/
static void Rec_ShowFamilyAddress (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:31:57 +02:00
const char *ClassForm)
{
extern const char *Txt_Family_address;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FamilyAddress\" class=\"%s\">"
2016-04-23 14:31:57 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:31:57 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Family_address);
2016-04-23 14:31:57 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"FamilyAddress\" name=\"FamilyAddress\""
2016-04-23 14:31:57 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2016-04-23 19:34:29 +02:00
UsrDat->FamilyAddress);
2016-04-23 14:31:57 +02:00
else if (UsrDat->FamilyAddress[0])
fprintf (Gbl.F.Out,"%s",UsrDat->FamilyAddress);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:36:02 +02:00
/*****************************************************************************/
/************************ Show user's family phone ***************************/
/*****************************************************************************/
static void Rec_ShowFamilyPhone (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:36:02 +02:00
const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE\">"
"<label for=\"FamilyPhone\" class=\"%s\">"
2016-04-23 14:36:02 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2016-04-23 14:36:02 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 14:36:02 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"FamilyPhone\" name=\"FamilyPhone\""
2016-04-23 14:36:02 +02:00
" maxlength=\"%u\" value=\"%s\""
2016-04-23 19:34:29 +02:00
" class=\"REC_C2_BOT_INPUT\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2016-04-23 19:34:29 +02:00
UsrDat->FamilyPhone);
2016-04-23 14:36:02 +02:00
else if (UsrDat->FamilyPhone[0])
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->FamilyPhone,
UsrDat->FamilyPhone);
2016-04-23 14:36:02 +02:00
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:43:53 +02:00
/*****************************************************************************/
2016-04-23 14:51:12 +02:00
/************************** Show user's comments *****************************/
2016-04-23 14:43:53 +02:00
/*****************************************************************************/
static void Rec_ShowComments (struct UsrData *UsrDat,
2017-01-25 18:48:41 +01:00
bool ShowData,bool ICanEdit,
2016-04-23 14:43:53 +02:00
const char *ClassForm)
{
extern const char *Txt_USER_comments;
fprintf (Gbl.F.Out,"<tr>"
2016-12-27 14:04:47 +01:00
"<td class=\"REC_C1_BOT RIGHT_TOP\">"
"<label for=\"Comments\" class=\"%s\">%s:</label>"
2016-04-23 14:43:53 +02:00
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_TOP\">",
ClassForm,Txt_USER_comments);
2016-04-23 14:43:53 +02:00
if (ShowData)
{
2017-01-25 18:48:41 +01:00
if (ICanEdit)
2016-12-27 14:04:47 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"Comments\" name=\"Comments\""
" rows=\"4\" class=\"REC_C2_BOT_INPUT\">"
2016-04-23 14:43:53 +02:00
"%s"
"</textarea>",
UsrDat->Comments);
else if (UsrDat->Comments[0])
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, // Convert from HTML to rigorous HTML
UsrDat->Comments,Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",UsrDat->Comments);
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 14:51:12 +02:00
/*****************************************************************************/
/************************** Show user's institution **************************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
static void Rec_ShowInstitution (struct Instit *Ins,
2016-04-23 14:51:12 +02:00
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Institution;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 14:51:12 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Institution);
2016-04-23 14:51:12 +02:00
if (ShowData)
{
if (Ins->InsCod > 0)
{
if (Ins->WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ins->WWW);
fprintf (Gbl.F.Out,"%s",Ins->FullName);
if (Ins->WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:00:07 +02:00
/*****************************************************************************/
/*************************** Show user's centre ******************************/
/*****************************************************************************/
static void Rec_ShowCentre (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Centre;
struct Centre Ctr;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:00:07 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Centre);
2016-04-23 15:00:07 +02:00
if (ShowData)
{
if (UsrDat->Tch.CtrCod > 0)
{
Ctr.CtrCod = UsrDat->Tch.CtrCod;
Ctr_GetDataOfCentreByCod (&Ctr);
if (Ctr.WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Ctr.WWW);
fprintf (Gbl.F.Out,"%s",Ctr.FullName);
if (Ctr.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:08:32 +02:00
/*****************************************************************************/
/************************* Show user's department ****************************/
/*****************************************************************************/
static void Rec_ShowDepartment (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Department;
struct Department Dpt;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:08:32 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Department);
2016-04-23 15:08:32 +02:00
if (ShowData)
{
if (UsrDat->Tch.DptCod > 0)
{
Dpt.DptCod = UsrDat->Tch.DptCod;
Dpt_GetDataOfDepartmentByCod (&Dpt);
if (Dpt.WWW[0])
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"REC_DAT_BOLD\">",
Dpt.WWW);
fprintf (Gbl.F.Out,"%s",Dpt.FullName);
if (Dpt.WWW[0])
fprintf (Gbl.F.Out,"</a>");
}
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:15:06 +02:00
/*****************************************************************************/
/*************************** Show user's office ******************************/
/*****************************************************************************/
static void Rec_ShowOffice (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Office;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:15:06 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Office);
2016-04-23 15:15:06 +02:00
if (ShowData)
fprintf (Gbl.F.Out,"%s",UsrDat->Tch.Office);
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-23 15:20:37 +02:00
/*****************************************************************************/
/*************************** Show user's office phone ******************************/
/*****************************************************************************/
static void Rec_ShowOfficePhone (struct UsrData *UsrDat,
bool ShowData,const char *ClassForm)
{
extern const char *Txt_Phone;
fprintf (Gbl.F.Out,"<tr>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C1_BOT RIGHT_MIDDLE %s\">"
2016-04-23 15:20:37 +02:00
"%s:"
"</td>"
2016-04-23 19:34:29 +02:00
"<td class=\"REC_C2_BOT REC_DAT_BOLD LEFT_MIDDLE\">",
ClassForm,Txt_Phone);
2016-04-23 15:20:37 +02:00
if (ShowData)
2016-12-19 02:22:04 +01:00
fprintf (Gbl.F.Out,"<a href=\"tel:%s\" class=\"REC_DAT_BOLD\">%s</a>",
UsrDat->Tch.OfficePhone,
UsrDat->Tch.OfficePhone);
2016-04-23 15:20:37 +02:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
2016-04-22 19:50:59 +02:00
/*****************************************************************************/
/*********************** Write a link to netiquette rules ********************/
/*****************************************************************************/
2014-12-01 23:55:08 +01:00
static void Rec_WriteLinkToDataProtectionClause (void)
{
extern const char *Txt_DATA_PROTECTION_CLAUSE;
2016-11-13 20:54:06 +01:00
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
"<a class=\"TIT\" href=\"%s/%s/\" target=\"_blank\">%s</a>"
"</div>",
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_PUBLIC,Cfg_DATA_PROTECTION_FOLDER,
2014-12-01 23:55:08 +01:00
Txt_DATA_PROTECTION_CLAUSE);
}
/*****************************************************************************/
/**************** Update and show data from identified user ******************/
/*****************************************************************************/
void Rec_UpdateMyRecord (void)
{
/***** Get my data from record form *****/
Rec_GetUsrNameFromRecordForm (&Gbl.Usrs.Me.UsrDat);
Rec_GetUsrExtraDataFromRecordForm (&Gbl.Usrs.Me.UsrDat);
/***** Update my data in database *****/
2014-12-12 18:50:36 +01:00
Enr_UpdateUsrData (&Gbl.Usrs.Me.UsrDat);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**** Get and check future user's role in current course from record form ****/
/*****************************************************************************/
Rol_Role_t Rec_GetRoleFromRecordForm (void)
{
Rol_Role_t Role;
2015-09-16 22:13:00 +02:00
bool RoleOK = false;
2014-12-01 23:55:08 +01:00
/***** Get role as a parameter from form *****/
2017-01-29 21:41:08 +01:00
Role = (Rol_Role_t)
Par_GetParToUnsignedLong ("Role",
0,
Rol_NUM_ROLES - 1,
(unsigned long) Rol_UNKNOWN);
2014-12-01 23:55:08 +01:00
/***** Check if I can register a user
with the received role in current course *****/
/* Check for other possible errors */
switch (Gbl.Usrs.Me.LoggedRole)
{
2015-04-07 21:44:24 +02:00
case Rol_STUDENT: // I am logged as student
2014-12-01 23:55:08 +01:00
/* A student can only change his/her data, but not his/her role */
2015-09-16 22:13:00 +02:00
if (Role == Rol_STUDENT)
RoleOK = true;
2014-12-01 23:55:08 +01:00
break;
2017-01-19 18:32:28 +01:00
/*
2015-04-07 21:44:24 +02:00
case Rol_TEACHER: // I am logged as teacher
2017-01-19 18:32:28 +01:00
// A teacher can only register another user as teacher
// if the other is already teacher in any course.
// That is, a teacher can not upgrade a student
// (in all other courses) to teacher
2016-12-13 13:32:19 +01:00
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Other.UsrDat);
2015-09-16 22:13:00 +02:00
if ( Role == Rol_STUDENT ||
(Role == Rol_TEACHER && // He/she will be a teacher in current course
(Gbl.Usrs.Other.UsrDat.Roles & (1 << Rol_TEACHER)))) // He/she was a teacher in some courses
RoleOK = true;
2014-12-01 23:55:08 +01:00
break;
2017-01-19 18:32:28 +01:00
*/
case Rol_TEACHER: // I am logged as teacher
case Rol_DEG_ADM: // I am logged as degree admin
case Rol_CTR_ADM: // I am logged as centre admin
case Rol_INS_ADM: // I am logged as institution admin
2015-09-16 22:13:00 +02:00
if (Role == Rol_STUDENT ||
Role == Rol_TEACHER)
RoleOK = true;
break;
case Rol_SYS_ADM:
if ( Role == Rol_STUDENT ||
Role == Rol_TEACHER ||
(Role == Rol__GUEST_ && Gbl.CurrentCrs.Crs.CrsCod <= 0))
RoleOK = true;
break;
2014-12-01 23:55:08 +01:00
default:
break;
}
2015-09-16 22:13:00 +02:00
if (!RoleOK)
Lay_ShowErrorAndExit ("Wrong user's role.");
2014-12-01 23:55:08 +01:00
return Role;
}
/*****************************************************************************/
2016-11-18 01:07:00 +01:00
/*************** Get data fields of shared record from form ******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Rec_GetUsrNameFromRecordForm (struct UsrData *UsrDat)
{
2017-03-07 19:55:29 +01:00
char Surname1 [Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; // Temporary surname 1
char FirstName[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1]; // Temporary first name
2014-12-01 23:55:08 +01:00
2017-01-26 11:08:19 +01:00
/***** Get surname 1 *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("Surname1",Surname1,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
Str_ConvertToTitleType (Surname1);
// Surname 1 is mandatory, so avoid overwriting surname 1 with empty string
if (Surname1[0]) // New surname 1 not empty
2017-03-07 19:55:29 +01:00
Str_Copy (UsrDat->Surname1,Surname1,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
/***** Get surname 2 *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("Surname2",UsrDat->Surname2,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2014-12-01 23:55:08 +01:00
Str_ConvertToTitleType (UsrDat->Surname2);
2017-01-26 11:08:19 +01:00
/***** Get first name *****/
2017-03-07 19:55:29 +01:00
Par_GetParToText ("FirstName",FirstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2017-01-26 11:08:19 +01:00
Str_ConvertToTitleType (FirstName);
// First name is mandatory, so avoid overwriting first name with empty string
if (Surname1[0]) // New first name not empty
2017-03-07 19:55:29 +01:00
Str_Copy (UsrDat->FirstName,FirstName,
Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
2014-12-01 23:55:08 +01:00
2017-01-26 11:08:19 +01:00
/***** Build full name *****/
2014-12-01 23:55:08 +01:00
Usr_BuildFullName (UsrDat);
}
2015-12-07 23:13:08 +01:00
static void Rec_GetUsrExtraDataFromRecordForm (struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
/***** Get sex from form *****/
2017-01-29 21:41:08 +01:00
UsrDat->Sex = (Usr_Sex_t)
Par_GetParToUnsignedLong ("Sex",
(unsigned long) Usr_SEX_FEMALE,
(unsigned long) Usr_SEX_MALE,
(unsigned long) Usr_SEX_UNKNOWN);
2014-12-01 23:55:08 +01:00
/***** Get country code *****/
2017-01-28 20:32:50 +01:00
UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod");
2014-12-01 23:55:08 +01:00
2017-03-08 14:12:33 +01:00
Par_GetParToText ("OriginPlace",UsrDat->OriginPlace,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
Str_ConvertToTitleType (UsrDat->OriginPlace);
2015-10-23 01:06:32 +02:00
Dat_GetDateFromForm ("BirthDay","BirthMonth","BirthYear",
&(UsrDat->Birthday.Day ),
&(UsrDat->Birthday.Month),
&(UsrDat->Birthday.Year ));
2014-12-01 23:55:08 +01:00
Dat_ConvDateToDateStr (&(UsrDat->Birthday),UsrDat->StrBirthday);
2017-03-08 14:12:33 +01:00
Par_GetParToText ("LocalAddress",UsrDat->LocalAddress,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
Par_GetParToText ("LocalPhone",UsrDat->LocalPhone,Usr_MAX_BYTES_PHONE);
2017-03-08 14:12:33 +01:00
Par_GetParToText ("FamilyAddress",UsrDat->FamilyAddress,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
Par_GetParToText ("FamilyPhone",UsrDat->FamilyPhone,Usr_MAX_BYTES_PHONE);
Rec_GetUsrCommentsFromForm (UsrDat);
}
/*****************************************************************************/
/********** Get the comments of the record of a user from the form ***********/
/*****************************************************************************/
static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat)
{
/***** Check if memory is allocated for comments *****/
if (!UsrDat->Comments)
Lay_ShowErrorAndExit ("Can not read comments of a user.");
/***** Get the parameter with the comments *****/
Par_GetParToHTML ("Comments",UsrDat->Comments,Cns_MAX_BYTES_TEXT);
}
/*****************************************************************************/
/*** Put a link to the action to edit my institution, centre, department... **/
/*****************************************************************************/
2016-01-04 16:45:43 +01:00
void Rec_PutLinkToChangeMyInsCtrDpt (void)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Edit_my_institution;
/***** Link to edit my institution, centre, department... *****/
2017-04-17 19:03:21 +02:00
Lay_PutContextualLink (ActReqEdiMyIns,NULL,NULL,
"ins64x64.gif",
2016-07-01 16:32:42 +02:00
Txt_Edit_my_institution,Txt_Edit_my_institution,
NULL);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Show form to edit my institution, centre and department ***********/
/*****************************************************************************/
2015-09-24 18:02:21 +02:00
#define COL2_WIDTH 600
2014-12-01 23:55:08 +01:00
void Rec_ShowFormMyInsCtrDpt (void)
{
2016-11-13 13:40:52 +01:00
extern const char *Hlp_PROFILE_Institution;
2015-07-28 00:16:09 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2016-10-23 19:40:14 +02:00
extern const char *Txt_Please_select_the_country_of_your_institution;
2015-03-28 18:34:08 +01:00
extern const char *Txt_Please_fill_in_your_institution;
extern const char *Txt_Please_fill_in_your_centre_and_department;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Institution_centre_and_department;
extern const char *Txt_Institution;
2016-11-10 21:16:23 +01:00
extern const char *Txt_Country_of_your_institution;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Another_institution;
extern const char *Txt_Centre;
extern const char *Txt_Another_centre;
extern const char *Txt_Department;
extern const char *Txt_Another_department;
extern const char *Txt_Office;
extern const char *Txt_Phone;
2015-07-28 00:16:09 +02:00
const char *ClassForm = The_ClassForm[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
unsigned NumCty;
unsigned NumIns;
unsigned NumCtr;
unsigned NumDpt;
2016-12-13 13:32:19 +01:00
bool IAmTeacher;
/***** Get my roles if not yet got *****/
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
/***** Check if I am a teacher *****/
IAmTeacher = (Gbl.Usrs.Me.UsrDat.Roles & (1 << Rol_TEACHER));
2014-12-01 23:55:08 +01:00
2016-10-23 19:40:14 +02:00
/***** If there is no country, institution, centre or department *****/
if (Gbl.Usrs.Me.UsrDat.InsCtyCod < 0)
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_select_the_country_of_your_institution);
2016-10-23 19:40:14 +02:00
else if (Gbl.Usrs.Me.UsrDat.InsCod < 0)
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_institution);
2015-04-07 21:44:24 +02:00
else if ((Gbl.Usrs.Me.UsrDat.Roles & (1 << Rol_TEACHER)) &&
2014-12-01 23:55:08 +01:00
(Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0 ||
Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0))
2017-05-11 23:45:46 +02:00
Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_centre_and_department);
2014-12-01 23:55:08 +01:00
/***** Start table *****/
2016-11-14 10:05:41 +01:00
Lay_StartRoundFrameTable ("800px",
IAmTeacher ? Txt_Institution_centre_and_department :
Txt_Institution,
NULL,Hlp_PROFILE_Institution,2);
2014-12-01 23:55:08 +01:00
/***** Country *****/
2016-11-14 10:05:41 +01:00
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 21:30:22 +01:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"OthCtyCod\" class=\"%s\">%s:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2016-11-10 21:16:23 +01:00
ClassForm,Txt_Country_of_your_institution,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* If list of countries is empty, try to get it */
if (!Gbl.Ctys.Num)
{
2017-01-29 12:42:19 +01:00
Gbl.Ctys.SelectedOrder = Cty_ORDER_BY_COUNTRY;
2015-12-09 19:51:17 +01:00
Cty_GetListCountries (Cty_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
}
/* Start form to select the country of my institution */
Act_FormGoToStart (ActChgCtyMyIns);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtyCod\" name=\"OthCtyCod\""
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.InsCtyCod <= 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>");
for (NumCty = 0;
NumCty < Gbl.Ctys.Num;
NumCty++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctys.Lst[NumCty].CtyCod);
if (Gbl.Ctys.Lst[NumCty].CtyCod == Gbl.Usrs.Me.UsrDat.InsCtyCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Institution *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 21:30:22 +01:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"OthInsCod\" class=\"%s\">%s:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Institution,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of institutions in this country */
Ins_FreeListInstitutions ();
if (Gbl.Usrs.Me.UsrDat.InsCtyCod > 0)
2015-12-09 19:51:17 +01:00
Ins_GetListInstitutions (Gbl.Usrs.Me.UsrDat.InsCtyCod,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
/* Start form to select institution */
Act_FormGoToStart (ActChgMyIns);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthInsCod\" name=\"OthInsCod\""
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.InsCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.InsCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_institution);
for (NumIns = 0;
NumIns < Gbl.Inss.Num;
NumIns++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Inss.Lst[NumIns].InsCod);
if (Gbl.Inss.Lst[NumIns].InsCod == Gbl.Usrs.Me.UsrDat.InsCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Inss.Lst[NumIns].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
if (IAmTeacher)
{
/***** Centre *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 21:30:22 +01:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"OthCtrCod\" class=\"%s\">%s:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Centre,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of centres in this institution */
Ctr_FreeListCentres ();
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Ctr_GetListCentres (Gbl.Usrs.Me.UsrDat.InsCod);
/* Start form to select centre */
Act_FormGoToStart (ActChgMyCtr);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"OthCtrCod\" name=\"OthCtrCod\""
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.Tch.CtrCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_centre);
for (NumCtr = 0;
NumCtr < Gbl.Ctrs.Num;
NumCtr++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Ctrs.Lst[NumCtr].CtrCod);
if (Gbl.Ctrs.Lst[NumCtr].CtrCod == Gbl.Usrs.Me.UsrDat.Tch.CtrCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Ctrs.Lst[NumCtr].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Department *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 21:30:22 +01:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-27 16:45:37 +01:00
"<label for=\"DptCod\" class=\"%s\">%s:</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Department,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
/* Get list of departments in this institution */
Dpt_FreeListDepartments ();
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Dpt_GetListDepartments (Gbl.Usrs.Me.UsrDat.InsCod);
/* Start form to select department */
Act_FormGoToStart (ActChgMyDpt);
2016-12-25 21:30:22 +01:00
fprintf (Gbl.F.Out,"<select id=\"DptCod\" name=\"DptCod\""
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\">"
2014-12-01 23:55:08 +01:00
"<option value=\"-1\"",
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2014-12-01 23:55:08 +01:00
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_department);
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Dpts.Lst[NumDpt].DptCod);
if (Gbl.Dpts.Lst[NumDpt].DptCod == Gbl.Usrs.Me.UsrDat.Tch.DptCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Dpts.Lst[NumDpt].FullName);
}
2015-03-13 00:16:02 +01:00
fprintf (Gbl.F.Out,"</select>");
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Office *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"Office\" class=\"%s\">"
2015-07-28 00:16:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Office,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
Act_FormGoToStart (ActChgMyOff);
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\" id=\"Office\" name=\"Office\""
2015-09-23 14:31:47 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 14:12:33 +01:00
Usr_MAX_CHARS_ADDRESS,
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.Office,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
/***** Phone *****/
fprintf (Gbl.F.Out,"<tr>"
2016-12-25 20:51:53 +01:00
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"OfficePhone\" class=\"%s\">"
2015-07-28 00:16:09 +02:00
"%s:"
2016-12-25 20:51:53 +01:00
"</label>"
2015-07-28 00:16:09 +02:00
"</td>"
2015-09-24 18:02:21 +02:00
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
2015-07-27 19:42:24 +02:00
ClassForm,Txt_Phone,
2015-09-24 18:02:21 +02:00
COL2_WIDTH);
2014-12-01 23:55:08 +01:00
Act_FormGoToStart (ActChgMyOffPho);
2016-12-25 20:51:53 +01:00
fprintf (Gbl.F.Out,"<input type=\"tel\""
" id=\"OfficePhone\" name=\"OfficePhone\""
2015-09-06 19:51:06 +02:00
" maxlength=\"%u\" value=\"%s\""
2015-09-28 18:28:29 +02:00
" style=\"width:500px;\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2017-03-08 01:21:21 +01:00
Usr_MAX_CHARS_PHONE,
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
2015-03-13 00:16:02 +01:00
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2014-12-01 23:55:08 +01:00
}
/***** End table *****/
2015-04-12 18:01:06 +02:00
Lay_EndRoundFrameTable ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******** Receive form data to change the country of my institution **********/
/*****************************************************************************/
void Rec_ChgCountryOfMyInstitution (void)
{
2016-10-23 19:40:14 +02:00
/***** Get country code of my institution *****/
Gbl.Usrs.Me.UsrDat.InsCtyCod = Cty_GetAndCheckParamOtherCtyCod ();
2014-12-01 23:55:08 +01:00
/***** Update institution, centre and department *****/
// When country changes, the institution, centre and department must be reset
2016-10-23 19:40:14 +02:00
Gbl.Usrs.Me.UsrDat.InsCod = -1L;
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/**************** Receive form data to change my institution *****************/
/*****************************************************************************/
void Rec_UpdateMyInstitution (void)
{
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
/***** Get my institution *****/
/* Get institution code */
2016-10-23 19:40:14 +02:00
Ins.InsCod = Ins_GetAndCheckParamOtherInsCod ();
2014-12-01 23:55:08 +01:00
/* Get country of institution */
2016-10-23 19:40:14 +02:00
if (Ins.InsCod > 0)
{
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
if (Gbl.Usrs.Me.UsrDat.InsCtyCod != Ins.CtyCod)
Gbl.Usrs.Me.UsrDat.InsCtyCod = Ins.CtyCod;
}
2014-12-01 23:55:08 +01:00
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.InsCod = Ins.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/******************* Receive form data to change my centre *******************/
/*****************************************************************************/
void Rec_UpdateMyCentre (void)
{
struct Centre Ctr;
/***** Get my centre *****/
/* Get centre code */
2016-10-23 19:40:14 +02:00
Ctr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod ();
2014-12-01 23:55:08 +01:00
/* Get institution of centre */
2016-10-23 19:40:14 +02:00
if (Ctr.CtrCod > 0)
2014-12-01 23:55:08 +01:00
{
2016-10-23 19:40:14 +02:00
Ctr_GetDataOfCentreByCod (&Ctr);
if (Gbl.Usrs.Me.UsrDat.InsCod != Ctr.InsCod)
{
Gbl.Usrs.Me.UsrDat.InsCod = Ctr.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.DptCod = -1L;
}
2014-12-01 23:55:08 +01:00
}
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = Ctr.CtrCod;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/***************** Receive form data to change my department *****************/
/*****************************************************************************/
void Rec_UpdateMyDepartment (void)
{
struct Department Dpt;
/***** Get my department *****/
/* Get department code */
if ((Dpt.DptCod = Dpt_GetParamDptCod ()) < 0)
Lay_ShowErrorAndExit ("Code of department is missing.");
/* Get institution of department */
2016-10-23 19:40:14 +02:00
if (Dpt.DptCod > 0)
2014-12-01 23:55:08 +01:00
{
2016-10-23 19:40:14 +02:00
Dpt_GetDataOfDepartmentByCod (&Dpt);
if (Gbl.Usrs.Me.UsrDat.InsCod != Dpt.InsCod)
{
Gbl.Usrs.Me.UsrDat.InsCod = Dpt.InsCod;
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = -1L;
}
2014-12-01 23:55:08 +01:00
}
/***** Update institution, centre and department *****/
Gbl.Usrs.Me.UsrDat.Tch.DptCod = Dpt.DptCod;
2014-12-12 18:50:36 +01:00
Enr_UpdateInstitutionCentreDepartment ();
2014-12-01 23:55:08 +01:00
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/******************* Receive form data to change my office *******************/
/*****************************************************************************/
void Rec_UpdateMyOffice (void)
{
2017-03-08 14:12:33 +01:00
char Query[128 + Usr_MAX_BYTES_ADDRESS];
2014-12-01 23:55:08 +01:00
/***** Get my office *****/
2017-03-08 14:12:33 +01:00
Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Usr_MAX_BYTES_ADDRESS);
2014-12-01 23:55:08 +01:00
/***** Update office *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"UPDATE usr_data SET Office='%s' WHERE UsrCod=%ld",
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.Office,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update office");
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}
/*****************************************************************************/
/**************** Receive form data to change my office phone ****************/
/*****************************************************************************/
void Rec_UpdateMyOfficePhone (void)
{
2017-01-28 15:58:46 +01:00
char Query[128 + Usr_MAX_BYTES_PHONE];
2014-12-01 23:55:08 +01:00
/***** Get my office *****/
Par_GetParToText ("OfficePhone",Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,Usr_MAX_BYTES_PHONE);
/***** Update office phone *****/
2017-03-24 01:09:27 +01:00
sprintf (Query,"UPDATE usr_data SET OfficePhone='%s' WHERE UsrCod=%ld",
2014-12-01 23:55:08 +01:00
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update office phone");
/***** Show form again *****/
Rec_ShowFormMyInsCtrDpt ();
}