Version 15.225.16

This commit is contained in:
Antonio Cañas Vargas 2016-06-16 19:30:29 +02:00
parent a15143387c
commit ed6b24d1e4
9 changed files with 140 additions and 15 deletions

View File

@ -31,6 +31,7 @@
#include "swad_announcement.h"
#include "swad_calendar.h"
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_enrollment.h"
#include "swad_follow.h"
#include "swad_global.h"

View File

@ -41,6 +41,7 @@
#include "swad_chat.h"
#include "swad_database.h"
#include "swad_degree_type.h"
#include "swad_duplicate.h"
#include "swad_exam.h"
#include "swad_enrollment.h"
#include "swad_follow.h"
@ -1056,6 +1057,7 @@ Users:
883. ActRemOldUsr Eliminate completely old users
NEW. ActLstDupUsr List possible duplicate users
NEW. ActLstSimUsr List users similar to a given one (possible duplicates)
884. ActLstClk List last clicks in real time
Social:
@ -2452,6 +2454,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActRemOldUsr */{ 773,-1,TabUsr,ActLstOth ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemoveOldUsrs ,NULL},
/* ActLstDupUsr */{1578,-1,TabUsr,ActLstOth ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Dup_ListDuplicateUsrs ,NULL},
/* ActLstSimUsr */{1579,-1,TabUsr,ActLstOth ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Dup_ListSimilarUsrs ,NULL},
/* ActLstClk */{ 989,-1,TabUsr,ActLstCon ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Con_ShowLastClicks ,NULL},
@ -4417,6 +4420,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq
ActReqRemTchPho, // #1576
ActReqRemMyPho, // #1577
ActLstDupUsr, // #1578
ActLstSimUsr, // #1579
};
/*****************************************************************************/

View File

@ -72,9 +72,9 @@ typedef enum
typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+154+172+36+28+84)
#define Act_NUM_ACTIONS (1+9+51+15+90+70+67+246+186+155+172+36+28+84)
#define Act_MAX_ACTION_COD 1578
#define Act_MAX_ACTION_COD 1579
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20
@ -1095,8 +1095,9 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica
#define ActRemOldUsr (ActChgNumRowFooGrp+152)
#define ActLstDupUsr (ActChgNumRowFooGrp+153)
#define ActLstSimUsr (ActChgNumRowFooGrp+154)
#define ActLstClk (ActChgNumRowFooGrp+154)
#define ActLstClk (ActChgNumRowFooGrp+155)
/*****************************************************************************/
/******************************** Social tab *********************************/

View File

