mirror of https://github.com/acanas/swad-core.git
Version 15.32
This commit is contained in:
parent
840b2a2344
commit
885947ebb2
707
js/swad.js
707
js/swad.js
|
@ -20,6 +20,8 @@
|
|||
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/>.
|
||||
*/
|
||||
// Global variable (string) used to write HTML
|
||||
var Gbl_HTMLContent;
|
||||
|
||||
// Global variable used in refreshConnected()
|
||||
var ActionAJAX;
|
||||
|
@ -541,87 +543,100 @@ function uncheckChildren(MainCheckbox, GroupCheckboxes) {
|
|||
|
||||
// Change text of a test descriptor
|
||||
function changeTxtTag(NumTag){
|
||||
var Sel = document.getElementById('SelDesc'+NumTag);
|
||||
document.getElementById('TagTxt'+NumTag).value = Sel.options[Sel.selectedIndex].value;
|
||||
var Sel = document.getElementById('SelDesc' + NumTag);
|
||||
|
||||
document.getElementById('TagTxt' + NumTag).value = Sel.options[Sel.selectedIndex].value;
|
||||
}
|
||||
|
||||
// Change selectors of test descriptors
|
||||
function changeSelTag(NumTag){
|
||||
function changeSelTag(NumTag) {
|
||||
var Sel = document.getElementById('SelDesc'+NumTag);
|
||||
var Txt = document.getElementById('TagTxt'+NumTag);
|
||||
for (var i=0; i<Sel.options.length-1 ; i++)
|
||||
if (Sel.options[i].value.toUpperCase() == Txt.value.toUpperCase()){
|
||||
var Txt = document.getElementById('TagTxt' +NumTag);
|
||||
|
||||
for (var i=0; i<Sel.options.length - 1; i++)
|
||||
if (Sel.options[i].value.toUpperCase() == Txt.value.toUpperCase()) {
|
||||
Sel.options[i].selected = true;
|
||||
Txt.value = Sel.options[i].value;
|
||||
break;
|
||||
}
|
||||
if (i == Sel.options.length-1) // End reached without matching
|
||||
if (i == Sel.options.length - 1) // End reached without matching
|
||||
Sel.options[i].selected = true;
|
||||
}
|
||||
|
||||
// Activate or deactivate answer types of a test question
|
||||
function enableDisableAns(Formul) {
|
||||
var Tst_ANS_INT = 0;
|
||||
var Tst_ANS_FLOAT = 1;
|
||||
var Tst_ANS_INT = 0;
|
||||
var Tst_ANS_FLOAT = 1;
|
||||
var Tst_ANS_TRUE_FALSE = 2;
|
||||
var Tst_ANS_UNIQUE_CHOICE = 3;
|
||||
var Tst_ANS_MULTIPLE_CHOICE = 4;
|
||||
var Tst_ANS_TEXT = 5;
|
||||
var Tst_ANS_TEXT = 5;
|
||||
|
||||
if (Formul.AnswerType[Tst_ANS_INT].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
if (Formul.elements[i].name == 'AnsInt') Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsMulti' ||
|
||||
Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'Shuffle') Formul.elements[i].disabled = true;
|
||||
if (Formul.elements[i].name == 'AnsInt')
|
||||
Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsMulti' ||
|
||||
Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'Shuffle')
|
||||
Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],true);
|
||||
}
|
||||
else if (Formul.AnswerType[Tst_ANS_FLOAT].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
if (Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax') Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsInt' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax')
|
||||
Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsInt' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'AnsMulti' ||
|
||||
Formul.elements[i].name == 'Shuffle') Formul.elements[i].disabled = true;
|
||||
Formul.elements[i].name == 'Shuffle')
|
||||
Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],true);
|
||||
}
|
||||
else if (Formul.AnswerType[Tst_ANS_TRUE_FALSE].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
if (Formul.elements[i].name == 'AnsTF') Formul.elements[i].disabled = false;
|
||||
if (Formul.elements[i].name == 'AnsTF')
|
||||
Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsInt' ||
|
||||
Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'AnsMulti' ||
|
||||
Formul.elements[i].name == 'Shuffle') Formul.elements[i].disabled = true;
|
||||
Formul.elements[i].name == 'Shuffle')
|
||||
Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],true);
|
||||
}
|
||||
else if (Formul.AnswerType[Tst_ANS_UNIQUE_CHOICE].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
if (Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'Shuffle') Formul.elements[i].disabled = false;
|
||||
Formul.elements[i].name == 'Shuffle')
|
||||
Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsInt' ||
|
||||
Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsMulti') Formul.elements[i].disabled = true;
|
||||
Formul.elements[i].name == 'AnsMulti')
|
||||
Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],false);
|
||||
}
|
||||
else if (Formul.AnswerType[Tst_ANS_MULTIPLE_CHOICE].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
if (Formul.elements[i].name == 'AnsMulti' ||
|
||||
Formul.elements[i].name == 'Shuffle') Formul.elements[i].disabled = false;
|
||||
Formul.elements[i].name == 'Shuffle')
|
||||
Formul.elements[i].disabled = false;
|
||||
else if (Formul.elements[i].name == 'AnsInt' ||
|
||||
Formul.elements[i].name == 'AnsFloatMin' ||
|
||||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni') Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],false);
|
||||
Formul.elements[i].name == 'AnsUni')
|
||||
Formul.elements[i].disabled = true;
|
||||
else
|
||||
enableDisableContAns(Formul.elements[i],false);
|
||||
}
|
||||
else if (Formul.AnswerType[Tst_ANS_TEXT].checked){
|
||||
for (var i=0; i<Formul.elements.length; i++)
|
||||
|
@ -630,26 +645,31 @@ function enableDisableAns(Formul) {
|
|||
Formul.elements[i].name == 'AnsFloatMax' ||
|
||||
Formul.elements[i].name == 'AnsTF' ||
|
||||
Formul.elements[i].name == 'AnsUni' ||
|
||||
Formul.elements[i].name == 'AnsMulti') Formul.elements[i].disabled = true;
|
||||
else enableDisableContAns(Formul.elements[i],false);
|
||||
Formul.elements[i].name == 'AnsMulti')
|
||||
Formul.elements[i].disabled = true;
|
||||
else
|
||||
enableDisableContAns(Formul.elements[i],false);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate or deactivate response contents of a test question
|
||||
function enableDisableContAns(Elem,IsDisabled) {
|
||||
function enableDisableContAns(Elem, IsDisabled) {
|
||||
var Tst_MAX_OPTIONS_PER_QUESTION = 10;
|
||||
for (var i=0; i<Tst_MAX_OPTIONS_PER_QUESTION; i++)
|
||||
if (Elem.name == ('AnsStr'+i) || Elem.name == ('FbStr'+i))
|
||||
|
||||
for ( var i = 0; i < Tst_MAX_OPTIONS_PER_QUESTION; i++)
|
||||
if (Elem.name == ('AnsStr' + i) ||
|
||||
Elem.name == ('FbStr' + i))
|
||||
Elem.disabled = IsDisabled;
|
||||
}
|
||||
|
||||
// Selection of statistics of current course ****/
|
||||
function enableDetailedClicks () {
|
||||
function enableDetailedClicks() {
|
||||
document.getElementById('CountType').disabled = true;
|
||||
document.getElementById('GroupedBy').disabled = true;
|
||||
document.getElementById('RowsPage').disabled = false;
|
||||
}
|
||||
function disableDetailedClicks () {
|
||||
|
||||
function disableDetailedClicks() {
|
||||
document.getElementById('CountType').disabled = false;
|
||||
document.getElementById('GroupedBy').disabled = false;
|
||||
document.getElementById('RowsPage').disabled = true;
|
||||
|
@ -659,375 +679,340 @@ function disableDetailedClicks () {
|
|||
/************************ Draw an academic calendar **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function Cal_DrawCalendar (id,TimeUTC,PrintView,CGI,CurrentPlcCod,FormGoToCalendarParams,FormEventParams)
|
||||
{
|
||||
var StartingMonth = [ // Calendar starts one row before current month
|
||||
9, // January --> September
|
||||
9, // February --> September
|
||||
9, // Mars --> September
|
||||
9, // April --> September
|
||||
1, // May --> January
|
||||
1, // June --> January
|
||||
1, // July --> January
|
||||
1, // August --> January
|
||||
5, // September --> May
|
||||
5, // October --> May
|
||||
5, // November --> May
|
||||
5 // December --> May
|
||||
];
|
||||
var d = new Date;
|
||||
d.setTime(TimeUTC * 1000);
|
||||
var CurrentMonth = d.getMonth() + 1;
|
||||
var CurrentYear = d.getFullYear();
|
||||
var CurrentDay = d.getDate();
|
||||
var Month = StartingMonth[CurrentMonth - 1];
|
||||
var Year = (Month < CurrentMonth) ? CurrentYear :
|
||||
CurrentYear - 1;
|
||||
var Row;
|
||||
var Col;
|
||||
var MonthIdNum = 0;
|
||||
var MonthId;
|
||||
function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView,
|
||||
CGI,FormGoToCalendarParams,FormEventParams) {
|
||||
var StartingMonth = [ // Calendar starts one row before current month
|
||||
9, // January --> September
|
||||
9, // February --> September
|
||||
9, // Mars --> September
|
||||
9, // April --> September
|
||||
1, // May --> January
|
||||
1, // June --> January
|
||||
1, // July --> January
|
||||
1, // August --> January
|
||||
5, // September --> May
|
||||
5, // October --> May
|
||||
5, // November --> May
|
||||
5 // December --> May
|
||||
];
|
||||
var d = new Date;
|
||||
d.setTime(TimeUTC * 1000);
|
||||
var CurrentMonth = d.getMonth() + 1;
|
||||
var CurrentYear = d.getFullYear();
|
||||
var CurrentDay = d.getDate();
|
||||
var Month = StartingMonth[CurrentMonth - 1];
|
||||
var Year = (Month < CurrentMonth) ? CurrentYear :
|
||||
CurrentYear - 1;
|
||||
var Row;
|
||||
var Col;
|
||||
var MonthIdNum = 0;
|
||||
var MonthId;
|
||||
|
||||
/***** Draw several months *****/
|
||||
HTMLContent += '<table style="margin:0 auto; border-spacing:6px;">';
|
||||
/***** Draw several months *****/
|
||||
Gbl_HTMLContent += '<table style="margin:0 auto; border-spacing:6px;">';
|
||||
|
||||
for (Row = 0;
|
||||
Row < 4;
|
||||
Row++)
|
||||
{
|
||||
HTMLContent += '<tr>';
|
||||
for (Col = 0;
|
||||
Col < 4;
|
||||
Col++)
|
||||
{
|
||||
MonthIdNum++;
|
||||
MonthId = id + '_month_' + MonthIdNum;
|
||||
|
||||
HTMLContent += '<td class="CENTER_TOP" style="width:150px;">';
|
||||
DrawMonth (MonthId,Year,Month,CurrentMonth,CurrentDay,true,PrintView,CGI,CurrentPlcCod,FormGoToCalendarParams,FormEventParams);
|
||||
HTMLContent += '</td>';
|
||||
if (++Month == 13)
|
||||
{
|
||||
Month = 1;
|
||||
Year++;
|
||||
}
|
||||
for (Row = 0;
|
||||
Row < 4;
|
||||
Row++) {
|
||||
Gbl_HTMLContent += '<tr>';
|
||||
for (Col = 0;
|
||||
Col < 4;
|
||||
Col++) {
|
||||
MonthIdNum++;
|
||||
MonthId = id + '_month_' + MonthIdNum;
|
||||
|
||||
Gbl_HTMLContent += '<td class="CENTER_TOP" style="width:150px;">';
|
||||
DrawMonth(MonthId, Year, Month, CurrentMonth, CurrentDay,
|
||||
CurrentPlcCod, true, PrintView, CGI,
|
||||
FormGoToCalendarParams, FormEventParams);
|
||||
Gbl_HTMLContent += '</td>';
|
||||
if (++Month == 13) {
|
||||
Month = 1;
|
||||
Year++;
|
||||
}
|
||||
}
|
||||
Gbl_HTMLContent += '</tr>';
|
||||
}
|
||||
HTMLContent += '</tr>';
|
||||
}
|
||||
HTMLContent += '</table>';
|
||||
Gbl_HTMLContent += '</table>';
|
||||
|
||||
document.getElementById(id).innerHTML = HTMLContent;
|
||||
}
|
||||
document.getElementById(id).innerHTML = Gbl_HTMLContent;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Draw current month ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function DrawCurrentMonth (id,TimeUTC,CGI,CurrentPlcCod,FormGoToCalendarParams,FormEventParams) {
|
||||
function DrawCurrentMonth (id,TimeUTC,CurrentPlcCod,
|
||||
CGI,FormGoToCalendarParams,FormEventParams) {
|
||||
var d = new Date;
|
||||
d.setTime(TimeUTC * 1000);
|
||||
var Year = d.getFullYear();
|
||||
var Month = d.getMonth() + 1;
|
||||
var CurrentDay = d.getDate();
|
||||
|
||||
DrawMonth (id,Year,Month,Month,CurrentDay,false,false,CGI,CurrentPlcCod,FormGoToCalendarParams,FormEventParams);
|
||||
document.getElementById(id).innerHTML = HTMLContent;
|
||||
DrawMonth(id,Year,Month,Month,CurrentDay,CurrentPlcCod,false,false,
|
||||
CGI,FormGoToCalendarParams,FormEventParams);
|
||||
document.getElementById(id).innerHTML = Gbl_HTMLContent;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Draw a month *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,DrawingCalendar,PrintView,CGI,CurrentPlcCod,FormGoToCalendarParams,FormEventParams)
|
||||
{
|
||||
var NumDaysMonth = [
|
||||
0,
|
||||
31, // 1: January
|
||||
28, // 2: February
|
||||
31, // 3: Mars
|
||||
30, // 4: April
|
||||
31, // 5: May
|
||||
30, // 6: June
|
||||
31, // 7: July
|
||||
31, // 8: Agoust
|
||||
30, // 9: September
|
||||
31, // 10: October
|
||||
30, // 11: November
|
||||
31, // 12: December
|
||||
];
|
||||
var Hld_HOLIDAY = 0;
|
||||
var Hld_NON_SCHOOL_PERIOD = 1;
|
||||
var Week;
|
||||
var DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
|
||||
var Day;
|
||||
var NumDaysInMonth;
|
||||
var Yea = YearToDraw;
|
||||
var Mon = MonthToDraw;
|
||||
var YYYYMMDD;
|
||||
var NumHld;
|
||||
var ClassForDay; // Class of day depending on type of day
|
||||
var TextForDay; // Text associated to a day, for example the name of the holiday
|
||||
var NumExamAnnouncement; // Number of exam announcement
|
||||
var ResultOfCmpStartDate;
|
||||
var ContinueSearching;
|
||||
var ThisDayHasEvent;
|
||||
var IsToday;
|
||||
var FormIdNum = 0;
|
||||
var FormId;
|
||||
function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlcCod,
|
||||
DrawingCalendar,PrintView,
|
||||
CGI,FormGoToCalendarParams,FormEventParams) {
|
||||
var NumDaysMonth = [
|
||||
0,
|
||||
31, // 1: January
|
||||
28, // 2: February
|
||||
31, // 3: Mars
|
||||
30, // 4: April
|
||||
31, // 5: May
|
||||
30, // 6: June
|
||||
31, // 7: July
|
||||
31, // 8: Agoust
|
||||
30, // 9: September
|
||||
31, // 10: October
|
||||
30, // 11: November
|
||||
31, // 12: December
|
||||
];
|
||||
var Hld_HOLIDAY = 0;
|
||||
var Hld_NON_SCHOOL_PERIOD = 1;
|
||||
var Week;
|
||||
var DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
|
||||
var Day;
|
||||
var NumDaysInMonth;
|
||||
var Yea = YearToDraw;
|
||||
var Mon = MonthToDraw;
|
||||
var YYYYMMDD;
|
||||
var NumHld;
|
||||
var ClassForDay; // Class of day depending on type of day
|
||||
var TextForDay; // Text associated to a day, for example the name of the holiday
|
||||
var NumExamAnnouncement; // Number of exam announcement
|
||||
var ResultOfCmpStartDate;
|
||||
var ContinueSearching;
|
||||
var ThisDayHasEvent;
|
||||
var IsToday;
|
||||
var FormIdNum = 0;
|
||||
var FormId;
|
||||
|
||||
/***** Compute number of day of month for the first box *****/
|
||||
/* The initial day of month can be -5, -4, -3, -2, -1, 0, or 1
|
||||
If it's -5 then write 6 boxes of the previous month.
|
||||
If it's -4 then write 5 boxes of the previous month.
|
||||
If it's -3 then write 4 boxes of the previous month.
|
||||
If it's -2 then write 3 boxes of the previous month.
|
||||
If it's -1 then write 2 boxes of the previous month.
|
||||
If it's 0 then write 1 box of the previous month.
|
||||
If it's 1 then write 0 boxes of the previous month. */
|
||||
/***** Compute number of day of month for the first box *****/
|
||||
/* The initial day of month can be -5, -4, -3, -2, -1, 0, or 1
|
||||
If it's -5 then write 6 boxes of the previous month.
|
||||
If it's -4 then write 5 boxes of the previous month.
|
||||
If it's -3 then write 4 boxes of the previous month.
|
||||
If it's -2 then write 3 boxes of the previous month.
|
||||
If it's -1 then write 2 boxes of the previous month.
|
||||
If it's 0 then write 1 box of the previous month.
|
||||
If it's 1 then write 0 boxes of the previous month. */
|
||||
|
||||
if ((DayOfWeek = GetDayOfWeek (Yea,Mon,1)) == 0)
|
||||
Day = 1;
|
||||
else
|
||||
{
|
||||
if (Mon <= 1)
|
||||
{
|
||||
Mon = 12;
|
||||
Yea--;
|
||||
if ((DayOfWeek = GetDayOfWeek(Yea, Mon, 1)) == 0)
|
||||
Day = 1;
|
||||
else {
|
||||
if (Mon <= 1) {
|
||||
Mon = 12;
|
||||
Yea--;
|
||||
} else
|
||||
Mon--;
|
||||
NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary(Yea) :
|
||||
NumDaysMonth[Mon];
|
||||
Day = NumDaysInMonth - DayOfWeek + 1;
|
||||
}
|
||||
else
|
||||
Mon--;
|
||||
NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) :
|
||||
NumDaysMonth[Mon];
|
||||
Day = NumDaysInMonth - DayOfWeek + 1;
|
||||
}
|
||||
|
||||
/***** Start of month *****/
|
||||
HTMLContent += '<div class="MONTH_CONTAINER">';
|
||||
/***** Start of month *****/
|
||||
Gbl_HTMLContent += '<div class="MONTH_CONTAINER">';
|
||||
|
||||
/***** Month name *****/
|
||||
if (DrawingCalendar)
|
||||
HTMLContent += '<div class="MONTH">';
|
||||
else
|
||||
{
|
||||
FormId = id + '_show_calendar';
|
||||
HTMLContent += '<form method="post" action="' +
|
||||
CGI +
|
||||
'" id="' +
|
||||
FormId +
|
||||
'">' +
|
||||
FormGoToCalendarParams +
|
||||
'<div class="MONTH">' +
|
||||
'<a href="" class="MONTH"' +
|
||||
' onclick="document.getElementById(\'' + FormId + '\').submit();return false;">';
|
||||
}
|
||||
HTMLContent += MONTHS_CAPS[MonthToDraw-1] + ' ' + YearToDraw;
|
||||
if (DrawingCalendar)
|
||||
HTMLContent += '</div>';
|
||||
else
|
||||
HTMLContent += '</a></div></form>';
|
||||
|
||||
/***** Month head: first letter for each day of week *****/
|
||||
HTMLContent += '<table class="MONTH_TABLE_DAYS">'
|
||||
HTMLContent += '<tr>';
|
||||
for (DayOfWeek = 0;
|
||||
DayOfWeek < 7;
|
||||
DayOfWeek++)
|
||||
HTMLContent += '<td class="' +
|
||||
((DayOfWeek == 6) ? 'DAY_NO_WRK_HEAD' :
|
||||
'DAY_WRK_HEAD') +
|
||||
'">' +
|
||||
DAYS_CAPS[DayOfWeek] +
|
||||
'</td>';
|
||||
HTMLContent += '</tr>';
|
||||
|
||||
/***** Draw every week of the month *****/
|
||||
for (Week = 0;
|
||||
Week < 6;
|
||||
Week++)
|
||||
{
|
||||
HTMLContent += '<tr>';
|
||||
|
||||
/***** Draw every day of the week *****/
|
||||
for (DayOfWeek = 0;
|
||||
DayOfWeek < 7;
|
||||
DayOfWeek++)
|
||||
{
|
||||
/***** Set class for day being drawn *****/
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_WRK' :
|
||||
'DAY_WRK_LIGHT');
|
||||
TextForDay = '';
|
||||
|
||||
/* Check if day is a holiday or a school day */
|
||||
YYYYMMDD = Yea*10000 + Mon*100 + Day;
|
||||
for (NumHld = 0, ContinueSearching = true;
|
||||
NumHld < Hlds.length && ContinueSearching;
|
||||
NumHld++)
|
||||
if (Hlds[NumHld].PlcCod <= 0 ||
|
||||
Hlds[NumHld].PlcCod == CurrentPlcCod)
|
||||
{
|
||||
if (Hlds[NumHld].StartDate > YYYYMMDD) // List is ordered by start date. If start date is greater than date being drawn, don't continue searching
|
||||
ContinueSearching = false;
|
||||
else // start date <= date being drawn
|
||||
switch (Hlds[NumHld].HldTyp)
|
||||
{
|
||||
case Hld_HOLIDAY:
|
||||
if (Hlds[NumHld].StartDate == YYYYMMDD) // If start date == date being drawn
|
||||
{
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_HLD' :
|
||||
'DAY_HLD_LIGHT');
|
||||
TextForDay = Hlds[NumHld].Name;
|
||||
ContinueSearching = false;
|
||||
}
|
||||
break;
|
||||
case Hld_NON_SCHOOL_PERIOD:
|
||||
if (Hlds[NumHld].EndDate >= YYYYMMDD) // If start date <= date being drawn <= end date
|
||||
{
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_NO_WORK' :
|
||||
'DAY_NO_WORK_LIGHT');
|
||||
TextForDay = Hlds[NumHld].Name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Day being drawn is sunday? */
|
||||
if (DayOfWeek == 6) // All the sundays are holidays
|
||||
ClassForDay = (Mon == MonthToDraw) ? 'DAY_HLD' :
|
||||
'DAY_HLD_LIGHT';
|
||||
|
||||
/* Date being drawn is today? */
|
||||
IsToday = (Yea == YearToDraw &&
|
||||
Mon == MonthToDraw &&
|
||||
Mon == CurrentMonth &&
|
||||
Day == CurrentDay);
|
||||
|
||||
/* Check if day has an exam announcement */
|
||||
ThisDayHasEvent = false;
|
||||
if (!DrawingCalendar || Mon == MonthToDraw) // If drawing calendar and the month is not the real one, don't draw exam announcements
|
||||
for (NumExamAnnouncement = 0;
|
||||
NumExamAnnouncement < LstExamAnnouncements.length;
|
||||
NumExamAnnouncement++)
|
||||
if (Yea == LstExamAnnouncements[NumExamAnnouncement].Year &&
|
||||
Mon == LstExamAnnouncements[NumExamAnnouncement].Month &&
|
||||
Day == LstExamAnnouncements[NumExamAnnouncement].Day)
|
||||
{
|
||||
ThisDayHasEvent = true;
|
||||
if (!PrintView)
|
||||
TextForDay = STR_EXAM + ': ' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Year + '-' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Month + '-' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Day;
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Write the box with the day *****/
|
||||
HTMLContent += '<td class="' +
|
||||
((IsToday && !PrintView) ? (ThisDayHasEvent ? 'TODAY_EVENT' :
|
||||
'TODAY') :
|
||||
(ThisDayHasEvent ? 'DAY_EVENT' :
|
||||
'DAY')) +
|
||||
'">';
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent)
|
||||
{
|
||||
FormIdNum++;
|
||||
FormId = id + '_event_' + FormIdNum;
|
||||
HTMLContent += '<form method="post" action="' +
|
||||
CGI +
|
||||
'" id="' +
|
||||
FormId +
|
||||
'">';
|
||||
HTMLContent += FormEventParams;
|
||||
HTMLContent += '<div class="' + ClassForDay + '"';
|
||||
if (TextForDay.length)
|
||||
HTMLContent += ' title="' + TextForDay + '"';
|
||||
HTMLContent += '>';
|
||||
HTMLContent += '<a href="" class="' + ClassForDay + '"' +
|
||||
' onclick="document.getElementById(\'' + FormId + '\').submit();return false;">';
|
||||
}
|
||||
else
|
||||
{
|
||||
HTMLContent += '<div class="' + ClassForDay + '"';
|
||||
if (TextForDay.length)
|
||||
HTMLContent += ' title="' + TextForDay + '"';
|
||||
HTMLContent += '>';
|
||||
}
|
||||
|
||||
/* Write the day of month */
|
||||
HTMLContent += Day;
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent)
|
||||
HTMLContent += '</a></div></form>';
|
||||
else
|
||||
HTMLContent += '</div>';
|
||||
|
||||
HTMLContent += '</td>';
|
||||
|
||||
/***** Set the next day *****/
|
||||
NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) :
|
||||
NumDaysMonth[Mon];
|
||||
if (++Day > NumDaysInMonth)
|
||||
{
|
||||
if (++Mon > 12)
|
||||
{
|
||||
Yea++;
|
||||
Mon = 1;
|
||||
}
|
||||
Day = 1;
|
||||
}
|
||||
/***** Month name *****/
|
||||
if (DrawingCalendar)
|
||||
Gbl_HTMLContent += '<div class="MONTH">';
|
||||
else {
|
||||
FormId = id + '_show_calendar';
|
||||
Gbl_HTMLContent += '<form method="post" action="' + CGI + '" id="' + FormId + '">' +
|
||||
FormGoToCalendarParams +
|
||||
'<div class="MONTH">' +
|
||||
'<a href="" class="MONTH" onclick="document.getElementById(\'' + FormId +
|
||||
'\').submit();return false;">';
|
||||
}
|
||||
HTMLContent += '</tr>';
|
||||
}
|
||||
Gbl_HTMLContent += MONTHS_CAPS[MonthToDraw - 1] + ' ' + YearToDraw;
|
||||
if (DrawingCalendar)
|
||||
Gbl_HTMLContent += '</div>';
|
||||
else
|
||||
Gbl_HTMLContent += '</a></div></form>';
|
||||
|
||||
/***** End of month *****/
|
||||
HTMLContent += '</table></div>';
|
||||
}
|
||||
/***** Month head: first letter for each day of week *****/
|
||||
Gbl_HTMLContent += '<table class="MONTH_TABLE_DAYS">' + '<tr>';
|
||||
for (DayOfWeek = 0; DayOfWeek < 7; DayOfWeek++)
|
||||
Gbl_HTMLContent += '<td class="' +
|
||||
((DayOfWeek == 6) ? 'DAY_NO_WRK_HEAD' :
|
||||
'DAY_WRK_HEAD') +
|
||||
'">' +
|
||||
DAYS_CAPS[DayOfWeek] +
|
||||
'</td>';
|
||||
Gbl_HTMLContent += '</tr>';
|
||||
|
||||
/***** Draw every week of the month *****/
|
||||
for (Week = 0;
|
||||
Week < 6;
|
||||
Week++) {
|
||||
Gbl_HTMLContent += '<tr>';
|
||||
|
||||
/***** Draw every day of the week *****/
|
||||
for (DayOfWeek = 0;
|
||||
DayOfWeek < 7;
|
||||
DayOfWeek++) {
|
||||
/***** Set class for day being drawn *****/
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_WRK' :
|
||||
'DAY_WRK_LIGHT');
|
||||
TextForDay = '';
|
||||
|
||||
/* Check if day is a holiday or a school day */
|
||||
YYYYMMDD = Yea * 10000 + Mon * 100 + Day;
|
||||
for (NumHld = 0, ContinueSearching = true;
|
||||
NumHld < Hlds.length && ContinueSearching;
|
||||
NumHld++)
|
||||
if (Hlds[NumHld].PlcCod <= 0 ||
|
||||
Hlds[NumHld].PlcCod == CurrentPlcCod) {
|
||||
if (Hlds[NumHld].StartDate > YYYYMMDD) // List is ordered by start date. If start date is greater than date being drawn, don't continue searching
|
||||
ContinueSearching = false;
|
||||
else
|
||||
// start date <= date being drawn
|
||||
switch (Hlds[NumHld].HldTyp) {
|
||||
case Hld_HOLIDAY:
|
||||
if (Hlds[NumHld].StartDate == YYYYMMDD) { // If start date == date being drawn
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_HLD' :
|
||||
'DAY_HLD_LIGHT');
|
||||
TextForDay = Hlds[NumHld].Name;
|
||||
ContinueSearching = false;
|
||||
}
|
||||
break;
|
||||
case Hld_NON_SCHOOL_PERIOD:
|
||||
if (Hlds[NumHld].EndDate >= YYYYMMDD) { // If start date <= date being drawn <= end date
|
||||
ClassForDay = ((Mon == MonthToDraw) ? 'DAY_NO_WORK' :
|
||||
'DAY_NO_WORK_LIGHT');
|
||||
TextForDay = Hlds[NumHld].Name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Day being drawn is sunday? */
|
||||
if (DayOfWeek == 6) // All the sundays are holidays
|
||||
ClassForDay = (Mon == MonthToDraw) ? 'DAY_HLD' :
|
||||
'DAY_HLD_LIGHT';
|
||||
|
||||
/* Date being drawn is today? */
|
||||
IsToday = (Yea == YearToDraw &&
|
||||
Mon == MonthToDraw &&
|
||||
Mon == CurrentMonth &&
|
||||
Day == CurrentDay);
|
||||
|
||||
/* Check if day has an exam announcement */
|
||||
ThisDayHasEvent = false;
|
||||
if (!DrawingCalendar || Mon == MonthToDraw) // If drawing calendar and the month is not the real one, don't draw exam announcements
|
||||
for (NumExamAnnouncement = 0;
|
||||
NumExamAnnouncement < LstExamAnnouncements.length;
|
||||
NumExamAnnouncement++)
|
||||
if (Yea == LstExamAnnouncements[NumExamAnnouncement].Year &&
|
||||
Mon == LstExamAnnouncements[NumExamAnnouncement].Month &&
|
||||
Day == LstExamAnnouncements[NumExamAnnouncement].Day) {
|
||||
ThisDayHasEvent = true;
|
||||
if (!PrintView)
|
||||
TextForDay = STR_EXAM + ': ' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Year + '-' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Month + '-' +
|
||||
LstExamAnnouncements[NumExamAnnouncement].Day;
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Write the box with the day *****/
|
||||
Gbl_HTMLContent += '<td class="' +
|
||||
((IsToday && !PrintView) ? (ThisDayHasEvent ? 'TODAY_EVENT' :
|
||||
'TODAY') :
|
||||
(ThisDayHasEvent ? 'DAY_EVENT' :
|
||||
'DAY')) +
|
||||
'">';
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent) {
|
||||
FormIdNum++;
|
||||
FormId = id + '_event_' + FormIdNum;
|
||||
Gbl_HTMLContent += '<form method="post" action="' + CGI + '" id="' + FormId + '">' +
|
||||
FormEventParams +
|
||||
'<div class="' + ClassForDay + '"';
|
||||
if (TextForDay.length)
|
||||
Gbl_HTMLContent += ' title="' + TextForDay + '"';
|
||||
Gbl_HTMLContent += '><a href="" class="' + ClassForDay + '"' +
|
||||
' onclick="document.getElementById(\'' + FormId +
|
||||
'\').submit();return false;">';
|
||||
} else {
|
||||
Gbl_HTMLContent += '<div class="' + ClassForDay + '"';
|
||||
if (TextForDay.length)
|
||||
Gbl_HTMLContent += ' title="' + TextForDay + '"';
|
||||
Gbl_HTMLContent += '>';
|
||||
}
|
||||
|
||||
/* Write the day of month */
|
||||
Gbl_HTMLContent += Day;
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent)
|
||||
Gbl_HTMLContent += '</a></div></form>';
|
||||
else
|
||||
Gbl_HTMLContent += '</div>';
|
||||
|
||||
Gbl_HTMLContent += '</td>';
|
||||
|
||||
/***** Set the next day *****/
|
||||
NumDaysInMonth = (Mon == 2) ? GetNumDaysFebruary (Yea) :
|
||||
NumDaysMonth[Mon];
|
||||
if (++Day > NumDaysInMonth) {
|
||||
if (++Mon > 12) {
|
||||
Yea++;
|
||||
Mon = 1;
|
||||
}
|
||||
Day = 1;
|
||||
}
|
||||
}
|
||||
Gbl_HTMLContent += '</tr>';
|
||||
}
|
||||
|
||||
/***** End of month *****/
|
||||
Gbl_HTMLContent += '</table></div>';
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Compute day of the week from a given date *****************/
|
||||
/*****************************************************************************/
|
||||
// Return 0 for monday, 1 for tuesday,... 6 for sunday
|
||||
|
||||
function GetDayOfWeek (Year,Month,Day)
|
||||
{
|
||||
if (Month <= 2)
|
||||
{
|
||||
function GetDayOfWeek (Year,Month,Day) {
|
||||
if (Month <= 2) {
|
||||
Month += 12;
|
||||
Year--;
|
||||
}
|
||||
return (
|
||||
(
|
||||
(
|
||||
Day+
|
||||
(Month*2)+
|
||||
Math.floor(((Month+1)*3)/5)+
|
||||
Year+
|
||||
Math.floor(Year/4)-
|
||||
Math.floor(Year/100)+
|
||||
Math.floor(Year/400)
|
||||
+2
|
||||
) % 7
|
||||
) + 5
|
||||
) % 7;
|
||||
}
|
||||
}
|
||||
return (((Day +
|
||||
(Month * 2) +
|
||||
Math.floor (((Month + 1) * 3) / 5) +
|
||||
Year +
|
||||
Math.floor (Year / 4) -
|
||||
Math.floor (Year/100) +
|
||||
Math.floor (Year/400) +
|
||||
2) % 7) + 5) % 7;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Return the number of days of february ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function GetNumDaysFebruary (Year)
|
||||
{
|
||||
return (GetIfLeapYear (Year) ? 29 :
|
||||
28);
|
||||
}
|
||||
function GetNumDaysFebruary (Year) {
|
||||
return (GetIfLeapYear (Year) ? 29 : 28);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Return true if year is leap ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
function GetIfLeapYear (Year)
|
||||
{
|
||||
function GetIfLeapYear (Year) {
|
||||
return (Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2053,7 +2053,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActAdmAsgWrkUsr */{ 792, 2,TabAss,ActAdmAsgWrkUsr ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"editfolderuser" },
|
||||
/* ActReqAsgWrkCrs */{ 899, 3,TabAss,ActReqAsgWrkCrs ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_AskEditWorksCrs ,"folderusers" },
|
||||
/* ActReqTst */{ 103, 4,TabAss,ActReqTst ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowFormAskTst ,"test" },
|
||||
/* ActSeeCal */{ 16, 5,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Cal_DrawCalendar ,"date" },
|
||||
/* ActSeeCal */{ 16, 5,TabAss,ActSeeCal ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Cal_DrawCalendar ,"date" },
|
||||
/* ActSeeExaAnn */{ 85, 6,TabAss,ActSeeExaAnn ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ListExamAnnouncementsSee ,"announce" },
|
||||
/* ActSeeAdmMrk */{ 17, 7,TabAss,ActSeeAdmMrk ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"grades" },
|
||||
|
||||
|
@ -2182,7 +2182,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActSeeUsrTstExa */{1081,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowUsrsTestResults ,NULL},
|
||||
/* ActSeeOneTstExaOth*/{1082,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowOneTestExam ,NULL},
|
||||
|
||||
/* ActPrnCal */{ 71,-1,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Cal_DrawCalendar ,NULL},
|
||||
/* ActPrnCal */{ 71,-1,TabAss,ActSeeCal ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Cal_DrawCalendar ,NULL},
|
||||
|
||||
/* ActEdiExaAnn */{ 91,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_PutFrmEditAExamAnnouncement,NULL},
|
||||
/* ActRcvExaAnn */{ 110,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ReceiveExamAnnouncement ,NULL},
|
||||
|
|
329
swad_calendar.c
329
swad_calendar.c
|
@ -44,9 +44,6 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
||||
bool DrawingCalendar,bool PrintView);
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Draw current month ****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -66,26 +63,23 @@ void Cal_DrawCurrentMonth (void)
|
|||
/***** Create list of dates of exam announcements *****/
|
||||
Exa_CreateListOfExamAnnouncements ();
|
||||
|
||||
/***** Draw the month *****/
|
||||
// Cal_DrawMonth (Gbl.Now.Date.Year,Gbl.Now.Date.Month,false,false);
|
||||
|
||||
/***** Draw the month in JavaScript *****/
|
||||
/* JavaScript will write HTML here */
|
||||
fprintf (Gbl.F.Out,"<div id=\"CurrentMonth\">"
|
||||
"</div>");
|
||||
|
||||
/* Write script to draw the month */
|
||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n"
|
||||
" var HTMLContent = '';\n"
|
||||
" DrawCurrentMonth ('CurrentMonth',%ld,'%s/%s',%ld,",
|
||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
|
||||
" Gbl_HTMLContent = '';"
|
||||
" DrawCurrentMonth ('CurrentMonth',%ld,%ld,'%s/%s',",
|
||||
(long) Gbl.StartExecutionTimeUTC,
|
||||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Gbl.CurrentCtr.Ctr.PlcCod);
|
||||
Gbl.CurrentCtr.Ctr.PlcCod,
|
||||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
Act_SetParamsForm (Params,ActSeeCal,true);
|
||||
fprintf (Gbl.F.Out,"'%s',",Params);
|
||||
Act_SetParamsForm (Params,ActSeeExaAnn,true);
|
||||
fprintf (Gbl.F.Out,"'%s');\n"
|
||||
"</script>\n",Params);
|
||||
fprintf (Gbl.F.Out,"'%s');"
|
||||
"</script>",Params);
|
||||
|
||||
/***** Free list of dates of exam announcements *****/
|
||||
Exa_FreeListExamAnnouncements ();
|
||||
|
@ -114,28 +108,6 @@ void Cal_DrawCurrentMonth (void)
|
|||
void Cal_DrawCalendar (void)
|
||||
{
|
||||
extern const char *Txt_Print;
|
||||
/*
|
||||
static unsigned StartingMonth[1+12] = // Calendar starts one row before current month
|
||||
{
|
||||
0, // Not used
|
||||
9, // January --> September
|
||||
9, // February --> September
|
||||
9, // Mars --> September
|
||||
9, // April --> September
|
||||
1, // May --> January
|
||||
1, // June --> January
|
||||
1, // July --> January
|
||||
1, // August --> January
|
||||
5, // September --> May
|
||||
5, // October --> May
|
||||
5, // November --> May
|
||||
5, // December --> May
|
||||
};
|
||||
*/
|
||||
// unsigned Row,Col;
|
||||
// unsigned Month = StartingMonth[Gbl.Now.Date.Month];
|
||||
// unsigned Year = (Month < Gbl.Now.Date.Month) ? Gbl.Now.Date.Year :
|
||||
// Gbl.Now.Date.Year - 1;
|
||||
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
|
||||
|
||||
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
|
||||
|
@ -172,46 +144,25 @@ void Cal_DrawCalendar (void)
|
|||
"<div id=\"calendar\">"
|
||||
"</div>");
|
||||
|
||||
/*
|
||||
for (Row = 0;
|
||||
Row < 4;
|
||||
Row++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
for (Col = 0;
|
||||
Col < 4;
|
||||
Col++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<td class=\"CENTER_TOP\" style=\"width:150px;\">");
|
||||
Cal_DrawMonth (Year,Month,true,(Gbl.CurrentAct == ActPrnCal));
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
if (++Month == 13)
|
||||
{
|
||||
Month = 1;
|
||||
Year++;
|
||||
}
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</table>"
|
||||
"</td>"
|
||||
"</tr>");
|
||||
*/
|
||||
/* Write script to draw the month */
|
||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">\n"
|
||||
" var HTMLContent = '';\n"
|
||||
" Cal_DrawCalendar('calendar',%ld,%s,'%s/%s',%ld,",
|
||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
|
||||
" Gbl_HTMLContent = '';"
|
||||
" Cal_DrawCalendar('calendar',%ld,%ld,%s,'%s/%s',",
|
||||
(long) Gbl.StartExecutionTimeUTC,
|
||||
(Gbl.CurrentAct == ActPrnCal) ? "true" : "false",
|
||||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Gbl.CurrentCtr.Ctr.PlcCod);
|
||||
Gbl.CurrentCtr.Ctr.PlcCod,
|
||||
(Gbl.CurrentAct == ActPrnCal) ? "true" :
|
||||
"false",
|
||||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
Act_SetParamsForm (Params,ActSeeCal,true);
|
||||
fprintf (Gbl.F.Out,"'%s',",Params);
|
||||
fprintf (Gbl.F.Out,"'%s',",
|
||||
Params);
|
||||
Act_SetParamsForm (Params,ActSeeExaAnn,true);
|
||||
fprintf (Gbl.F.Out,"'%s');\n"
|
||||
"</script>\n",Params);
|
||||
fprintf (Gbl.F.Out,"'%s');"
|
||||
"</script>",
|
||||
Params);
|
||||
|
||||
fprintf (Gbl.F.Out,"</td></tr>");
|
||||
fprintf (Gbl.F.Out,"</td>"
|
||||
"</tr>");
|
||||
|
||||
/***** Free list of dates of exam announcements *****/
|
||||
Exa_FreeListExamAnnouncements ();
|
||||
|
@ -219,241 +170,3 @@ void Cal_DrawCalendar (void)
|
|||
/***** End frame *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Draw a month *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
||||
bool DrawingCalendar,bool PrintView)
|
||||
{
|
||||
extern const unsigned Dat_NumDaysMonth[1+12];
|
||||
extern const char *Txt_Show_calendar;
|
||||
extern const char *Txt_DAYS_CAPS[7];
|
||||
extern const char *Txt_MONTHS_CAPS[12];
|
||||
extern const char *Txt_Exam_of_X;
|
||||
char StrExamOfX[512+Crs_MAX_LENGTH_COURSE_FULL_NAME];
|
||||
unsigned Week;
|
||||
unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
|
||||
unsigned DayOfMonth;
|
||||
unsigned NumDaysInMonth;
|
||||
unsigned Year = RealYear;
|
||||
unsigned Month = RealMonth;
|
||||
char YYYYMMDD[4+2+2+1];
|
||||
unsigned NumHld;
|
||||
char *ClassForDay; // Class of day depending on type of day
|
||||
char *TextForDay; // Text associated to a day, for example the name of the holiday
|
||||
unsigned NumExamAnnouncement; // Number of exam announcement
|
||||
int ResultOfCmpStartDate;
|
||||
bool ContinueSearching;
|
||||
bool PutLinkToCalendar = !DrawingCalendar && Gbl.CurrentCrs.Crs.CrsCod > 0;
|
||||
bool ThisDayHasEvent = false;
|
||||
bool IsToday;
|
||||
|
||||
/***** Compute number of day of month for the first box *****/
|
||||
/* The initial day of month can be -5, -4, -3, -2, -1, 0, or 1
|
||||
If it's -5 then write 6 boxes of the previous month.
|
||||
If it's -4 then write 5 boxes of the previous month.
|
||||
If it's -3 then write 4 boxes of the previous month.
|
||||
If it's -2 then write 3 boxes of the previous month.
|
||||
If it's -1 then write 2 boxes of the previous month.
|
||||
If it's 0 then write 1 box of the previous month.
|
||||
If it's 1 then write 0 boxes of the previous month. */
|
||||
|
||||
if ((DayOfWeek = Dat_GetDayOfWeek (Year,Month,1)) == 0)
|
||||
DayOfMonth = 1;
|
||||
else
|
||||
{
|
||||
if (Month <= 1)
|
||||
{
|
||||
Month = 12;
|
||||
Year--;
|
||||
}
|
||||
else
|
||||
Month--;
|
||||
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
||||
Dat_NumDaysMonth[Month];
|
||||
DayOfMonth = NumDaysInMonth - DayOfWeek + 1;
|
||||
}
|
||||
|
||||
/***** Start of month *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"MONTH_CONTAINER\">");
|
||||
|
||||
/***** Month name *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"MONTH\">");
|
||||
if (PutLinkToCalendar)
|
||||
{
|
||||
Act_FormStart (ActSeeCal);
|
||||
Act_LinkFormSubmit (Txt_Show_calendar,"MONTH");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"%s %u",
|
||||
Txt_MONTHS_CAPS[RealMonth-1],RealYear);
|
||||
if (PutLinkToCalendar)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"</a>");
|
||||
Act_FormEnd ();
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/***** Month head: first letter for each day of week *****/
|
||||
fprintf (Gbl.F.Out,"<table class=\"MONTH_TABLE_DAYS\">"
|
||||
"<tr>");
|
||||
for (DayOfWeek = 0;
|
||||
DayOfWeek < 7;
|
||||
DayOfWeek++)
|
||||
fprintf (Gbl.F.Out,"<td class=\"%s\">"
|
||||
"%c"
|
||||
"</td>",
|
||||
(DayOfWeek == 6) ? "DAY_NO_WRK_HEAD" :
|
||||
"DAY_WRK_HEAD",
|
||||
Txt_DAYS_CAPS[DayOfWeek][0]);
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
|
||||
/***** Draw every week of the month *****/
|
||||
for (Week = 0;
|
||||
Week < 6;
|
||||
Week++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
|
||||
/***** Draw every day of the week *****/
|
||||
for (DayOfWeek = 0;
|
||||
DayOfWeek < 7;
|
||||
DayOfWeek++)
|
||||
{
|
||||
/***** Set class for day being drawn *****/
|
||||
ClassForDay = (Month == RealMonth) ? "DAY_WRK" :
|
||||
"DAY_WRK_LIGHT";
|
||||
TextForDay = NULL;
|
||||
|
||||
/* Check if day is a holiday or a school day */
|
||||
sprintf (YYYYMMDD,"%04u%02u%02u",Year,Month,DayOfMonth);
|
||||
for (NumHld = 0, ContinueSearching = true;
|
||||
NumHld < Gbl.Hlds.Num && ContinueSearching;
|
||||
NumHld++)
|
||||
if (Gbl.Hlds.Lst[NumHld].PlcCod <= 0 ||
|
||||
Gbl.Hlds.Lst[NumHld].PlcCod == Gbl.CurrentCtr.Ctr.PlcCod)
|
||||
{
|
||||
ResultOfCmpStartDate = strcmp (Gbl.Hlds.Lst[NumHld].StartDate.YYYYMMDD,YYYYMMDD);
|
||||
if (ResultOfCmpStartDate > 0) // List is ordered by start date. If start date is greater than date being drawn, don't continue searching
|
||||
|
||||
ContinueSearching = false;
|
||||
else // ResultOfCmpStartDate <= 0 <==> start date <= date being drawn
|
||||
switch (Gbl.Hlds.Lst[NumHld].HldTyp)
|
||||
{
|
||||
case Hld_HOLIDAY:
|
||||
if (ResultOfCmpStartDate == 0) // If start date == date being drawn
|
||||
{
|
||||
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
||||
"DAY_HLD_LIGHT";
|
||||
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
||||
ContinueSearching = false;
|
||||
}
|
||||
break;
|
||||
case Hld_NON_SCHOOL_PERIOD:
|
||||
if (strcmp (Gbl.Hlds.Lst[NumHld].EndDate.YYYYMMDD,YYYYMMDD) >= 0) // If start date <= date being drawn <= end date
|
||||
{
|
||||
ClassForDay = (Month == RealMonth) ? "DAY_NO_WORK" :
|
||||
"DAY_NO_WORK_LIGHT";
|
||||
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Day being drawn is sunday? */
|
||||
if (DayOfWeek == 6) // All the sundays are holidays
|
||||
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
||||
"DAY_HLD_LIGHT";
|
||||
|
||||
/* Date being drawn is today? */
|
||||
IsToday = (Month == RealMonth &&
|
||||
Year == Gbl.Now.Date.Year &&
|
||||
Month == Gbl.Now.Date.Month &&
|
||||
DayOfMonth == Gbl.Now.Date.Day);
|
||||
|
||||
/* Check if day has an exam announcement */
|
||||
ThisDayHasEvent = false;
|
||||
if (!DrawingCalendar || Month == RealMonth) // If drawing calendar and the month is not the real one, don't draw exam announcements
|
||||
for (NumExamAnnouncement = 0;
|
||||
NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc;
|
||||
NumExamAnnouncement++)
|
||||
if (Year == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year &&
|
||||
Month == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month &&
|
||||
DayOfMonth == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day)
|
||||
{
|
||||
ThisDayHasEvent = true;
|
||||
if (!PrintView)
|
||||
{
|
||||
sprintf (StrExamOfX,Txt_Exam_of_X,Gbl.CurrentCrs.Crs.FullName);
|
||||
sprintf (Gbl.Title,"%s: %02u/%02u/%04u",
|
||||
StrExamOfX,
|
||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day,
|
||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month,
|
||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Write the box with the day *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"%s\">",
|
||||
(IsToday && !PrintView) ? (ThisDayHasEvent ? "TODAY_EVENT" :
|
||||
"TODAY") :
|
||||
(ThisDayHasEvent ? "DAY_EVENT" :
|
||||
"DAY" ));
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent)
|
||||
{
|
||||
Act_FormStart (ActSeeExaAnn);
|
||||
fprintf (Gbl.F.Out,"<table style=\"width:100%%;\">"
|
||||
"<tr>"
|
||||
"<td class=\"%s\">",
|
||||
ClassForDay);
|
||||
Act_LinkFormSubmit (Gbl.Title,ClassForDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"%s\"",ClassForDay);
|
||||
if (!PrintView && TextForDay)
|
||||
fprintf (Gbl.F.Out," title=\"%s\"",TextForDay);
|
||||
fprintf (Gbl.F.Out,">");
|
||||
}
|
||||
|
||||
/* Write the day of month */
|
||||
fprintf (Gbl.F.Out,"%u",DayOfMonth);
|
||||
|
||||
/* If day has an exam announcement */
|
||||
if (!PrintView && ThisDayHasEvent)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"</a>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>");
|
||||
Act_FormEnd ();
|
||||
}
|
||||
else
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/***** Set the next day *****/
|
||||
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
||||
Dat_NumDaysMonth[Month];
|
||||
if (++DayOfMonth > NumDaysInMonth)
|
||||
{
|
||||
if (++Month > 12)
|
||||
{
|
||||
Year++;
|
||||
Month = 1;
|
||||
}
|
||||
DayOfMonth = 1;
|
||||
}
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</tr>");
|
||||
}
|
||||
|
||||
/***** End of month *****/
|
||||
fprintf (Gbl.F.Out,"</table>"
|
||||
"</div>");
|
||||
}
|
||||
|
|
|
@ -103,17 +103,19 @@
|
|||
// TODO: Put headers Content-type and Content-disposition when redirecting with Location:
|
||||
// TODO: System admin should be able to remove/edit user's mail (when he/she detects a recipient does not exists, for example)
|
||||
// TODO: When a new assignment/attendance/survey is incorrect, the second time the form is shown, it should be filled with partial data, now is always empty
|
||||
// TODO: Global announcements should be available for all users?
|
||||
// TODO: Dates in Holidays should be shown in big-endian
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.31 (2015/10/30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.32 (2015/10/30)"
|
||||
|
||||
// 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.32: Oct 30, 2015 Code refactoring and cleaning related to calendar. (186617 lines)
|
||||
Version 15.31: Oct 30, 2015 Calendar is drawn in browser using JavaScript. (186902 lines)
|
||||
Version 15.30: Oct 30, 2015 Current month is drawn in browser using JavaScript. (186795 lines)
|
||||
Version 15.29.4: Oct 29, 2015 Writing JavaScript function to draw a month in browser. Not finished. (186729 lines)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_connected.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_logo.h"
|
||||
#include "swad_notice.h"
|
||||
|
@ -451,7 +452,6 @@ static void Lay_WriteScripts (void)
|
|||
unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5, 6 */
|
||||
unsigned NumHld;
|
||||
unsigned NumExamAnnouncement; // Number of exam announcement
|
||||
char Params[256+256+Ses_LENGTH_SESSION_ID+256];
|
||||
|
||||
/***** General scripts for swad *****/
|
||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\" src=\"%s/swad.js\">"
|
||||
|
@ -532,7 +532,7 @@ static void Lay_WriteScripts (void)
|
|||
|
||||
fprintf (Gbl.F.Out," var STR_EXAM = '");
|
||||
fprintf (Gbl.F.Out,Txt_Exam_of_X,Gbl.CurrentCrs.Crs.FullName);
|
||||
fprintf (Gbl.F.Out,"';");
|
||||
fprintf (Gbl.F.Out,"';\n");
|
||||
|
||||
fprintf (Gbl.F.Out," var Hlds = [];\n");
|
||||
for (NumHld = 0;
|
||||
|
@ -554,8 +554,7 @@ static void Lay_WriteScripts (void)
|
|||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month,
|
||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day);
|
||||
|
||||
fprintf (Gbl.F.Out," var HTMLContent;"
|
||||
"</script>\n");
|
||||
fprintf (Gbl.F.Out,"</script>\n");
|
||||
}
|
||||
|
||||
/***** Scripts depending on action *****/
|
||||
|
|
|
@ -293,9 +293,8 @@ static bool Tab_CheckIfICanViewTab (Act_Tab_t Tab)
|
|||
return (Gbl.CurrentDeg.Deg.DegCod > 0 &&
|
||||
Gbl.CurrentCrs.Crs.CrsCod <= 0);
|
||||
case TabCrs:
|
||||
case TabAss:
|
||||
return (Gbl.CurrentCrs.Crs.CrsCod > 0);
|
||||
case TabMsg:
|
||||
case TabMsg: // TODO: Show this tab in any case when Announcements will be available for all
|
||||
return (Gbl.Usrs.Me.Logged ||
|
||||
Gbl.CurrentCrs.Crs.CrsCod > 0);
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue