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