@ -128,13 +128,17 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.225.15 (2016-06-16)"
#define Log_PLATFORM_VERSION "SWAD 15.225.16 (2016-06-16)"
#define CSS_FILE "swad15.225.11.css"
#define JS_FILE "swad15.216.js"
// 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
/*
Version 15.225.16:Jun 16, 2016 New action to show similar users. Not finished. (202887 lines)
1 change necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1579','es','N','Listar usuarios similares');
Version 15.225.15:Jun 16, 2016 Button in possible duplicate user to show similar users. (202781 lines)
Version 15.225.14:Jun 16, 2016 Code refactoring in listing of users. (202741 lines)
Version 15.225.13:Jun 16, 2016 Check if a user in listing of possible duplicate users has accepted all his/her courses. (202790 lines)

View File

@ -25,16 +25,12 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
// #include <ctype.h> // For isalnum, isdigit, etc.
// #include <limits.h> // For maximum values
// #include <linux/limits.h> // For PATH_MAX
// #include <linux/stddef.h> // For NULL
// #include <stdlib.h> // For exit, system, malloc, free, rand, etc.
// #include <string.h> // For string functions
// #include <sys/wait.h> // For the macro WEXITSTATUS
// #include <unistd.h> // For access, lstat, getpid, chdir, symlink, unlink
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_global.h"
#include "swad_layout.h"
#include "swad_role.h"
@ -202,7 +198,128 @@ void Dup_ListDuplicateUsrs (void)
Gbl.RowEvenOdd,
Usr_NUM_MAIN_FIELDS_DATA_USR-2,
Gbl.RowEvenOdd);
Act_FormStart (ActLstDupUsr); // TODO: Change to new action
Act_FormStart (ActLstSimUsr);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Lay_PutConfirmButtonInline (Txt_Similar_users);
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/* Write all the courses this user belongs to */
Crs_GetAndWriteCrssOfAUsr (&UsrDat,Rol_TEACHER);
Crs_GetAndWriteCrssOfAUsr (&UsrDat,Rol_STUDENT);
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
}
else // User does not exists ==>
// remove user from table of possible duplicate users
Dup_RemoveUsrFromDuplicated (UsrDat.UsrCod);
}
/***** End table *****/
fprintf (Gbl.F.Out,"</table>");
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
else // There are no users
Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_UNKNOWN]);
/***** End frame *****/
Lay_EndRoundFrame ();
}
/*****************************************************************************/
/********************* List similar users to a given one *********************/
/*****************************************************************************/
// TODO: Write the code of this function
void Dup_ListSimilarUsrs (void)
{
extern const char *Txt_Possibly_duplicate_users;
extern const char *Txt_Informants;
extern const char *Txt_Similar_users;
extern const char *Txt_No_users_found[Rol_NUM_ROLES];
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumUsrs;
unsigned NumUsr;
struct UsrData UsrDat;
unsigned NumInformants;
/***** Start frame with list of possible duplicate users *****/
Lay_StartRoundFrame (NULL,Txt_Possibly_duplicate_users,NULL);
/***** Build query *****/
sprintf (Query,"SELECT UsrCod,COUNT(*) AS N,MIN(UNIX_TIMESTAMP(InformTime)) AS T"
" FROM usr_duplicated"
" GROUP BY UsrCod"
" ORDER BY N DESC,T DESC");
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get requests for enrollment");
/***** List possible duplicated users *****/
if (NumUsrs)
{
/***** Initialize field names *****/
Usr_SetUsrDatMainFieldNames ();
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Start table *****/
fprintf (Gbl.F.Out,"<table class=\"CELLS_PAD_2\">");
/***** Heading row with column names *****/
Gbl.Usrs.Listing.WithPhotos = true;
Usr_WriteHeaderFieldsUsrDat (false); // Columns for the data
/***** List users *****/
for (NumUsr = 0, Gbl.RowEvenOdd = 0;
NumUsr < NumUsrs;
NumUsr++)
{
row = mysql_fetch_row (mysql_res);
/* Get user code (row[0]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
{
if (Usr_GetNumCrssOfUsr (UsrDat.UsrCod) != 0)
UsrDat.Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0);
else
UsrDat.Accepted = false;
/* Write data of this user */
Usr_WriteRowUsrMainData (NumUsrs - NumUsr,&UsrDat,false);
/* Write number of informants (row[1]) if greater than 1 */
if (sscanf (row[1],"%u",&NumInformants) != 1)
Lay_ShowErrorAndExit ("Wrong number of informers.");
if (NumInformants > 1)
fprintf (Gbl.F.Out,"<tr>"
"<td colspan=\"2\" class=\"COLOR%u\"></td>"
"<td colspan=\"%u\""
" class=\"DAT LEFT_MIDDLE COLOR%u\">"
"%s: %u"
"</td>"
"</tr>",
Gbl.RowEvenOdd,
Usr_NUM_MAIN_FIELDS_DATA_USR-2,
Gbl.RowEvenOdd,
Txt_Informants,
NumInformants);
/* Write link to view users similar to this */
fprintf (Gbl.F.Out,"<tr>"
"<td colspan=\"2\" class=\"COLOR%u\"></td>"
"<td colspan=\"%u\""
" class=\"DAT LEFT_MIDDLE COLOR%u\">",
Gbl.RowEvenOdd,
Usr_NUM_MAIN_FIELDS_DATA_USR-2,
Gbl.RowEvenOdd);
Act_FormStart (ActLstSimUsr);
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
Lay_PutConfirmButtonInline (Txt_Similar_users);
Act_FormEnd ();

View File

@ -42,6 +42,7 @@
void Dup_ReportUsrAsPossibleDuplicate (void);
void Dup_PutLinkToListDupUsrs (void);
void Dup_ListDuplicateUsrs (void);
void Dup_ListSimilarUsrs (void);
void Dup_RemoveUsrFromDuplicated (long UsrCod);
#endif

View File

@ -31,6 +31,7 @@
#include "swad_account.h"
#include "swad_announcement.h"
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_enrollment.h"
#include "swad_global.h"
#include "swad_ID.h"

View File

@ -41,6 +41,7 @@
#include "swad_connected.h"
#include "swad_course.h"
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_enrollment.h"
#include "swad_global.h"
#include "swad_group.h"

View File

@ -357,9 +357,4 @@ void Usr_GetAndShowNumUsrsInPlatform (Rol_Role_t Role);
bool Usr_CheckIfUsrBanned (long UsrCod);
void Usr_RemoveUsrFromUsrBanned (long UsrCod);
void Dup_ReportUsrAsPossibleDuplicate (void);
void Dup_PutLinkToListDupUsrs (void);
void Dup_ListDuplicateUsrs (void);
void Dup_RemoveUsrFromDuplicated (long UsrCod);
#endif