Skip to content

Commit

Permalink
Added 'training-mode' - works like the server-mode except that data f…
Browse files Browse the repository at this point in the history
…iles are not modified.
  • Loading branch information
Ricolindo L Carino authored and Ricolindo L Carino committed Aug 29, 2012
1 parent 8d17654 commit adbfe11
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 66 deletions.
4 changes: 2 additions & 2 deletions BASE.F90
Expand Up @@ -43,10 +43,9 @@ module BASE
character(len= 9), parameter :: CGI_SCRIPT = 'relay.php'
character(len=18), parameter :: CGI_PATH = '/cgi-bin/'//CGI_SCRIPT

! flags to control generation of log files, backups, etc
! flags to control generation of log files, backups
logical, parameter :: MANY_LOG_FILES = .true. ! a log file for every run?
logical, parameter :: DO_NOT_BACKUP = .false. ! create backups?
logical, parameter :: CHECK_PASSWORD = .true. ! check Registrar's password

! directory separator; delete, directory, mkdir commands
#if defined GNULINUX
Expand All @@ -73,6 +72,7 @@ module BASE

integer :: stderr = 999 ! unit number of file for error messages
integer :: adminPassword = 0 ! randomly generated password for REGISTRAR
logical :: checkPassword = .true. ! check the password

! Max length of file path+name
integer, parameter :: MAX_LEN_FILE_PATH = 256
Expand Down
3 changes: 3 additions & 0 deletions BLOCKS.F90
Expand Up @@ -175,6 +175,9 @@ subroutine xml_write_blocks(path, NumBlocks, Block, Section, iDept)

integer :: blk, sect, i

! training only?
if (noWrites) return

! generate file name
if (iDept>0) then
fileName = trim(dirXML)//trim(path)//'BLOCKS-'//trim(Department(iDept)%Code)//'.XML'
Expand Down
6 changes: 6 additions & 0 deletions CHECKLISTS.F90
Expand Up @@ -109,6 +109,9 @@ subroutine xml_write_student_grades(std)

integer :: idx

! training only?
if (noWrites) return

! generate file name
idx = index(Student(std)%StdNo,dash)-1
if (idx<2) idx = 2
Expand Down Expand Up @@ -164,6 +167,9 @@ subroutine xml_write_substitutions(std)
integer :: crse_required, idx, k, l
integer :: rank, Year, Term, idxCURR

! training only?
if (noWrites) return

! generate file name
idx = index(Student(std)%StdNo,dash)-1
if (idx<2) idx = 2
Expand Down
6 changes: 6 additions & 0 deletions COLLEGES.F90
Expand Up @@ -149,6 +149,9 @@ subroutine xml_write_university(path)

character(len=*), intent(in) :: path

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'UNIVERSITY.XML'
call xml_open_file(unitNum, XML_ROOT_UNIVERSITY, fileName, eof)

Expand Down Expand Up @@ -291,6 +294,9 @@ subroutine xml_write_colleges(path)
character(len=*), intent(in) :: path
integer :: ldx

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'COLLEGES.XML'

call xml_open_file(unitNum, XML_ROOT_COLLEGES, fileName, ldx)
Expand Down
9 changes: 9 additions & 0 deletions CURRICULA.F90
Expand Up @@ -88,6 +88,9 @@ subroutine xml_write_curricula(path)
character(len=255) :: mesg
character(len=MAX_LEN_CURRICULUM_CODE) :: tCurriculum

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'CURRICULA.XML'
call xml_open_file(unitNo, XML_ROOT_CURRICULA, fileName, idx)

Expand Down Expand Up @@ -315,6 +318,9 @@ subroutine xml_write_equivalencies(path)
integer :: idx, tdx
character(len=255) :: mesg

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'EQUIVALENCIES.XML'
call xml_open_file(unitNo, XML_ROOT_EQUIVALENCIES, fileName, idx)
write(unitNo,AFORMAT) &
Expand Down Expand Up @@ -843,6 +849,9 @@ subroutine xml_write_intake(path)
character(len=*), intent(in) :: path
integer :: idxCURR

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'INTAKE.XML'

call xml_open_file(unitNo, XML_INTAKE, fileName, idxCURR)
Expand Down
3 changes: 3 additions & 0 deletions DEPARTMENTS.F90
Expand Up @@ -136,6 +136,9 @@ subroutine xml_write_departments(path)
character(len=*), intent(in) :: path
integer :: ldx

