File:  [LON-CAPA] / loncom / homework / gradesubmission.pl
Revision 1.2: download - view: text, annotated - select for diffs
Wed Nov 16 23:34:27 2005 UTC (18 years, 5 months ago) by albertel
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_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, 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_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_99_1, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- adding in a use of the correct_answer

    1: #!/usr/bin/perl
    2: # The LearningOnline Network with CAPA
    3: # example submissions grader for use with <externalresponse>
    4: #
    5: # $Id: gradesubmission.pl,v 1.2 2005/11/16 23:34:27 albertel Exp $
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   29: 
   30: use strict;
   31: use CGI qw(:standard);
   32: 
   33: my %form;
   34: &main();
   35: sub main {
   36:     my $q=new CGI;
   37:     print $q->header(-type => 'text/xml');
   38:     %form = $q->Vars();
   39:     my ($result,$message) = &grade();
   40:     &print_result($result,$message);
   41: }
   42: 
   43: sub print_result {
   44:     my ($result,$message) = @_;
   45:     print("<loncapagrade>\n");
   46:     print("<awarddetail>$result</awarddetail>\n");
   47:     print("<message>$message</message>\n");
   48:     print "</loncapagrade>";
   49: }
   50: 
   51: 
   52: sub grade {
   53:     if ($form{'LONCAPA_student_response'} =~ /a/) {
   54: 	return ('APPROX_ANS','Go a!');
   55:     } 
   56:     if ($form{'LONCAPA_student_response'} =~ /b/) {
   57: 	return ('EXACT_ANS','Go b!');
   58:     }
   59:     if ($form{'LONCAPA_student_response'} =~ /c/) {
   60: 	return ('INCORRECT','No c');
   61:     }
   62:     if ($form{'LONCAPA_student_response'} eq 
   63: 	$form{'LONCAPA_correct_answer'}) {
   64: 	return ('EXACT_ANS','Yep!');
   65:     }
   66: 
   67:     return ('INCORRECT','Hrrm');
   68: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>