/* imp-tran.p - Import Student transcripts The transcript importer will import the marks in the order they are setup for the appropriate year and building. It will import all enabled marks for each grading period and each period in order. For many districts, you marks will look something like MP1 MP2 EX1 SM1 MP3 MP4 EX2 SM2 which would be 4 marking periods, 2 exams and 2 semesters. Grades can be left blank, but you must leave the field blank and not shift everything over. For example, if a site only has semester grades to import, the import text would look like (for the above setup): - - - A+ - - - A 1 - Student ID (REQUIRED) 2 - Transcript Name Code (REQUIRED) 3 - School Year (i.e. 1994/95) (REQUIRED) 4 - Building Code (REQUIRED) 5 - Grade (REQUIRED) 6 - Course Code (REQUIRED) 7 - Section # (OPTIONAL, but suggested. If valid, will auto-link to the student schedule for the school year) 8 - Rankable? (optional - default from course catalog or master-schd) 9 - Course Absence Count (optional - default is 0) 10 - Course Tardy Count (optional - default is 0) 11 - Attempted Credits (optional - default from course catalog/master-schd) 12 - Earned Credits (optional - default is 0) 13 - First Mark (if any) 14 - Second Mark (if any) 15 - Third Mark (if any) 16 - Fourth Mark (if any) 17 - Fifth Mark (if any) 18 - Sixth Mark (if any) 19 - Seventh Mark (if any) 20 - Eigth Mark (if any) 21 - Ninth Mark (if any) 22 - Tenth Mark (if any) 23 - Eleventh Mark (if any) 24 - Twelevth Mark (if any) 25 - Comments for the year 26 - Comments for the course 27 - GPA Multiplier (optional - default from course catalog or master-schd) 28 - Grading Policy (optional - default from course catalog or master-schd) */ /* Include commons */ {common.i NEW} {p-init.i "'IMPORTER'"} /* Constants */ &SCOPED WriteCmd PUT STREAM LogStream UNFORMATTED &SCOPED WriteHdr "#" LineCnt ", " ImportText[1] ", " ImportText[3] ": " &SCOPED WriteLog {&WriteCmd} {&WriteHdr} /* Define Variables */ DEFINE VARIABLE ImportFile AS CHARACTER NO-UNDO. DEFINE VARIABLE ExportFile AS CHARACTER NO-UNDO. DEFINE VARIABLE LogFile AS CHARACTER NO-UNDO. DEFINE VARIABLE ReplaceMode AS LOGICAL NO-UNDO. DEFINE VARIABLE PurgeMode AS LOGICAL NO-UNDO. DEFINE VARIABLE ImportText AS CHARACTER EXTENT 50 NO-UNDO. DEFINE VARIABLE LineCnt AS INTEGER NO-UNDO. DEFINE VARIABLE AutoCreate AS LOGICAL NO-UNDO. /* Variables for statistics */ DEFINE VARIABLE TotalLineCnt AS INTEGER NO-UNDO. DEFINE VARIABLE StartTime AS INTEGER NO-UNDO. DEFINE VARIABLE LastUpdate AS INTEGER NO-UNDO. DEFINE VARIABLE PercentDone AS DECIMAL NO-UNDO. DEFINE VARIABLE LinesPerSec AS DECIMAL NO-UNDO. DEFINE VARIABLE ErrorCnt AS INTEGER NO-UNDO. DEFINE VARIABLE Elapsed AS CHARACTER NO-UNDO. DEFINE VARIABLE TimeRemain AS CHARACTER NO-UNDO. /* Specific purpose variables */ DEFINE VARIABLE MarkPtr AS INTEGER NO-UNDO. DEFINE VARIABLE SectionNum AS INTEGER NO-UNDO. DEFINE VARIABLE PruneRecords AS LOGICAL INITIAL Yes NO-UNDO. DEFINE VARIABLE FoundCourse AS LOGICAL NO-UNDO. DEFINE VARIABLE FoundMark AS LOGICAL NO-UNDO. DEFINE VARIABLE PolicyPtr AS INTEGER NO-UNDO. /* Define Work tables */ DEFINE TEMP-TABLE TranMark NO-UNDO FIELD school-year-id LIKE school-year.school-year-id FIELD bldg-id LIKE building.bldg-id FIELD mark-order AS INTEGER FIELD grading-period-id AS INTEGER FIELD mark-id AS INTEGER INDEX mark-order school-year-id bldg-id mark-order. /* Define Buffers */ DEFINE BUFFER YearBuff FOR school-year. DEFINE BUFFER BldgBuff FOR building. DEFINE BUFFER VrsnBuff FOR schd-version. /* Define Streams */ DEFINE STREAM ImportStream. DEFINE STREAM LogStream. DEFINE STREAM ExportStream. /* Status frame */ FORM TotalLineCnt COLUMN-LABEL "Total!Lines" FORMAT "zzzzz9" LineCnt COLUMN-LABEL "Curnt!Line" FORMAT "zzzzz9" PercentDone COLUMN-LABEL "%age!Done" FORMAT "zz9.99%" LinesPerSec COLUMN-LABEL "Lines!/sec" FORMAT "zz9.99" ErrorCnt COLUMN-LABEL "Errors" FORMAT "zzzz9" Elapsed COLUMN-LABEL "Elapsed!Time" TimeRemain COLUMN-LABEL "Time!Remain" WITH FRAME StatusFrame 1 DOWN CENTERED ROW 9 OVERLAY COLOR VALUE(the-color.c-proc) TITLE COLOR VALUE(the-color.c-title) " Student Transcript Importation Statistics ". /* First, get the import file */ QueryBlock: DO WHILE TRUE ON ERROR UNDO, RETURN ON ENDKEY UNDO, RETURN: /* Define the form */ FORM ImportFile LABEL " Import from" FORMAT "x(255)" VIEW-AS FILL-IN SIZE 32 BY 1 SPACE(1) PurgeMode LABEL " Purge transcripts first" FORMAT "Yes/No" SKIP ReplaceMode LABEL " Existing records should be" FORMAT "Replaced/Kept" LogFile LABEL " Log import results to" FORMAT "x(255)" VIEW-AS FILL-IN SIZE 32 BY 1 SPACE(1) AutoCreate LABEL " Auto-create codes" FORMAT "Yes/No" SKIP PruneRecords LABEL " Prune unused records" FORMAT "Yes/No" SKIP /* ExportFile LABEL " Backup replaced data to" FORMAT "x(255)" VIEW-AS FILL-IN SIZE 32 BY 1 */ WITH FRAME QueryFrame OVERLAY 1 DOWN CENTERED ROW 10 SIDE-LABELS COLOR VALUE(the-color.c-proc) PROMPT VALUE(the-color.c-input). /* Default things for the user */ ON LEAVE OF ImportFile IN FRAME QueryFrame DO: /* Define Variables */ DEFINE VARIABLE DotPtr AS INTEGER NO-UNDO. /* Get pointer to decimal */ DotPtr = INDEX(ImportFile:SCREEN-VALUE, "."). IF DotPtr = 0 THEN RETURN. /* Default the log file */ IF LogFile:SCREEN-VALUE = "" THEN LogFile:SCREEN-VALUE = SUBSTR(SELF:SCREEN-VALUE, 1, DotPtr - 1) + ".log". /* Default the backup file */ /*IF ExportFile:SCREEN-VALUE = "" THEN ExportFile:SCREEN-VALUE = SUBSTR(SELF:SCREEN-VALUE, 1, DotPtr - 1) + ".org". */ END. /* Query the user */ UPDATE ImportFile SKIP PurgeMode SKIP ReplaceMode SKIP LogFile SKIP AutoCreate SKIP PruneRecords SKIP /* ExportFile */ SKIP WITH FRAME QueryFrame OVERLAY 1 DOWN CENTERED ROW 10 SIDE-LABELS COLOR VALUE(the-color.c-proc) PROMPT VALUE(the-color.c-input) TITLE COLOR VALUE(the-color.c-title) " Import Student Transcripts ". /* See if the note exists */ IF SEARCH(ImportFile) = ? THEN DO: BELL. {safe-msg.i "'Cannot find the import source file'"} NEXT. END. /* Make sure the backup file should be overwritten */ /* IF SEARCH(ExportFile) <> ? THEN DO: DO ON ERROR UNDO, NEXT QueryBlock ON ENDKEY UNDO, NEXT QueryBlock: MESSAGE COLOR VALUE(the-color.c-alert) " " ExportFile "already exists " SKIP " Do you want to overwrite it?" SKIP VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO UPDATE OverwriteFile AS LOGICAL. END. /* Iterate if not okay */ IF NOT OverwriteFile THEN NEXT. END. */ /* Done */ LEAVE. END. /* Purge catalogs */ IF PurgeMode THEN DO: MESSAGE "Purging transcripts, please be patient...". FOR EACH stu-transcript-year: DELETE stu-transcript-year. END. FOR EACH stu-transcript-course: DELETE stu-transcript-course. END. FOR EACH stu-transcript-mark: DELETE stu-transcript-mark. END. HIDE MESSAGE NO-PAUSE. END. /* Load the profile */ FIND FIRST spm-prof NO-LOCK. /* Get line count */ INPUT STREAM ImportStream THROUGH VALUE("wc -l " + ImportFile). IMPORT STREAM ImportStream ImportText. INPUT STREAM ImportStream CLOSE. TotalLineCnt = INTEGER(ImportText[1]). DISPLAY TotalLineCnt WITH FRAME StatusFrame. /* Open the file */ INPUT STREAM ImportStream FROM VALUE(ImportFile). OUTPUT STREAM LogStream TO VALUE(LogFile) PAGE-SIZE 0. /* OUTPUT STREAM ExportStream TO VALUE(ExportFile) PAGE-SIZE 0. */ /* Hide the query frame */ HIDE FRAME QueryFrame NO-PAUSE. /* Reset counters */ ASSIGN StartTime = TIME LastUpdate = StartTime. /* Begin Processing */ ImportLoop: REPEAT ON ERROR UNDO, LEAVE ON ENDKEY UNDO, LEAVE: /* Get a line */ ImportText = "". IMPORT STREAM ImportStream ImportText. LineCnt = LineCnt + 1. /* Update status display */ IF (TIME - LastUpdate) > 2 THEN DO: DISPLAY LineCnt (LineCnt / TotalLineCnt) * 100 @ PercentDone LineCnt / (TIME - StartTime) @ LinesPerSec ErrorCnt STRING(TIME - StartTime, "HH:MM:SS") @ Elapsed STRING(INTEGER((TotalLineCnt - LineCnt) / (LineCnt / (TIME - StartTime))), "HH:MM:SS") @ TimeRemain WITH FRAME StatusFrame. LastUpdate = TIME. END. /* Make sure we have our required fields */ IF (ImportText[1] = "") OR (ImportText[1] = ?) OR (ImportText[2] = "") OR (ImportText[2] = ?) OR (ImportText[3] = "") OR (ImportText[3] = ?) OR (ImportText[4] = "") OR (ImportText[4] = ?) OR (ImportText[5] = "") OR (ImportText[5] = ?) OR (ImportText[6] = "") OR (ImportText[6] = ?) THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "One or more REQUIRED fields missing, NOT imported" SKIP. NEXT ImportLoop. END. /* Locate the year */ FIND YearBuff WHERE YearBuff.school-year-name = ImportText[3] NO-LOCK NO-ERROR. IF NOT AVAILABLE YearBuff THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown school year '" ImportText[3] "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Make sure we can find the building */ FIND FIRST BldgBuff OF YearBuff NO-LOCK WHERE BldgBuff.bldg-code = ImportText[4] NO-ERROR. IF NOT AVAILABLE BldgBuff THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Bldg '" ImportText[4] "'is not on file, NOT imported" SKIP. NEXT ImportLoop. END. /* See if the student is already on file */ FIND stu-base WHERE stu-base.stu-id = ImportText[1] NO-ERROR. IF NOT AVAILABLE stu-base THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Student is not on file, NOT imported" SKIP. NEXT ImportLoop. END. /* Load up the grade */ FIND grade-catalog OF BldgBuff WHERE grade-catalog.grade-name = ImportText[5] NO-LOCK NO-ERROR. IF NOT AVAILABLE grade-catalog THEN DO: IF NOT AutoCreate THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown grade '" ImportText[5] "' for building, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Create a new grade */ CREATE grade-catalog. ASSIGN grade-catalog.school-year-id = BldgBuff.school-year-id grade-catalog.bldg-id = BldgBuff.bldg-id grade-catalog.grade-name = CAPS(ImportText[5]) grade-catalog.description = "<< CREATED BY IMPORTER >>". {&WriteLog} "Created grade catalog entry " ImportText[5] ", Please check it out" SKIP. END. /* Locate the transcript */ FIND transcript-name WHERE transcript-name.transcript-name = ImportText[2] NO-LOCK NO-ERROR. IF NOT AVAILABLE transcript-name THEN DO: IF NOT AutoCreate THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown transcript name '" ImportText[2] "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Create a new transcript */ CREATE transcript-name. ASSIGN transcript-name.transcript-name = CAPS(ImportText[2]) transcript-name.description = "<< CREATED BY IMPORT >>". /* Log it */ {&WriteLog} "Created transcript " ImportText[2] ", Please check it out" SKIP. END. /* Make sure the building/grade are in the transcript listing */ FIND transcript-grade NO-LOCK WHERE transcript-grade.transcript-id = transcript-name.transcript-id AND transcript-grade.school-year-id = YearBuff.school-year-id AND transcript-grade.bldg-id = BldgBuff.bldg-id AND transcript-grade.grade-id = grade-catalog.grade-id NO-ERROR. IF NOT AVAILABLE transcript-grade THEN DO: IF NOT AutoCreate THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown transcript grade '" grade-catalog.grade-name "' for building '" BldgBuff.bldg-code "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Create a new grade */ CREATE transcript-grade. ASSIGN transcript-grade.transcript-id = transcript-name.transcript-id transcript-grade.school-year-id = YearBuff.school-year-id transcript-grade.bldg-id = BldgBuff.bldg-id transcript-grade.grade-id = grade-catalog.grade-id transcript-grade.comments = "<< CREATED BY IMPORTER >>". {&WriteLog} "Created transcript year/bldg/grade entry, Please check it out" SKIP. END. /* Load the version buffer */ FIND FIRST VrsnBuff OF BldgBuff NO-LOCK WHERE VrsnBuff.active-schedule = Yes. /* See if we have (or build one up) a mark list for this building/year */ FIND FIRST TranMark WHERE TranMark.school-year-id = YearBuff.school-year-id AND TranMark.bldg-id = BldgBuff.bldg-id NO-ERROR. IF NOT AVAILABLE TranMark THEN DO: MarkPtr = 0. /* Process all the grading periods */ FOR EACH grading-period OF BldgBuff NO-LOCK, EACH grading-period-mark OF grading-period NO-LOCK, grading-mark OF grading-period-mark NO-LOCK BY grading-period.school-year-id BY grading-period.bldg-id BY grading-period.start-date BY grading-period-mark.mark-order: /* Create an entry */ CREATE TranMark. ASSIGN MarkPtr = MarkPtr + 1 TranMark.school-year-id = YearBuff.school-year-id TranMark.bldg-id = BldgBuff.bldg-id TranMark.mark-order = MarkPtr TranMark.grading-period-id = grading-period.grading-period-id TranMark.mark-id = grading-period-mark.mark-id. END. /* Make sure we found something */ IF MarkPtr = 0 THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "No Transcript/grading marks setup for this year & building '" BldgBuff.bldg-code "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Lookup the course */ FIND FIRST course-catalog OF BldgBuff NO-LOCK WHERE course-catalog.course-code = ImportText[6] NO-ERROR. IF NOT AVAILABLE course-catalog THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Course " ImportText[6] " not in course catalog, NOT imported" SKIP. NEXT ImportLoop. END. /* Clear the master schedule */ FIND master-schd WHERE RECID(master-schd) = ? NO-ERROR. FIND stu-schedule WHERE RECID(stu-schedule) = ? NO-ERROR. /* Get the section # */ SectionNum = INTEGER(ImportText[7]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Bad section number '" ImportText[7] "'encountered, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Lookup the master schedule */ IF (ImportText[7] <> "") AND (ImportText[7] <> ?) THEN DO: FIND FIRST master-schd OF VrsnBuff NO-LOCK WHERE (master-schd.course-id = course-catalog.course-id) AND (master-schd.section-num = SectionNum) NO-ERROR. IF AVAILABLE master-schd THEN DO: /* See if the student has this course */ FIND FIRST stu-schedule OF VrsnBuff NO-LOCK WHERE (stu-schedule.course-id = master-schd.course-id) AND (stu-schedule.section-id = master-schd.section-id) AND (stu-schedule.current-entry = Yes) AND (stu-schedule.stu-seq = stu-base.stu-seq) NO-ERROR. END. END. /** Time to start creating transcript data **/ /* Load the entry for this year */ FIND FIRST stu-transcript-year WHERE stu-transcript-year.school-year-id = YearBuff.school-year-id AND stu-transcript-year.transcript-id = transcript-name.transcript-id AND stu-transcript-year.stu-seq = stu-base.stu-seq NO-ERROR. IF NOT AVAILABLE stu-transcript-year THEN DO: CREATE stu-transcript-year. ASSIGN stu-transcript-year.school-year-id = YearBuff.school-year-id stu-transcript-year.transcript-id = transcript-name.transcript-id stu-transcript-year.stu-seq = stu-base.stu-seq stu-transcript-year.bldg-id = BldgBuff.bldg-id stu-transcript-year.grade-id = grade-catalog.grade-id stu-transcript-year.comments = ImportText[25]. END. /* Load the course entry (differently depending on master-schd issues) */ IF AVAILABLE stu-schedule THEN DO: FIND FIRST stu-transcript-course WHERE stu-transcript-course.stu-seq = stu-base.stu-seq AND stu-transcript-course.transcript-id = transcript-name.transcript-id AND stu-transcript-course.school-year-id = YearBuff.school-year-id AND stu-transcript-course.bldg-id = BldgBuff.bldg-id AND stu-transcript-course.course-id = course-catalog.course-id AND stu-transcript-course.section-id = master-schd.section-id NO-ERROR. /* Handle preserving existing data */ IF AVAILABLE stu-transcript-course AND NOT ReplaceMode THEN DO: /* Handle unreplacable mode */ {&WriteLog} "Existing transcript for course, NOT imported" SKIP. NEXT ImportLoop. END. /* Create an entry, if needed */ IF NOT AVAILABLE stu-transcript-course THEN DO: CREATE stu-transcript-course. ASSIGN stu-transcript-course.stu-seq = stu-base.stu-seq stu-transcript-course.transcript-id = transcript-name.transcript-id stu-transcript-course.school-year-id = YearBuff.school-year-id stu-transcript-course.bldg-id = BldgBuff.bldg-id stu-transcript-course.course-id = course-catalog.course-id stu-transcript-course.section-id = master-schd.section-id stu-transcript-course.section-num = master-schd.section-num stu-transcript-course.rankable = master-schd.include-rank stu-transcript-course.grading-policy = master-schd.grading-policy stu-transcript-course.attempted-credit = master-schd.credit stu-transcript-course.course-level-id = master-schd.course-level-id. END. END. ELSE DO: FIND FIRST stu-transcript-course WHERE stu-transcript-course.stu-seq = stu-base.stu-seq AND stu-transcript-course.transcript-id = transcript-name.transcript-id AND stu-transcript-course.school-year-id = YearBuff.school-year-id AND stu-transcript-course.bldg-id = BldgBuff.bldg-id AND stu-transcript-course.course-id = course-catalog.course-id AND stu-transcript-course.section-num = SectionNum NO-ERROR. /* Handle preserving existing data */ IF AVAILABLE stu-transcript-course AND NOT ReplaceMode THEN DO: /* Handle unreplacable mode */ {&WriteLog} "Existing transcript for course, NOT imported" SKIP. NEXT ImportLoop. END. /* Create an entry, if needed */ IF NOT AVAILABLE stu-transcript-course THEN DO: CREATE stu-transcript-course. ASSIGN stu-transcript-course.stu-seq = stu-base.stu-seq stu-transcript-course.transcript-id = transcript-name.transcript-id stu-transcript-course.school-year-id = YearBuff.school-year-id stu-transcript-course.bldg-id = BldgBuff.bldg-id stu-transcript-course.course-id = course-catalog.course-id stu-transcript-course.section-id = ? stu-transcript-course.section-num = SectionNum stu-transcript-course.rankable = course-catalog.include-rank stu-transcript-course.grading-policy = course-catalog.grading-policy stu-transcript-course.attempted-credit = course-catalog.credit stu-transcript-course.course-level-id = course-catalog.course-level-id. END. END. /* See if it should be rankable */ IF (ImportText[8] <> "") AND (ImportText[8] <> ?) THEN DO: stu-transcript-course.rankable = ImportText[8] BEGINS "Y". END. /* Check on absences */ IF (ImportText[9] <> "") AND (ImportText[9] <> ?) THEN DO: stu-transcript-course.absence-count = DECIMAL(ImportText[9]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Illegal number '" ImportText[9] "' for absence count, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Check on tardies */ IF (ImportText[10] <> "") AND (ImportText[10] <> ?) THEN DO: stu-transcript-course.tardy-count = DECIMAL(ImportText[10]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Illegal number '" ImportText[10] "'for tardy count, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Check on attempted credits */ IF (ImportText[11] <> "") AND (ImportText[11] <> ?) THEN DO: stu-transcript-course.attempted-credit = DECIMAL(ImportText[11]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Illegal number '" ImportText[11] "' for attempted credit, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Check on earned credits */ IF (ImportText[12] <> "") AND (ImportText[12] <> ?) THEN DO: stu-transcript-course.earned-credit = DECIMAL(ImportText[12]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Illegal number '" ImportText[12] "' for earned credit, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Check on overridden GPA Mulitplier */ IF (ImportText[27] <> "") AND (ImportText[27] <> ?) THEN DO: stu-transcript-course.gpa-multiplier = DECIMAL(ImportText[27]) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Illegal number '" ImportText[27] "' for GPA Multiplier, NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Set the orverride flag */ stu-transcript-course.override-gpa-multiplier = Yes. END. /* Check on overridden Gradign Policy */ IF (ImportText[28] <> "") AND (ImportText[28] <> ?) THEN DO: PolicyPtr = LOOKUP(ImportText[27], "Numeric,Letter,Pass/Fail"). IF PolicyPtr = 0 THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown grading policy '" ImportText[27] "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Set the orverride flag */ ASSIGN stu-transcript-course.grading-policy = ENTRY(PolicyPtr, "Numeric,Letter,Pass/Fail") stu-transcript-course.override-grading-policy = Yes. END. /* Set course comment in place */ stu-transcript-course.comments = ImportText[26]. /* Reset mark-d-cator */ FoundMark = No. /** Load/Process all marks **/ MarkLoop: DO MarkPtr = 1 TO 12: /* See if we should skip this */ IF (ImportText[MarkPtr + 12] = ?) OR (ImportText[MarkPtr + 12] = "") THEN NEXT. /* Lookup the mark */ FIND FIRST course-level-grade OF BldgBuff NO-LOCK WHERE course-level-grade.course-level-id = stu-transcript-course.course-level-id AND course-level-grade.letter-grade = ImportText[MarkPtr + 12] NO-ERROR. IF NOT AVAILABLE course-level-grade THEN DO: IF NOT AutoCreate THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "Unknown letter grade '" ImportText[MarkPtr + 12] "', NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. /* Create a new grade */ CREATE course-level-grade. ASSIGN course-level-grade.school-year-id = BldgBuff.school-year-id course-level-grade.bldg-id = BldgBuff.bldg-id course-level-grade.course-level-id = stu-transcript-course.course-level-id course-level-grade.letter-grade = CAPS(ImportText[MarkPtr + 12]) course-level-grade.description = "<< CREATED BY IMPORTER >>". {&WriteLog} "Created grade " ImportText[MarkPtr + 12] ", Please check it out" SKIP. END. /* Fetch the mark record */ FIND FIRST TranMark WHERE TranMark.school-year-id = YearBuff.school-year-id AND TranMark.bldg-id = BldgBuff.bldg-id AND TranMark.mark-order = MarkPtr NO-ERROR. IF NOT AVAILABLE TranMark THEN DO: {&WriteLog} "WARNING: Extra mark #" MarkPtr " ignored!" SKIP. NEXT MarkLoop. END. /* Load/Create stu-grade-mark record */ FIND FIRST stu-transcript-mark OF stu-transcript-course WHERE stu-transcript-mark.grading-period-id = TranMark.grading-period-id AND stu-transcript-mark.mark-id = TranMark.mark-id NO-ERROR. IF NOT AVAILABLE stu-transcript-mark THEN DO: CREATE stu-transcript-mark. ASSIGN stu-transcript-mark.stu-seq = stu-transcript-course.stu-seq stu-transcript-mark.transcript-id = stu-transcript-course.transcript-id stu-transcript-mark.school-year-id = stu-transcript-course.school-year-id stu-transcript-mark.bldg-id = stu-transcript-course.bldg-id stu-transcript-mark.course-level-id = stu-transcript-course.course-level-id stu-transcript-mark.grading-period-id = TranMark.grading-period-id stu-transcript-mark.mark-id = TranMark.mark-id stu-transcript-mark.transcript-seq = stu-transcript-course.transcript-seq. END. /* Assign the mark */ ASSIGN FoundMark = Yes stu-transcript-mark.course-level-grade-id = course-level-grade.course-level-grade-id. END. /* If we didn't assign a mark, undo this */ IF NOT FoundMark THEN DO: ErrorCnt = ErrorCnt + 1. {&WriteLog} "No marks found for course - course NOT imported" SKIP. UNDO ImportLoop, NEXT ImportLoop. END. END. /* Final statistics update */ DISPLAY LineCnt (LineCnt / TotalLineCnt) * 100 @ PercentDone LineCnt / (TIME - StartTime) @ LinesPerSec ErrorCnt STRING(TIME - StartTime, "HH:MM:SS") @ Elapsed STRING(INTEGER((TotalLineCnt - LineCnt) / (LineCnt / (TIME - StartTime))), "HH:MM:SS") @ TimeRemain WITH FRAME StatusFrame. /* Prune records */ IF PruneRecords THEN DO: MESSAGE "Pruning unused transcript records, please wait...". /* Process each stu-transcript-year */ FOR EACH stu-transcript-year, stu-base OF stu-transcript-year NO-LOCK, transcript-name OF stu-transcript-year NO-LOCK: FoundCourse = No. FOR EACH stu-transcript-course OF stu-transcript-year: FIND FIRST stu-transcript-mark OF stu-transcript-course NO-ERROR. IF NOT AVAILABLE stu-transcript-mark THEN DO: FIND FIRST course-catalog OF stu-transcript-course NO-LOCK. PUT STREAM LogStream UNFORMATTED " Purging unused course " course-catalog.course-code " for student " stu-base.stu-id " (" stu-base.stu-name ")" SKIP. DELETE stu-transcript-course. NEXT. END. FoundCourse = Yes. END. IF NOT FoundCourse THEN DO: FIND school-year OF stu-transcript-year NO-LOCK. PUT STREAM LogStream UNFORMATTED " Purging unused year " school-year.school-year-name " for student " stu-base.stu-id " (" stu-base.stu-name ")" SKIP. DELETE stu-transcript-year. NEXT. END. END. HIDE MESSAGE NO-PAUSE. END. /* Close the input & log streams */ INPUT STREAM ImportStream CLOSE. OUTPUT STREAM LogStream CLOSE. /* OUTPUT STREAM ExportStream CLOSE. */ /* We are done */ {safe-msg.i "'Import Complete'"} RETURN.