! training only?
if (noWrites) return

fileName = trim(dirXML)//trim(path)//'DEPARTMENTS.XML'
call xml_open_file(unitNum, XML_ROOT_DEPARTMENTS, fileName, ldx)
write(unitNum,AFORMAT) &
Expand Down
2 changes: 2 additions & 0 deletions EditSECTIONS.F90
Expand Up @@ -642,7 +642,9 @@ subroutine section_offer_subject(device, NumSections, Section, Offering, NumBloc
type (TYPE_OFFERED_SUBJECTS), intent(in out), dimension (MAX_ALL_DUMMY_SUBJECTS:MAX_ALL_SUBJECTS) :: Offering
character(len=MAX_LEN_SUBJECT_CODE) :: tSubject
character(len=MAX_LEN_SECTION_CODE) :: tSection
#if defined CUSTOM
character(len=MAX_LEN_DEPARTMENT_CODE) :: tDepartment
#endif
integer :: crse, Term, kdx, dept
character (len=127) :: mesg

Expand Down
93 changes: 40 additions & 53 deletions HTML.F90
Expand Up @@ -114,7 +114,7 @@ subroutine html_login(fname, mesg)
write(device,AFORMAT) '<option value="'//trim(itoa(i))//'"> '//trim(UserList(i)%Name)
end do
write(device,AFORMAT) '</select>&nbsp;&nbsp; '
if (CHECK_PASSWORD) then
if (checkPassword) then
write(device,AFORMAT) &
'<b>Password is : </b> <input type="password" name="P" value="">&nbsp;&nbsp;'
end if
Expand Down Expand Up @@ -787,34 +787,13 @@ subroutine html_write_footer(device)

integer, intent(in) :: device

! integer :: gdx
!
! if (isRoleAdmin) then
! write(device,AFORMAT) &
! '<b>Links to ''administrative'' college: '//trim(College(CollegeIdxUser)%Code)// &
! '</b> - '//trim(College(CollegeIdxUser)%Name)
! call html_college_info(device, CollegeIdxUser)
!
! ! links to other colleges
! write(device,AFORMAT) '<b>Links to other colleges:</b>'
! do gdx = 1,NumColleges
! ! my college links already printed above?
! if (gdx==CollegeIdxUser) cycle
! ! fnCollegeLinks requested already printed above?
! if (REQUEST==fnCollegeLinks .and. gdx==targetCollege) cycle
! write(device,AFORMAT) trim(cgi_make_href(fnCollegeLinks, targetUser, College(gdx)%Code, &
! A1=College(gdx)%Code, pre=nbsp))
! end do
! end if

! last piece of info on the page
call date_and_time (date=currentDate,time=currentTime)
write(device,AFORMAT) &
'<small><i>Generated '//currentDate(1:4)//fslash//currentDate(5:6)//fslash//currentDate(7:8)// &
dash//currentTime(1:2)//':'//currentTime(3:4)//'.'// &
nbsp//nbsp//' Please report errors to '//trim(UniversityCode)//space//trim(REGISTRAR)//'.'// &
nbsp//nbsp//CONTACT, &
nbsp//nbsp//' Or see <a target="0" href="http://code.google.com/p/heeds/">HEEDS on the web</a>.', &
nbsp//nbsp//' Please report errors to '//trim(UniversityCode)//space//trim(REGISTRAR)//'.'// & ! nbsp//nbsp//CONTACT, &
nbsp//nbsp//' <a target="0" href="http://code.google.com/p/heeds/">HEEDS on the Web</a>.', &
'</i></small>', &
'</body></html>'

Expand Down Expand Up @@ -1095,7 +1074,7 @@ subroutine html_college_info(device, coll)

end if

n_count = 0
n_count = 0 ! any students?
do std=1,NumStudents
if (Curriculum(Student(std)%CurriculumIdx)%CollegeIdx /= coll) cycle
n_count = n_count+1
Expand All @@ -1118,8 +1097,8 @@ subroutine html_college_info(device, coll)
end do
if (n_count > 0) then
write(device,AFORMAT) trim(cgi_make_href(fnStudentsByName, targetUser, ch, &
A1=tCollege, A2=ch, &
post='('//trim(itoa(n_count))//')&nbsp;'))
A1=tCollege, A2=ch, &
post='('//trim(itoa(n_count))//')&nbsp;'))
!else
! write(device,AFORMAT) ch//nbsp
end if
Expand Down Expand Up @@ -1161,52 +1140,60 @@ subroutine html_college_info(device, coll)
end do
if (n_count > 0) then
write(device,AFORMAT) trim(cgi_make_href(fnStudentsByProgram, targetUser, CurrProgCode(cdx), &
A1=CurrProgCode(cdx), &
post='('//trim(itoa(n_count))//')&nbsp;'))
A1=CurrProgCode(cdx), &
post='('//trim(itoa(n_count))//')&nbsp;'))
do ldx=cdx+1,NumCurricula
if (CurrProgCode(ldx) == CurrProgCode(cdx)) done(ldx) = .true.
end do
end if
end do
write(device,AFORMAT) trim(cgi_make_href(fnStudentsDistribution, targetUser, 'Distribution among curricula', &
A1=tCollege))
A1=tCollege))
write(device,AFORMAT) '</li>'
end if
write(device,AFORMAT) '</ul><hr></li>'
end if

! any curricular programs
n_count = 0
do cdx=1,NumCurricula
if (Curriculum(cdx)%CollegeIdx /= coll) cycle
n_count = n_count+1
exit
end do
if (available(fnCurriculumList)) then
write(device,AFORMAT) '<li><b>Curricular programs</b> : &nbsp;'
done = .false.
do cdx=1,NumCurricula
if (Curriculum(cdx)%CollegeIdx /= coll) cycle
if (done(cdx)) cycle
write(device,AFORMAT) trim(cgi_make_href(fnCurriculumList, targetUser, CurrProgCode(cdx), &
A1=CurrProgCode(cdx), &
post=nbsp))
do ldx=cdx+1,NumCurricula
if (CurrProgCode(ldx) == CurrProgCode(cdx)) done(ldx) = .true.
if (n_count>0) then
write(device,AFORMAT) '<li><b>Curricular programs</b> : &nbsp;'
done = .false.
do cdx=1,NumCurricula
if (Curriculum(cdx)%CollegeIdx /= coll) cycle
if (done(cdx)) cycle
write(device,AFORMAT) trim(cgi_make_href(fnCurriculumList, targetUser, CurrProgCode(cdx), &
A1=CurrProgCode(cdx), post=nbsp))
do ldx=cdx+1,NumCurricula
if (CurrProgCode(ldx) == CurrProgCode(cdx)) done(ldx) = .true.
end do
end do
end do
write(device,AFORMAT) '</li><hr>'
write(device,AFORMAT) '</li><hr>'
end if
end if

! subjects
call links_to_subjects(device, coll, tLen, tArray(1))

! CURRENT SEMESTER
write(device,AFORMAT) '<hr>', &
'<li><b>'//trim(txtSemester(currentTerm+3)//' Semester, SY '//trim(itoa(currentYear))//dash// &
trim(itoa(currentYear+1))//' '//txtPeriod(Period))//'</b><ul>'
write(device,AFORMAT) &
'<li><b>'//trim(txtSemester(currentTerm+3)//' Semester, SY '//trim(itoa(currentYear))//dash// &
trim(itoa(currentYear+1))//' '//txtPeriod(Period))//'</b><ul>'

! blocks
call links_to_blocks(device, 0, coll)
if (n_count>0) call links_to_blocks(device, 0, coll)

! classes
call links_to_sections(device, 0, coll, tLen, tArray(1))

! enlistment summary
call links_to_depts(device, coll, fnEnlistmentSummary, '<b>Summary of enlistment</b>')
if (tLen>0) call links_to_depts(device, coll, fnEnlistmentSummary, '<b>Summary of enlistment</b>')

! teachers
call links_to_teachers(device, 0, coll)
Expand All @@ -1222,16 +1209,16 @@ subroutine html_college_info(device, coll)
'<li><b>'//green//trim(txtSemester(targetTerm+3))//' Semester, SY '// &
trim(itoa(targetYear))//dash//itoa(targetYear+1)//black//'</b><ul>'

if (available(fnDemandFreshmen)) then
if (available(fnDemandFreshmen) .and. tLen>0 ) then
write(device,AFORMAT) trim(cgi_make_href(fnDemandFreshmen, targetUser, 'new freshmen', &
A1=tCollege, pre='<li><b>Demand for subjects by ', post='</b></li>'))
end if

! demand for subjects
call links_to_depts(device, coll, fnDemandForSubjects, '<b>Demand for subjects</b>')
if (tLen>0) call links_to_depts(device, coll, fnDemandForSubjects, '<b>Demand for subjects</b>')

! blocks
call links_to_blocks(device, fnNextOFFSET, coll)
if (n_count>0) call links_to_blocks(device, fnNextOFFSET, coll)

! classes
call links_to_sections(device, fnNextOFFSET, coll, tLen, tArray(1))
Expand Down Expand Up @@ -1292,7 +1279,7 @@ subroutine links_to_subjects(device, coll, numAreas, AreaList)
character (len=MAX_LEN_SUBJECT_CODE) :: tSubject
character(len=MAX_LEN_DEPARTMENT_CODE) :: tDepartment

if (.not. available(fnSubjectList)) return
if (.not. available(fnSubjectList) .or. numAreas==0) return

write(device,AFORMAT) '<li><b>Subjects</b> in : '
do dept=2,NumDepartments
Expand Down Expand Up @@ -1321,7 +1308,7 @@ subroutine links_to_subjects(device, coll, numAreas, AreaList)
tSubject = SubjectArea(AreaList(dept))%Code
write(device,AFORMAT) trim(cgi_make_href(fnSubjectList, targetUser, tSubject, A1=tSubject, post=nbsp))
end do
write(device,AFORMAT) '</li>'
write(device,AFORMAT) '</li><hr>'
return
end subroutine links_to_subjects

Expand All @@ -1334,7 +1321,7 @@ subroutine links_to_sections(device, OFFSET, coll, numAreas, AreaList)
character (len=MAX_LEN_SUBJECT_CODE) :: tSubject
character(len=MAX_LEN_DEPARTMENT_CODE) :: tDepartment

if (.not. available(OFFSET+fnScheduleOfClasses)) return
if (.not. available(OFFSET+fnScheduleOfClasses) .or. numAreas==0) return
tCollege = College(coll)%Code

write(device,AFORMAT) '<li><b>Class schedules</b> in : '
Expand Down
33 changes: 25 additions & 8 deletions MAIN.F90
Expand Up @@ -48,7 +48,7 @@ program MAIN
'year - the year when current Academic Year started', &
'term - 1=first sem, 2=second sem', &
'period - 1=enrollment period, 2=mid-term, 3=end-of-term (grades are available)', &
'action - convert, checklists, advise, schedule, server'
'action - convert, checklists, advise, schedule, server, training'
stop
end if

Expand All @@ -71,20 +71,34 @@ program MAIN
call getarg(4, argString)
Period = atoi(argString)

! allow files to be rewritten
noWrites = .false.

if (iTmp>4) then
call getarg(5, argString)
call upper_case(argString)

select case (trim(argString))

case ('CHECKLISTS')

case ('ADVISE')

case ('SCHEDULE')

case ('SERVER')
noWrites = .false.
checkPassword = .true.

case default
argString = 'CONVERT'
argString = 'TRAINING'
noWrites = .true.
checkPassword = .false.
end select
else
argString = 'CONVERT'
argString = 'TRAINING'
noWrites = .true.
checkPassword = .false.
end if

write(*,*) PROGNAME//VERSION//' started '//currentDate//dash//currentTime
Expand Down Expand Up @@ -322,13 +336,11 @@ program MAIN

select case (trim(argString))

case ('CONVERT')

case ('ADVISE')

case ('SCHEDULE')

case ('SERVER')
case ('SERVER', 'TRAINING')

call create_user_names()
write(*,*) NumUsers, ' users'
Expand Down Expand Up @@ -356,8 +368,13 @@ program MAIN
write(*,AFORMAT) 'The '//PROGNAME//' back-end program is ready.', &
'The CGI script is '//CGI_PATH, &
'Temporary HTML files will be in '//trim(dirTmp), &
'No. of predefined users is '//itoa(NumUsers), &
'The administrative password is '//itoa(adminPassword)
'No. of predefined users is '//itoa(NumUsers)

if (noWrites) then ! training mode
write(*,AFORMAT) ' ', PROGNAME//' is in training mode. Any made changes will be lost after the program exits.'
else ! server mode
write(*,AFORMAT) 'The administrative password is '//itoa(adminPassword)
end if

! start of server loop
call server_start()
Expand Down

0 comments on commit adbfe11

Please sign in to comment.