Version 16.225.7

This commit is contained in:
Antonio Cañas Vargas 2017-05-26 20:11:24 +02:00
parent ed6f02788e
commit ea255a5fa3
2 changed files with 97 additions and 144 deletions

View File

@ -231,19 +231,19 @@
// TODO: Statistics of hits in course accessible by non-editing teachers. // TODO: Statistics of hits in course accessible by non-editing teachers.
// TODO: Fix order of teachers when listing record cards of teachers
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.225.6 (2017-05-26)" #define Log_PLATFORM_VERSION "SWAD 16.225.7 (2017-05-26)"
#define CSS_FILE "swad16.222.css" #define CSS_FILE "swad16.222.css"
#define JS_FILE "swad16.206.3.js" #define JS_FILE "swad16.206.3.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.225.7: May 26, 2017 Fix bug in order of users when listing record cards of teachers.
Code refactoring in checkboxes to select users. (220509 lines)
Version 16.225.6: May 26, 2017 Fixed bug printing classphoto of teachers. (220553 lines) Version 16.225.6: May 26, 2017 Fixed bug printing classphoto of teachers. (220553 lines)
Version 16.225.5: May 26, 2017 Removed link to show all data of students. (220543 lines) Version 16.225.5: May 26, 2017 Removed link to show all data of students. (220543 lines)
Version 16.225.4: May 26, 2017 Removed link to show all data of teachers. (220562 lines) Version 16.225.4: May 26, 2017 Removed link to show all data of teachers. (220562 lines)

View File

