mirror of https://github.com/acanas/swad-core.git
Version 15.213
This commit is contained in:
parent
dde24c8652
commit
5dad067f19
|
@ -194,17 +194,14 @@ function setLocalDateTimeFormFromUTC (id,TimeUTC) {
|
|||
|
||||
// Set UTC time from local date-time form fields
|
||||
function setUTCFromLocalDateTimeForm (id) {
|
||||
var d = new Date();
|
||||
|
||||
// Important: set year first in order to work properly with leap years
|
||||
d.setFullYear(document.getElementById(id+'Year' ).value);
|
||||
d.setMonth (document.getElementById(id+'Month' ).value-1);
|
||||
d.setDate (document.getElementById(id+'Day' ).value);
|
||||
d.setHours (document.getElementById(id+'Hour' ).value);
|
||||
d.setMinutes (document.getElementById(id+'Minute').value);
|
||||
d.setSeconds (document.getElementById(id+'Second').value);
|
||||
d.setMilliseconds(0);
|
||||
|
||||
// Important: set date all at once to avoid problems with different length of months
|
||||
var d = new Date(document.getElementById(id+'Year' ).value,
|
||||
document.getElementById(id+'Month' ).value-1,
|
||||
document.getElementById(id+'Day' ).value,
|
||||
document.getElementById(id+'Hour' ).value,
|
||||
document.getElementById(id+'Minute').value,
|
||||
document.getElementById(id+'Second').value,
|
||||
0);
|
||||
document.getElementById(id+'TimeUTC').value = d.getTime() / 1000;
|
||||
}
|
||||
|
|
@ -140,13 +140,15 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.212.9 (2016-05-30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.213 (2016-05-31)"
|
||||
#define CSS_FILE "swad15.210.css"
|
||||
#define JS_FILE "swad15.197.js"
|
||||
#define JS_FILE "swad15.213.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.213: May 31, 2016 Code refactoring related to renaming test tags.
|
||||
Fixed bug in dates reported by Christian A. Morillas Gutiérrez. (201581 lines)
|
||||
Version 15.212.9: May 30, 2016 Link to list institutions of country in country configuration. (201567 lines)
|
||||
Version 15.212.8: May 30, 2016 Link to list centres of institution in institution configuration. (201555 lines)
|
||||
Version 15.212.7: May 30, 2016 Link to list degrees of centre in centre configuration. (201547 lines)
|
||||
|
|
48
swad_test.c
48
swad_test.c
|
@ -1413,13 +1413,7 @@ void Tst_RenameTag (void)
|
|||
Par_GetParToText ("NewTagTxt",NewTagTxt,Tst_MAX_BYTES_TAG);
|
||||
|
||||
/***** Check that the new tag is not empty *****/
|
||||
if (!NewTagTxt[0])
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_You_can_not_leave_the_name_of_the_tag_X_empty,
|
||||
OldTagTxt);
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||
}
|
||||
else
|
||||
if (NewTagTxt[0]) // New tag not empty
|
||||
{
|
||||
/***** Check if the old tag is equal to the new one
|
||||
(this happens when user press INTRO
|
||||
|
@ -1431,23 +1425,28 @@ void Tst_RenameTag (void)
|
|||
if ((ExistingNewTagCod = Tst_GetTagCodFromTagTxt (NewTagTxt)) > 0) // The new tag was already in database
|
||||
{
|
||||
// TODO: Fix Bug: when renaming unique tag "examen" to "Examen", tag is removed!
|
||||
/***** Complex update made to not repeat tags *****/
|
||||
/* Step 1. Get tag code of the old tag */
|
||||
/***** Get tag code of the old tag *****/
|
||||
if ((OldTagCod = Tst_GetTagCodFromTagTxt (OldTagTxt)) < 0)
|
||||
Lay_ShowErrorAndExit ("Tag does not exists.");
|
||||
|
||||
/* Step 2: If the new tag existed for a question ==> delete old tag from tst_question_tags; the new tag will remain
|
||||
If the new tag did not exist for a question ==> change old tag to new tag in tst_question_tags */
|
||||
/***** Complex update made to not repeat tags:
|
||||
- If the new tag existed for a question ==>
|
||||
delete old tag from tst_question_tags;
|
||||
the new tag will remain
|
||||
- If the new tag did not exist for a question ==>
|
||||
change old tag to new tag in tst_question_tags *****/
|
||||
/* Create a temporary table with all the question codes
|
||||
that had the new tag as one of their tags */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary table");
|
||||
|
||||
sprintf (Query,"CREATE TEMPORARY TABLE tst_question_tags_tmp ENGINE=MEMORY"
|
||||
" SELECT QstCod FROM tst_question_tags WHERE TagCod='%ld'",
|
||||
ExistingNewTagCod);
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
|
||||
/* Remove old tag in questions where it would be repeated */
|
||||
sprintf (Query,"DELETE FROM tst_question_tags"
|
||||
" WHERE TagCod='%ld'"
|
||||
" AND QstCod IN"
|
||||
|
@ -1455,6 +1454,7 @@ void Tst_RenameTag (void)
|
|||
OldTagCod);
|
||||
DB_QueryDELETE (Query,"can not remove a tag from some questions");
|
||||
|
||||
/* Change old tag to new tag in questions where it would not be repeated */
|
||||
sprintf (Query,"UPDATE tst_question_tags"
|
||||
" SET TagCod='%ld'"
|
||||
" WHERE TagCod='%ld'"
|
||||
|
@ -1464,11 +1464,13 @@ void Tst_RenameTag (void)
|
|||
OldTagCod);
|
||||
DB_QueryUPDATE (Query,"can not update a tag in some questions");
|
||||
|
||||
/* Drop temporary table, no longer necessary */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary table");
|
||||
|
||||
/* Delete old tag from tst_tags because it is not longer used */
|
||||
/***** Delete old tag from tst_tags
|
||||
because it is not longer used *****/
|
||||
sprintf (Query,"DELETE FROM tst_tags WHERE TagCod='%ld'",
|
||||
OldTagCod);
|
||||
DB_QueryDELETE (Query,"can not remove old tag");
|
||||
|
@ -1496,6 +1498,12 @@ void Tst_RenameTag (void)
|
|||
Lay_ShowAlert (Lay_INFO,Gbl.Message);
|
||||
}
|
||||
}
|
||||
else // New tag empty
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_You_can_not_leave_the_name_of_the_tag_X_empty,
|
||||
OldTagTxt);
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||
}
|
||||
|
||||
/***** Show again the form to configure test *****/
|
||||
Tst_ShowFormConfig ();
|
||||
|
@ -5631,7 +5639,7 @@ static long Tst_GetTagCodFromTagTxt (const char *TagTxt)
|
|||
|
||||
/***** Get tag code from database *****/
|
||||
sprintf (Query,"SELECT TagCod FROM tst_tags"
|
||||
" WHERE tst_tags.CrsCod='%ld' AND tst_tags.TagTxt='%s'",
|
||||
" WHERE CrsCod='%ld' AND TagTxt='%s'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,TagTxt);
|
||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get tag");
|
||||
|
||||
|
@ -6126,10 +6134,14 @@ static void Tst_RemoveUnusedTagsFromCurrentCrs (void)
|
|||
char Query[1024];
|
||||
|
||||
/***** Remove unused tags from tst_tags *****/
|
||||
sprintf (Query,"DELETE FROM tst_tags WHERE CrsCod='%ld' AND TagCod NOT IN"
|
||||
" (SELECT DISTINCT tst_question_tags.TagCod FROM tst_questions,tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod='%ld' AND tst_questions.QstCod=tst_question_tags.QstCod)",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
sprintf (Query,"DELETE FROM tst_tags"
|
||||
" WHERE CrsCod='%ld' AND TagCod NOT IN"
|
||||
" (SELECT DISTINCT tst_question_tags.TagCod"
|
||||
" FROM tst_questions,tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod='%ld'"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod)",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove unused tags");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue