File:  [LON-CAPA] / loncom / html / adm / help / tex / Institutional_Integration_Course_Codes.tex
Revision 1.6: download - view: text, annotated - select for diffs
Wed Dec 4 18:04:10 2013 UTC (10 years, 8 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0, HEAD
Fix typo and update year in example

    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),
   22: \begin{quote}
   23: e.g., @\{\$codetitles\}
   24: \begin{quote}
   25: = (\char`\"{}year\char`\"{},\char`\"{}semester\char`\"{},\char`\"{}department\char`\"{},\char`\"{}number\char`\"{})
   26: \end{quote}
   27: \end{quote}
   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}
   34: fs =$>$ 'Fall',
   35: 
   36: ss =$>$ 'Spring',
   37: 
   38: us =$>$ 'Summer');
   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: 
   46: At MSU, {}``fs13nop590'' is an example of an institutional course
   47: code; including the following entry in the instcodes hash passed in
   48: by reference - \$\$instcodes\{'43551dedcd43febmsul1'\} = 'fs13nop590'
   49: would cause the \$codes perl data structure to be populated.
   50: 
   51: fs13nop590 would be split as follows:
   52: 
   53: \$\$codes\{\{'year'\} = '2013'
   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}
   85: \texttt{if (\$\$instcodes\{\$cid\} =\~{} m/\^{}({[}suf]s)(\textbackslash{}d\{2\})(\textbackslash{}w\{2,3\})(\textbackslash{}d\{3,4\}\textbackslash{}w?)\$/)
   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: 
   98: \texttt{\$numyear =\~{} s/\^{}0//;}
   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: 
  135: At MSU, the regular expression fragments used mirror those included
  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: 
  148: \texttt{'Semester' => '\^{}{[}sfu]s',}
  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>