@ -74,23 +74,52 @@ const char *Usr_StringsSexDB[Usr_NUM_SEXS] =
"all", "all",
}; };
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES] = const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES] =
{ {
"", // Usr_LIST_UNKNOWN "", // Usr_LIST_UNKNOWN
"classphoto", // Usr_LIST_AS_CLASS_PHOTO "classphoto", // Usr_LIST_AS_CLASS_PHOTO
"list", // Usr_LIST_AS_LISTING "list", // Usr_LIST_AS_LISTING
}; };
const char *Usr_IconsClassPhotoOrList[Usr_NUM_USR_LIST_TYPES] =
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
static const char *Usr_IconsClassPhotoOrList[Usr_NUM_USR_LIST_TYPES] =
{ {
"", // Usr_LIST_UNKNOWN "", // Usr_LIST_UNKNOWN
"classphoto16x16.gif", // Usr_LIST_AS_CLASS_PHOTO "classphoto16x16.gif", // Usr_LIST_AS_CLASS_PHOTO
"list64x64.gif", // Usr_LIST_AS_LISTING "list64x64.gif", // Usr_LIST_AS_LISTING
}; };
static const char *Usr_NameSelUnsel[Rol_NUM_ROLES] =
{
NULL, // Rol_UNK
"SEL_UNSEL_GSTS", // Rol_GST
NULL, // Rol_USR
"SEL_UNSEL_STDS", // Rol_STD
"SEL_UNSEL_NETS", // Rol_NET
"SEL_UNSEL_TCHS", // Rol_TCH
NULL, // Rol_DEG_ADM
NULL, // Rol_CTR_ADM
NULL, // Rol_INS_ADM
NULL, // Rol_SYS_ADM
};
static const char *Usr_ParamUsrCod[Rol_NUM_ROLES] =
{
"UsrCodAll", // Rol_UNK (here means all users)
"UsrCodGst", // Rol_GST
NULL, // Rol_USR
"UsrCodStd", // Rol_STD
"UsrCodNET", // Rol_NET
"UsrCodTch", // Rol_TCH
NULL, // Rol_DEG_ADM
NULL, // Rol_CTR_ADM
NULL, // Rol_INS_ADM
NULL, // Rol_SYS_ADM
};
#define Usr_NUM_MAIN_FIELDS_DATA_ADM 7 #define Usr_NUM_MAIN_FIELDS_DATA_ADM 7
#define Usr_NUM_ALL_FIELDS_DATA_GST 17 #define Usr_NUM_ALL_FIELDS_DATA_GST 17
#define Usr_NUM_ALL_FIELDS_DATA_STD 13 #define Usr_NUM_ALL_FIELDS_DATA_STD 13
@ -5185,9 +5214,9 @@ void Usr_PutHiddenParUsrCodAll (Act_Action_t NextAction,const char *ListUsrCods)
/***** Put a parameter with the encrypted user codes of several users *****/ /***** Put a parameter with the encrypted user codes of several users *****/
if (Gbl.Session.IsOpen) if (Gbl.Session.IsOpen)
Ses_InsertHiddenParInDB (NextAction,"UsrCodAll",ListUsrCods); Ses_InsertHiddenParInDB (NextAction,Usr_ParamUsrCod[Rol_UNK],ListUsrCods);
else else
Par_PutHiddenParamString ("UsrCodAll",ListUsrCods); Par_PutHiddenParamString (Usr_ParamUsrCod[Rol_UNK],ListUsrCods);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5197,95 +5226,47 @@ void Usr_PutHiddenParUsrCodAll (Act_Action_t NextAction,const char *ListUsrCods)
void Usr_GetListsSelectedUsrsCods (void) void Usr_GetListsSelectedUsrsCods (void)
{ {
unsigned Length; unsigned Length;
Rol_Role_t Role;
/***** Allocate memory for the lists of users *****/ /***** Get possible list of all selected users *****/
Usr_AllocateListSelectedUsrCod (Rol_UNK); Usr_AllocateListSelectedUsrCod (Rol_UNK);
Usr_AllocateListSelectedUsrCod (Rol_GST);
Usr_AllocateListSelectedUsrCod (Rol_STD);
Usr_AllocateListSelectedUsrCod (Rol_NET);
Usr_AllocateListSelectedUsrCod (Rol_TCH);
/***** Get selected users *****/
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
{ {
Ses_GetHiddenParFromDB (Gbl.Action.Act,"UsrCodAll",Gbl.Usrs.Select[Rol_UNK], Ses_GetHiddenParFromDB (Gbl.Action.Act,Usr_ParamUsrCod[Rol_UNK],Gbl.Usrs.Select[Rol_UNK],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,Gbl.Usrs.Select[Rol_UNK], Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,Gbl.Usrs.Select[Rol_UNK],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS,true); Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS,true);
} }
else else
Par_GetParMultiToText ("UsrCodAll",Gbl.Usrs.Select[Rol_UNK], Par_GetParMultiToText (Usr_ParamUsrCod[Rol_UNK],Gbl.Usrs.Select[Rol_UNK],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
Par_GetParMultiToText ("UsrCodGst",Gbl.Usrs.Select[Rol_GST], /***** Get list of selected users for each possible role *****/
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Guests for (Role = Rol_TCH; // From the highest possible role of selected users...
Par_GetParMultiToText ("UsrCodStd",Gbl.Usrs.Select[Rol_STD], Role >= Rol_GST; // ...downto the lowest possible role of selected users
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Students Role--)
Par_GetParMultiToText ("UsrCodNET",Gbl.Usrs.Select[Rol_NET], if (Usr_ParamUsrCod[Role])
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Non-editing teachers {
Par_GetParMultiToText ("UsrCodTch",Gbl.Usrs.Select[Rol_TCH], /* Get parameter with selected users with this role */
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Teachers Usr_AllocateListSelectedUsrCod (Role);
Par_GetParMultiToText (Usr_ParamUsrCod[Role],Gbl.Usrs.Select[Role],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
/* /* Add selected users with this role
sprintf (Gbl.Alert.Txt,"UsrCodAll = %s / UsrCodTch = %s / UsrCodStd = %s", to the list with all selected users */
Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select.Tch,Gbl.Usrs.Select.Std); if (Gbl.Usrs.Select[Role][0])
Lay_ShowErrorAndExit (Gbl.Alert.Txt); {
*/ if (Gbl.Usrs.Select[Rol_UNK][0])
/***** Add guests to the list with all selected users *****/ if ((Length = strlen (Gbl.Usrs.Select[Rol_UNK])) <
if (Gbl.Usrs.Select[Rol_GST][0]) Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
{ {
if (Gbl.Usrs.Select[Rol_UNK][0]) Gbl.Usrs.Select[Rol_UNK][Length ] = Par_SEPARATOR_PARAM_MULTIPLE;
if ((Length = strlen (Gbl.Usrs.Select[Rol_UNK])) < Gbl.Usrs.Select[Rol_UNK][Length + 1] = '\0';
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) }
{ Str_Concat (Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select[Role],
Gbl.Usrs.Select[Rol_UNK][Length ] = Par_SEPARATOR_PARAM_MULTIPLE; Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
Gbl.Usrs.Select[Rol_UNK][Length + 1] = '\0'; }
} }
Str_Concat (Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select[Rol_GST],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
}
/***** Add students to the list with all selected users *****/
if (Gbl.Usrs.Select[Rol_STD][0])
{
if (Gbl.Usrs.Select[Rol_UNK][0])
if ((Length = strlen (Gbl.Usrs.Select[Rol_UNK])) <
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
{
Gbl.Usrs.Select[Rol_UNK][Length ] = Par_SEPARATOR_PARAM_MULTIPLE;
Gbl.Usrs.Select[Rol_UNK][Length + 1] = '\0';
}
Str_Concat (Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select[Rol_STD],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
}
/***** Add non-editing teachers to the list with all selected users *****/
if (Gbl.Usrs.Select[Rol_NET][0])
{
if (Gbl.Usrs.Select[Rol_UNK][0])
if ((Length = strlen (Gbl.Usrs.Select[Rol_UNK])) <
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
{
Gbl.Usrs.Select[Rol_UNK][Length ] = Par_SEPARATOR_PARAM_MULTIPLE;
Gbl.Usrs.Select[Rol_UNK][Length + 1] = '\0';
}
Str_Concat (Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select[Rol_NET],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
}
/***** Add teachers to the list with all selected users *****/
if (Gbl.Usrs.Select[Rol_TCH][0])
{
if (Gbl.Usrs.Select[Rol_UNK][0])
if ((Length = strlen (Gbl.Usrs.Select[Rol_UNK])) <
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
{
Gbl.Usrs.Select[Rol_UNK][Length ] = Par_SEPARATOR_PARAM_MULTIPLE;
Gbl.Usrs.Select[Rol_UNK][Length + 1] = '\0';
}
Str_Concat (Gbl.Usrs.Select[Rol_UNK],Gbl.Usrs.Select[Rol_TCH],
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
}
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5752,29 +5733,15 @@ void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role)
"<th colspan=\"%u\" class=\"LEFT_MIDDLE LIGHT_BLUE\">" "<th colspan=\"%u\" class=\"LEFT_MIDDLE LIGHT_BLUE\">"
"<label>", "<label>",
Usr_GetColumnsForSelectUsrs ()); Usr_GetColumnsForSelectUsrs ());
switch (Role) if (Usr_NameSelUnsel[Role] &&
{ Usr_ParamUsrCod[Role])
case Rol_STD: fprintf (Gbl.F.Out,"<input type=\"checkbox\""
fprintf (Gbl.F.Out,"<input type=\"checkbox\"" " name=\"%s\" value=\"\""
" name=\"SEL_UNSEL_STDS\" value=\"\"" " onclick=\"togglecheckChildren(this,'%s')\" />",
" onclick=\"togglecheckChildren(this,'UsrCodStd')\" />"); Usr_NameSelUnsel[Role],
break; Usr_ParamUsrCod[Role]);
case Rol_NET: else
fprintf (Gbl.F.Out,"<input type=\"checkbox\"" Lay_ShowErrorAndExit ("Wrong role.");
" name=\"SEL_UNSEL_NETS\" value=\"\""
" onclick=\"togglecheckChildren(this,'UsrCodNET')\" />");
break;
case Rol_TCH:
fprintf (Gbl.F.Out,"<input type=\"checkbox\""
" name=\"SEL_UNSEL_TCHS\" value=\"\""
" onclick=\"togglecheckChildren(this,'UsrCodTch')\" />");
break;
default:
fprintf (Gbl.F.Out,"<input type=\"checkbox\""
" name=\"SEL_UNSEL_GSTS\" value=\"\""
" onclick=\"togglecheckChildren(this,'UsrCodGst')\" />");
break;
}
Sex = Usr_GetSexOfUsrsLst (Role); Sex = Usr_GetSexOfUsrsLst (Role);
fprintf (Gbl.F.Out,"%s:" fprintf (Gbl.F.Out,"%s:"
"</label>" "</label>"
@ -5829,43 +5796,29 @@ static void Usr_PutCheckboxToSelectUser (struct UsrData *UsrDat,bool UsrIsTheMsg
{ {
bool CheckboxChecked; bool CheckboxChecked;
/***** Check box *****/ if (Usr_NameSelUnsel[UsrDat->RoleInCurrentCrsDB] &&
fprintf (Gbl.F.Out,"<input type=\"checkbox\" name=\""); Usr_ParamUsrCod[UsrDat->RoleInCurrentCrsDB])
switch (UsrDat->RoleInCurrentCrsDB)
{ {
case Rol_STD: /***** Check box must be checked? *****/
fprintf (Gbl.F.Out,"UsrCodStd\" value=\"%s\"" CheckboxChecked = false;
" onclick=\"checkParent(this,'SEL_UNSEL_STDS')\"", if (UsrIsTheMsgSender)
UsrDat->EncryptedUsrCod); CheckboxChecked = true;
break; else
case Rol_NET: /* Check if user is in lists of selected users */
fprintf (Gbl.F.Out,"UsrCodNET\" value=\"%s\"" CheckboxChecked = Usr_FindUsrCodInListOfSelectedUsrs (UsrDat->EncryptedUsrCod);
" onclick=\"checkParent(this,'SEL_UNSEL_NETS')\"",
UsrDat->EncryptedUsrCod); /***** Check box *****/
break; fprintf (Gbl.F.Out,"<input type=\"checkbox\" name=\"%s\" value=\"%s\""
case Rol_TCH: " onclick=\"checkParent(this,'%s')\"",
fprintf (Gbl.F.Out,"UsrCodTch\" value=\"%s\"" Usr_ParamUsrCod[UsrDat->RoleInCurrentCrsDB],
" onclick=\"checkParent(this,'SEL_UNSEL_TCHS')\"", UsrDat->EncryptedUsrCod,
UsrDat->EncryptedUsrCod); Usr_NameSelUnsel[UsrDat->RoleInCurrentCrsDB]);
break; if (CheckboxChecked)
default: fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out,"UsrCodGst\" value=\"%s\"" fprintf (Gbl.F.Out," />");
" onclick=\"checkParent(this,'SEL_UNSEL_GSTS')\"",
UsrDat->EncryptedUsrCod);
break;
} }
/***** Check box must be checked? *****/
CheckboxChecked = false;
if (UsrIsTheMsgSender)
CheckboxChecked = true;
else else
/* Check if user is in lists of selected users */ Lay_ShowErrorAndExit ("Wrong role.");
CheckboxChecked = Usr_FindUsrCodInListOfSelectedUsrs (UsrDat->EncryptedUsrCod);
if (CheckboxChecked)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," />");
} }
/*****************************************************************************/ /*****************************************************************************/