Version 16.247.4

This commit is contained in:
Antonio Cañas Vargas 2017-07-02 19:46:53 +02:00
parent b8beeeb1c5
commit 0219949cd4
2 changed files with 26 additions and 19 deletions

View File

@ -231,23 +231,22 @@
// TODO: Fix bug: Error when a link end in a dot. Example: "A guide to building..." --> "A guide to building._..url" (two dots) // TODO: Fix bug: Error when a link end in a dot. Example: "A guide to building..." --> "A guide to building._..url" (two dots)
// TODO: Cuando sólo se cambian los grupos y no el rol de un profesor ya existente, no sale ningún mensaje. se haga lo que se haga en la edición debería salir un mensaje del tipo "Cambios realizados" // TODO: Cuando sólo se cambian los grupos y no el rol de un profesor ya existente, no sale ningún mensaje. se haga lo que se haga en la edición debería salir un mensaje del tipo "Cambios realizados"
// TODO: Al inscribir un profesor, en la ficha de confirmación aparece como rol "Desconocido" en lugar de "Profesor"
// TODO: Al buscar asignaturas, Estudiantes y Profesores están al revés // TODO: Al buscar asignaturas, Estudiantes y Profesores están al revés
// !!!!!!!!!!!!!!!!!!!!!!!!!
// BUG!!!! Al ver resultados de una encuesta: "Space allocated to string is full."
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.247.3 (2017-07-02)" #define Log_PLATFORM_VERSION "SWAD 16.247.4 (2017-07-02)"
#define CSS_FILE "swad16.235.1.css" #define CSS_FILE "swad16.235.1.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.247.4: Jul 02, 2017 Fixed bug in surveys. (222138 lines)
Version 16.247.3: Jul 02, 2017 Students can not view records of some users who do not share groups with them. (222132 lines) Version 16.247.3: Jul 02, 2017 Students can not view records of some users who do not share groups with them. (222132 lines)
Version 16.247.2: Jun 23, 2017 Non-editing teachers can not view records of some users who do not share groups with them. Version 16.247.2: Jun 23, 2017 Non-editing teachers can not view records of some users who do not share groups with them.
Code refactoring related with roles. (222094 lines) Code refactoring related with roles. (222094 lines)

View File

@ -138,7 +138,7 @@ static void Svy_RemAnswersOfAQuestion (long QstCod);
static Svy_AnswerType_t Svy_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD); static Svy_AnswerType_t Svy_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD);
static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd); static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd);
static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res); static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res);
static int Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns); static bool Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns);
static void Svy_FreeTextChoiceAnswers (struct SurveyQuestion *SvyQst,unsigned NumAnswers); static void Svy_FreeTextChoiceAnswers (struct SurveyQuestion *SvyQst,unsigned NumAnswers);
static void Svy_FreeTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns); static void Svy_FreeTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns);
@ -392,6 +392,9 @@ void Svy_SeeOneSurvey (void)
struct Survey Svy; struct Survey Svy;
struct SurveyQuestion SvyQst; struct SurveyQuestion SvyQst;
/***** Initialize question to zero *****/
Svy_InitQst (&SvyQst);
/***** Get parameters *****/ /***** Get parameters *****/
Svy_GetParamSvyOrder (); Svy_GetParamSvyOrder ();
Grp_GetParamWhichGrps (); Grp_GetParamWhichGrps ();
@ -2871,16 +2874,16 @@ static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res)
/******************* Allocate memory for a choice answer *********************/ /******************* Allocate memory for a choice answer *********************/
/*****************************************************************************/ /*****************************************************************************/
static int Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns) static bool Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns)
{ {
Svy_FreeTextChoiceAnswer (SvyQst,NumAns); Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL) if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
{ {
sprintf (Gbl.Alert.Txt,"Not enough memory to store answer."); sprintf (Gbl.Alert.Txt,"Not enough memory to store answer.");
return 0; return false;
} }
SvyQst->AnsChoice[NumAns].Text[0] = '\0'; SvyQst->AnsChoice[NumAns].Text[0] = '\0';
return 1; return true;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2956,7 +2959,8 @@ void Svy_ReceiveQst (void)
NumAns < Svy_MAX_ANSWERS_PER_QUESTION; NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
NumAns++) NumAns++)
{ {
Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns); if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
Lay_ShowErrorAndExit (Gbl.Alert.Txt);
sprintf (AnsStr,"AnsStr%u",NumAns); sprintf (AnsStr,"AnsStr%u",NumAns);
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER); Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
} }
@ -3364,14 +3368,18 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy,struct SurveyQuestion *Sv
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumUsrsThisAnswer; unsigned NumUsrsThisAnswer;
char *Answer;
size_t AnsLength;
/***** Get answers of this question *****/
NumAnswers = Svy_GetAnswersQst (SvyQst->QstCod,&mysql_res); // Result: AnsInd,NumUsrs,Answer NumAnswers = Svy_GetAnswersQst (SvyQst->QstCod,&mysql_res); // Result: AnsInd,NumUsrs,Answer
/***** Write the answers *****/ /***** Write the answers *****/
if (NumAnswers) if (NumAnswers)
{ {
/* Check number of answers */
if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION)
Lay_ShowErrorAndExit ("Wrong number of answers.");
/* Write one row for each answer */
Tbl_StartTable (5); Tbl_StartTable (5);
for (NumAns = 0; for (NumAns = 0;
NumAns < NumAnswers; NumAns < NumAnswers;
@ -3384,13 +3392,12 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy,struct SurveyQuestion *Sv
Lay_ShowErrorAndExit ("Error when getting number of users who have marked an answer."); Lay_ShowErrorAndExit ("Error when getting number of users who have marked an answer.");
/* Convert the answer (row[2]), that is in HTML, to rigorous HTML */ /* Convert the answer (row[2]), that is in HTML, to rigorous HTML */
AnsLength = strlen (row[2]); if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
if ((Answer = malloc (AnsLength + 1)) == NULL) Lay_ShowErrorAndExit (Gbl.Alert.Txt);
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
Str_Copy (Answer,row[2], Svy_MAX_BYTES_ANSWER);
AnsLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Answer,AnsLength,false); SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false);
/* Selectors and label with the letter of the answer */ /* Selectors and label with the letter of the answer */
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
@ -3425,7 +3432,8 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy,struct SurveyQuestion *Sv
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP\">" fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP\">"
"<label for=\"Ans%010u_%010u\" class=\"DAT\">%s</label>" "<label for=\"Ans%010u_%010u\" class=\"DAT\">%s</label>"
"</td>", "</td>",
(unsigned) SvyQst->QstCod,NumAns,Answer); (unsigned) SvyQst->QstCod,NumAns,
SvyQst->AnsChoice[NumAns].Text);
/* Show stats of this answer */ /* Show stats of this answer */
if (Svy->Status.ICanViewResults) if (Svy->Status.ICanViewResults)
@ -3434,7 +3442,7 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy,struct SurveyQuestion *Sv
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
/* Free memory allocated for the answer */ /* Free memory allocated for the answer */
free ((void *) Answer); Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
} }
Tbl_EndTable (); Tbl_EndTable ();
} }