File:  [LON-CAPA] / loncom / html / adm / help / tex / Institutional_Integration_Course_Codes.tex
Revision 1.3: download - view: text, annotated - select for diffs
Tue Jul 29 20:52:20 2008 UTC (16 years ago) by raeburn
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_99_1, version_2_10_0_RC2, version_2_10_0_RC1, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox
- Fix some carets.

    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 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. 
   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: 
   41: At MSU, {}``fs03nop590,'' is an example of an institutional course
   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: 
   48: \$\$codes\{\{'year'\} = '2003'
   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}
   80: \texttt{if (\$\$instcodes\{\$cid\} =\~{} m/\^{}({[}suf]s)(\textbackslash{}d\{2\})(\textbackslash{}w\{2,3\})(\textbackslash{}d\{3,4\}\textbackslash{}w?)\$/)
   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: 
   93: \texttt{\$numyear =\~{} s/\^{}0//;}
   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: 
  130: At MSU, the regular expression fragments used mirror those included
  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: 
  143: \texttt{'Semester' => '\^{}{[}sfu]s',}
  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>