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