Annotation of loncom/html/adm/help/tex/Institutional_Integration_Course_Codes.tex, revision 1.1
1.1 ! raeburn 1: \label{Institutional_Integration_Course_Codes}
! 2: Courses in a domain can be self-cataloging if assigned an institutional
! 3: code. For this to work, two routines need to be customized in localenroll.pm
! 4: - \emph{instcode\_format()} and \emph{instcode\_defaults()}. The first
! 5: of these is used to split institutional course codes into their constituent
! 6: parts, and to populate some perl data structures with these data.
! 7: LON-CAPA will use these perl structures to generate linked select boxes
! 8: which can be used when searching the {}``official'' course catalog.
! 9: The second routine is used when constructing a regular expression for
! 10: retrieval of courses based on search criteria specified by the user via the
! 11: linked select boxes. The search criteria are combined with defaults for any
! 12: components not explicitly selected (the defaults are fragments of a generic
! 13: institutional code) to create the regular expression used in the course search.
! 14:
! 15: \textbf{\large instcode\_format}
! 16:
! 17: Six arguments are required:
! 18:
! 19: \begin{enumerate}
! 20: \item domain (\$dom)
! 21: \item reference to hash of institutional course IDs (\$instcodes)
! 22: \item reference to hash of codes (\$codes)
! 23: \item reference to array of titles (\$codetitles), e.g., @\{\$codetitles\}
! 24: = (\char`\"{}year\char`\"{},\char`\"{}semester\char`\"{},\char`\"{}department\char`\"{},\char`\"{}number\char`\"{})
! 25: \item reference to hash of abbreviations used in categories, (\$cat\_titles)
! 26: e.g.,
! 27:
! 28: \begin{quote}
! 29: \%\{\$\$cat\_titles\{'Semester'\}\} = (
! 30: \begin{quote}
! 31: fs => 'Fall',
! 32:
! 33: ss => 'Spring',
! 34:
! 35: us => 'Summer');
! 36: \end{quote}
! 37: \end{quote}
! 38: \item reference to hash of arrays specifying sort order used in category
! 39: titles (\$cat\_order), e.g., @\{\$\$cat\_order\{'Semester'\}\} = ('ss','us','fs');
! 40: \end{enumerate}
! 41: The routine returns 'ok' if no errors occurred.
! 42:
! 43: At MSU, {}``fs03nop590'' is an example of an institutional course
! 44: code; including the following entry in the instcodes hash passed in
! 45: by reference - \$\$instcodes\{'43551dedcd43febmsul1'\} = 'fs03nop590'
! 46: would cause the \$codes perl data structure to be populated.
! 47:
! 48: fs03nop590 would be split as follows:
! 49:
! 50: \$\$codes\{'year'\} = '2003'
! 51:
! 52: \$\$codes\{'semester'\} = 'Fall'
! 53:
! 54: \$\$codes\{'department'\} = 'nop'
! 55:
! 56: \$\$codes\{'number'\} = '590'
! 57:
! 58: The routine used at MSU is as follows:
! 59:
! 60: \begin{quotation}
! 61: \texttt{sub instcode\_format \{}
! 62: \begin{quotation}
! 63: \texttt{my (\$dom,\$instcodes,\$codes,\$codetitles,\$cat\_titles,\$cat\_order)
! 64: = @\_;}
! 65:
! 66: \texttt{@\{\$codetitles\} = (\char`\"{}Year\char`\"{},\char`\"{}Semester\char`\"{},\char`\"{}Department\char`\"{},\char`\"{}Number\char`\"{});}
! 67:
! 68: \texttt{\%\{\$\$cat\_titles\{'Semester'\}\} = (}
! 69: \begin{quotation}
! 70: \texttt{fs => 'Fall',}
! 71:
! 72: \texttt{ss => 'Spring',}
! 73:
! 74: \texttt{us => 'Summer'}
! 75: \end{quotation}
! 76: \texttt{);}
! 77:
! 78: \texttt{@\{\$\$cat\_order\{'Semester'\}\} = ('ss','us','fs');}
! 79:
! 80: \texttt{foreach my \$cid (keys \%\{\$instcodes\}) \{}
! 81: \begin{quotation}
! 82: \texttt{if (\$\$instcodes\{\$cid\} =\~{} m/^({[}suf]s)(\textbackslash{}d\{2\})(\textbackslash{}w\{2,3\})(\textbackslash{}d\{3,4\}\textbackslash{}w?)\$/)
! 83: \{}
! 84: \begin{quotation}
! 85: \texttt{\$\$codes\{\$cid\}\{'Semester'\} = \$1;}
! 86:
! 87: \texttt{\$\$codes\{\$cid\}\{'Department'\} = \$3;}
! 88:
! 89: \texttt{\$\$codes\{\$cid\}\{'Number'\} = \$4;}
! 90:
! 91: \texttt{my \$year = \$2;}
! 92:
! 93: \texttt{my \$numyear = \$year;}
! 94:
! 95: \texttt{\$numyear =\~{} s/^0//;}
! 96:
! 97: \texttt{\$\$codes\{\$cid\}\{'Year'\} = \$year;}
! 98:
! 99: \texttt{unless (defined(\$\$cat\_titles\{'Year'\}\{\$year\})) \{}
! 100: \begin{quotation}
! 101: \texttt{\$\$cat\_titles\{'Year'\}\{\$year\} = 2000 + \$numyear;}
! 102: \end{quotation}
! 103: \texttt{\}}
! 104: \end{quotation}
! 105: \texttt{\}}
! 106: \end{quotation}
! 107: \texttt{\}}
! 108:
! 109: \texttt{my \$outcome = 'ok';}
! 110:
! 111: \texttt{return \$outcome;}
! 112: \end{quotation}
! 113: \texttt{\}}
! 114: \end{quotation}
! 115: \textbf{\large instcode\_defaults}{\large \par}
! 116:
! 117: Three arguments are required:
! 118:
! 119: \begin{enumerate}
! 120: \item domain (\$dom)
! 121: \item reference to hash which will contain default regular expression matches
! 122: for different components of an institutional course code
! 123:
! 124:
! 125: (\$defaults)
! 126:
! 127: \item reference to array which will contain order of component parts used
! 128: in institutional code. (\$code\_order)
! 129: \end{enumerate}
! 130: The routine returns 'ok' if no errors occurred.
! 131:
! 132: At MSU , the regaular expression fragments used mirror those included
! 133: in the regular expression used in instcode\_format() to split an institutional
! 134: course code into its component parts.
! 135:
! 136: \begin{quotation}
! 137: \texttt{sub instcode\_defaults \{}
! 138: \begin{quotation}
! 139: \texttt{my (\$dom,\$defaults,\$code\_order) = @\_;}
! 140:
! 141: \texttt{\%\{\$defaults\} = (}
! 142: \begin{quotation}
! 143: \texttt{'Year' => '\textbackslash{}d\{2\}',}
! 144:
! 145: \texttt{'Semester' => '^{[}sfu]s',}
! 146:
! 147: \texttt{'Department' => '\textbackslash{}w\{2,3\}',}
! 148:
! 149: \texttt{'Number' => '\textbackslash{}d\{3,4\}\textbackslash{}w?',}
! 150: \end{quotation}
! 151: \texttt{);}
! 152:
! 153: \texttt{@\{\$code\_order\} = ('Semester','Year','Department','Number');}
! 154:
! 155: \texttt{return 'ok';}
! 156: \end{quotation}
! 157: \texttt{\}}
! 158: \end{quotation}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>