You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: jj v. a. <we...@ma...> - 2005-07-30 00:11:35
|
Log Message: ----------- Fix glitch in keeping menus in sync in advanced search panel, and deal better with undefined parameters. Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: SetMaker.pm Revision Data ------------- Index: SetMaker.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v retrieving revision 1.46 retrieving revision 1.47 diff -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -u -r1.46 -r1.47 --- lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm +++ lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm @@ -47,6 +47,13 @@ use constant ALL_SECTIONS => 'All Sections'; use constant ALL_TEXTBOOKS => 'All Textbooks'; +#use constant LIB2_DATA => [ + #[qw(dbchapter library_chapters), ALL_CHAPTERS], + #[qw(dbsection library_sections), ALL_SECTIONS], + #[qw(dbsubject library_subjects), ALL_SUBJECT], + #[qw(textbook library_textbook), ALL_TEXTBOOKS], + #]; + ## Flags for operations on files use constant ADDED => 1; @@ -506,12 +513,21 @@ my $right_button_style = "width: 18ex"; my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); + if(! grep { $_ eq $r->param('library_subjects') } @subjs) { + $r->param('library_subjects', ''); + } unshift @subjs, ALL_SUBJECTS; my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); + if(! grep { $_ eq $r->param('library_chapters') } @chaps) { + $r->param('library_chapters', ''); + } unshift @chaps, ALL_CHAPTERS; my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); + if(! grep { $_ eq $r->param('library_sections') } @sects) { + $r->param('library_sections', ''); + } unshift @sects, ALL_SECTIONS; my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); @@ -520,6 +536,9 @@ for my $ta (@{$texts}) { $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")"; } + if(! grep { $_ eq $r->param('library_textbook') } @textarray) { + $r->param('library_textbook', ''); + } unshift @textarray, ALL_TEXTBOOKS; my $atb = ALL_TEXTBOOKS; $textlabels{$atb} = ALL_TEXTBOOKS; @@ -793,6 +812,14 @@ )); } +sub clear_default { + my $r = shift; + my $param = shift; + my $default = shift; + my $newvalue = $r->param($param) || ''; + $newvalue = '' if($newvalue eq $default); + $r->param($param, $newvalue); +} sub pre_header_initialize { my ($self) = @_; @@ -806,10 +833,10 @@ my $library_basic = $r->param('library_is_basic') || 1; ## Fix some parameters - $r->param('library_subjects', '') if($r->param('library_subjects') eq ALL_SUBJECTS); - $r->param('library_chapters', '') if($r->param('library_chapters') eq ALL_CHAPTERS); - $r->param('library_sections', '') if($r->param('library_sections') eq ALL_SECTIONS); - $r->param('library_textbook', '') if($r->param('library_textbook') eq ALL_TEXTBOOKS); + clear_default($r,'library_subjects', ALL_SUBJECTS); + clear_default($r,'library_chapters', ALL_CHAPTERS); + clear_default($r,'library_sections', ALL_SECTIONS); + clear_default($r,'library_textbook', ALL_TEXTBOOKS); ## These directories will have individual buttons %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs}; |
From: Mike G. v. a. <we...@ma...> - 2005-07-29 21:40:54
|
Log Message: ----------- Backing out of the changes just made for a moment. I've discovered that making this switch: CGI::p(CGI::code($details)), to CGI::code(CGI::p($details)), speeds things up immensly. (From 165 seconds down to 12 seconds on the example I'm doing.) Even without any other changes. Since the other changes complicate things a bit, I'll put off adding the ability to have $details be a reference. It's possible that allowing $details to be passed as a reference is a good idea anyway, on general principles. I want first to see if it makes a difference in terms of memory consumption. Modified Files: -------------- webwork-modperl/lib/WeBWorK: ContentGenerator.pm Revision Data ------------- Index: ContentGenerator.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator.pm,v retrieving revision 1.139 retrieving revision 1.140 diff -Llib/WeBWorK/ContentGenerator.pm -Llib/WeBWorK/ContentGenerator.pm -u -r1.139 -r1.140 --- lib/WeBWorK/ContentGenerator.pm +++ lib/WeBWorK/ContentGenerator.pm @@ -1671,17 +1671,8 @@ my %headers = $r->headers_in; join("", map { CGI::Tr(CGI::td(CGI::small($_)), CGI::td(CGI::small($headers{$_}))) } keys %headers); }; - # dereference details, - # if it is a long report pass details by reference rather than by value - my @expandedDetails; - if (ref($details) =~ /SCALAR/i) { - push @expandedDetails, ${$details}; - } elsif (ref($details) =~/ARRAY/i) { - push @expandedDetails, @{ $details }; - } else { - push @expandedDetails, $details; - } - return join("", + + return CGI::h2("WeBWorK Error"), CGI::p(<<EOF), WeBWorK has encountered a software error while attempting to process this @@ -1692,7 +1683,7 @@ CGI::h3("Error messages"), CGI::p(CGI::code($error)), CGI::h3("Error details"), - CGI::code(CGI::p(@expandedDetails)), + CGI::code(CGI::p($details)), CGI::h3("Request information"), CGI::table({border=>"1"}, CGI::Tr(CGI::td("Time"), CGI::td($time)), @@ -1701,8 +1692,7 @@ CGI::Tr(CGI::td("HTTP Headers"), CGI::td( CGI::table($headers), )), - ), - ); + ); } =item warningOutput($warnings) |
From: Mike G. v. a. <we...@ma...> - 2005-07-29 21:25:33
|
Log Message: ----------- When print error output errorOutput($error, $details) allow $details to be a reference to a string or a reference to an array. This may not make much difference when the details are short, but it can make a very large difference if the details are long. Modified Files: -------------- webwork-modperl/lib/WeBWorK: ContentGenerator.pm Revision Data ------------- Index: ContentGenerator.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator.pm,v retrieving revision 1.138 retrieving revision 1.139 diff -Llib/WeBWorK/ContentGenerator.pm -Llib/WeBWorK/ContentGenerator.pm -u -r1.138 -r1.139 --- lib/WeBWorK/ContentGenerator.pm +++ lib/WeBWorK/ContentGenerator.pm @@ -1671,8 +1671,17 @@ my %headers = $r->headers_in; join("", map { CGI::Tr(CGI::td(CGI::small($_)), CGI::td(CGI::small($headers{$_}))) } keys %headers); }; - - return + # dereference details, + # if it is a long report pass details by reference rather than by value + my @expandedDetails; + if (ref($details) =~ /SCALAR/i) { + push @expandedDetails, ${$details}; + } elsif (ref($details) =~/ARRAY/i) { + push @expandedDetails, @{ $details }; + } else { + push @expandedDetails, $details; + } + return join("", CGI::h2("WeBWorK Error"), CGI::p(<<EOF), WeBWorK has encountered a software error while attempting to process this @@ -1683,7 +1692,7 @@ CGI::h3("Error messages"), CGI::p(CGI::code($error)), CGI::h3("Error details"), - CGI::p(CGI::code($details)), + CGI::code(CGI::p(@expandedDetails)), CGI::h3("Request information"), CGI::table({border=>"1"}, CGI::Tr(CGI::td("Time"), CGI::td($time)), @@ -1692,7 +1701,8 @@ CGI::Tr(CGI::td("HTTP Headers"), CGI::td( CGI::table($headers), )), - ); + ), + ); } =item warningOutput($warnings) |
From: Mike G. v. a. <we...@ma...> - 2005-07-29 21:23:11
|
Log Message: ----------- Make sure that the timers flush after every print . :-) Modified Files: -------------- webwork-modperl/lib/WeBWorK: Timing.pm Revision Data ------------- Index: Timing.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Timing.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -Llib/WeBWorK/Timing.pm -Llib/WeBWorK/Timing.pm -u -r1.10 -r1.11 --- lib/WeBWorK/Timing.pm +++ lib/WeBWorK/Timing.pm @@ -170,6 +170,7 @@ my ($self) = @_; if ($Enabled) { + local($|=1); #flush after each print my $fh; if ($Logfile ne "") { if (open my $tmpFH, ">>", $Logfile) { |
From: jj v. a. <we...@ma...> - 2005-07-29 20:44:05
|
Log Message: ----------- More improvements on library - advanced panel. Still a work in progress. Modified Files: -------------- webwork-modperl/lib/WeBWorK/Utils: ListingDB.pm Revision Data ------------- Index: ListingDB.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Utils/ListingDB.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -Llib/WeBWorK/Utils/ListingDB.pm -Llib/WeBWorK/Utils/ListingDB.pm -u -r1.10 -r1.11 --- lib/WeBWorK/Utils/ListingDB.pm +++ lib/WeBWorK/Utils/ListingDB.pm @@ -29,7 +29,7 @@ &createListing &updateListing &deleteListing &getAllChapters &getAllSections &searchListings &getAllListings &getSectionListings &getAllDBsubjects &getAllDBchapters &getAllDBsections &getDBTextbooks - &getDBListings + &getDBListings &countDBListings ); %EXPORT_TAGS =(); @EXPORT_OK =qw(); @@ -216,6 +216,50 @@ return @results; } + +sub countDBListings { + my $r = shift; + my $ce = $r->ce; + my $subj = $r->param('library_subjects') || ""; + my $chap = $r->param('library_chapters') || ""; + my $sec = $r->param('library_sections') || ""; + my $text = $r->param('library_textbook') || ""; + my $textchap = $r->param('library_textbook_chapter') || ""; + my $textsec = $r->param('library_textbook_section') || ""; + + my $dbh = getDB($ce); + + my $extrawhere = ''; + if($subj) { + $subj =~ s/'/\\'/g; + $extrawhere .= " AND dbsj.name=\"$subj\" "; + } + if($chap) { + $chap =~ s/'/\\'/g; + $extrawhere .= " AND dbc.name=\"$chap\" "; + } + if($sec) { + $sec =~ s/'/\\'/g; + $extrawhere .= " AND dbsc.name=\"$sec\" "; + } + if($text) { + $text =~ s/'/\\'/g; + $extrawhere .= " AND t.textbook_id=\"$text\" "; + } + + my $query = "SELECT COUNT(DISTINCT pgf.pgfile_id) from pgfile pgf, + DBsection dbsc, DBchapter dbc, DBsubject dbsj, pgfile_problem pgp, + problem p, textbook t + WHERE dbsj.DBsubject_id = dbc.DBsubject_id AND + dbc.DBchapter_id = dbsc.DBchapter_id AND + dbsc.DBsection_id = pgf.DBsection_id AND + pgf.pgfile_id = pgp.pgfile_id AND + pgp.problem_id = p.problem_id AND + p.textbook_id = t.textbook_id \n $extrawhere"; + my $pg_id_ref = $dbh->selectrow_arrayref($query); + return($pg_id_ref->[0]) +} + ############################################################################## # input expected: keywords,<keywords>,chapter,<chapter>,section,<section>,path,<path>,filename,<filename>,author,<author>,instituition,<instituition>,history,<history> sub createListing { |
From: jj v. a. <we...@ma...> - 2005-07-29 20:44:00
|
Log Message: ----------- More improvements on library - advanced panel. Still a work in progress. Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: SetMaker.pm Revision Data ------------- Index: SetMaker.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -u -r1.45 -r1.46 --- lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm +++ lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm @@ -503,6 +503,7 @@ my $self = shift; my $r = $self->r; my $ce = $r->ce; + my $right_button_style = "width: 18ex"; my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); unshift @subjs, ALL_SUBJECTS; @@ -514,7 +515,6 @@ unshift @sects, ALL_SECTIONS; my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); - #my @textarray = map { $_->[1]." by ".$_->[2] } @{$texts}; my @textarray = map { $_->[0] } @{$texts}; my %textlabels = (); for my $ta (@{$texts}) { @@ -531,9 +531,20 @@ my $text_popup = CGI::popup_menu(-name => 'library_textbook', -values =>\@textarray, -labels => \%textlabels, - -default=>$textbook_selected); + -default=>$textbook_selected, + -onchange=>"submit();return true"); + + my $library_keywords = $r->param('library_keywords') || ''; + my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); + my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); + if($count_line==0) { + $count_line = "There are no matching pg files"; + } else { + $count_line = "There are $count_line matching WeBWorK problem files"; + } + print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, CGI::hidden(-name=>"library_is_basic", -default=>[2]), CGI::start_table({-width=>"100%"}), @@ -547,7 +558,8 @@ -onchange=>"submit();return true" )]), CGI::td({-colspan=>2, -align=>"right"}, - CGI::submit(-name=>"lib_select_subject", -value=>"Update Lists"))), + CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", + -style=> $right_button_style))), CGI::Tr( CGI::td(["Chapter:", CGI::popup_menu(-name=> 'library_chapters', @@ -556,7 +568,8 @@ -onchange=>"submit();return true" )]), CGI::td({-colspan=>2, -align=>"right"}, - CGI::submit(-name=>"library_basic", -value=>"Basic Search")) + CGI::submit(-name=>"library_reset", -value=>"Reset", + -style=>$right_button_style)) ), CGI::Tr( CGI::td(["Section:", @@ -565,28 +578,22 @@ -default=> $section_selected, -onchange=>"submit();return true" )]), + CGI::td({-colspan=>2, -align=>"right"}, + CGI::submit(-name=>"library_basic", -value=>"Basic Search", + -style=>$right_button_style)) ), CGI::Tr( CGI::td(["Textbook:", $text_popup]), ), + CGI::Tr(CGI::td("Keywords:"),CGI::td({-colspan=>2}, + CGI::textfield(-name=>"library_keywords", + -default=>$library_keywords, + -override=>1, + -size=>40))), CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), + CGI::Tr(CGI::td({-colspan=>3, -align=>"center"}, $count_line)), CGI::end_table(), )); - #CGI::Tr( - # CGI::td("Textbook:"), - # CGI::td({-colspan=>2}, - # CGI::popup_menu(-name=> 'library_textbooks', - # -values=>\@textbooks, - # #-default=> $section_selected - #))), - - #CGI::Tr( - # CGI::td("Keywords:"), - # CGI::td({-colspan=>2}, - # CGI::textfield(-name=>"keywords", - # -default=>"Keywords not implemented yet", - # -override=>1, -size=>60 - #))), } |
From: Sam H. v. a. <we...@ma...> - 2005-07-29 19:41:54
|
Log Message: ----------- Fix use of $SIG{__WARN__} and $SIG{__DIE__}. * Each change to $SIG{__WARN__} and $SIG{__DIE__} is now dynamically scoped with "local", rather than changing globally and then restoring at the end of the block. * The special value "DEFAULT" is used instead of sub {CORE::die(@_)} or sub {CORE::warn(@_)} when preparing to eval STRING code. * Where $SIG{__WARN__} and $SIG{__DIE__} are overridden to do preprocessing with PG_errorMessage, the previously installed handlers will be called instead of the built-in warn or die functions after preprocessing occurs. (For example, the warn and die handlers defined in Apache::WeBWorK or the warn handler defined in WeBWorK::PG will be called.) * The behavior in process_answers is modified so that the custom handlers are installed once before the answer evaluation loop. This causes them to be in effect during the setup/teardown code, but I don't think this will be a problem. Modified Files: -------------- pg/lib/WeBWorK/PG: Translator.pm Revision Data ------------- Index: Translator.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/WeBWorK/PG/Translator.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/WeBWorK/PG/Translator.pm -Llib/WeBWorK/PG/Translator.pm -u -r1.13 -r1.14 --- lib/WeBWorK/PG/Translator.pm +++ lib/WeBWorK/PG/Translator.pm @@ -793,16 +793,26 @@ $self ->{errors} .= qq{ERROR: This problem file was empty!\n} unless ($evalString) ; $self ->{errors} .= qq{ERROR: You must define the environment before translating.} unless defined( $self->{envir} ); - # reset the error detection - $SIG{__WARN__} = sub {CORE::warn(@_) } unless ref($SIG{__WARN__}) =~/CODE/; - my $save_SIG_warn_trap = $SIG{__WARN__}; - #FIXME -- this may not work with the xmlrpc access - # this formats the error message within the existing warn message. - $SIG{__WARN__} = sub {&$save_SIG_warn_trap(PG_errorMessage('message',@_))}; - #$SIG{__WARN__} = sub {CORE::warn(PG_errorMessage('message',@_))}; - my $save_SIG_die_trap = $SIG{__DIE__}; - $SIG{__DIE__} = sub {CORE::die(PG_errorMessage('traceback',@_))}; - + + # install handlers for warn and die that call PG_errorMessage. + # if the existing signal handler is not a coderef, the built-in warn or + # die function is called. this does not account for the case where the + # handler is set to "IGNORE" or to the name of a function. in these cases + # the built-in function will be called. + + my $outer_sig_warn = $SIG{__WARN__}; + local $SIG{__WARN__} = sub { + ref $outer_sig_warn eq "CODE" + ? &$outer_sig_warn(PG_errorMessage('message', $_[0])) + : warn PG_errorMessage('message', $_[0]); + }; + + my $outer_sig_die = $SIG{__DIE__}; + local $SIG{__DIE__} = sub { + ref $outer_sig_die eq "CODE" + ? &$outer_sig_die(PG_errorMessage('traceback', $_[0])) + : die PG_errorMessage('traceback', $_[0]); + }; =pod @@ -990,8 +1000,6 @@ $self ->{ PG_HEADER_TEXT_REF } = $PG_HEADER_TEXT_REF; $self ->{ rh_correct_answers } = $PG_ANSWER_HASH_REF; $self ->{ PG_FLAGS_REF } = $PG_FLAGS_REF; - $SIG{__DIE__} = $save_SIG_die_trap; - $SIG{__WARN__} = $save_SIG_warn_trap; $self ->{errors}; } # end translate @@ -1068,8 +1076,48 @@ my @answer_entry_order = ( defined($self->{PG_FLAGS_REF}->{ANSWER_ENTRY_ORDER}) ) ? @{$self->{PG_FLAGS_REF}->{ANSWER_ENTRY_ORDER}} : keys %{$rh_correct_answers}; + # define custom warn/die handlers for answer evaluation. these used to be inside + # the foreach loop around the conditional involving $rf_fun, but for efficiency + # we've moved it out here. This means that the handlers will be active during the + # code before and after the actual answer evaluation. + + my $outer_sig_warn = $SIG{__WARN__}; + local $SIG{__WARN__} = sub { + ref $outer_sig_warn eq "CODE" + ? &$outer_sig_warn(PG_errorMessage('message', $_[0])) + : warn PG_errorMessage('message', $_[0]); + }; + + # the die handler is a closure over %errorTable and $outer_sig_die. + # + # %errorTable accumulates a "full" error message for each error that occurs during + # answer evaluation. then, right after the evaluation (which is done within a call + # to Safe::reval), $@ is checked and it's value is looked up in %errorTable to get + # the full error to report. + # + # my question: why is this a hash? this is die, so once one occurs, we exit the reval. + # wouldn't it be sufficient to have a scalar like $backtrace_for_last_error? + # + # Note that %errorTable is cleared for each answer. + my %errorTable; + my $outer_sig_die = $SIG{__DIE__}; + local $SIG{__DIE__} = sub { + + # this chunk taken from dpvc's original handler + my $fullerror = PG_errorMessage('traceback', @_); + my ($error,$traceback) = split /\n/, $fullerror, 2; + $fullerror =~ s/\n /<BR> /g; $fullerror =~ s/\n/<BR>/g; + $error .= "\n"; + $errorTable{$error} = $fullerror; + # end of dpvc's original code + + ref $outer_sig_die eq "CODE" + ? &$outer_sig_die($error) + : die $error; + }; + # apply each instructors answer to the corresponding student answer - + foreach my $ans_name ( @answer_entry_order ) { my ($ans, $errors) = $self->filter_answer( $h_student_answers{$ans_name} ); no strict; @@ -1085,29 +1133,9 @@ # in case the answer evaluator forgets to check $self->{safe}->share('$rf_fun','$temp_ans'); - local %errorTable; - $SIG{__DIE__} = sub { - # - # Get full traceback, but save it in local variable so that - # we can add it later. This is because some evaluators use - # eval to trap errors and then report them in the message - # column of the results table, and we don't want to include - # the traceback there. - # - my $fullerror = PG_errorMessage('traceback',@_); - my ($error,$traceback) = split /\n/, $fullerror, 2; - $fullerror =~ s/\n /<BR> /g; $fullerror =~ s/\n/<BR>/g; - $error .= "\n"; - $errorTable{$error} = $fullerror; - CORE::die($error); - }; - # reset the error detection - my $save_SIG_warn_trap = $SIG{__WARN__}; - $save_SIG_warn_trap = sub {CORE::warn @_} unless ref($save_SIG_warn_trap) =~/CODE/; - $SIG{__WARN__} = sub {&$save_SIG_warn_trap(PG_errorMessage('message',@_))}; - - my $save_SIG_die_trap = $SIG{__DIE__}; - + # clear %errorTable for each problem + %errorTable = (); + my $rh_ans_evaluation_result; if (ref($rf_fun) eq 'CODE' ) { $rh_ans_evaluation_result = $self->{safe} ->reval( '&{ $rf_fun }($temp_ans)' ) ; @@ -1125,10 +1153,6 @@ warn "Error in Translator.pm::process_answers: Answer $ans_name:<BR>\n Unrecognized evaluator type |", ref($rf_fun), "|"; } - $SIG{__DIE__} = $save_SIG_die_trap; - $SIG{__WARN__} = $save_SIG_warn_trap; - - use strict; unless ( ( ref($rh_ans_evaluation_result) eq 'HASH') or ( ref($rh_ans_evaluation_result) eq 'AnswerHash') ) { warn "Error in Translator.pm::process_answers: Answer $ans_name:<BR>\n @@ -1495,10 +1519,10 @@ sub PG_restricted_eval { my $string = shift; my ($pck,$file,$line) = caller; - my $save_SIG_warn_trap = $SIG{__WARN__}; - $SIG{__WARN__} = sub { CORE::die @_}; - my $save_SIG_die_trap = $SIG{__DIE__}; - $SIG{__DIE__}= sub {CORE::die @_}; + + local $SIG{__WARN__} = "DEFAULT"; + local $SIG{__DIE__} = "DEFAULT"; + no strict; my $out = eval ("package main; " . $string ); my $errors = $@; @@ -1509,18 +1533,17 @@ # . $errors . # "The calling package is $pck\n" if defined($errors) && $errors =~/\S/; use strict; - $SIG{__DIE__} = $save_SIG_die_trap; - $SIG{__WARN__} = $save_SIG_warn_trap; + return (wantarray) ? ($out, $errors,$full_error_report) : $out; } sub PG_macro_file_eval { # would like to modify this so that it requires use strict on the files that it evaluates. my $string = shift; my ($pck,$file,$line) = caller; - my $save_SIG_warn_trap = $SIG{__WARN__}; - $SIG{__WARN__} = sub { CORE::die @_}; - my $save_SIG_die_trap = $SIG{__DIE__}; - $SIG{__DIE__}= sub {CORE::die @_}; + + local $SIG{__WARN__} = "DEFAULT"; + local $SIG{__DIE__} = "DEFAULT"; + no strict; my $out = eval ("package main; be_strict();" . $string ); my $errors =$@; @@ -1528,8 +1551,7 @@ . $errors . "The calling package is $pck\n" if defined($errors) && $errors =~/\S/; use strict; - $SIG{__DIE__} = $save_SIG_die_trap; - $SIG{__WARN__} = $save_SIG_warn_trap; + return (wantarray) ? ($out, $errors,$full_error_report) : $out; } =head2 PG_answer_eval @@ -1563,13 +1585,10 @@ # This is pretty tricky and doesn't always work right. # We seem to need PG_priv instead of main when PG_answer_eval is called within a completion # 'package PG_priv; ' - my $save_SIG_warn_trap = $SIG{__WARN__}; - $SIG{__WARN__} = sub { CORE::die @_}; - my $save_SIG_die_trap = $SIG{__DIE__}; - $SIG{__DIE__}= sub {CORE::die @_}; - my $save_SIG_FPE_trap= $SIG{'FPE'}; - #$SIG{'FPE'} = \&main::PG_floating_point_exception_handler; - #$SIG{'FPE'} = sub {exit(0)}; + + local $SIG{__WARN__} = "DEFAULT"; + local $SIG{__DIE__} = "DEFAULT"; + no strict; my $out = eval('package main;'.$string); $out = '' unless defined($out); @@ -1578,9 +1597,7 @@ $errors The calling package is $pck\n" if defined($errors) && $errors =~/\S/; use strict; - $SIG{__DIE__} = $save_SIG_die_trap; - $SIG{__WARN__} = $save_SIG_warn_trap; - $SIG{'FPE'} = $save_SIG_FPE_trap if defined $save_SIG_FPE_trap; + return (wantarray) ? ($out, $errors,$full_error_report) : $out; |
From: jj v. a. <we...@ma...> - 2005-07-28 21:23:31
|
Log Message: ----------- Fixed minor glitch from problems not associated to any textbook. Modified Files: -------------- webwork-modperl/lib/WeBWorK/Utils: ListingDB.pm Revision Data ------------- Index: ListingDB.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Utils/ListingDB.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -Llib/WeBWorK/Utils/ListingDB.pm -Llib/WeBWorK/Utils/ListingDB.pm -u -r1.9 -r1.10 --- lib/WeBWorK/Utils/ListingDB.pm +++ lib/WeBWorK/Utils/ListingDB.pm @@ -85,7 +85,7 @@ $chapstring $subjstring $sectstring "; my $text_ref = $dbh->selectall_arrayref($query); my @texts = @{$text_ref}; - #@texts = grep { $_->[1] =~ /\S/ } @texts; + @texts = grep { $_->[1] =~ /\S/ } @texts; return(\@texts); } |
From: jj v. a. <we...@ma...> - 2005-07-28 21:11:38
|
Log Message: ----------- Added advanced search panel for database library. Still more features to come. Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: SetMaker.pm webwork-modperl/lib/WeBWorK/Utils: ListingDB.pm Revision Data ------------- Index: SetMaker.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v retrieving revision 1.44 retrieving revision 1.45 diff -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -u -r1.44 -r1.45 --- lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm +++ lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm @@ -42,6 +42,10 @@ use constant MY_PROBLEMS => ' My Problems '; use constant MAIN_PROBLEMS => ' Main Problems '; use constant CREATE_SET_BUTTON => 'Create New Set'; +use constant ALL_CHAPTERS => 'All Chapters'; +use constant ALL_SUBJECTS => 'All Subjects'; +use constant ALL_SECTIONS => 'All Sections'; +use constant ALL_TEXTBOOKS => 'All Textbooks'; ## Flags for operations on files @@ -351,17 +355,16 @@ } ##### Version 3 is the problem library +# +# This comes in 3 forms, problem library version 1, and for version 2 there +# is the basic, and the advanced interfaces. This function checks what we are +# supposed to do, or aborts if the problem library has not been installed. - -# There a different levels, and you can pick a new chapter, -# pick a new section, pick all from chapter, pick all from section -# -# Incoming data - current chapter, current section sub browse_library_panel { my $self=shift; my $r = $self->r; my $ce = $r->ce; - + # See if the problem library is installed my $libraryRoot = $r->{ce}->{problemLibrary}->{root}; @@ -384,13 +387,13 @@ } } - # Now check what version we are supposed to use my $libraryVersion = $r->{ce}->{problemLibrary}->{version} || 1; if($libraryVersion == 1) { return $self->browse_library_panel1; } elsif($libraryVersion == 2) { - return $self->browse_library_panel2; + return $self->browse_library_panel2 if($self->{library_basic}==1); + return $self->browse_library_panel2adv; } else { print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, "The problem library version is set to an illegal value."))); @@ -403,22 +406,17 @@ my $r = $self->r; my $ce = $r->ce; - my $default_chap = "All Chapters"; - my $default_sect = "All Sections"; - my @chaps = WeBWorK::Utils::ListingDB::getAllChapters($r->{ce}); - unshift @chaps, $default_chap; - my $chapter_selected = $r->param('library_chapters') || $default_chap; + unshift @chaps, ALL_CHAPTERS; + my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; my @sects=(); - if ($chapter_selected ne $default_chap) { + if ($chapter_selected ne ALL_CHAPTERS) { @sects = WeBWorK::Utils::ListingDB::getAllSections($r->{ce}, $chapter_selected); } - my @textbooks = ('Textbook info not ready'); - - unshift @sects, $default_sect; - my $section_selected = $r->param('library_sections') || $default_sect; + unshift @sects, ALL_SECTIONS; + my $section_selected = $r->param('library_sections') || ALL_SECTIONS; my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, @@ -439,21 +437,6 @@ -default=> $section_selected ))), - #CGI::Tr( - # CGI::td("Textbook:"), - # CGI::td({-colspan=>2}, - # CGI::popup_menu(-name=> 'library_textbooks', - # -values=>\@textbooks, - # #-default=> $section_selected - #))), - - #CGI::Tr( - # CGI::td("Keywords:"), - # CGI::td({-colspan=>2}, - # CGI::textfield(-name=>"keywords", - # -default=>"Keywords not implemented yet", - # -override=>1, -size=>60 - #))), CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), CGI::end_table(), )); @@ -464,54 +447,146 @@ my $r = $self->r; my $ce = $r->ce; - my $default_subj = "All Subjects"; - my $default_chap = "All Chapters"; - my $default_sect = "All Sections"; - - my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($ce); - unshift @subjs, $default_subj; - my $subject_selected = $r->param('library_subjects') || $default_subj; - - my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($ce, $subject_selected); - unshift @chaps, $default_chap; - my $chapter_selected = $r->param('library_chapters') || $default_chap; + my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); + unshift @subjs, ALL_SUBJECTS; + + my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); + unshift @chaps, ALL_CHAPTERS; my @sects=(); - if ($chapter_selected ne $default_chap) { - @sects = WeBWorK::Utils::ListingDB::getAllDBsections($ce, $chapter_selected); - } - unshift @sects, $default_sect; - my $section_selected = $r->param('library_sections') || $default_sect; + @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); + unshift @sects, ALL_SECTIONS; + + my $subject_selected = $r->param('library_subjects') || ALL_SUBJECTS; + my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; + my $section_selected = $r->param('library_sections') || ALL_SECTIONS; + my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, - CGI::start_table(), + CGI::hidden(-name=>"library_is_basic", -default=>[1]), + CGI::start_table({-width=>"100%"}), CGI::Tr( CGI::td(["Subject:", CGI::popup_menu(-name=> 'library_subjects', -values=>\@subjs, -default=> $subject_selected, -onchange=>"submit();return true" - ), - CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")])), + )]), + CGI::td({-colspan=>2, -align=>"right"}, + CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")) + ), CGI::Tr( CGI::td(["Chapter:", CGI::popup_menu(-name=> 'library_chapters', -values=>\@chaps, -default=> $chapter_selected, -onchange=>"submit();return true" - )])), + )]), + CGI::td({-colspan=>2, -align=>"right"}, + CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")) + ), CGI::Tr( - CGI::td("Section:"), - CGI::td({-colspan=>2}, + CGI::td(["Section:", CGI::popup_menu(-name=> 'library_sections', -values=>\@sects, -default=> $section_selected - ))), + )]), + ), CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), CGI::end_table(), )); + +} + +sub browse_library_panel2adv { + my $self = shift; + my $r = $self->r; + my $ce = $r->ce; + my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); + unshift @subjs, ALL_SUBJECTS; + + my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); + unshift @chaps, ALL_CHAPTERS; + + my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); + unshift @sects, ALL_SECTIONS; + + my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); + #my @textarray = map { $_->[1]." by ".$_->[2] } @{$texts}; + my @textarray = map { $_->[0] } @{$texts}; + my %textlabels = (); + for my $ta (@{$texts}) { + $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")"; + } + unshift @textarray, ALL_TEXTBOOKS; + my $atb = ALL_TEXTBOOKS; $textlabels{$atb} = ALL_TEXTBOOKS; + + my $section_selected = $r->param('library_sections') || ALL_SECTIONS; + my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; + my $subject_selected = $r->param('library_subjects') || ALL_SUBJECTS; + my $textbook_selected = $r->param('library_textbook') || ALL_TEXTBOOKS; + + my $text_popup = CGI::popup_menu(-name => 'library_textbook', + -values =>\@textarray, + -labels => \%textlabels, + -default=>$textbook_selected); + my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); + + print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, + CGI::hidden(-name=>"library_is_basic", -default=>[2]), + CGI::start_table({-width=>"100%"}), + # Html done by hand since it is temporary + CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')), + CGI::Tr( + CGI::td(["Subject:", + CGI::popup_menu(-name=> 'library_subjects', + -values=>\@subjs, + -default=> $subject_selected, + -onchange=>"submit();return true" + )]), + CGI::td({-colspan=>2, -align=>"right"}, + CGI::submit(-name=>"lib_select_subject", -value=>"Update Lists"))), + CGI::Tr( + CGI::td(["Chapter:", + CGI::popup_menu(-name=> 'library_chapters', + -values=>\@chaps, + -default=> $chapter_selected, + -onchange=>"submit();return true" + )]), + CGI::td({-colspan=>2, -align=>"right"}, + CGI::submit(-name=>"library_basic", -value=>"Basic Search")) + ), + CGI::Tr( + CGI::td(["Section:", + CGI::popup_menu(-name=> 'library_sections', + -values=>\@sects, + -default=> $section_selected, + -onchange=>"submit();return true" + )]), + ), + CGI::Tr( + CGI::td(["Textbook:", $text_popup]), + ), + CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), + CGI::end_table(), + )); + #CGI::Tr( + # CGI::td("Textbook:"), + # CGI::td({-colspan=>2}, + # CGI::popup_menu(-name=> 'library_textbooks', + # -values=>\@textbooks, + # #-default=> $section_selected + #))), + + #CGI::Tr( + # CGI::td("Keywords:"), + # CGI::td({-colspan=>2}, + # CGI::textfield(-name=>"keywords", + # -default=>"Keywords not implemented yet", + # -override=>1, -size=>60 + #))), } @@ -721,6 +796,13 @@ my $db = $r->db; my $maxShown = $r->param('max_shown') || MAX_SHOW_DEFAULT; $maxShown = 10000000 if($maxShown eq 'All'); # let's hope there aren't more + my $library_basic = $r->param('library_is_basic') || 1; + + ## Fix some parameters + $r->param('library_subjects', '') if($r->param('library_subjects') eq ALL_SUBJECTS); + $r->param('library_chapters', '') if($r->param('library_chapters') eq ALL_CHAPTERS); + $r->param('library_sections', '') if($r->param('library_sections') eq ALL_SECTIONS); + $r->param('library_textbook', '') if($r->param('library_textbook') eq ALL_TEXTBOOKS); ## These directories will have individual buttons %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs}; @@ -864,13 +946,12 @@ $use_previous_problems=0; } - ##### View whole chapter from the library - ## This will change somewhat later + ##### View from the library database } elsif ($r->param('lib_view')) { @pg_files=(); - my @dbsearch = WeBWorK::Utils::ListingDB::getSectionListings($r, subject_default => 'All Subjects', chapter_default => 'All Chapters', section_default=>'All Sections'); + my @dbsearch = WeBWorK::Utils::ListingDB::getSectionListings($r); my ($result, $tolibpath); for $result (@dbsearch) { $tolibpath = "Library/$result->{path}/$result->{filename}"; @@ -997,6 +1078,10 @@ } elsif ($r->param('select_all')) { @past_marks = map {1} @past_marks; + } elsif ($r->param('library_basic')) { + $library_basic = 1; + } elsif ($r->param('library_advanced')) { + $library_basic = 2; } elsif ($r->param('select_none')) { @past_marks = (); @@ -1030,7 +1115,7 @@ $self->{pg_files} = \@pg_files; $self->{past_marks} = \@past_marks; $self->{all_db_sets} = \@all_db_sets; - + $self->{library_basic} = $library_basic; } Index: ListingDB.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Utils/ListingDB.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/WeBWorK/Utils/ListingDB.pm -Llib/WeBWorK/Utils/ListingDB.pm -u -r1.8 -r1.9 --- lib/WeBWorK/Utils/ListingDB.pm +++ lib/WeBWorK/Utils/ListingDB.pm @@ -28,8 +28,8 @@ @EXPORT =qw( &createListing &updateListing &deleteListing &getAllChapters &getAllSections &searchListings &getAllListings &getSectionListings - &getAllDBsubjects &getAllDBchapters &getAllDBsections - &getDBsectionListings + &getAllDBsubjects &getAllDBchapters &getAllDBsections &getDBTextbooks + &getDBListings ); %EXPORT_TAGS =(); @EXPORT_OK =qw(); @@ -46,151 +46,172 @@ return($dbh); } -=item getAllDBsubjects($ce) +=item getDBTextbooks($r) +Returns an array of Textbook names consistent with the subject, chapter, +section selected + +$r is a Apache request object so we can extract whatever parameters we want + +=cut + +sub getDBTextbooks { + my $r = shift; + my $dbh = getDB($r->ce); + # there aren't many, so first get a list of all texts, and then remove + # the ones which aren't ok + my ($sectstring, $chapstring, $subjstring) = ('','',''); + my $subj = $r->param('library_subjects') || ""; + my $chap = $r->param('library_chapters') || ""; + my $sec = $r->param('library_sections') || ""; + if($subj) { + $subj =~ s/'/\\'/g; + $subjstring = " AND t.name = \'$subj\'\n"; + } + if($chap) { + $chap =~ s/'/\\'/g; + $chapstring = " AND c.name = \'$chap\' AND c.DBsubject_id=t.DBsubject_id\n"; + } + if($sec) { + $sec =~ s/'/\\'/g; + $sectstring = " AND s.name = \'$sec\' AND s.DBchapter_id = c.DBchapter_id AND s.DBsection_id=pgf.DBsection_id"; + } + my $query = "SELECT DISTINCT tbk.textbook_id,tbk.title,tbk.author, + tbk.edition + FROM textbook tbk, problem p, pgfile_problem pg, pgfile pgf, + DBsection s, DBchapter c, DBsubject t + WHERE tbk.textbook_id=p.textbook_id AND p.problem_id=pg.problem_id AND + s.DBchapter_id=c.DBchapter_id AND c.DBsubject_id=t.DBsubject_id + AND pgf.DBsection_id=s.DBsection_id AND pgf.pgfile_id=pg.pgfile_id + $chapstring $subjstring $sectstring "; + my $text_ref = $dbh->selectall_arrayref($query); + my @texts = @{$text_ref}; + #@texts = grep { $_->[1] =~ /\S/ } @texts; + return(\@texts); +} + +=item getAllDBsubjects($r) Returns an array of DBsubject names -$ce is a WeBWorK::CourseEnvironment object that describes the problem library. +$r is the Apache request object =cut sub getAllDBsubjects { - my $ce = shift; + my $r = shift; my @results=(); - my ($row,$listing); + my $row; my $query = "SELECT DISTINCT name FROM DBsubject"; - my $dbh = getDB($ce); + my $dbh = getDB($r->ce); my $sth = $dbh->prepare($query); $sth->execute(); - while (1) { - $row = $sth->fetchrow_array; - last if (!defined($row)); - my $listing = $row; - push @results, $listing; + while ($row = $sth->fetchrow_array()) { + push @results, $row; } return @results; } -=item getAllDBchapters($ce) +=item getAllDBchapters($r) Returns an array of DBchapter names -$ce is a WeBWorK::CourseEnvironment object that describes the problem library. +$r is the Apache request object =cut sub getAllDBchapters { - my $ce = shift; - my $subject = shift; - my @results=(); - my ($row,$listing); - my $where = ""; - my $dbh = getDB($ce); - if($subject) { - my $subject_id = ""; - my $query = "SELECT DBsubject_id FROM DBsubject WHERE name = \"$subject\""; - my $subject_id = $dbh->selectrow_array($query); - $where = " WHERE DBsubject_id=\"$subject_id\" "; - } - my $query = "SELECT DISTINCT name FROM DBchapter $where "; - my $sth = $dbh->prepare($query); - $sth->execute(); - while (1) { - $row = $sth->fetchrow_array; - last if (!defined($row)); - my $listing = $row; - push @results, $listing; - } + my $r = shift; + my $subject = $r->param('library_subjects'); + return () unless($subject); + my $dbh = getDB($r->ce); + my $query = "SELECT DISTINCT c.name FROM DBchapter c, DBsubject t + WHERE c.DBsubject_id = t.DBsubject_id AND + t.name = \"$subject\""; + my $all_chaps_ref = $dbh->selectall_arrayref($query); + my @results = map { $_->[0] } @{$all_chaps_ref}; return @results; } -=item getAllDBsections($ce,$chapter) +=item getAllDBsections($r) Returns an array of DBsection names -$ce is a WeBWorK::CourseEnvironment object that describes the problem library. -$chapter is an DBchapter name - +$r is the Apache request object + =cut sub getAllDBsections { - my $ce = shift; - my $chapter = shift; - # $chapter = '"'.$chapter.'"'; # \'$chapter\' or \"$chapter\" does not work in $query anymore! wth? - my @results=(); - my ($row,$listing); - my $dbh = getDB($ce); - my $query = "SELECT DBchapter_id FROM DBchapter - WHERE name = \"$chapter\" "; - my $chapter_id = $dbh->selectrow_array($query); - die "ERROR - no such chapter: $chapter\n" unless(defined $chapter_id); - $query = "SELECT DISTINCT name FROM DBsection - WHERE DBchapter_id = $chapter_id"; - my $sth = $dbh->prepare($query); - $sth->execute(); - while (1) - { - $row = $sth->fetchrow_array; - last if (!defined($row)); - my $listing = $row; - push @results, $listing; - } + my $r = shift; + my $subject = $r->param('library_subjects'); + return () unless($subject); + my $chapter = $r->param('library_chapters'); + return () unless($chapter); + my $dbh = getDB($r->ce); + my $query = "SELECT DISTINCT s.name FROM DBsection, DBsection s, + DBchapter c, DBsubject t + WHERE s.DBchapter_id = c.DBchapter_id AND + c.DBsubject_id = t.DBsubject_id AND + t.name = \"$subject\" AND c.name = \"$chapter\""; + my $all_sections_ref = $dbh->selectall_arrayref($query); + my @results = map { $_->[0] } @{$all_sections_ref}; return @results; } -=item getDBSectionListings($ce, $chapter, $section) +=item getDBSectionListings($r) Returns an array of hash references with the keys: path, filename. -$ce is a WeBWorK::CourseEnvironment object that describes the problem library. -$chapter is an DBchapter name -$section is a DBsection name +$r is an Apache request object that has all needed data inside of it + +Here, we search on all known fields out of r =cut -sub getDBsectionListings { - - my $ce = shift; - my $subj = shift; - my $chap = shift; - my $sec = shift; +sub getDBListings { + my $r = shift; + my $ce = $r->ce; + my $subj = $r->param('library_subjects') || ""; + my $chap = $r->param('library_chapters') || ""; + my $sec = $r->param('library_sections') || ""; + my $text = $r->param('library_textbook') || ""; + my $textchap = $r->param('library_textbook_chapter') || ""; + my $textsec = $r->param('library_textbook_section') || ""; my $dbh = getDB($ce); - my $subjstring = ''; + my $extrawhere = ''; if($subj) { $subj =~ s/'/\\'/g; - $subjstring = " AND t.name=\"$subj\" "; + $extrawhere .= " AND dbsj.name=\"$subj\" "; } - my $chapstring = ''; if($chap) { $chap =~ s/'/\\'/g; - $chapstring = " AND c.name=\"$chap\" "; + $extrawhere .= " AND dbc.name=\"$chap\" "; } - my $secstring = ''; if($sec) { $sec =~ s/'/\\'/g; - $secstring = " AND s.name=\"$sec\" "; + $extrawhere .= " AND dbsc.name=\"$sec\" "; } - - my $query = "SELECT DBsection_id - FROM DBsection s, DBchapter c, DBsubject t - WHERE t.DBsubject_id = c.DBsubject_id - and s.DBchapter_id = c.DBchapter_id - $subjstring $chapstring $secstring"; - my $section_id_ref = $dbh->selectall_arrayref($query); - die "getDBSectionListings - no such section: $chap $sec\n" unless(defined $section_id_ref); - my @section_ids = @{$section_id_ref}; - @section_ids = map { "DBsection_id = ". $_->[0] } @section_ids; - my @results; #returned - $query = "SELECT path_id, filename - FROM pgfile WHERE ". join(" OR ", @section_ids); - my $sth = $dbh->prepare($query); - - $sth->execute(); - while (1){ - my ($path_id, $pgfile) = $sth->fetchrow_array(); - last if (!defined($pgfile)); - my $path = $dbh->selectrow_array("SELECT path FROM path - WHERE path_id = $path_id"); - push @results, {"path" => $path, "filename" => $pgfile}; + if($text) { + $text =~ s/'/\\'/g; + $extrawhere .= " AND t.textbook_id=\"$text\" "; + } + + my $query = "SELECT DISTINCT pgf.pgfile_id from pgfile pgf, + DBsection dbsc, DBchapter dbc, DBsubject dbsj, pgfile_problem pgp, + problem p, textbook t + WHERE dbsj.DBsubject_id = dbc.DBsubject_id AND + dbc.DBchapter_id = dbsc.DBchapter_id AND + dbsc.DBsection_id = pgf.DBsection_id AND + pgf.pgfile_id = pgp.pgfile_id AND + pgp.problem_id = p.problem_id AND + p.textbook_id = t.textbook_id \n $extrawhere"; + my $pg_id_ref = $dbh->selectall_arrayref($query); + my @pg_ids = map { $_->[0] } @{$pg_id_ref}; + my @results=(); + for my $pgid (@pg_ids) { + $query = "SELECT path, filename FROM pgfile pgf, path p + WHERE p.path_id = pgf.path_id AND pgf.pgfile_id=\"$pgid\""; + my $row = $dbh->selectrow_arrayref($query); + push @results, {'path' => $row->[0], 'filename' => $row->[1] }; + } return @results; } @@ -368,16 +389,12 @@ sub getSectionListings { #print STDERR "ListingDB::getSectionListings(chapter,section)\n"; my $r = shift; - my %defaults = @_; my $ce = $r->ce; + my $version = $ce->{problemLibrary}->{version} || 1; + if($version == 2) { return(getDBListings($r))} my $subj = $r->param('library_subjects') || ""; my $chap = $r->param('library_chapters') || ""; my $sec = $r->param('library_sections') || ""; - $subj = '' if ($subj eq $defaults{subject_default}); - $chap = '' if ($chap eq $defaults{chapter_default}); - $sec = '' if ($sec eq $defaults{section_default}); - my $version = $ce->{problemLibrary}->{version} || 1; - if($version == 2) { return(getDBsectionListings($ce, $subj, $chap, $sec))} my $chapstring = ''; if($chap) { |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:48:43
|
Log Message: ----------- Adding final problems for modelCourse Added Files: ----------- webwork2/courses/modelCourse/templates/set0: paperHeaderFile0.pg prob1.pg prob1a.pg prob1b.pg prob1c.pg prob2.pg prob3.pg prob5.pg screenHeaderFile0.pg webwork2/courses/modelCourse/templates/set0/prob4: 1-55141.gif 1-65474.gif 1-75352.gif 1-79226.gif 2-11287.gif 2-63428.gif 2-68382.gif 2-96187.gif 3-18387.gif 3-44144.gif 3-55459.gif 3-69221.gif prob4.pg webwork2/courses/modelCourse/templates/setDemo: calc.html Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/set0/prob1b.pg @@ -0,0 +1,106 @@ +##DESCRIPTION +## help for leaning precedence +##ENDDESCRIPTION + +##KEYWORDS('functions') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + + +BEGIN_TEXT +This problem will help you learn the rules of precedence, i.e. the order in which +mathematical operations are performed. You can use parentheses (and also square brackets +[ ] and/or curly braces $LB $RB) if you want to change the normal way operations work.$PAR + +So first let us review the normal way operations are performed.$PAR + +The rules are simple. Exponentiation is always done before multiplication +and division and multiplication and division are always done before addition +and subtraction. (Mathematically we say exponentiation takes precedence over +multiplication and division, etc.). For example what is 1+2*3? $BR +\{ ans_rule(25) \} +END_TEXT + +$ans = 7; +ANS(std_num_cmp($ans)); + + +BEGIN_TEXT +$BR and what is \( 2\cdot 3^2 \)? $BR +\{ ans_rule(25) \} +END_TEXT + +$ans = 2*3**2; +ANS(std_num_cmp($ans)); + +BEGIN_TEXT + +$BR +Now sometime you want to force things to be done in a different way. This is +what parentheses are used for. The rule is: whatever is enclosed in +parentheses is done before anything else (and things in the inner most +parentheses are done first). + +For example how do you enter \[ \frac {1+\sin(3)}{2+\tan(4)}\quad ? \] Hint: this is a good place to use +[ ]'s and also to use the ${LQ}Preview${RQ} button. $BR +\{ ans_rule(25) \} +END_TEXT + +$ans = (1+sin(3))/(2+tan(4)) ; +ANS(std_num_cmp($ans)); + +BEGIN_TEXT +$BR +Here are some more examples: + +(1+3)9 =36, (2*3)**2 = 6**2 = 36, 3**(2*2) = 3**4 = 81, (2+3)**2 = 5**2 = 25, 3**(2+2) = 3**4 = 81 + +$BR +(Here we have used ** to denote exponentiation and you can also use this instead of a ${LQ}caret${RQ} if you want). Try entering some of these and use the "Preview" button to see the result. The "correct" +result for this answer blank is 36, but by using the ${LQ}Preview${RQ} button, you can enter whatever +you want and use WeBWorK as a hand calculator.$BR +\{ ans_rule(25) \} + +END_TEXT + +$ans =36; + +ANS(std_num_cmp($ans)); + +BEGIN_TEXT +$BR + +There is one other thing to be careful of. Multiplication and division have the +same precedence and there are no universal rules as to which should be done first. +For example, what does 2/3*4 mean? (Note that / is the "division symbol", which +is usually written as a line with two dots, but unfortunately, this "line with +two dots" symbol is not on computer keyboards. Don't think of / as the horizontal +line in a fraction. Ask yourself what 1/2/2 should mean.) WeBWorK and most other +computers read things from left to right, i.e. 2/3*4 means (2/3)*4 or 8/3, IT DOES +NOT MEAN 2/12. Some computers may do operations from right to left. If you +want 2/(3*4) = 2/12, you have to use parentheses. The same thing happens with +addition and subtraction. 1-3+2 = 0 but 1-(3+2) = -4. This is one case where using +parentheses even if they are not needed might be a good idea, e.g. write (2/3)*4 +even though you could write 2/3*4. This is also a case where previewing your answer +can save you a lot a grief since you will be able to see what you entered. + +$BR +Enter 2/3*4 and use the Preview button to see what you get.$BR +\{ ans_rule(25) \} +END_TEXT + +$ans = 8/3; +ANS(std_num_cmp($ans)); + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/set0/prob1.pg @@ -0,0 +1,114 @@ +##DESCRIPTION +## A very simple first problem +##ENDDESCRIPTION + +# this is a comment. i just added it. nifty! + +##KEYWORDS('algebra') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$a = random(-10,-1,1); +$b = random(1,11,1); +$c = random(1,11,1); +$d = random(1,11,1); + +BEGIN_TEXT +This problem demonstrates how you enter numerical answers into WeBWorK. $PAR +Evaluate the expression \(3($a )($b -$c -2($d ))\): + \{ ans_rule(10) \} +$BR + +END_TEXT + + +$ans = 3*($a)*($b-$c-2*($d)); + +ANS(strict_num_cmp($ans)); + +BEGIN_TEXT +In the case above you need to enter a number, since we're testing whether you can multiply +out these numbers. (You can use a calculator if you want.) +$PAR +For most problems, you will be able to get WeBWorK to +do some of the work for you. For example +$BR +Calculate ($a) * ($b): \{ ans_rule()\} +$BR + +END_TEXT + + +$ans = $a*$b; + +ANS(std_num_cmp($ans)); + +BEGIN_TEXT + +The asterisk is what most computers use to denote multiplication and you can use this with WeBWorK. +But WeBWorK will also allow you to use a space to denote multiplication. +You can either \($a * $b\) or \{$a*$b\} or even \($a \ $b\). All will work. Try them. +$PAR +Now try calculating the sine of 45 degrees ( that's sine of pi over 4 in radians +and numerically sin(pi/4) equals \{1/sqrt(2)\} or, more precisely, \(1/\sqrt{2} \) ). +You can enter this as sin(pi/4) , as +sin(3.1415926/4), as 1/sqrt(2), as 2**(-.5), etc. This is because WeBWorK knows about +functions like sin and sqrt (square root). (Note: exponents +can be indicated by either a "caret" or **). Try it.$BR \( \sin(\pi/4) = \) \{ ans_rule(20) \}$PAR + + Here's the +\{ htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list of the functions") \} + which WeBWorK understands. WeBWorK ALWAYS uses radian mode for trig functions. + $PAR + +END_TEXT + +ANS( std_num_cmp(sin(3.1415926/4)) ); + +BEGIN_TEXT + +You can also use juxtaposition to denote multiplication. E.g. enter \( 2\sin(3\pi/2) \). +You can enter this as 2*sin(3*pi/2) or more simply as 2sin(3pi/2). Try it: $BR +\{ ans_rule(20) \}$PAR + +END_TEXT + +$pi = 4*atan(1); +ANS( std_num_cmp(2*sin(3*$pi/2)) ); + +BEGIN_TEXT + +Sometimes you need to use ( )'s to make your meaning clear. E.g. 1/2+3 is 3.5, but 1/(2+3) is .2 Why? +Try entering both and use the ${LQ}Preview${RQ} button below to see the difference. In addition to +( )'s, you can also use [ ]'s and $LB ${RB}'s. $BR +\{ ans_rule(20) \}$PAR + + +END_TEXT + +ANS( std_num_cmp(.2)); + +BEGIN_TEXT + +You can always try to enter answers and let WeBWorK do the calculating. +WeBWorK will tell you if the problem requires a strict numerical answer. +The way we use WeBWorK in this class there is no penalty for getting an answer wrong. What counts +is that you get the answer right eventually (before the due date). For complicated answers, +you should use the ${LQ}Preview${RQ} button to check for syntax errors and also to check that the answer +you enter is really what you think it is. + + +END_TEXT + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/set0/prob3.pg @@ -0,0 +1,78 @@ +##DESCRIPTION +## sample matching problem +##ENDDESCRIPTION + +##KEYWORDS('sample') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + + +$a = random(-10,10,1); +$b = random(1,3,1); +$c = abs($a); +#$indextag = abs(($a < 0) -2) +if ($a <0) {$sgn = "+";} else {$sgn = "-";} +#$sgn = choose(indextag,"+","-") +## If e.g. $a = -3, write |x+3| instead of |x--3| +## Write an ifThenElse macro +$questStr1 = EV2(" \(x\) is less than $a" ); +$ansStr1 = EV2(" \(x \lt $a\)"); +$questStr2 =EV2( " \(x\) is any real number" ); +$ansStr2 = EV2(" \(-\infty \lt x \lt \infty\)"); +$questStr3 = EV2(" \(x\) is greater than $a" ); +$ansStr3 = EV2(" \($a \lt x\)"); +$questStr4 = EV2(" \(x\) is less than or equal to $a" ); +$ansStr4 = EV2(" \(x \leq $a\)"); +$questStr5 = EV2(" \(x\) is greater than or equal to $a"); +$ansStr5 = EV2(" \(x \geq $a\)"); +$questStr6 = EV2(" The distance from \(x\) to $a is less than or equal to $b"); +$ansStr6 = EV2(" \(|x $sgn $c| \leq $b\)"); +$questStr7 = EV2(" The distance from \(x\) to $a is more than $b"); +$ansStr7 = EV2(" \(|x $sgn $c| \gt $b\)"); + +@questions =( $questStr1,$questStr2,$questStr3,$questStr4,$questStr5,$questStr6,$questStr7); +@answers =( $ansStr1,$ansStr2,$ansStr3,$ansStr4,$ansStr5,$ansStr6,$ansStr7); + +# Now randomize the questions: +@slice = &NchooseK(7,5); +@shuffle = &shuffle(scalar(@slice)); +################################################################################ + +TEXT(EV2(<<EOT)); +This problem demonstrates a WeBWorK Matching question. $PAR +Match the statements defined below with the letters labeling their +equivalent expressions. $BR +You must get all of the answers correct to receive credit. +$BR +EOT +TEXT( +&match_questions_list(@questions[@slice]), +&OL(@answers[@slice[@shuffle]]) +); +ANS( str_cmp([ @ALPHABET[&invert(@shuffle)] ] ) ); + ##the correct answers are obtained by applying + ##the inverse (adjoint) permutation to the captions. + +TEXT(<<EOT); +For this problem WeBWorK only tells you that all your answers are correct or that at least one is wrong. +This makes the problem harder and is usually used only for T/F and matching questions. +The idea is to encourage you to think rather than to just try guessing. +$PAR +If you are having trouble reading the mathematics on the screen, this means that you are using "text" mode. +If you are using Netscape or MSIE then you can get an easier to read version of the equations by returning to the +problem list page (use the button at the top of this page) and choosing "formatted-text" or "typeset" instead +of "text". Sometimes there is a 15-20 second delay in viewing a problem in "typeset" mode the first time. +EOT + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/set0/screenHeaderFile0.pg @@ -0,0 +1,46 @@ +##Screen set header for set 0, Fall 1998 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + + + +BEGIN_TEXT; +WeBWorK assignment number $setNumber is due $formatedDueDate. + +$PAR +This first problem set (set 0) is designed to acquaint you with using WeBWorK. +YOUR SCORE ON THIS SET WILL NOT BE COUNTED TOWARD YOUR FINAL GRADE. +In addition to doing the screen problems, practice getting a hard copy print out of the +problem set. You probably won't need it for this problem set, but you may in the future. +If you need software installed on your own computer look +\{ htmlLink("/index.html#software","here")\}. +$PAR +The primary purpose of WeBWorK is to let you know if you are getting the right answer or to alert +you if you get the wrong answer. Usually you can attempt a problem as many times as you want before +the due date. However, if you are having trouble figuring out your error, you should +consult the book, or ask a fellow student, one of the TA's or +your professor for help. Don't spend a lot of time guessing -- it's not very efficient or effective. +$PAR + +You can use the Feedback button on each problem +page to send e-mail to the professors. +$PAR +Give 4 or 5 significant digits for (floating point) numerical answers. +For most problems when entering numerical answers, you can if you wish +enter elementary expressions such as 2^3 instead of 8, sin(3pi/2) instead +of -1, e^(ln(2)) instead of 2, +(2+tan(3))*(4-sin(5))^6-7/8 instead of 27620.3413, etc. + + Here's the +\{ htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list of the functions") \} + which WeBWorK understands. +END_TEXT + +&ENDDOCUMENT; --- /dev/null +++ courses/modelCourse/templates/set0/prob5.pg @@ -0,0 +1,44 @@ +##DESCRIPTION +## practice problem +##ENDDESCRIPTION + +##KEYWORDS('sample') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + + +$a = random(100,200,1); +$b = random(250,350,1); +$c = random(-31,-3,1); +TEXT(EV2(<<EOT)); +This problem demonstrates a WeBWorK question that requires you to enter a number or a fraction. $PAR +Evaluate the expression \(\frac{|$a-$b|}{|$c|}\). Give your answer in decimal notation +correct to three decimal places or give your answer as a fraction. +$BR $BR \{ANS_RULE(1,10) \} +$BR +EOT +$ans = abs($a-$b)/abs($c); +ANS(arith_num_cmp($ans)); +TEXT(<<EOT); +$PAR +Now that you have finished you can use the "Prob. List" button at the top of the page +to return to the problem list page. You'll see that the problems you have done have been +labeled as correct or incorrect, so you can go back and do problems you skipped or couldn't +get right the first time. Once you have done a problem correctly it is ALWAYS listed as correct +even if you go back and do it incorrectly later. This means you can use WeBWorK to review +course material without any danger of changing your grade. + +EOT + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/set0/prob1a.pg @@ -0,0 +1,58 @@ +##DESCRIPTION +## sample of entering functions as answers +##ENDDESCRIPTION + +##KEYWORDS('functions') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + + +BEGIN_TEXT +This problem demonstrates how you enter function answers into WeBWorK. $PAR +First enter the function \(\sin\; x\). When entering the function, you should enter +sin(x), but WeBWorK will also accept sin x or even sinx. If you remember your trig +identities, sin(x) = -cos(x+pi/2) and WeBWorK will accept this or any other function +equal to sin(x), +e.g. sin(x) +sin(x)**2+cos(x)**2-1 +$BR\{ans_rule(35) \} + +END_TEXT + +$ans = "sin(x)"; +ANS(function_cmp($ans)); + +BEGIN_TEXT +$PAR +We said you should enter sin(x) even though WeBWorK will also accept sin x or even sinx because you +are less likely to make a mistake. Try entering sin(2x) without the parentheses and you may be surprised +at what you get. Use the Preview button to see what you get. WeBWorK will evaluate functions (such +as sin) before doing anything else, so sin 2x means first apply sin which gives sin(2) and then +mutiple by x. Try it. +$BR\{ans_rule(35) \} + +END_TEXT + + +$ans = "sin(2*x)"; +ANS(function_cmp($ans)); + +TEXT(EV2(<<EOT)); +$PAR Now enter the function \(2\cos t\). Note this is a function of \( t\) and not \( x\). Try entering +2cos x and see what happens. +$BR \{ans_rule(35) \} +EOT + +$ans = "2*cos(t)"; +ANS(function_cmp($ans,'t')); + +ENDDOCUMENT(); # This should be the last executable line the problem. --- /dev/null +++ courses/modelCourse/templates/set0/prob1c.pg @@ -0,0 +1,15 @@ + + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT("Hello world"); + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/set0/paperHeaderFile0.pg @@ -0,0 +1,29 @@ +##Problem set header for set 0, Summer 2001 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + +$dateTime = $formatedDueDate; + +TEXT(EV2(<<EOT)); +$BEGIN_ONE_COLUMN +\noindent {\large \bf $studentName} +\hfill +\noindent {\large \bf MATH Summer 2001} +\par +\noindent{\large \bf Homework Set $setNumber due $dateTime}\par + +\noindent This first set (set 0) is designed to acquaint you with using WeBWorK. +{\bf Your score on this set will not be counted toward your final grade} +\par +\noindent You may need to give 4 or 5 significant digits for some (floating point) numerical answers in order to have them accepted by the computer. +$END_ONE_COLUMN +EOT + +&ENDDOCUMENT; --- /dev/null +++ courses/modelCourse/templates/set0/prob2.pg @@ -0,0 +1,72 @@ +##DESCRIPTION +## sample true-false question +##ENDDESCRIPTION + +##KEYWORDS('true-false') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +TEXT(EV2(<<EOT)); +This problem demonstrates a WeBWorK True/False question. $PAR +Enter a T or an F in each answer space below +to indicate whether the corresponding statement is true or +false.$BR +You must get all of the answers correct to receive credit. +$BR +EOT + +## First we set up our variables. +$a = random(1,5,1); +$b = random(6,10,1); +$c = random(-10,-1,1); +$d = random(-10,-1,1); +$e = random(1,10,1); + +$questStr1 = EV2(" \(-$a \lt -$b\)"); +$ansStr1 = "F"; +$questStr2 = EV2(" \($c \leq $c\)"); +$ansStr2 = "T"; +$questStr3 = EV2(" \($d \lt $d\)"); +$ansStr3 = "F"; +$questStr4 = EV2(" \(\pi \geq 3.1416\)"); +$ansStr4 = "F"; +$questStr5 = EV2(" \($e-1 \leq $e\)"); +$ansStr5 = "T"; + +@questions =( $questStr1,$questStr2,$questStr3,$questStr4,$questStr5); +@answers =( $ansStr1,$ansStr2,$ansStr3,$ansStr4,$ansStr5); + +## Now choose randomly 4 questions out of the 5 question strings above. + +@slice = NchooseK(scalar(@questions),4); + +## Next we output the 4 chosen questions. #match_ +TEXT( +&match_questions_list(@questions[@slice]) +); + +ANS(str_cmp([ @answers[@slice] ] )); +TEXT(<<EOT); +$PAR Notice that if one of your answers is wrong then, in this problem, WeBWorK will tell you which +parts are wrong and which parts are right. This is the behavior for most problems, but for true/false +or multiple choice questions +WeBWorK will usually only tell you whether or not all the answers are correct. +It won't tell you which ones are wrong. The idea is to encourage you to think rather than to just try guessing. +$PAR +In every case all of the +answers must be correct before you get credit for the problem. + + +EOT +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/set0/prob4/prob4.pg @@ -0,0 +1,99 @@ +##DESCRIPTION +## Goal: Identify that a line represents an increasing, decreasing or constant function +## or is not the graph of a function (when the line is vertical). +## Contains an introduction explaining the importance of linear (affine) functions. +##ENDDESCRIPTION + +##KEYWORDS('graphs') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + + +$pictSet = random(1,3,1); #there are three sets of graphs + +$pictNum = random(1,4,1); #each set has 4 graphs the numbers are below + +@pictID = ( +"1-55141.gif", +"1-79226.gif", +"1-75352.gif", +"1-65474.gif", +"2-96187.gif", +"2-11287.gif", +"2-68382.gif", +"2-63428.gif", +"3-44144.gif", +"3-69221.gif", +"3-18387.gif", +"3-55459.gif" +); + +sub pictIndex{ # this gives offsets into @pictID -- I was too laxy to do multidimensional arrays + my ($i,$j)=@_; + return(($i-1)*4+$j-1 ) + } + +@question = (); +@answer =(); + +TEXT( + + qq! This problem demonstrates a WeBWorK problem involving graphics. $PAR + The simplest functions are the linear (or affine) functions --- + the functions whose graphs are + a straight line. They are important because many functions (the so-called + differentiable functions) ${LQ}locally$RQ look like straight lines. + (${LQ}locally$RQ means that + if we zoom in and look at the function at very powerful magnification + it will look like a straight line.) $PAR + !, + "Enter the letter of the graph of the function which corresponds to + each statement. $BR" + ); + +qa(~~@question,~~@answer, +"The graph of the line is increasing", +@pictID[&pictIndex($pictSet,1)], +"The graph of the line is decreasing", +@pictID[&pictIndex($pictSet,2)], +"The graph of the line is constant", +@pictID[&pictIndex($pictSet,3)], +"The graph of the line is not the graph of a function", +@pictID[&pictIndex($pictSet,4)], +); + +@slice = 0..3; # select an ordered subset of the questions and answers +@shuffle = &shuffle(scalar(@slice)); # create a permutation of the right length +@images = @answer[@slice[@shuffle]]; # create a permuted list of the answers +@captions =@ALPHABET[0..3]; # the caption letters are always in order + +TEXT( +&match_questions_list(@question[@slice]), +&imageRow(~~@images,~~@captions) +); + +ANS(std_str_cmp_list( @ALPHABET[&invert(@shuffle ) ] ) ); + +TEXT(EV2(<<EOT)); +This is another problem where you aren't told if some of your answers are right. (With +matching questions and true false questions, this is the standard behavior -- otherwise +it is too easy to guess your way to the answer without learning anything.) +$PAR +If you are having a hard time seeing the picture clearly, click on the picture. It will +expand to a larger picture on its own page so that you can inspect it more closely. +$PAR +Some problems display a link to a web page where you can get additional information +or a hint:\{ htmlLink(alias("testing.html"),"Hint")\} +EOT +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/calc.html @@ -0,0 +1,57 @@ +<HTML> +<HEAD> +<TITLE>The JavaScript Source: Calculators: Basic</TITLE> +<META HTTP-EQUIV="The JavaScript Source" CONTENT="no-cache"> +<META NAME="description" CONTENT="This is a very simple calculator, all done with javascript. Just click the numbers and the operators and use the "=" button to calculate! This is a neat example of the LIMITLESS (!) powers of JavaScript."> +</HEAD> + +<BODY BGCOLOR=#ffffff vlink=#0000ff> + +<P> + + +I took this calculator straight from the web at <A HREF="http://javascriptsource.com">javascriptsource.com</A> +<P> + +This is a very simple calculator, +all done with javascript. +Just click the numbers and +the operators and use the "=" button to calculate! + +<CENTER> +<FORM NAME="Calc"> +<TABLE BORDER=4> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input" Size="16"> +<br> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'"> +<INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'"> +<INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'"> +<INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '"> +<br> +<INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'"> +<INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'"> +<INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'"> +<INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '"> +<br> +<INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'"> +<INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'"> +<INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'"> +<INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '"> +<br> +<INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''"> +<INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'"> +<INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)"> +<INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '"> +<br> +</TD> +</TR> +</TABLE> +</FORM> +</CENTER> +</body></html> |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:45:17
|
Log Message: ----------- adding setDemo files to modelCourse Added Files: ----------- webwork2/courses/modelCourse/templates/setDemo: c4s5p2.pg josephus.pg limits.pg liteApplet1.pg liteApplet2.pg nsc2s10p2.pg paperHeaderFile1.pg prob0837.pg prob5.pg prob6b.pg s2_2_1.pg sample_myown_ans.pg sample_units_ans.pg screenHeaderFile1.pg srw1_9_4.pg Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/setDemo/screenHeaderFile1.pg @@ -0,0 +1,85 @@ +##Screen set header for set 0, Fall 1998 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + + + +BEGIN_TEXT +This is a demonstration set designed to illustrate the range of types of questions which can be asked using WeBWorK rather than to illustrate a typical calculus problem set. + +$PAR +$BBOLD 1. Simple numerical problem. $EBOLD A simple problem requiring a numerical answer. It illustrates how one can allow WeBWorK to calculate answers from formulas (e.g. an answer such as sqrt(3^2 +4^2) can be entered instead of the answer 5.). It also shows +an example of feedback on the correctness of each answer, rather than grading the entire problem. +$PAR +$BBOLD 2. Graphs and limits. $EBOLD The graph in this example is constructed on the fly. From the graph a student is supposed to determine the values and limits of the function at various points. The immediate feedback on this problem is particularly useful, since students often make unconcious mistakes. +$PAR +$BBOLD 3. Derivatives. $EBOLD An example of checking answers which are formulas, rather than numbers. +$PAR +$BBOLD 4. Anti-derivatives. $EBOLD This example will accept any anti-derivative, adjusting for the fact that the answer is only defined up to a constant. +$PAR +$BBOLD 5. Answers with units. $EBOLD Try entering the answer to this question in meters (m) and also centimeters (cm). +$PAR +$BBOLD 6. A physics example. $EBOLD Includes a static picture. +$PAR +$BBOLD 7. More graphics. $EBOLD An example of on-the-fly graphics. Select the graph of f, it's derivative and it's second derivatives. +$PAR +$BBOLD 8. JavaScript example. $EBOLD I'm particularly fond of this example. The computer provides an "oracle" function: give it a number \(x\) and it will provide you with the value \(f(x)\) of the function at \(x\). Using this, calculate the value of the derivative of \(f\) at 2. (i.e. \(f'(2)\) ). Students are forced to use the Newton quotient, since there are no formulas to work with. I don't think this problem could be asked as written homework. +$PAR +$BBOLD 9. Java example. $EBOLD This gives an example of incorporating a java applet which can be used experimentally to determine answers for WeBWorK questions. This particular example is somewhat forced. There is a lot of room for experimentation and improvement in combining these two technologies. +$PAR +$BBOLD 10. Palindrome. $EBOLD To answer this problem enter any palindrome. This problem illustrates the power of the "answer-evaluator" model. For each problem the problem designer writes a function which accepts a student's answer and produces a 0 or 1 (for incorrect or correct). Usually this is done by comparing with an answer given by the problem designer, but in this case the function checks if the answer is the same forward and backward. +$PAR +$BBOLD 11. Lite Applet. $EBOLD An example of using the map lite applet +$PAR +$PAR +$BBOLD 12. Lite Applet. $EBOLD An example of using the map lite applet where the cities are +chosen randomly.l +$PAR +$BBOLD 13. JavaScript $EBOLD The Josephus problem. Currently the javaScript is a bit too complicated, since it uses frames. With a little more work one might be able to embed this in a PG problem. +$PAR +END_TEXT + + + +BEGIN_TEXT +$HR + +Use this box to give information about this problem +set. Typical information might include some of these facts: +$PAR +WeBWorK assignment number $setNumber is due on : $formatedDueDate. + + +$PAR +The primary purpose of WeBWorK is to let you know if you are getting the right answer or to alert +you if you get the wrong answer. Usually you can attempt a problem as many times as you want before +the due date. However, if you are having trouble figuring out your error, you should +consult the book, or ask a fellow student, one of the TA's or +your professor for help. Don't spend a lot of time guessing -- it's not very efficient or effective. +$PAR + +You can use the Feedback button on each problem +page to send e-mail to the professors. +$PAR +Give 4 or 5 significant digits for (floating point) numerical answers. +For most problems when entering numerical answers, you can if you wish +enter elementary expressions such as 2^3 instead of 8, sin(3*pi/2) instead +of -1, e^(ln(2)) instead of 2, +(2+tan(3))*(4-sin(5))^6-7/8 instead of 27620.3413, etc. +$PAR + Here's the +\{ htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list of the functions") \} + which WeBWorK understands. + +Along with the \{htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!, "list of units")\} which WeBWorK understands. This can be useful in +physics problems. +END_TEXT + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/sample_myown_ans.pg @@ -0,0 +1,86 @@ +DOCUMENT(); + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +BEGIN_TEXT + This problem demonstrates how you can write your own procedure to check answers. + The procedure is embedded right in the problem. If you wanted to use it for several + problems, you could put it in a file similar to "PGanswermacros.pl" and load it into + the problem. + + This problem asks you to enter a palindrome, a word, number, or phrase that is the same + when read backwards or forward. For example, madam or Hannah. For us a standard + palindrome will ignore spaces and case, but a strict palindrome will not. So e.g. Hannah + is a standard but not a strict palindrome. We will write a test for both types. $BR $BR + Enter a standard palindrome such as "Hannah", "1234321", or "Mom". $BR + This uses std${US}palindrome${US}test $BR + \{ans_rule(60) \} +END_TEXT + + +$std_palindrome_test = sub { + my $in = shift @_; + my $normalizedCorrectAnswer = "There are many correct answers, e.g. Hannah"; + $in =~ s|~~s+||g; # remove all spaces + ## use ~~ inplace of perl's backslash in problems + $in = uc $in; # Make letters uppercase + ## use ~~ inplace of perl's backslash in problems + my $reverse = reverse $in; + my $correctQ = ($in eq $reverse) ? 1: 0; + my $ansMsg = ''; + unless ($in =~ m|~~S|) { + $correctQ = 0; + $ansMsg = 'An empty string is not accepted as a palindrome'; + } + my $rh_answer = new AnswerHash( score => $correctQ, + correct_ans => $normalizedCorrectAnswer, + student_ans => $in, + ans_message => $ansMsg, + type => 'custom' + ); + $rh_answer; + +}; + +ANS($std_palindrome_test); + + +BEGIN_TEXT; +$PAR +Now enter a strict palindrome such as "1234321", or "mom". $BR +This uses strict${US}palindrome${US}test $BR +\{ans_rule(60) \} +END_TEXT + +$strict_palindrome_test = sub { + my $in = shift @_; + my $normalizedCorrectAnswer = "There are many correct answers, e.g. HannaH"; + $in =~ s/~~s*$//; # remove trailing whitespace ## use ~~ inplace of perl's backslash in problems + $in =~ s/^~~s*//; # remove initial spaces ## use ~~ inplace of perl's backslash in problems + my $reverse = reverse $in; + my $correctQ = ($in eq $reverse) ? 1: 0; + my $ansMsg = ''; + unless ($in =~ m|~~S|) { + $correctQ = 0; + $ansMsg = 'An empty string is not accepted as a palindrome'; + } + + my $rh_answer = {score => $correctQ, + correct_ans => $normalizedCorrectAnswer, + student_ans => $in, + ans_message => $ansMsg, + type => 'custom' + }; + $rh_answer; +}; + +ANS($strict_palindrome_test); + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/nsc2s10p2.pg @@ -0,0 +1,67 @@ +#DESCRIPTION +# Identify the graphs of the function and the derivative +#ENDDESCRIPTION + +#KEYWORDS('derivatives', 'graphs') +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl", + "PGgraphmacros.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 0; + +$a=random(0, 6.3, .1); +$b=random(1.1, 1.5, .1); + +$dom = 4; +@slice = NchooseK(3,3); + +@colors = ("blue", "red", "black"); +@sc = @colors[@slice]; #scrambled colors +@sa = ('A','B','C')[@slice]; + + +$f = "sin($a+$b*cos(x)) for x in <-$dom,$dom> using color:$sc[0] and weight:2"; +$fp = "cos($a+$b*cos(x))*(-$b)*sin(x) for x in <-$dom,$dom> using color=$sc[1] and weight:2"; +$fpp = " -sin($a+$b*cos(x))*$b*$b*sin(x)*sin(x) + cos($a+$b*cos(x))*(-$b)*cos(x) for x in <-$dom,$dom> using color=$sc[2] and weight=2"; + +$graph = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]); + +($fRef,$fpRef,$fppRef) = plot_functions( $graph, + $f,$fp,$fpp + ); + +# create labels + +$label_point=-0.75; +$label_f = new Label ( $label_point,&{$fRef->rule}($label_point),$sa[0],"$sc[0]",'left') ; + # NOTE: $fRef->rule is a reference to the subroutine which calculates the + # function. It was defined in the output of plot_functions. It is used here + # to calculate the y value of the label corresponding to the function, + # and below to find the y values for the labels corresponding to the + # first and second derivatives. + +$label_fp = new Label ( $label_point,&{$fpRef->rule}($label_point),$sa[1],"$sc[1]",'left') ; +$label_fpp = new Label ( $label_point,&{$fppRef->rule}($label_point),$sa[2],"$sc[2]",'left'); + +# insert the labels into the graph + +$graph->lb($label_f,$label_fp,$label_fpp); + +BEGIN_TEXT +\{ image(insertGraph($graph))\}$BR +Identify the graphs A (blue), B( red) and C (green) as the graphs of a function and its +derivatives:$PAR +\{ans_rule(4)\} is the graph of the function $PAR +\{ans_rule(4)\} is the graph of the function's first derivative $PAR +\{ans_rule(4)\} is the graph of the function's second derivative $PAR +END_TEXT +ANS(std_str_cmp_list( @sa ) ); + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/c4s5p2.pg @@ -0,0 +1,50 @@ +#DESCRIPTION +#KEYOWRDS('integrals', 'substitution') +# Integrals - \int_0^{$x1} x(x^2 ?{$a})^5 dx +# Substitution +#ENDDESCRIPTION + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem()); +$showPartialCorrectAnswers = 1; + +$n = random(3,6,1); +$n1 = $n-1; + +BEGIN_TEXT +Find \[ F(x) = \int x^{$n1}\cos(x^{$n}) \; dx \] +Give a specific function for \( F(x) \). $BR $BR + +F(x) = \{ans_rule(45)\} +END_TEXT + +$ans = "sin(x^$n)/$n"; +ANS(function_cmp_up_to_constant($ans )); + +#$ans = "sin(x^$n)/$n + c"; # c is the constant of integration which + # is a free parameter. It can be adjusted + # to match the student's answer. +#ANS( fun_cmp($ans, params => ['c'] ) ); +$a1= random(-9,-1,1); +$b1= random(0,9,1); + +BEGIN_TEXT +$BR $BR +Evaluate \[ F(x) = \int_{$a1}^{$b1} x^{$n1}\cos(x^{$n}) \; dx \] +$BR +\{ans_rule(50)\} +END_TEXT + +$ans = (sin($b1**$n) - sin($a1**$n))/$n; + +&ANS(num_cmp($ans )); + + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/prob6b.pg @@ -0,0 +1,88 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +#<<<######################################################### +# allow the student to change the seed for this problem. + +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? +${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); +BEGIN_TEXT +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ MODES( +TeX => qq! Change the problem seed to change the problem:$problemSeed!, +Latex2HTML => qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +HTML => qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} +END_TEXT +#########################################################>>> +$p = random(2,9,1); # multiplier +$p2 = ( $p % 2 == 0) ? 2*$p : $p; + +TEXT(beginproblem()); + +# The link to the java applet is hard wired to use the java applet +# served from the University of Rochester WeBWorK machine. +# It is possible to set this up so that the java applet is served +# from any machine +# For details use the Feedback button to contact the authors of WeBWorK + +BEGIN_TEXT +This problem requires a browser capable of running Java. + +$PAR +This problem illustrates how you can Java applets in a WeBWorK example. +$PAR +This polar coordinate grapher was constructed at the Mathematics Department +of The Johns Hopkins University and the applet is being served from their computer. +$PAR +WeBWorK can use existing $BBOLD JavaScript$EBOLD and $BBOLD Java $EBOLD code to +augment its capabilities. +$HR +END_TEXT +TEXT(MODES( +TeX => "\fbox{The Johns Hopkins University Mathematics Department's + polar graph plotting applet goes here}", +HTML => qq{ + <APPLET CODE="PolarApplet/PolarApplet.class" WIDTH="250" HEIGHT="350" + CODEBASE="http://xena.mat.jhu.edu/vander/stable/"> + <PARAM NAME="tmin" VALUE="0"> + <PARAM NAME="tmax" VALUE="2*pi"> + <PARAM NAME="showcartesian" VALUE="no"> + <PARAM NAME="showinterval" VALUE="YES"> + </APPLET> +}, +Latex2HTML => qq!\begin{rawhtml} + <APPLET CODE="PolarApplet/PolarApplet.class" WIDTH="250" HEIGHT="350" + CODEBASE="http://xena.mat.jhu.edu/vander/stable/"> + <PARAM NAME="tmin" VALUE="0"> + <PARAM NAME="tmax" VALUE="2*pi"> + <PARAM NAME="showcartesian" VALUE="no"> + <PARAM NAME="showinterval" VALUE="YES"> + </APPLET>\end{rawhtml} +! +)); + +BEGIN_TEXT +$PAR +For what value of \( k \) does the graph of \( r = \cos(kt) \) look +like a rose with $p2 petals? +$BR +\(k = \) \{ ans_rule(20) \} ; + +$PAR + +END_TEXT + +ANS(num_cmp($p) ); + +ENDDOCUMENT(); + --- /dev/null +++ courses/modelCourse/templates/setDemo/josephus.pg @@ -0,0 +1,206 @@ +&DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +# define function to be evaluated + +HEADER_TEXT(<<EOF); +<script LANGUAGE="JavaScript"> + +function joeGame(n, k, m){ +this.people = n +this.skip = k +this.keep = m +this.list = new Array(n) +for (var i=0; i<n; i++) { + this.list[i] = 0 + } +} + +var currentGame = new joeGame(10,0,0) + +function joeth(n, k, s) { +var x = k*s +while (x > n) { + x = Math.floor(( k*(x-n) - 1.0 )/ (k-1.0) ) + } +return(x) +} + +function playGame() { + +var newN = parseInt(document.gameForm.peopleNumField.value) +var newK = parseInt(document.gameForm.skipNumField.value) + +var suff = new String("th") + +var s +var n = newN +var k = newK +var numRows = Math.floor(n/20) +var numLeft = n - 20*numRows + +if (!newN || !newK) { + alert ("Enter some data.") + document.gameForm.peopleNumField.focus() + } +else + { + +currentGame = new joeGame(n, k, 1) + +for (var s=1; s<=currentGame.people; s++){ + currentGame.list[s-1] = joeth(n, k, s) + } + +if ((newK % 10) == 1) { + if ((newK == 1) || (newK > 20)) { + suff = "st" + } + else { + suff="th" + } +} +else { + if ((newK % 10) == 2){ + if ((newK == 2) || (newK > 20)) { + suff = "nd" + } + else { + suff="th" + } + } + else { + if ((newK % 10) == 3){ + if ((newK == 3) || (newK > 20)) { + suff = "rd" } + else { + suff="th" + } + } + } +} + +parent.gameStatus.document.clear() +parent.gameStatus.document.write("<H2> The Josephus Game </H2>") +parent.gameStatus.document.write("<FONT SIZE=2> Playing the Josephus Game with <B>" + + document.gameForm.peopleNumField.value + "</B> people, ") +parent.gameStatus.document.write(" eliminating every <B>" + + document.gameForm.skipNumField.value + "</B><SUP>" + suff + "</SUP> person, leaves ") +parent.gameStatus.document.write(" person <U><B>" + currentGame.list[n-1] + "</B></U> as the last survivor. ") +parent.gameStatus.document.write("<P>The entire elimination order is <BR><BR>") + +for (var d=0; d<numRows; d++) { + parent.gameStatus.document.write("<TABLE BORDER=1> \n <TR> <TH> Order Eliminated </TH>") + for (var k=1; k<=20; k++) { + parent.gameStatus.document.write(" <TD> " + (20*d + k) + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n <TR> <TH> Person Eliminated </TH> ") + + for (k=0; k<20; k++) { + parent.gameStatus.document.write(" <TD> " + currentGame.list[20*d+k] + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n </TABLE> <BR>") + } +if (numLeft > 0) { + parent.gameStatus.document.write("<TABLE BORDER=1> \n <TR> <TH> Order Eliminated</TH>") + for (var k=1; k<=numLeft; k++) { + parent.gameStatus.document.write(" <TD> " + (20*d + k) + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n <TR> <TH> Person Eliminated </TH> ") + + for (k=0; k<numLeft; k++) { + parent.gameStatus.document.write(" <TD> " + currentGame.list[20*d+k] + " </TD> ") + } + parent.gameStatus.document.write("</TR> \n </TABLE> <BR></FONT>") + } + } + parent.gameStatus.document.close() +} + + +function clearStuff(){ +parent.gameStatus.document.open() +parent.gameStatus.document.clear() +parent.gameStatus.document.location = "gamestart.html" +parent.gameStatus.document.close() +document.gameForm.peopleNumField.focus() +currentGame.people = 10 +currentGame.skip = 0 +currentGame.keep = 0 +for (var i=0; i++; i<currentGame.people) { + currentGame.list[i] = 0 + } +} + + +function main() { +parent.gameStatus.document.open() +playGame() +parent.gameStatus.document.close() +} + +</script> + + +EOF + + +TEXT(beginproblem()); +TEXT(MODES( +TeX => '', +Latex2HTML => "\begin{rawhtml} <NOSCRIPT> This problem requires that Java + Script be enabled </NOSCRIPT> \end{rawhtml}", +HTML => "<NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT>" +)); + +BEGIN_TEXT +$PAR +This problem illustrates how you can embed JavaScript code in a WeBWorK example +to create an interactive homework problem that could never be provided by a text book. +Stolen from Doug Ensley and mathDL. +http://www.mathdl.org/offsite.html?page=http://www.ship.edu/~deensl/mathdl/Joseph.html&content_id=41520 +END_TEXT + +BEGIN_TEXT +<script> + document.main(); +</script> +END_TEXT +TEXT(<<EOF); +<form NAME="gameForm" onReset="clearStuff()"> +<table CELLSPACING=10 CELLPADDING=10 > +<tr VALIGN=TOP> +<td> +<table> +<tr> +<th><i>n</i> = </th> + +<td><input TYPE="text" NAME="peopleNumField" SIZE=5></td> +</tr> + +<tr> +<th><i>k</i> = </th> + +<td><input TYPE="text" NAME="skipNumField" SIZE=5></td> +</tr> +</table> +<input TYPE="button" NAME="playButton" VALUE="Start" + onClick="playGame()"><input TYPE="reset" NAME="resetButton" VALUE="Clear All"></td> + +<td WIDTH="200"><font size=-1>Set the parameters and press <b>Start</b> +to see the elimination order when you start with <b><i>n</i></b> people +and eliminate every <b><i>k</i></b><sup>th</sup> one.</font></td> +</tr> +</table> + +<p></form> +EOF +$ans =3; + +ANS(num_cmp($ans,reltol=>1,format =>"%0.14g") ); #We are allowing 1 percent error for the answer. + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/s2_2_1.pg @@ -0,0 +1,56 @@ +##DESCRIPTION +##KEYWORDS('derivatives') +## Find a derivative of a polynomial, evaluate it at a point +##ENDDESCRIPTION + +DOCUMENT(); # This should be the first executable line in the problem. +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +$a1 = random(2,7,1); +$b1 = random(2,12,1); +$c1 = random(1,40,1); +$x1 = random(1,5,1); +$deriv1 = 2*$a1*$x1-$b1; +$funct1 = "2*$a1*x-$b1"; + +BEGIN_TEXT +If \( f(x) = $a1 x^2 - $b1 x -$c1 \), find \( f'( x ) \). +$BR $BR \{ans_rule(48) \} +$BR +END_TEXT + +$ans = $funct1; +&ANS(fun_cmp($ans)); + +$a1_2 = 2*$a1; +&SOLUTION(EV3(<<'EOT')); +$SOL $BR +In general the derivative of \( x^n \) is \( nx^{n-1} \). Using this (and the +basic sum and constant multiple rules) we find the derivative of $BR +\(${a1}x^2 - ${b1}x -$c1 \quad \) is $BR \( ${a1_2}x - $b1 \).$BR $BR +EOT + +BEGIN_TEXT +Find \( f'( $x1 ) \). +$BR $BR \{ans_rule(48) \} +$BR $BR +END_TEXT + +$ans = $deriv1; +&ANS(num_cmp($ans)); + +&SOLUTION(EV3(<<'EOT')); +$SOL $BR +To find the derivative we just have to evaluate \( f'( x ) \) at +\( x = $x1) \), i.e. \( ${a1_2}\cdot$x1 - $b1 \) or $ans. +EOT + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setDemo/prob5.pg @@ -0,0 +1,138 @@ +&DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +######################################################### +# allow the student to change the seed for this problem. + +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? ${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); +BEGIN_TEXT +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ MODES( +TeX => qq! Change the problem seed to change the problem:$problemSeed!, +Latex2HTML => qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +HTML => qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} +END_TEXT +######################################################### +# define function to be evaluated +$a= random(1,3,1); +$b= random(-4,4,.1); +$c = random(-4,4,1); +$x0=random(-2,2,1); +$function = FEQ(" ${a}x^2+${b}x +$c "); +sub fp { # define a subroutine to calculate the derivative + my $x = shift; + 2*$a*$x+$b; +} +$ans = fp($x0); +HEADER_TEXT(<<EOF); +<SCRIPT LANGUAGE="JavaScript"> +<!-- This script and many more are available online from --> +<!-- The JavaScript Source!! http://javascriptsource.com --> + +<!-- Begin + +function func(x) { +return( $a*Math.pow(x,2) + $b*x +$c );} + +// End + --> +</SCRIPT> + +EOF + + +TEXT(beginproblem()); +TEXT(MODES( +TeX => '', +Latex2HTML => "\begin{rawhtml} <NOSCRIPT> This problem requires that Java + Script be enabled </NOSCRIPT> \end{rawhtml}", +HTML => "<NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT>" +)); + +BEGIN_TEXT +$PAR +This problem illustrates how you can embed JavaScript code in a WeBWorK example +to create an interactive homework problem that could never be provided by a text book. +$PAR +WeBWorK can use existing $BBOLD JavaScript$EBOLD and $BBOLD Java $EBOLD code to augment its capabilities. +$HR +$PAR +By typing any value x into the left hand window and pressing the --f--\(>\) button +you can determine the value of f(x). +$PAR +Using this 'oracle' function, calculate the derivative of \( f \) at x=$x0. +$PAR +\(f'($x0) =\) \{ans_rule(20) \} You can use a +\{htmlLink(alias('calc.html'), "calculator" ,q!TARGET = "calculator"!) \} + +$PAR +END_TEXT + +$javaScript =<<ENDOFSCRIPT; +<CENTER> +<TABLE BORDER=4> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input1" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output1.value=func(this.form.Input1.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output1" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input2" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output2.value=func(this.form.Input2.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output2" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input3" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output3.value=func(this.form.Input3.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output3" Size="20"> +</TD> +</TR> +</TABLE> + +</CENTER> +ENDOFSCRIPT + +TEXT(M3( + " \fbox{ The java Script calculator was displayed here + }", + "\begin{rawhtml} $javaScript \end{rawhtml}", + $javaScript + )); + + + +ANS(std_num_cmp($ans,1,"%0.14g") ); #We are allowing 1 percent error for the answer. + + +&ENDDOCUMENT; + --- /dev/null +++ courses/modelCourse/templates/setDemo/prob0837.pg @@ -0,0 +1,66 @@ +DOCUMENT(); + +loadMacros( "PGbasicmacros.pl", + "PGauxiliaryFunctions.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PG_CAPAmacros.pl" +); + +TEXT(beginproblem()); + +# machine translated from CAPA. +# This is probaly not a good model for elegant PG code. +## ************************************** +## +## Projectile motion. +## By F. Wolfs, WO...@NS... +## No unauthorized commercial use +## Imported Files +## ${CAPA_Tools}Problem +## ${CAPA_GraphicsDirectory}Gtype08/prob37.eps +## Values needing defined: +## prob_val (number, e.g. /LET prob_val=1) +## prob_try (number, e.g. /LET prob_try=5) +## +## Last modified 07/08/97 +## by: Patrick D. Freivald, pa...@fr... +## +## ************************************** +## +$L = random( 2.0 , 10.0 , 0.2 ) ; +$h = random( 0.5 , 0.5 * $L , 0.1 ) ; +$Theta = random( 35.0 , 60.0 , 1.0 ) ; +$v0_sq = $smallg * $L / ( 2.0 * cos( $Theta * $degrad ) * cos( $Theta * $degrad ) * ( tan( $Theta * $degrad ) - $h / $L ) ) ; +$v0 = pow( $v0_sq , 0.5 ) ; +## +CAPA_import( " ${CAPA_Tools}Problem " ); +TEXT(CAPA_EV (<<'END_OF_TEXT')); +A basketball player throws the ball at a \{ spf( $Theta , "%0.0f" ) \}\{ $deg_u \} angle above the horizontal to a hoop which is located a horizontal distance \{ CAPA_tex( '/*L/*' , 'L' ) \} = \{ spf( $L , "%0.1f" ) \} \{ $m_u \} from the point of release and at a height \{ CAPA_tex( '/*h/*' , 'h' ) \} = \{ spf( $h , "%0.1f" ) \} \{ $m_u \} above it. What is the required speed if the basketball is to reach the hoop? +\{ CAPA_web( '' , '\noindent {\centerline{\epsfxsize = 2.4 in \epsffile{${CAPA_GraphicsDirectory}Gtype08/prob37.eps}}}' , '<img src = ${CAPA_Graphics_URL}Gtype08/prob37.gif align=center width=275>' ) \} +END_OF_TEXT + +## + +TEXT("$BR$BR",ans_rule(30),"$BR"); +ANS( CAPA_ans( $v0 , 'format' => "%0.2e" , 'sig' => '3 PLUS 13', 'reltol' => 1 , 'wgt' => $prob_val , 'tries' => $prob_try , 'unit' => 'm/s' ) ); +ENDDOCUMENT(); +##################### + +###Error: $smallg not defined in this file +###Error: $degrad not defined in this file +###Error: $degrad not defined in this file +###Error: $degrad not defined in this file +###Error: $deg_u not defined in this file +###Error: $m_u not defined in this file +###Error: $m_u not defined in this file +###Error: $prob_val not defined in this file +###Error: $prob_try not defined in this file + +##################### + + +################################################# +## Processing time = 0 secs ( 0.56 usr 0.00 sys = 0.56 cpu) +################################################# --- /dev/null +++ courses/modelCourse/templates/setDemo/limits.pg @@ -0,0 +1,90 @@ +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 1; + +$a=random(-3,3,1); +$b=random(-2,3,1); +$c=random(-3,2,1); +$m1=random(-1,1,0.5); +$m2=($b - $a)/2; +$m3=($c - $b - 1)/2; +$m4=random(-1,1,0.5); +@slice = NchooseK(3,3); + +@colors = ("blue", "red", "green"); +@sc = @colors[@slice]; #scrambled colors +@sa = ('A','B','C')[@slice]; + +$f1 = FEQ("${m1}(x+1) + $a for x in [-2,-1) using color:$sc[0] and weight:2"); +$f2 = FEQ("${m2}(x-1) + $b for x in (-1,1) using color=$sc[0] and weight:2"); +$f3 = FEQ("${m3}(x-3) + $c for x in [1,3) using color=$sc[0] and weight=2"); +$f4 = FEQ("1+$a for x in [-1,-1] using color=$sc[0] and weight=2"); +$f5 = FEQ("${m4}(x-3) + $c for x in (3,4] using color=$sc[0] and weight=2"); + +$graph = init_graph(-3,-6,5,6,'axes'=>[0,0],'grid'=>[8,12]); + +($f1Ref,$f2Ref,$f3Ref,$f4Ref,$f5Ref) = plot_functions($graph,$f1,$f2,$f3,$f4,$f5); + +BEGIN_TEXT +Let F be the function below.$PAR +If you are having a hard time seeing the picture clearly, click on the picture. It will expand to a larger picture on its own page so that you can inspect it more clearly.$PAR +END_TEXT + +TEXT(image( insertGraph($graph), height=>200, width=>200 )); + +BEGIN_TEXT +$BR +$BR +Evaluate each of the following expressions. $PAR +Note: Enter 'DNE' if the limit does not exist or is not defined. $PAR + +a) \( \lim_{x \to -1^-} F(x) \) = \{ans_rule(4)\} +$PAR + +b) \( \lim_{x \to -1^+} F(x) \) = \{ans_rule(4)\} +$PAR + +c) \( \lim_{x \to -1} F(x) \) = \{ans_rule(4)\} +$PAR + +d) \( F(-1) \) = \{ans_rule(4)\} +$PAR + +e) \( \lim_{x \to 1^-} F(x) \) = \{ans_rule(4)\} +$PAR + +f) \( \lim_{x \to 1^+} F(x) \) = \{ans_rule(4)\} +$PAR + +g) \( \lim_{x \to 1} F(x) \) = \{ans_rule(4)\} +$PAR + +h) \( \lim_{x \to 3} F(x) \) = \{ans_rule(4)\} +$PAR + +i) \( F(3) \) = \{ans_rule(4)\} +$PAR + +END_TEXT + +$ap1 = 1 + $a; +$bp1 = 1 + $b; + +# limits at -1 +ANS(num_cmp( [ $a, $a, $a, $ap1] , strings => ['DNE'] )) ; +# limits at 1 +ANS(num_cmp( [ $b, $bp1,'DNE'] , strings => ['DNE'] )) ; +# limits at 3 +ANS(num_cmp( [ $c, 'DNE' ] , strings => ['DNE'] )) ; + + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/paperHeaderFile1.pg @@ -0,0 +1,31 @@ +##Problem set header for set 0, Spring 1999 + +&DOCUMENT; + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + +$dateTime = $formatedDueDate; + +TEXT(EV2(<<EOT)); +$BEGIN_ONE_COLUMN +\noindent {\large \bf $studentName} +\hfill +\noindent {\large \bf MAA Minicourse San Diego January 2002} +\par +\noindent{\large \bf Homework Set $setNumber due $dateTime}\par + +\noindent This is a demonstration set designed to show you some types of questions +that can be asked using WeBWorK. + +\par +\noindent You may need to give 4 or 5 significant digits for some (floating point) +numerical answers in order to have them accepted by the computer. +$END_ONE_COLUMN +EOT + +&ENDDOCUMENT; --- /dev/null +++ courses/modelCourse/templates/setDemo/liteApplet1.pg @@ -0,0 +1,68 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + +# The link to the java applet is hard wired to use the java applet +# served from the University of Rochester WeBWorK machine. +# It is possible to set this up so that the java applet is served +# from any machine +# For details use the Feedback button to contact the authors of WeBWorK + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +$appletText = +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + my $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion* sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} + +$kandahar = [132,101]; +$kabul = [209,185]; +$mazur_e_sharif = [170, 243]; +$shindand = [46, 155]; + +$questions = EV3( +"$PAR How far is it from Kandahar to Kabul? " , ans_rule(30), +" $PAR How far is it from Kabul to Mazar-e-Sharif? ", ans_rule(30), +" $PAR How far is it from Kandahar to Shindand? " , ans_rule(30), +); +#TEXT( +#begintable(2), +#row( $appletText, $questions), +#endtable() +#); +TEXT($appletText, $questions); +ANS(num_cmp(dist($kandahar,$kabul), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kabul, $mazur_e_sharif), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kandahar,$shindand), reltol => 3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setDemo/sample_units_ans.pg @@ -0,0 +1,41 @@ +DOCUMENT(); +loadMacros( "PGbasicmacros.pl", + "PGauxiliaryFunctions.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +TEXT(beginproblem()); + +$showPartialCorrectAnswers = 1; +$showHint =0; + +$fx = random( 2.1, 6.0 , 0.1) ; +$fy = random( 3.1, 8.0 , 0.1) ; +$ansxy = sqrt($fx * $fx + $fy * $fy); +$anscm = $ansxy*100; + +BEGIN_TEXT +This problem demonstrates how WeBWorK handles +numerical answers involving units. WeBWorK can handle all units that +are used in elementary physics courses. +See \{ htmlLink("http://webwork.math.rochester.edu/spring00-phy121/help_units.html","answers with units") \} +for more details. $PAR + +Two perpendicular sides of a triangle are $fx m and +$fy m long respectively. +What is the length of the third side of the triangle? $BR$BR +You can answer this in terms of m's, cm's, km's, in's, ft, etc. but you must enter the units. $BR$BR +Check "Show Hint" and then "Submit Answer" if you don't remember the Pythagorean theorem. +END_TEXT + +HINT(EV3(<<'EOT')); +Remembering the Pythagorean theorem \( A^2 +B^2 = C^2 \), you can enter +sqrt($fx^2 + $fy^2) m or \{spf($ansxy, "%0.2f" )\} m or \{spf($anscm, "%0.2f" )\} cm or ... +EOT + +BEGIN_TEXT +\{ans_rule(40) \} +END_TEXT +ANS(num_cmp("$ansxy", units => 'm')); +ENDDOCUMENT() --- /dev/null +++ courses/modelCourse/templates/setDemo/srw1_9_4.pg @@ -0,0 +1,112 @@ +##DESCRIPTION +## find distance between two points, find coordinates of the midpoint of +## a line segment connecting them +##ENDDESCRIPTION + +##KEYWORDS('algebra', 'coordinate geometry', 'distance', 'midpoint') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGauxiliaryFunctions.pl" +); + +TEXT(&beginproblem); + +$showPartialCorrectAnswers = 1; + +#install_problem_grader(~~&std_problem_grader); ##uncomment to use std grader +#install_problem_grader(~~&custom_problem_grader); ##uncomment to use custom grader + + +$x1 = random(1,5,1); +$y1 = random(-5,-1,1); +$x2 = random(-10,-3,1); +$y2 = random(-9,-2,1); +$len1 = sqrt(($x1-$x2)**2 + ($y1-$y2)**2); +$midx = ($x1+$x2)/2; +$midy = ($y1+$y2)/2; + +BEGIN_TEXT +Consider the two points \( ($x1 ,$y1 )\) and \( ($x2 ,$y2 )\). +The distance between them is:$BR +\{ans_rule(30) \} +$BR +END_TEXT + +$ans = $len1; +&ANS(std_num_cmp($ans)); + +BEGIN_TEXT +The x co-ordinate of the midpoint of the line +segment that joins them is:\{ans_rule(20) \} +$BR +END_TEXT +$ans = $midx; +&ANS(std_num_cmp($ans)); + +BEGIN_TEXT +The y co-ordinate of the midpoint of the line segment that joins them is: +\{ans_rule(20) \} +$BR +END_TEXT +$ans = $midy; +&ANS(std_num_cmp($ans)); + + +sub custom_problem_grader { + my $rh_evaluated_answers = shift; + my $rh_problem_state = shift; + my %form_options = @_; + my %evaluated_answers = %{$rh_evaluated_answers}; + # The hash $rh_evaluated_answers typically contains: + # 'answer1' => 34, 'answer2'=> 'Mozart', etc. + + # By default the old problem state is simply passed back out again. + my %problem_state = %$rh_problem_state; + + + # %form_options might include + # The user login name + # The permission level of the user + # The studentLogin name for this psvn. + # Whether the form is asking for a refresh or is submitting a new answer. + + # initial setup of the answer + my $total=0; + my %problem_result = ( score => 0, + errors => '', + type => 'custom_problem_grader', + msg => 'Part 1 is worth 50% and parts 2 and 3 are worth 25% each.', + ); + + # Return unless answers have been submitted + unless ($form_options{answers_submitted} == 1) { + return(~~%problem_result,~~%problem_state); + } + # Answers have been submitted -- process them. + + $total += .5*($evaluated_answers{'AnSwEr1'}->{score}); + $total += .25*($evaluated_answers{'AnSwEr2'}->{score}); + $total += .25*($evaluated_answers{'AnSwEr3'}->{score}); + + + $problem_result{score} = $total; + # increase recorded score if the current score is greater. + $problem_state{recorded_score} = $problem_result{score} if $problem_result{score} > $problem_state{recorded_score}; + + + $problem_state{num_of_correct_ans}++ if $total == 1; + $problem_state{num_of_incorrect_ans}++ if $total < 1 ; + (~~%problem_result, ~~%problem_state); + +} + + +ENDDOCUMENT(); # This should be the last executable line in the problem. + + --- /dev/null +++ courses/modelCourse/templates/setDemo/liteApplet2.pg @@ -0,0 +1,74 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +TEXT( +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +), +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion * sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} +@cities = ( + { name => 'Kandahar', location => [132,101] }, + { name => 'Kabul', location => [209,185] }, + { name => 'Mazur e Sharif', location => [170, 243] }, + { name => 'Shindand', location => [46, 155] }, + { name => 'Zaranj', location => [39, 93] } +); +@index = NchooseK(scalar(@cities), 3 ); +sub cityName { + my $index = shift ; + $cities[$index -1]->{name}; +} +sub cityLoc { + my $index = shift; + $cities[$index-1]->{location}; +} + +$conversion = 300 /(145 - 72); # number of km per pixel +BEGIN_TEXT +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[2])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[2])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +END_TEXT + +ANS(num_cmp(dist(cityLoc($index[1]),cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]), cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]),cityLoc($index[2])), reltol=>3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:43:57
|
Log Message: ----------- adding more files to make modelCourse conform with hosted.webwork version Added Files: ----------- webwork2/courses/modelCourse/templates/setMAAtutorial/htmllinksexample: 1-24438.gif 1-31126.gif 1-34859.gif 1-42639.gif 1-76239.gif 1-89540.gif 1-91734.gif 1-96355.gif 1.gif 2-42653.gif 2-49261.gif 2-54427.gif 2-62384.gif 2-64591.gif 2-70190.gif 2-81779.gif 2-92879.gif 2.gif 3-14197.gif 3-14538.gif 3-37616.gif 3-46739.gif 3-52898.gif 3-68458.gif 3-89262.gif 3-99389.gif 3.gif htmllinksexample.pg webwork2/courses/modelCourse/templates/setMAAtutorial/staticgraphicsexample: 1-24438.gif 1-24438.png 1-31126.gif 1-31126.png 1-34859.gif 1-34859.png 1-42639.gif 1-42639.png 1-76239.gif 1-76239.png 1-89540.gif 1-89540.png 1-91734.gif 1-91734.png 1-96355.gif 1-96355.png 1.gif 1.png 2-42653.gif 2-42653.png 2-49261.gif 2-49261.png 2-54427.gif 2-54427.png 2-62384.gif 2-62384.png 2-64591.gif 2-64591.png 2-68458.png 2-68458.pnm 2-70190.gif 2-70190.png 2-81779.gif 2-81779.png 2-92879.gif 2-92879.png 2.gif 2.png 3-14197.gif 3-14197.png 3-14538.gif 3-14538.png 3-37616.gif 3-37616.png 3-46739.gif 3-46739.png 3-52898.gif 3-52898.png 3-68458.gif 3-68458.png 3-89262.gif 3-89262.png 3-99389.gif 3-99389.png 3.gif 3.png staticgraphicsexample.pg tmp Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/htmllinksexample/htmllinksexample.pg @@ -0,0 +1,80 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); +$showPartialCorrectAnswers = 0; + +TEXT(beginproblem(), $BR,$BBOLD, "HTML links example", $EBOLD, $BR,$BR); + +BEGIN_TEXT +This example shows how to link to resources outside the problem itself. +$PAR +Linking to other web pages over the internet is easy. For example, +you can get more information about the buffon needle problem and how it is used by ants to find new nest sites by linking to + \{ htmlLink("http://www.maa.org/mathland/mathtrek_5_15_00.html", + "Ivars Peterson's column on the MAA site") \}. +$PAR +END_TEXT + +# You can write the HTML code yourself, but +# that will look funny when the problem is printed in +# hard copy, so it is probably better to use the +# htmlLink('url','text') function which +# will create something readable when the problem is printed. + +BEGIN_TEXT +All of the files in the html directory of your WeBWorK course site can be read +by anyone with a web browser and the URL (the address of the file). This is a good +place to put files that are referenced by more than one problem in your WeBWorK course. +$PAR +Here is the link to +the +\{ htmlLink(alias("${htmlDirectory}calc.html"), + 'to the calculator page', + qq!target="ww_calculator" + ONCLICK="window.open( this.href, this.target, + 'width=250,height=350,scrollbars=no,resizable=off' + )" +!) \} +stored in the top level of the +html directory of the tutorialCourse. +$PAR +END_TEXT + +# To link to files on your own computer use the alias function whose +# job it is to find the file in question. +# You need to do this access indirectly, because WeBWorK is set up to +# restrict access to most files -- (you don't want everyone reading +# the source text of the WeBWorK problems, they could reconstruct the answer.) +# +# Note that you need double quotes around "${htmlDirectory}calc.html" so that +# the string in $htmlDirectory will be +# concatenated with calc.html to form a string describing +# the DIRECTORY in which the file is to be found. Alias converts +# the directory to a URL + +BEGIN_TEXT +Finally there are files, such as picture files, which are +stored with the problem itself in the same directory. + $BR \{ image("2-70190.gif", width=>200, height=>200) \} + +END_TEXT + +# Image automatically uses alias +# to search for files. + +BEGIN_TEXT +$PAR +And the table below has three more graphs which are stored +in the directory containing the current problem. $PAR +END_TEXT + +TEXT( + begintable(3), + row( image( [ ( '1-24438.gif', '2-49261.gif', '3-37616.gif') ], + tex_size=>200, width=>200, height=>200 )), + endtable() +); + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/staticgraphicsexample/tmp @@ -0,0 +1,3 @@ +#!/usr/bin/csh + +cat $1 | giftopnm | pnmtopng >$2 --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/staticgraphicsexample/staticgraphicsexample.pg @@ -0,0 +1,115 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); +TEXT($BEGIN_ONE_COLUMN); +TEXT(beginproblem(), $BR,$BBOLD, "Static graphics Example", $EBOLD, $BR,$BR); + +$showPartialCorrectAnswers = 0; +# Define which of the three sets of pictures to use + +# The pictures are labeled 1.png, 2.png and 3.png and +# stored in the same directory as staticgraphicsexample.png +# These are the corresponding transformed pictures. +# Be careful with the labeling, since the URL's could give the +# correct answers away. +# (In this example the middle integer tells you +# the correct position.) + +$pictID[1] = [ +"1-31126.png", # "\( F(x+3)\)", +"1-76239.png", # "\(F(x-3) \)" , +"1-96355.png", # "\( -F(-x)\)", +"1-24438.png", # "\( F(-x) \)", +"1-89540.png", # "\( 5F(x) \)", +"1-42639.png", # "\( F(3x) \)" , +"1-91734.png", # "\( F(x/3) \)", +"1-34859.png", # "\( F(x^2) \)", +]; +$pictID[2] = [ +"2-70190.png", # ditto +"2-49261.png", +"2-62384.png", +"2-54427.png", +"2-64591.png", +"2-42653.png", +"2-81779.png", +"2-92879.png", +]; +$pictID[3] = [ +"3-14197.png", +"3-89262.png", +"3-99389.png", +"3-68458.png", +"3-14538.png", +"3-37616.png", +"3-46739.png", +"3-52898.png", +]; +$ml = new_match_list(); + +$pictSet=random(1,3,1); # Choose one of the three picture sets +$pictSet=1; +$pictSetname = $pictSet.".png"; +$ml->qa ( +"\( F(x+3)\) ", +image($pictID[$pictSet][0],tex_size=>200), +"\(F(x-3) \)" , +image($pictID[$pictSet][1],tex_size=>200), +"\( -F(-x)\) ", +image($pictID[$pictSet][2],tex_size=>200), +"\( F(-x) \)", +image($pictID[$pictSet][3],tex_size=>200), +"\( 5F(x) \)", +image($pictID[$pictSet][4],tex_size=>200), +"\( F(3x) \)" , +image($pictID[$pictSet][5],tex_size=>200), +"\( F(x/3) \)", +image($pictID[$pictSet][6],tex_size=>200), +"\( F(x^2) \)", +image($pictID[$pictSet][7],tex_size=>200), +); + +$ml->choose(4); +sub format_graphs { + my $self = shift; + my @in = @_; + my $out = ""; + while(@in) { + $out .= shift(@in). "#" ; + } + $out; # The output has to be a string in order to conform to the + # specs for the match list object, but I've put some + # markers in (#) so that + # I can break the string up into a list for use + # as an input into row. +} + +# We need to change the output, since the normal +# output routine will put the pictures one above another. +$ml->rf_print_a(~~&format_graphs); + +BEGIN_TEXT +This is a graph of the function \( F(x) \): +($BBOLD Click on image for a larger view $EBOLD) +$PAR +\{ image($pictSetname, tex_size => 200) \} +$PAR +Enter the letter of the graph below which corresponds to the transformation +of the function. +\{ $ml -> print_q \} +END_TEXT + +# Place the output into a table +TEXT( + begintable(4), + row( split("#",$ml->print_a() ) ), + row('A', 'B', 'C', 'D' ), + endtable(), +); + +ANS( str_cmp( $ml ->ra_correct_ans() ) ) ; + +TEXT($END_ONE_COLUMN); +ENDDOCUMENT(); \ No newline at end of file |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:42:26
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial/staticgraphicsexample In directory devel.webwork.rochester.edu:/tmp/cvs-serv48449/staticgraphicsexample Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial/staticgraphicsexample added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:42:04
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial/htmllinksexample In directory devel.webwork.rochester.edu:/tmp/cvs-serv48376/htmllinksexample Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial/htmllinksexample added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:41:26
|
Log Message: ----------- updating modelCourse to conform to hosted.webwork Added Files: ----------- webwork2/courses/modelCourse/templates/setMAAtutorial: MAAtutorialSetHeader.pg conditionalquestionexample.pg hello.pg hermitegraphexample.pg javaappletexample.pg javascriptexample1.pg javascriptexample2.pg liteApplet1.pg liteApplet2.pg matchinglistexample.pg multiplechoiceexample.pg ontheflygraphicsexample1.pg ontheflygraphicsexample2.pg paperHeader.pg popuplistexample.pg prob3.pg prob4.pg screenHeader.pg simple_drawing.pg simplemultiplechoiceexample.pg standardexample.pg truefalseexample.pg vectorfieldexample.pg Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/standardexample.pg @@ -0,0 +1,47 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGauxiliaryFunctions.pl" +); + +TEXT(beginproblem(), $BR,$BBOLD, "Standard Example", $EBOLD, $BR,$BR); + +# A question requiring a string answer. +$str = 'world'; +#$str = "Dolly"; +BEGIN_TEXT +Complete the sentence: $BR +\{ ans_rule(20) \} $str; +$PAR +END_TEXT + +ANS( str_cmp( "Hello") ); + +# A question requiring a numerical answer. +#define the variables +$a = 3; +$b = 5; +#$a=random(1,9,1); +#$b=random(2,9,1); + +BEGIN_TEXT +Enter the sum of these two numbers: $BR + \($a + $b = \) \{ans_rule(10) \} +$PAR +END_TEXT + +$sum = $a + $b; +ANS( num_cmp( $sum ) ); + +# A question requiring an expression as an answwer +BEGIN_TEXT +Enter the derivative of \[ f(x) = x^{$b} \] $BR +\(f '(x) = \) \{ ans_rule(30) \} +$PAR +END_TEXT +$new_exponent = $b-1; +$ans2 = "$b*x^($new_exponent)"; +ANS( fun_cmp( $ans2 ) ); +ENDDOCUMENT(); + \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/javascriptexample1.pg @@ -0,0 +1,146 @@ +DOCUMENT(); + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +TEXT(beginproblem(), $BR,$BBOLD, "JavaScript Example 1", $EBOLD, $BR,$BR); +# define function to be evaluated +$a= random(1,3,1); +$b= random(-4,4,.1); +$c = random(-4,4,1); +$x0=random(-2,2,1); + +# function = ${a}x^2+${b}x +${c} +# This is just to provide the correct answer. +# This function will be defined for javaScript below. +sub fp { # define a perl subroutine to calculate the derivative + my $x = shift; + 2*$a*$x+$b; +} +$ans = fp($x0); + +## This text will be placed in the header section of the HTML page +## not in the body where TEXT output is placed. +## Not processing is done. + +HEADER_TEXT(<<EOF); +<SCRIPT LANGUAGE="JavaScript"> +<!-- Begin + +function func(x) { +return( $a*Math.pow(x,2) + $b*x +$c );} + // We redefine the function for the javaScript + // A savy student will be able to tell to read this + // by looking at the HTML source of their window. + // Later we'll see other methods that make this + // difficult or impossible. + +// End + --> +</SCRIPT> + +EOF + +TEXT(beginproblem()); +TEXT(MODES( TeX => "", + Latex2HTML => "\begin{rawhtml} + <NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT> ~~n\end{rawhtml} + ", + HTML_tth => "<NOSCRIPT> This problem requires that javaScript be enabled + </NOSCRIPT>~~n", + HTML => "<NOSCRIPT> This problem requires that javaScript be enabled + </NOSCRIPT>~~n" +)); + +$functionArrow = MODES( + TeX => "\(- f\rightarrow\)", + Latex2HTML => "\(- f\rightarrow \) ", + HTML_tth => "-- f -- > ", + HTML => '-- f -- > ' +); + +# The following string contains a combination of HTML and javaScript +# which displays the input table for the javaScript calculator + +$javaScript =<<ENDOFSCRIPT; +<CENTER> +<TABLE BORDER=4> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input1" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output1.value=func(this.form.Input1.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output1" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input2" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output2.value=func(this.form.Input2.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output2" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input3" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output3.value=func(this.form.Input3.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output3" Size="20"> +</TD> +</TR> +</TABLE> + +</CENTER> +ENDOFSCRIPT + + + +BEGIN_TEXT + +Find the derivative of the function f(x). The windows below will tell +you the value of f for any input x. (I call this an "oracle function", since +if you ask, it will tell.) +$PAR +\(f '( $x0 ) \) = \{ans_rule(50 ) \} +$PAR +You may want to use a +\{ htmlLink(alias("${htmlDirectory}calc.html"), + 'calculator', + qq! TARGET = "ww_calculator" + ONCLICK="window.open( this.href,this.target, + 'width=200, height=350, scrollbars=no, resizable=off' + )" +!) \} + +to find the result. + You can also enter numerical expressions and have + WeBWorK do the calculations for you. +END_TEXT + +# Here is where we actually print the javaScript, or alternatives for printed output. + +TEXT(MODES( + TeX => " \fbox{ The java Script calculator was displayed here + }", + HTML => $javaScript, + )); + +ANS(num_cmp($ans,reltol => 1) ); #We are allowing 1 percent error for the answer. + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/MAAtutorialSetHeader.pg @@ -0,0 +1,106 @@ +DOCUMENT(); + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); + +TEXT($BEGIN_ONE_COLUMN); + +TEXT(MODES(TeX =>EV3(<<'EOT'), HTML=>"", Latex2HTML=>"" )); +\noindent {\large \bf $studentName} +\hfill +\noindent {\large \bf MAA Minicourse New Orleans January 2001} +\par +\noindent WeBWorK assignment number \{ protect_underbar($setNumber) \} due $formattedDueDate;. +\hrule +EOT + + +################## +# EDIT BELOW HERE +################## + +BEGIN_TEXT +$BR +$BR +Welcome to the MAA short course on $BBOLD WeBWorK $EBOLD. +$PAR +Here is a synopsis of the tutorial examples presented in this set. They have been designed for learning the PG language, and are not necessarily the best questions to use for mathematics instruction. +$PAR +$BBOLD 1. Hello world example: $EBOLD Illustrates the basic structure of a PG problem. +$PAR +$BBOLD 2. Standard example: $EBOLD This covers what you need to know to ask the majority of the questions you would want to ask in a calculus course. Problems with text answers, numerical answers and answers involving expressions are covered. +$PAR +$BBOLD 3. Simple multiple choice example: $EBOLD Uses lists(arrays) to implement a multiple choice question. +$PAR +$BBOLD 4. Multiple choice example: $EBOLD Uses the multiple choice object to implement a multiple choice question. +$PAR +$BBOLD 5. Matching list example: $EBOLD +$PAR +$BBOLD 6. True/false example: $EBOLD +$PAR +$BBOLD 7. Pop-up true/false example: $EBOLD Answers are chosen from a pop-up list. +$PAR +$BBOLD 8. On-the-fly graphics example 1: $EBOLD The graphs are regenerated each time you press the submit button +$PAR +$BBOLD 9. On-the-fly-graphics example 2: $EBOLD -- Adds some randomization to the first example. +$PAR +$BBOLD 10. Static graphics example: $EBOLD Presents graphs created on a separate application (e.g. Mathematica) and saved. +$PAR +$BBOLD 11. Hermite graph example: $EBOLD A particularly useful way of generating predictable graphs by specifying the value and first derivative of a function at each point. Piecewise linear graphs are also included in this example. +$PAR +$BBOLD 12. HTML links example: $EBOLD Shows how to link other web resources to your WeBWorK problem. +$PAR +$BBOLD 13. JavaScript example 1: $EBOLD An example which takes advantage of this interactive media! This one requires students to calculate the derivative of a function from the definition. +$PAR +$BBOLD 14. JavaScript example 2: $EBOLD A variant of the previous example that generates the example function as a cubic spline so that students can't read the javaScript code to find out the answer. +$PAR +$BBOLD 15. Vector field example $EBOLD Generates vector field graphs on-the-fly. +$PAR +$BBOLD 16. Conditional question example: $EBOLD Illustrates how you can create a problem which first asks an easy question, and once that has been answered correctly, follows up with a more involved question on the same material. +$PAR +$BBOLD 17 Java applet example: $EBOLD A preliminary example of how to include Java applets in WeBWorK problems. +$HR +END_TEXT + +################## +# EDIT ABOVE HERE +################## +BEGIN_TEXT +The primary purpose of WeBWorK is to let you know if you are getting the right answer or to alert +you if you get the wrong answer. Usually you can attempt a problem as many times as you want before +the due date. However, if you are having trouble figuring out your error, you should +consult the book, or ask a fellow student, one of the TA's or +your professor for help. Don't spend a lot of time guessing -- it's not very efficient or effective. +The computer has NO CLUE about WHY your answer is wrong. Computers are good at checking, +but for help go to a human. + +$PAR +Give 4 or 5 significant digits for (floating point) numerical answers. +For most problems when entering numerical answers, you can if you wish +enter elementary expressions such as \( 2\wedge3 \) instead of 8, \( sin(3*pi/2) \)instead +of -1, \( e\wedge (ln(2)) \) instead of 2, +\( (2+tan(3))*(4-sin(5))\wedge6-7/8 \) instead of 27620.3413, etc. + Here's the +\{ htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list of the functions") \} + which WeBWorK understands. +$PAR +You can use the Feedback button on each problem +page to send e-mail to the professors. + + +$END_ONE_COLUMN +END_TEXT +#<<<######################################################## +BEGIN_TEXT +$HR +You can view the +\{ htmlLink(sourceAlias("links/set$setNumber/MAAtutorialSetHeader.html"), + "source", q!TARGET="source"!)\} +for this header file. +END_TEXT +#########################################################>>> +ENDDOCUMENT(); # This should be the last executable line in the problem. + --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/hermitegraphexample.pg @@ -0,0 +1,126 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGnumericalmacros.pl", + "PGgraphmacros.pl" +); +TEXT($BEGIN_ONE_COLUMN); +TEXT(beginproblem(), $BR,$BBOLD, "Hermite polynomial graph example", $EBOLD, $BR,$BR); +$showPartialAnswers = 1; + +$graph = init_graph(-5,-5,5,5,'axes'=>[0,0],'grid'=>[10,10]); + +my (@x_values1, @y_values1); +foreach $i (0..10) { + $x_values1[$i] =$i-5; + $y_values1[$i] = random(-4,4,1); +} + +# creates a reference to a perl subroutine for the piecewise linear function +# passing through the defined points +$fun_rule = plot_list(~~@x_values1, ~~@y_values1); + +#new function is to be plotted in graph +$f1=new Fun($fun_rule, $graph); +$f1->color('black'); + +$trans = non_zero_random(-2,2,1); +# add a new function to the graph which is a translate of the first +$fun_rule2 = sub{ my $x = shift; &$fun_rule($x-$trans) }; +$f2 = new Fun($fun_rule2, $graph); +$f2->color('orange'); + +$graph->stamps(open_circle(-1,&$fun_rule(-1),'black') ); +# indicates open interval at the left endpoint +$graph->stamps(closed_circle(4,&$fun_rule(4), 'black') ); +# and a closed interval at the right endpoint +# Be careful about getting the stamps properly located on the translated +# function below: +$graph->stamps(open_circle(-1 + $trans, &$fun_rule(-1),'orange') ); +# indicates open interval at the left endpoint +$graph->stamps(closed_circle(4 +$trans, &$fun_rule(4), 'orange') ); +# and a closed interval at the right endpoint + +$graph2 = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]); +$b1= random(-3.5,3.5,.5); +$b2= random(-3.5,3.5,.5); +$b3= random(-3.5,3.5,.5); +@x_val3 = (-4,-3,-2,-1, 0, 1, 2, 3, 4 ); +@y_val3 = ( 0, 1, 2, 0,$b1, $b2, $b3, 1, 2 ); +@yp_val3= ( .1, 1, 0,-2, 0, 1, 2, -3, 1 ); +$hermite = new Hermite( + ~~@x_val3, # x values + ~~@y_val3, # y values + ~~@yp_val3 # y prime values + ); +$spline_rule = $hermite->rf_f; +$f3 = new Fun($spline_rule, $graph2); +$f3->color('green'); +$graph2->stamps(closed_circle(-4, &$spline_rule(-4), 'green') ) ; +$graph2->stamps(closed_circle( 4, &$spline_rule( 4), 'green') ) ; + +# Insert the graphs and the text. +BEGIN_TEXT + +$PAR +We have developed other ways to specify graphs which are to be created 'on the fly'. +All of these new methods consist of adding macro packages to WeBWorK. Since they +do not require the core of WeBWorK to be changed, these enhancements can be added by +anyone using WeBWorK. +$PAR + These two piecewise linear graphs were created by specifying the points at the nodes. + $BR Click on the graph to view a larger image. +$PAR +\{ image(insertGraph($graph),tex_size => 300, width=> 300, height=> 300 ) \} +$HR +If the black function is written as \(f(x)\), then the orange function +would be written as \( f( \) \{ ans_rule \} \( ) \). +\{ANS(function_cmp("x-$trans")),'' \} +END_TEXT +# $PAR +# The numerical calculations were all written in Perl using +# numerical routines adapted from the Numerical Analysis book by Burden and Faires. +# $BR +# We are also working on a macro which will automatically +# identify the maximum, minimum and inflection points of an arbitary hermite +# cubic spline from its specifying values. This will allow automatic generation +# of problems in which the maximum, minimum and inflection points are to be +# deduced from a graph. +# +# Get the internal local maximums +@critical_points = keys %{$hermite->rh_critical_points}; +@critical_points = num_sort( @critical_points); +@minimum_points = (); +foreach my $x (@critical_points) { + push(@minimum_points, $x) if &{$hermite->rf_fpp}($x) >0 ; +} +# TEXT(pretty_print(~~@minimum_points)); # (for debugging purposes) +$answer_string = ""; +foreach my $x (@minimum_points) { + $answer_string .= EV2(' \{ ans_rule(10) \} '); +} + +BEGIN_TEXT +$HR +This graph was created using a hermite spline by specifying points at + +\{ begintable(1+scalar( @x_val3 ) ) \} +\{ row('x', @x_val3)\} +\{ row('y', @y_val3) \} +\{ row('yp',@yp_val3) \} +\{endtable() \} + +$PAR +\{ begintable(2) \} +\{row( image(insertGraph($graph2), tex_size => 300,width=>300, height=> 300), + "List the internal local minimum points $BR in increasing order: $BR $answer_string" + ) \} +\{ endtable() \} + +$PAR +END_TEXT +ANS(num_cmp([ @minimum_points ], tol => .3)); + +TEXT($END_ONE_COLUMN); +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/prob4.pg @@ -0,0 +1,95 @@ +#<PRE> +#Description +# Testing knowledge of differentiation rules +#EndDescription + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PGnumericalmacros.pl" + ); + +TEXT(&beginproblem); +$showPartialCorrectAnswers = 0; + + + +# allow the student to change the seed for this problem. +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? ${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); +BEGIN_TEXT + +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ M3( +qq! Change the problem seed to change the problem:$problemSeed!, +qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} + +$HR +END_TEXT + +######################################################################## +# Make a new select list +$ml = new_select_list(); +#$ml -> rf_print_q(~~&my_print_q); +# New versions using the macros in PGchoicemacros.pl +$ml->rf_print_q(~~&pop_up_list_print_q); +$ml -> ra_pop_up_list([ No_answer => " ?",SR => "Sum Rule",PR => "Product Rule",CR => "Chain rule",QR => "Quotient rule" ] ); + + +$ml -> qa ( +"\( (f(x) + g(x) )' = f'(x) + g'(x) \)", +"SR", +"\( ( f(x)g(x) )' = f'(x)g(x) + f(x)g'(x) \)", +"PR", +"\( ( f(g(x)) )' = f'(g(x))g'(x) \) ", +"CR", +"\( \frac{d}{dx} \sin(\cos(x)) = - \cos(\cos(x))\sin(x) \)", +"CR", +"\( (f(x) - g(x) )' = f'(x) - g'(x) \)", +"SR", +); + +$ml ->choose(5); + +#coda + + + + +BEGIN_TEXT + $PAR + +For each example below, list the label of the differentiation rule used in that example: $BR + +\{ $ml -> print_q \} + +$PAR +You can view the +\{ htmlLink(alias("${htmlDirectory}links/setDerivativeRules/prob2.html"), "source",q!TARGET="source"!) \} +for this problem. +or consult the +\{ htmlLink("/webwork_system_html/docs/techdescription/pglanguage/index.html","documentation") \} for more details on the PG language. + +END_TEXT + +install_problem_grader(~~&std_problem_grader); + +ANS( str_cmp( $ml->ra_correct_ans ) ) ; + +BEGIN_TEXT +$PAR +There are only a few examples in this problem. A production verison +would need more examples to choose from. +END_TEXT +ENDDOCUMENT(); # This should be the last executable line in the problem. +#</PRE> --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/matchinglistexample.pg @@ -0,0 +1,129 @@ +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + ); + + +TEXT(beginproblem(), $BR,$BBOLD, "Matching list example", $EBOLD, $BR,$BR); + + +# Since this is a matching question, we do not usually wish to tell students +# which parts of the matching question have been answered correctly and which +# areincorrect. That is too easy. To accomplish this we set the following +# flag to zero. +$showPartialCorrectAnswers = 0; + +# Make a new match list +$ml = new_match_list(); +# enter questions and matching answers +$ml -> qa ( + "\( \sin(x) \)", # Notice the use of the LateX construction + "\( \cos(x) \)", # for math mode: \\( ... \\) and the use of TeX + "\( \cos(x) \)", # symbols such as \\sin and \\tan. + "\( -\sin(x) \)", + "\( \tan(x) \)", + "\( \sec^2(x) \)", # Remember that in these strings we are + # only specifying typography,via TeX, + "\( x^{20} \)", #not any calculational rules. + "\( 20x^{19} \)", + "\( \sin(2x) \)", + "\( 2\cos(2x) \)", + "\( \sin(3x) \)", + "\( 3\cos(3x) \)" +); + + +# Calculate coefficients for another question +$b=random(2,5); +$exp= random(2,5); +$coeff=$b*$exp; +$new_exp = $exp-1; + +# Store the question and answers in the match list object. +$ml -> qa ( + '\( ${b}x^$exp \)', + '\( ${coeff}x^{$new_exp} \)', +); + +# Add another example +$b2=random(2,5); +$exp2= random(2,5); +$coeff2=$b2*$exp; +$new_exp2 = $exp-1; +$ml -> qa ( + "\( ${b2}x^$exp2 \)", + "\( ${coeff2}x^{$new_exp2} \)", +); + +# Choose four of the question and answer pairs at random. +$ml ->choose(4); +# Using choose(8) would choose all eight questions, +# but the order of the questions and answers would be +# scrambled. + +# The following code is needed to make the enumeration work right within tables +# when LaTeX output is being used. +# It is an example of the powerful tools of TeX and perl which are available +# for each PG problem author. +# Once we figure out the best way to protect enumerated lists automatically +# we will include it in the tables macro. Meantime, it is better to have +# have to do it by hand, rather than to have the wrong thing done automatically. + +$BSPACING = MODES( TeX => '\hbox to .5\linewidth {\hspace{0.5cm}\vbox {', + HTML =>' ', + Latex2HTML => ' ' +); +$ESPACING = MODES(TeX => '}}', HTML =>'', Latex2HTML => ''); +sub protect_enumerated_lists { + my @in = @_; + my @out = (); + foreach my $item (@in) { + push(@out, $BSPACING . $item . $ESPACING); + } + @out; +} +# End of code for protecting enumerated lists in TeX. + +# Now print the text using $ml->print_q for +# the questions and $ml->print_a to print the answers. + +BEGIN_TEXT +$PAR + +Place the letter of the derivative next to each function listed below: $BR +\{ $ml -> print_q \} +$PAR +\{$ml -> print_a \} +$PAR +END_TEXT + +ANS( str_cmp( $ml->ra_correct_ans ) ) ; +# insist that the first two questions (labeled 0 and 1) are always included +$ml ->choose([0,1],1); +BEGIN_TEXT +Let's print the questions again, but insist that the +first two questions (about sin and cos) always be included. +Here is a second way to format this question, using tables: +$PAR +\{begintable(2)\} +\{row(protect_enumerated_lists( $ml->print_q, $ml -> print_a) )\} +\{endtable()\} +$PAR +And below is yet another way to enter a table of questions and answers: +$PAR +END_TEXT +ANS( str_cmp( $ml->ra_correct_ans ) ) ; +# Finally add a last answer +$ml ->makeLast("The derivative is $BR not provided"); +BEGIN_TEXT + \{ begintable(2) \} + \{ row( protect_enumerated_lists($ml->print_q, $ml ->print_a))\} + \{endtable()\} +END_TEXT +# Enter the correct answers to be checked against the answers to the students. +ANS( str_cmp( $ml->ra_correct_ans ) ) ; + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/javascriptexample2.pg @@ -0,0 +1,154 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGnumericalmacros.pl", # needed for the javaScript spline code + ); +TEXT(beginproblem(), $BR,$BBOLD, "JavaScript Example 2", $EBOLD, $BR,$BR); + +# define function to be evaluated +$a= random(1,3,1); +$b= random(-4,4,.1); +$c = random(-4,4,1); +$x0=random(-2,2,1); + +# function = ${a}x^2+${b}x +${c}sin(x) +# This is just to provide the correct answer. +# This function will be defined for javaScript below. +sub fp { # define a perl subroutine to calculate the derivative + my $x = shift; + 2*$a*$x+$b; +} +$ans = fp($x0); + +# approximate the function by a cubic spline +sub fun{ + my $x = shift; + ${a}*$x**2+$b*$x +$c; +} +@x = (); +@y = (); +for ( $x1 = -3; $x1<3; $x1 = $x1+.1) { + push(@x, $x1); + push(@y, fun($x1) ); +} +#warn join(" ", @x) ; # test the calculation of the data points +#warn join(" ", @y) ; +$javascript= javaScript_cubic_spline(~~@x, ~~@y, name =>'func'); + +#$javascript =~s/</\</g; # make the script visible for debugging +#warn "script=$javascript" ; # check that the script was created + + + +## This text will be placed in the header section of the HTML page +## not in the body where TEXT output is placed. +## Not processing is done. + +HEADER_TEXT( javaScript_cubic_spline(~~@x, ~~@y, name =>'func') ); + + +TEXT(beginproblem()); +TEXT(MODES( TeX => "", + Latex2HTML => "\begin{rawhtml} + <NOSCRIPT> This problem requires that Java Script be + enabled </NOSCRIPT> ~~n\end{rawhtml} + ", + HTML_tth => "<NOSCRIPT> This problem requires that javaScript be + enabled </NOSCRIPT>~~n", + HTML => "<NOSCRIPT> This problem requires that javaScript be + enabled </NOSCRIPT>~~n" +)); + +$functionArrow = MODES( + TeX => "\(- f\rightarrow\)", + Latex2HTML => "\(- f\rightarrow \) ", + HTML_tth => "-- f -- > ", + HTML => '-- f -- > ' +); + +# The following string contains a combination of HTML and javaScript +# which displays the input table for the javaScript calculator + +$javaScript =<<ENDOFSCRIPT; +<CENTER> +<TABLE BORDER=4> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input1" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output1.value=func(this.form.Input1.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output1" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input2" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output2.value=func(this.form.Input2.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output2" Size="20"> +</TD> +</TR> +<TR> +<TD> +<INPUT TYPE="text" NAME="Input3" Value = "$x0" Size="20"> +</TD> +<TD> +<INPUT TYPE="button" VALUE="---f-->" + OnClick="this.form.Output3.value=func(this.form.Input3.value)"> +</TD> +<TD> +<INPUT TYPE="text" NAME="Output3" Size="20"> +</TD> +</TR> +</TABLE> + +</CENTER> +<!-- Script Size: 1.89 KB --> +ENDOFSCRIPT + +BEGIN_TEXT +Find the derivative of the function f(x). The windows below will tell +you the value of f for any input x. (I call this an "oracle function", since +if you ask, it will tell.) +$PAR +\(f'( $x0 ) \) = \{ans_rule(50 ) \} +$PAR +You may want to use a +\{ htmlLink(alias("${htmlDirectory}calc.html"), + 'calculator', + qq! TARGET = "ww_calculator" + ONCLICK="window.open( this.href,this.target, + 'width=200, height=350, scrollbars=no, resizable=off' + )" +!) \} + +to find the result. You can also enter numerical expressions and +have WeBWorK do the calculations for you. +END_TEXT + +# Here is where we actually print the javaScript, or alternatives for printed output. +TEXT(MODES( + TeX => " \fbox{ The java Script calculator was displayed here + }", + Latex2HTML => "\begin{rawhtml} $javaScript \end{rawhtml}", + HTML_tth => $javaScript, + HTML => $javaScript, + )); + + + + +ANS(num_cmp($ans,reltol => 1) ); #We are allowing 1 percent error for the answer. + + +ENDDOCUMENT(); --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/ontheflygraphicsexample1.pg @@ -0,0 +1,117 @@ +DOCUMENT(); +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl" +); + +TEXT(beginproblem(), $BR,$BBOLD, "On-the-fly Graphics Example1", $EBOLD, $BR,$BR); +$showPartialCorrectAnswers = 0; + +# First we define a graph with x and y in the range -4 to 4, axes (strong lines) +# defined at the point [0,0] and +# with 8 gridlines horizontally and 8 grid lines veritically. +# $graph is a graph object (or more appropriately, a pointer to a graph object). + +# We will define a function and it's first and second derivatives defined +# on the domain [-4,4] +$dom = 4; +$graph = init_graph(-$dom,-$dom,$dom,$dom,'axes'=>[0,0],'grid'=>[8,8]); + +# Here are the basic colors -- we'll mix them up in the next example +@colors = ("blue", "red", "green"); #orange, yellow, +@scrambled_colors = @colors; +@labels = ('A', 'B', 'C'); +@scrambled_labels = @labels; + +$a=random(0, 6.3, .1); +$b=random(1.1, 1.5, .1); +# now define the functions too be graphed +# defining strings need to be on one line (\n is not handled correctly) +# The three variables $f, $fp, and $fpp contain strings +# with the correct syntax to be inputs into the plot_function +# macro. The FEQ macro (Format EQuation) cleans up the writing of the function. +# Otherwise we would need to worry about the signs of $a, $b and so forth. +# For example if $b were negative, then after interpolation +# $a+$b might look like 3+-5. FEQ replaces the +- pair by -, which is what you want. + +# The first string (for $f) should be read as: "The function is calculated +# using sin($a+$b*cos(x)) +# and is defined for all x in the +# interval -$dom to +$dom. Draw the function using the first color +# in the permuted color list @scrambled_colors +# and using a weight (width) of two pixels." + +$f = FEQ( + "sin($a+$b*cos(x)) for x in <-$dom,$dom> using color:$scrambled_colors[0] and weight:2" +); +$fp = FEQ( + "cos($a+${b}*cos(x))*(-$b)*sin(x) for x in <-$dom,$dom> using color=$scrambled_colors[1] and weight:2" +); +# The multiplication signs are not actually needed, although they are allowed. + $fpp = FEQ("-sin($a+${b}*cos(x))*$b*$b* sin(x)* sin(x)+ cos($a+$b* cos(x))*(-$b)*cos(x) for x in <-$dom,$dom> using color=$scrambled_colors[2] and weight=2" +); + + + +# Install the functions into the graph object. +# Plot_functions converts the string to a subroutine which performs the +# necessary calculations and +# asks the graph object to plot the functions. + +($fRef,$fpRef,$fppRef) = plot_functions( $graph, + $f,$fp,$fpp + ); + +# The output of plot_functions is a list of pointers to functions which +# contain the appropriate data and methods. +# So $fpRef->rule points to the method which will calculate the value +# of the function. +# &{$fpRef->rule}(3) calculates the value of the function at 3. + +# create labels for each function +# The 'left' tag determines the justification of the label to the defining point. + + +$label_point=-0.75; +$label_f = new Label ( $label_point,&{$fRef->rule}($label_point), + $scrambled_labels[0], $scrambled_colors[0],'left'); + # NOTE: $fRef->ruleis a reference to the subroutine which calculates the + # function. It was defined in the output of plot_functions. + # It is used here to calculate the y value of the label corresponding + # to the function, and below to find the y values for the labels + # corresponding to the first and second derivatives. + +$label_fp = new Label ( $label_point,&{$fpRef->rule}($label_point), + $scrambled_labels[1],$scrambled_colors[1],'left'); +# Place the second letter in the permuted letter list at the point +# (-.75, fp(-.75)) using the second color in the permuted color list. + +$label_fpp = new Label ( $label_point,&{$fppRef->rule}($label_point), + $scrambled_labels[2],$scrambled_colors[2],'left'); + +# insert the labels into the graph +$graph->lb($label_f,$label_fp,$label_fpp); + +# make sure that the browser will fetch +# the new picture when it is created by changing the name of the +# graph each time the problem seed is changed. This helps prevent caching problems +# on browsers. + + $graph->gifName($graph->gifName()."-$newProblemSeed"); +# Begin writing the problem. +# This inserts the graph and then asks three questions: + +BEGIN_TEXT +\{ image(insertGraph($graph)) \} $PAR +Identify the graphs A (blue), B( red) and C (green) as the graphs +of a function and its +derivatives (click on the graph to see an enlarged image):$PAR +\{ans_rule(4)\} is the graph of the function $PAR +\{ans_rule(4)\} is the graph of the function's first derivative $PAR +\{ans_rule(4)\} is the graph of the function's second derivative $PAR +END_TEXT +ANS(str_cmp( [@scrambled_labels] ) ); + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/hello.pg @@ -0,0 +1,18 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + ); + +BEGIN_TEXT +Complete the sentence: $PAR +\{ ans_rule(20) \} world! +END_TEXT + +ANS( str_cmp( "Hello" ) ); # here is the answer, a string. + + + + +ENDDOCUMENT(); + \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/liteApplet1.pg @@ -0,0 +1,68 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + +# The link to the java applet is hard wired to use the java applet +# served from the University of Rochester WeBWorK machine. +# It is possible to set this up so that the java applet is served +# from any machine +# For details use the Feedback button to contact the authors of WeBWorK + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +$appletText = +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + my $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion* sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} + +$kandahar = [132,101]; +$kabul = [209,185]; +$mazur_e_sharif = [170, 243]; +$shindand = [46, 155]; + +$questions = EV3( +"$PAR How far is it from Kandahar to Kabul? " , ans_rule(30), +" $PAR How far is it from Kabul to Mazar-e-Sharif? ", ans_rule(30), +" $PAR How far is it from Kandahar to Shindand? " , ans_rule(30), +); +#TEXT( +#begintable(2), +#row( $appletText, $questions), +#endtable() +#); +TEXT($appletText, $questions); +ANS(num_cmp(dist($kandahar,$kabul), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kabul, $mazur_e_sharif), reltol => 3, units=>'km')); +ANS(num_cmp(dist($kandahar,$shindand), reltol => 3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/paperHeader.pg @@ -0,0 +1,22 @@ +## Paper set header for setSampleGraders + +DOCUMENT(); + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl" +); + + +BEGIN_TEXT +$BEGIN_ONE_COLUMN +This set shows how to write simple WeBWorK problems and introduces you to the most common +constructions. +$END_ONE_COLUMN + +END_TEXT + + +ENDDOCUMENT(); --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/ontheflygraphicsexample2.pg @@ -0,0 +1,124 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl" +); + +TEXT(beginproblem(), $BR,$BBOLD, "On-the-fly Graphics Example2", $EBOLD, $BR,$BR); + +# First we define a graph with x and y in the range -4 to 4, axes (strong lines) +# defined at the point [0,0] and +# with 8 gridlines horizontally and 8 grid lines veritically. +# $graph is a graph object (or more appropriately, a pointer to a graph object). + +# We will define a function and it's first and second derivatives +# defined on the domain [-4,4] + +$dom = 4; +$graph = init_graph(-$dom,-$dom,$dom,$dom,'axes'=>[0,0],'grid'=>[8,8]); + +# We need to scramble the colors and the labels -- otherwise every student +# will have the function is A, the derivative is B, etc. +# and the colors won't be scrambled either. + +#This provides a permutation of the numbers (0,1,2); + +@slice = NchooseK(3,3); + +# Here are the basic colors + +@colors = ("blue", "red", "green"); #orange, yellow, + +# This lists the colors in the order defined by the list in @slice +# It effectively applies the same permutation to the list of colors +# and to the list of labels. A will always be blue, B red, and C green +#and applies the same permutation to the list of labels + +@scrambled_colors = @colors[@slice]; +@labels = ('A', 'B', 'C'); +@scrambled_labels = @labels[@slice]; + +# The rest of this example is the same as ontheflygraphicsexample1 + +# function definitions need to be on one line +$a=random(0, 6.3, .1); +$b=random(1.1, 1.5, .1); + +# The three variables $f, $fp, and $fpp contain strings +# with the correct syntax to be inputs into the plot_function +# macro. The FEQ macro (Format EQuation) cleans up the writing of the function. +# Otherwise we would need to worry about the signs of $a, $b and so forth. +# For example if $b were negative, then after interpolation +# $a+$b might look like 3+-5. FEQ replaces the +- pair by -, which is what you want. + +# The first string (for $f) should be read as: "The function is calculated +# using sin($a+$b*cos(x)) +# and is defined for all x in the +# interval -$dom to +$dom. Draw the function using the first color +# in the permuted color list @scrambled_colors +# and using a weight (width) of two pixels." + +$f = FEQ("sin($a+$b*cos(x)) for x in <-$dom,$dom> using color:$scrambled_colors[0] and weight:2"); +$fp = FEQ("cos($a+${b}*cos(x))*(-$b)*sin(x) for x in <-$dom,$dom> using color=$scrambled_colors[1] and weight:2"); +$fpp = FEQ("-sin($a+${b}*cos(x))*$b*$b* sin(x)* sin(x)+ cos($a+$b* cos(x))*(-$b)*cos(x) for x in <-$dom,$dom> using color=$scrambled_colors[2] and weight=2"); + + +# Install the functions into the graph object. +# Plot_functions converts the string to a subroutine which performs the +# necessary calculations and +# asks the graph object to plot the functions. + +($fRef,$fpRef,$fppRef) = plot_functions( $graph, + $f,$fp,$fpp + ); +# The output of plot_functions is a list of pointers to functions which +# contain the appropriate data and methods. +# So $fpRef->rule points to the method which will calculate the value +# of the function. +# &{$fpRef->rule}(3) calculates the value of the function at 3. + +# create labels for each function +# The 'left' tag determines the justification of the label to the defining point. + + +$label_point=-0.75; +$label_f = new Label ( $label_point,&{$fRef->rule}($label_point), + $scrambled_labels[0],$scrambled_colors[0],'left') ; + # NOTE: $fRef->ruleis a reference to the subroutine which calculates the + # function. It was defined in the output of plot_functions. + # It is used here to calculate the y value of the label corresponding + # to the function, and below to find the y values for the labels + # corresponding to the first and second derivatives. + +$label_fp = new Label ( $label_point,&{$fpRef->rule}($label_point), + $scrambled_labels[1],$scrambled_colors[1],'left') ; +# Place the second letter in the permuted letter list at the point +# (-.75, fp(-.75)) using the second color in the permuted color list. + +$label_fpp = new Label ( $label_point,&{$fppRef->rule}($label_point),$scrambled_labels[2],$scrambled_colors[2],'left'); + +# insert the labels into the graph +$graph->lb($label_f,$label_fp,$label_fpp); + +# make sure that the browser will fetch +# the new picture when it is created by changing the name of the +# graph each time the problem seed is changed. +$graph->gifName($graph->gifName()."-$newProblemSeed"); + +# Begin writing the problem. +# This inserts the graph and then asks three questions: + +BEGIN_TEXT +\{ image(insertGraph($graph),width => 200, height => 200) \} $PAR +Identify the graphs A (blue), B( red) and C (green) as the graphs of a function and its +derivatives (click on the graph to see an enlarged image):$PAR +\{ans_rule(4)\} is the graph of the function $PAR +\{ans_rule(4)\} is the graph of the function's first derivative $PAR +\{ans_rule(4)\} is the graph of the function's second derivative $PAR +END_TEXT + +ANS(str_cmp( [@scrambled_labels] ) ); + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/liteApplet2.pg @@ -0,0 +1,74 @@ +DOCUMENT(); + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +$showPartialCorrectAnswers = 1; +TEXT(beginproblem()); + + +BEGIN_TEXT +This is a lite applet designed by Frank Wattenberg. +$BR +\{htmlLink( '/webwork2_course_files/demoCourse/live_map_instructions.html ', +'Instructions for using the map',' target="intro" ' )\} +$HR +END_TEXT +TEXT( +appletLink( +q! archive="/courses/system_html/applets/Image_and_Cursor_All/Image_and_Cursor.jar" +code="Image_and_Cursor" width = 500 height = 458 +!, +q!Your browser does not support Java, so nothing is displayed. + <param name = "applet_width" value = "500"> + <param name = "applet_height" value = "458"> + <param name = "image_width" value = "351"> + <param name = "image_height" value = "378"> + <param name = "backdrop_filename" value = "/courses/system_html/applets/Image_and_Cursor_All/AF-MAP.JPG"> + <param name = "display_placement" value = "1"> + <param name = "display_sw" value = "0"> +! +), +); +sub dist { + my $ra_pt1 = shift; + my $ra_pt2 =shift; + $conversion = 300 /(145 - 72); # number of km per pixel + return $conversion * sqrt( ($ra_pt1->[0] - $ra_pt2->[0])**2 + ($ra_pt1->[1] - $ra_pt2->[1])**2); +} +@cities = ( + { name => 'Kandahar', location => [132,101] }, + { name => 'Kabul', location => [209,185] }, + { name => 'Mazur e Sharif', location => [170, 243] }, + { name => 'Shindand', location => [46, 155] }, + { name => 'Zaranj', location => [39, 93] } +); +@index = NchooseK(scalar(@cities), 3 ); +sub cityName { + my $index = shift ; + $cities[$index -1]->{name}; +} +sub cityLoc { + my $index = shift; + $cities[$index-1]->{location}; +} + +$conversion = 300 /(145 - 72); # number of km per pixel +BEGIN_TEXT +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[2])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[1])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +$PAR +How far is it from \{cityName($index[2])\} to \{cityName($index[3])\}? \{ans_rule(30)\} +END_TEXT + +ANS(num_cmp(dist(cityLoc($index[1]),cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]), cityLoc($index[2])), reltol=>3, units=>'km')); +ANS(num_cmp(dist(cityLoc($index[2]),cityLoc($index[2])), reltol=>3, units=>'km')); + + + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/vectorfieldexample.pg @@ -0,0 +1,94 @@ +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PG.pl", + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", +); + +TEXT(beginproblem()); # standard preamble to each problem. + +# Since this is a true questions, we do not usually wish to tell students which +# parts of the matching question have been answered correctly and which are +# incorrect. That is too easy. To accomplish this we set the following flag to zero. +$showPartialCorrectAnswers = 0; + + +# Make a new select list + +$tf = new_match_list(); + +$numberOfQuestions = 4; +$tf -> qa ( +"\(y'= 2y + x^2e^{2x} \)", +sub{my ($x,$y) = @_; 2*$y+($x**2)*exp(2*$x); }, +"\( y'= -2 + x - y \)", +sub{my ($x,$y) = @_; -2 + $x - $y;}, +"\(y'= e^{-x} + 2y\)", +sub{my ($x,$y) = @_; exp(-$x) + 2*$y;}, +"\(y'= 2\sin(x) + 1 + y\)", +sub{my ($x,$y) = @_; 2*sin($x) + 1 + $y;}, +"\(y'= -\frac{2x+y)}{(2y)} \)", +sub{my ($x,$y) = @_; ($y==0)? -2*$x/0.001 : -(2*$x+$y)/(2*$y);}, +"\(y'= y + 2\)", +sub{my ($x,$y) = @_; $y + 2 ;}, +); + +$tf ->choose($numberOfQuestions); +BEGIN_TEXT +$BEGIN_ONE_COLUMN + +Match the following equations with their direction field. +Clicking on each picture will give you an +enlarged view. While you can probably solve this problem by guessing, +it is useful to try to predict characteristics of the direction field +and then match them to the picture. +$PAR +Here are some handy characteristics to start with -- +you will develop more as you practice. +$PAR + +\{OL( + "Set y equal to zero and look at how the derivative behaves along the x axis.", + "Do the same for the y axis by setting x equal to 0", + "Consider the curve in the plane defined by setting y'=0 + -- this should correspond to the points in the picture where the + slope is zero.", + "Setting y' equal to a constant other than zero gives the curve of points + where the slope is that + constant. These are called isoclines, and can be used to construct the + direction field picture by hand." +)\} + + + \{ $tf->print_q \} + +END_TEXT +$dx_rule = sub{my ($x,$y) = @_; 1; }; +$dy_rule = sub{my ($x,$y) = @_; $y; }; +# prepare graphs: +@dy_rules = @{ $tf->{selected_a} }; + +for my $i (0..$numberOfQuestions-1) { + $graph[$i] = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]); + $vectorfield[$i] = new VectorField($dx_rule, $dy_rules[$i], $graph[$i]); + $vectorfield[$i]->dot_radius(2); + $graphURL[$i] = insertGraph($graph[$i]); +} +#### +BEGIN_TEXT +$PAR + \{ imageRow( [@graphURL[0..$numberOfQuestions/2-1]], + [@ALPHABET[0..$numberOfQuestions/2-1]], height => 200, + width => 200,tex_size=>300 ) \} + \{ imageRow( [@graphURL[$numberOfQuestions/2..$numberOfQuestions-1]], + [@ALPHABET[$numberOfQuestions/2..$numberOfQuestions-1]], + height => 200, width => 200,tex_size=>300 ) \} + +$END_ONE_COLUMN +END_TEXT + +ANS( str_cmp( $tf->ra_correct_ans ) ) ; + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/truefalseexample.pg @@ -0,0 +1,63 @@ +DOCUMENT(); +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + +); +TEXT(beginproblem(), $BR,$BBOLD, "True False Example", $EBOLD, $BR,$BR); + +# Since this is a true questions, we do not usually wish to tell students which +# parts of the matching question have been answered correctly and which are +# incorrect. That is too easy. To accomplish this we set the following flag to +# zero. +$showPartialCorrectAnswers = 0; + +# True false questions are a special case of a "select list" +# Make a new select list +$tf = new_select_list(); +# $tf now "contains" the select list object. +# Insert some questions and whether or not they are true. + +$tf -> qa ( # each entry has to end with a comma +"All continuous functions are differentiable.", +"F", +"All differentiable functions are continuous.", +"T", +"All polynomials are differentiable.", +"T", +"All functions with positive derivatives are increasing.", +"T", +"All compact sets are closed", +"T", +"All closed sets are compact", +"F", +"All increasing functions have positive deriviatives", +"F", +"All differentiable strictly increasing functions have non-negative derivatives + at every point", +"T", +); + +# Choose four of the question and answer pairs at random. +$tf ->choose(4); + +# Now print the text using $ml->print_q for the questions +# and $ml->print_a to print the answers. + +BEGIN_TEXT +$PAR + +Enter T or F depending on whether the statement is true or false. +(You must enter T or F -- True and False will not work.)$BR + +\{ $tf-> print_q \} + +$PAR + +END_TEXT + +# Enter the correct answers to be checked against the answers to the students. + +ANS( str_cmp( $tf->ra_correct_ans ) ) ; + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/popuplistexample.pg @@ -0,0 +1,65 @@ +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); + +TEXT(beginproblem(), $BR,$BBOLD, "True False Pop-up Example", $EBOLD, $BR,$BR); +$showPartialCorrectAnswers = 0; + +# Make a new select list +$tf = new_select_list(); +# $tf now "contains" the select list object. + +# change the printing mechanism of the object to +# use pop-up list instead of an answer rule. +$tf->rf_print_q(~~&pop_up_list_print_q); + +# What should the pop-up list contain, and what string should it +# submit for an answer when selected? +# These are specified in the statment below. +# To enter T as an answer choose the list element "True" +# To enter F as an answer choose the list element "False" +# The first choice is a blank to make the students do SOMETHING!!! +$tf -> ra_pop_up_list( [ No_answer => " ?", T => "True", F => "False"] ); +# Note how the list is constructed [ answer => list element text, answer => list element text ] + +# Insert some questions and their answers. + +$tf -> qa ( # each entry has to end with a comma +"All continuous functions are differentiable.", +"F", +"All differentiable functions are continuous.", +"T", +"All polynomials are differentiable.", +"T", +"All functions with positive derivatives are increasing.", +"T", +"All compact sets are closed", +"T", +"All closed sets are compact", +"F", +"All increasing functions have positive deriviatives", +"F", +"All differentiable strictly increasing functions have non-negative derivatives + at every point", +"T", +); + +# Choose two of the question and answer pairs at random. +$tf ->choose(4); # Using choose(3) would choose all three + # questions, but the order of the questions + # and answers would be scrambled. + +# Now print the text using $ml->print_q for the questions. +BEGIN_TEXT +$PAR +Indicate whether each statement is true or false. $BR +\{ $tf-> print_q \} +$PAR +END_TEXT +# Enter the correct answers to be checked against the answers to the students. +ANS( str_cmp( $tf->ra_correct_ans ) ) ; + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/simplemultiplechoiceexample.pg @@ -0,0 +1,33 @@ +DOCUMENT(); # This should be the first executable line in the problem. +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", +); +TEXT(beginproblem(), $BR,$BBOLD, "Multiple choice example", $EBOLD, $BR,$BR); + + +$showPartialCorrectAnswers = 0; +$question = "What is the derivative of tan(x)?"; +# An example of a list or array variable. It begins with @. +@answer_list = ( "\( \sec^2(x) \)", # correct + "\( -\cot(x) \)", + "\( \tan(x) \)", + "\( \cosh(x) \)", + "\( \sin(x) \)", +); +# These commands permute the order of the answers. +#@permutation = NchooseK(5,5); # random permutation of the five answers +@permutation = (1,0,2,3,4); # example of fixed permutation +@permuted_answer_list = @answer_list[@permutation]; +@inverted_alphabet = @ALPHABET[invert( @permutation )]; # needed to check the answers + +# Use the macro OL to print an Ordered List of the answerslabeled with letters. +BEGIN_TEXT +$BR $question +$PAR \{ OL( @permuted_answer_list ) \} +$PAR Enter the letter corresponding to the correct answer: \{ ans_rule(10) \} +END_TEXT +ANS( str_cmp( $inverted_alphabet[0] ) ) ; + +ENDDOCUMENT(); \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/prob3.pg @@ -0,0 +1,162 @@ +#<HTML> +#<BODY BGCOLOR = "#ffffff"> +#<PRE> +# Description +# The first example using match lists +# EndDescription + + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros("PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl", + "PGgraphmacros.pl", + "PGnumericalmacros.pl" + ); + +# TEXT( ... , ... , ) +# Is the simplest way of printing text, each string in the input is immediately printed. +# It does not do any of the simplifying and evaluating tricks performed by the BEGIN_TEXT/END_TEXT construction. + +# beginproblem() is a macro which outputs the string +# which contains the number +# of points the problem is worth. + +# Putting these two ideas together prints the standard opening line of a problem. +# We will use this construction routinely at the beginning of all subsequent problems. +TEXT(beginproblem()); + +# Since this is a matching questions, we do not usually wish to tell students which +# parts of the matching question have been answered correctly and which are +# incorrect. That is too easy. To accomplish this we set the following flag to zero. +$showPartialCorrectAnswers = 0; + + +##################################################################### +# This section allows you to manipulate the problem seed while working on the problem +# thus seeing different versions of the problem. Skip the details of how this works +# for now. + +# allow the student to change the seed for this problem. +$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? ${$inputs_ref}{'newProblemSeed'} : $problemSeed; +$PG_random_generator->srand($newProblemSeed); + +BEGIN_TEXT + +To see a different version of the problem change +the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed: +\{ M3( +qq! Change the problem seed to change the problem:$problemSeed!, +qq! Change the problem seed to change the problem: + \begin{rawhtml} + <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10"> + \end{rawhtml}!, +qq! <INPUT NAME="newProblemSeed" VALUE = "$newProblemSeed" SIZE = "10">! +) +\} + +$HR +END_TEXT +##################################################################### + + +# Make a new match list +$ml = new_match_list(); + +# $ml now "contains" the match list object. (Actually $ml is a scalar variable which contains a pointer to +# the match list object, but you can think of the match list object as being shoe horned into the variable $ml. +# You need to remember that $ml contains (a pointer to) an object, and not ordinary data such as a number or string. + +# Some people use the convention $o_ml to remind them that the variable contains an object, but for short problems +# that is probably not necessary. + +# An object contains both data (in this case the list of questions and answers) and subroutines (called methods) +# for manipulating that data. + + +# Insert some questions and matching answers in the q/a list by calling on the objects qa method. +# using the construction $ml ->qa(..list of alternating questions and matching answers ...). +# Think of this as asking the object $ml to store the matching questions +# and answers given in the argument to the method qa. + +$ml -> qa ( +"\( \sin(x) \)", # Notice the use of the LateX construction for math mode: \\( ... \\) +"\( \cos(x) \)", # and the use of TeX symbols such as \\sin and \\tan +"\( \cos(x) \)", # Use " ... " to enter a string +"\( -\sin(x) \)", +"\( \tan(x) \)", +"\( \sec^2(x) \)" # Remember that in these strings we are only specifying typography, + # via TeX, not any calculational rules. +); + +# +# Calculate coefficients for another question +$b=random(2,5); +$exp= random(2,5); +$coeff=$b*$exp; +$new_exp = $exp-1; + +# Store the question and answers in the match list object. +$ml -> qa ( +"\( ${b}x^$exp \)", +"\( ${coeff}x^{$new_exp} \)", +); + +# Add another example +$b2=random(2,5); +$exp2= random(2,5); +$coeff2=$b2*$exp; +$new_exp2 = $exp-1; +$ml -> qa ( +"\( ${b2}x^$exp2 \)", +"\( ${coeff2}x^{$new_exp2} \)", +); + + +# Choose two of the question and answer pairs at random. +$ml ->choose(2); # Using choose(3) would choose all three questions, but the order of the questions and answers would be + # scrambled. + + +# Now print the text using $ml->print_q for the questions and $ml->print_a to print the answers. + +BEGIN_TEXT +$PAR + +Match the functions and their derivatives: $BR + +\{ $ml -> print_q \} + +$PAR + +\{$ml -> print_a \} +END_TEXT + +# Enter the correct answers to be checked against the answers to the students. + +ANS( str_cmp( $ml->ra_correct_ans ) ) ; + +# That's it. + +######################################################### + +BEGIN_TEXT +<hr> + +You can view the +\{ htmlLink(alias("${htmlDirectory}/links/set$setNumber/prob3.html"),"source", q!TARGET="source"!)\} +for this problem. +END_TEXT + +TEXT( +"$PAR Return to ", htmlLink($$inputs_ref{returnPage},$$inputs_ref{returnPage}), +) if exists($$inputs_ref{returnPage}); +######################################################### + + + +ENDDOCUMENT(); # This should be the last executable line in the problem. +#</PRE> +#</BODY> +#</HTML> --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/simple_drawing.pg @@ -0,0 +1,40 @@ +##DESCRIPTION +## A very simple drawing problem +##ENDDESCRIPTION + +##KEYWORDS('algebra') + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"PGgraphmacros.pl", +"PGauxiliaryFunctions.pl" +); + + +$graph = init_graph(-5,-5,5,5,ticks=>[4,4],axes=>[0,0],pixels=>[400,400]); + +$graph->moveTo(-2,1); +$graph->lineTo(2,2,'blue'); +$graph->lineTo(-1,2,'red'); +$graph->lineTo(-2,1,'green'); +$graph->fillRegion([0,1.7,'yellow']); +BEGIN_TEXT +\{image(insertGraph($graph),width=>400,height=>400)\} + + +END_TEXT + +# At the moment there is no easy way to change the weight of the lines being drawn. To do so one would want +# to incorporate some of the code in Fun.pm into WWPlot.pm itself. The code involves gdBrushed. +# Since GD has +# gone through many revisions since the WWPlot.pm code was written it may now be possible to write some of +# this code more efficiently. + + + +ENDDOCUMENT(); # This should be the last executable line in the problem. --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial/conditionalquestionexample.pg @@ -0,0 +1,83 @@ +DOCUMENT(); +loadMacros( + "PGbasicmacros.pl", + "PGchoicemacros.pl", + "PGanswermacros.pl" +); +TEXT(beginproblem(), $BR,$BBOLD, "Conditional questions example", $EBOLD, $BR,$BR); +$showPartialCorrectAnswers = 1; + +$a1 = random(3,25,1); +$b1 = random(2,27,1); +$x1 = random(-11,11,1); +$a2 = $a1+5; + +BEGIN_TEXT +If \( f(x) = $a1 x + $b1 \), find \( f'( $x1 ) \). +$BR $BR \{NAMED_ANS_RULE('first_answer',10) \} +$BR +END_TEXT + + + +$ans_eval1 = num_cmp($a1); +NAMED_ANS(first_answer => $ans_eval1); + +# Using named answers allows for more control. Any unique label can be +# used for an answer. +# (see http://webwork.math.rochester.edu/docs/docs/pglanguage/pgreference/managinganswers.html +# for more details on answer evaluator formats and on naming answers +# so that you can refer to them later. Look also at the pod documentation in +# PG.pl and PGbasicmacros.pl which you can also reach at +# http://webwork.math.rochester.edu/docs/techdescription/pglanguage/index.html) + +# Check to see that the first answer was answered correctly. If it was then we +# will ask further questions. +$first_Answer = $inputs_ref->{first_answer}; # We need to know what the answer + ... [truncated message content] |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:37:45
|
Log Message: ----------- Updating modelCourse to conform to the version currently on hosted.webwork Added Files: ----------- webwork2/courses/modelCourse/templates: setDemo.def setMAAtutorial.def Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/setMAAtutorial.def @@ -0,0 +1,23 @@ +openDate = 1/10/97 at 6:00am +dueDate = 1/1/05 at 2:00am +answerDate = 1/1/05 at 2:00am +paperHeaderFile = setMAAtutorial/MAAtutorialSetHeader.pg +screenHeaderFile = setMAAtutorial/MAAtutorialSetHeader.pg +problemList = +setMAAtutorial/hello.pg, 1 +setMAAtutorial/standardexample.pg, 1 +setMAAtutorial/simplemultiplechoiceexample.pg, 1 +setMAAtutorial/multiplechoiceexample.pg, 1 +setMAAtutorial/matchinglistexample.pg, 1 +setMAAtutorial/truefalseexample.pg, 1 +setMAAtutorial/popuplistexample.pg, 1 +setMAAtutorial/ontheflygraphicsexample1.pg, 1 +setMAAtutorial/ontheflygraphicsexample2.pg, 1 +setMAAtutorial/staticgraphicsexample/staticgraphicsexample.pg, 1 +setMAAtutorial/hermitegraphexample.pg, 1 +setMAAtutorial/htmllinksexample/htmllinksexample.pg, 1 +setMAAtutorial/javascriptexample1.pg, 1 +setMAAtutorial/javascriptexample2.pg, 1 +setMAAtutorial/vectorfieldexample.pg, 1 +setMAAtutorial/conditionalquestionexample.pg, 1 +setMAAtutorial/javaappletexample.pg, 1 --- /dev/null +++ courses/modelCourse/templates/setDemo.def @@ -0,0 +1,27 @@ +setNumber=Demo +openDate = 1/10/98 at 6:00am +dueDate = 1/1/06 at 2:00am +answerDate = 1/1/06 at 2:00am +paperHeaderFile = setDemo/paperHeaderFile1.pg +screenHeaderFile = setDemo/screenHeaderFile1.pg + +problemList = + +setDemo/srw1_9_4.pg, 1 +setDemo/limits.pg, 1 +setDemo/s2_2_1.pg, 1 +setDemo/c4s5p2.pg, 1 +setDemo/sample_units_ans.pg, 1 + +setDemo/prob0837.pg, 1 +setDemo/nsc2s10p2.pg, 1 +setDemo/prob5.pg, 1 +setDemo/prob6b.pg, 1 +setDemo/sample_myown_ans.pg, 1 + + + + + + + |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:36:51
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/setDemo In directory devel.webwork.rochester.edu:/tmp/cvs-serv47188/setDemo Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/setDemo added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:36:46
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial In directory devel.webwork.rochester.edu:/tmp/cvs-serv47188/setMAAtutorial Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/setMAAtutorial added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:15:16
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/set0/prob4 In directory devel.webwork.rochester.edu:/tmp/cvs-serv31630/prob4 Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/set0/prob4 added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:11:23
|
Update of /webwork/cvs/system/webwork2/courses/modelCourse/templates/set0 In directory devel.webwork.rochester.edu:/tmp/cvs-serv31606/set0 Log Message: Directory /webwork/cvs/system/webwork2/courses/modelCourse/templates/set0 added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 19:10:06
|
Log Message: ----------- Correcting version of modelCourse to bring it in line with the model course currently on hosted.webwork Modified Files: -------------- webwork2/courses/modelCourse/templates: set0.def Revision Data ------------- Index: set0.def =================================================================== RCS file: /webwork/cvs/system/webwork2/courses/modelCourse/templates/set0.def,v retrieving revision 1.1 retrieving revision 1.2 diff -Lcourses/modelCourse/templates/set0.def -Lcourses/modelCourse/templates/set0.def -u -r1.1 -r1.2 --- courses/modelCourse/templates/set0.def +++ courses/modelCourse/templates/set0.def @@ -4,10 +4,10 @@ answerDate = 1/21/09 at 6:00am screenHeaderFile = setHeader.pg problemList = -localLibrary/set0/prob1.pg, 1 -localLibrary/set0/prob1a.pg, 1 -localLibrary/set0/prob1b.pg, 1 -localLibrary/set0/prob2.pg, 1 -localLibrary/set0/prob3.pg, 1 -localLibrary/set0/prob4/prob4.pg, 1 -localLibrary/set0/prob5.pg, 1 +set0/prob1.pg, 1 +set0/prob1a.pg, 1 +set0/prob1b.pg, 1 +set0/prob2.pg, 1 +set0/prob3.pg, 1 +set0/prob4/prob4.pg, 1 +set0/prob5.pg, 1 |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 17:20:39
|
Log Message: ----------- Adding template contents to modelCourse Added Files: ----------- webwork-modperl/courses/modelCourse/templates: README course_info.txt demoCourse.lst set0.def setHeader.pg Revision Data ------------- --- /dev/null +++ courses/modelCourse/templates/course_info.txt @@ -0,0 +1 @@ + --- /dev/null +++ courses/modelCourse/templates/demoCourse.lst @@ -0,0 +1,10 @@ +000-00-000a ,PRACTICE1 ,JANE ,C , , , , ,practice1 = =20 +000-00-000b ,PRACTICE2 ,JANE ,C , , , , ,practice2 = =20 +000-00-000c ,PRACTICE3 ,JANE ,C , , , , ,practice3 = =20 +000-00-000d ,PRACTICE4 ,JANE ,C , , , , ,practice4 = =20 +000-00-000e ,PRACTICE5 ,JANE ,C , , , , ,practice5 = =20 +000-00-000f ,PRACTICE6 ,JANE ,C , , , , ,practice6 = =20 +000-00-000g ,PRACTICE7 ,JANE ,C , , , , ,practice7 = =20 +000-00-000h ,PRACTICE8 ,JANE ,C , , , , ,practice8 = =20 +000-00-000i ,PRACTICE9 ,JANE ,C , , , , ,practice9 = =20 +111-11-1111 ,Smith ,Donald ,C , , , ,DA...@uw... ,dasmith --- /dev/null +++ courses/modelCourse/templates/setHeader.pg @@ -0,0 +1,88 @@ +########################################################################= ######## +# WeBWorK Online Homework Delivery System +# Copyright =A9 2000-2003 The WeBWorK Project, http://openwebwork.sf.net= / +# $CVSHeader: webwork-modperl/courses/modelCourse/templates/setHeader.pg= ,v 1.1 2005/07/28 17:22:09 gage Exp $ +#=20 +# This program is free software; you can redistribute it and/or modify i= t under +# the terms of either: (a) the GNU General Public License as published b= y the +# Free Software Foundation; either version 2, or (at your option) any la= ter +# version, or (b) the "Artistic License" which comes with this package. +#=20 +# This program is distributed in the hope that it will be useful, but WI= THOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or = FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License o= r the +# Artistic License for more details. +########################################################################= ######## + +DOCUMENT(); + +loadMacros( + "PG.pl", + "PGbasicmacros.pl", +=09 +); + +TEXT($BEGIN_ONE_COLUMN); + +TEXT(MODES(TeX =3D>EV3(<<'EOT'),HTML=3D>"",Latex2HTML=3D>"")); +\noindent {\large \bf $studentName} +\hfill +\noindent {\large \bf MTH 161 $sectionNumber Fall 2003} +\par + +EOT + +BEGIN_TEXT + +$BBOLD WeBWorK assignment number $setNumber is due : $formattedDueDa= te. $EBOLD + +$PAR + +$PAR +The=20 +(* home page *) +\{=20 +#htmlLink(qq!http://www.math.rochester.edu/courses/161/home/!,"home page= ")=20 +\}=20 +for the course contains the syllabus, grading policy and other informati= on. =20 +$PAR +END_TEXT + +################## +# EDIT BELOW HERE +################## +BEGIN_TEXT +$HR +$PAR +This file is /conf/snippets/setHeader.pg you can use it as=20 +a model for creating files which introduce each problem set. +$PAR +$HR +END_TEXT +################## +# EDIT ABOVE HERE +################## +BEGIN_TEXT +The primary purpose of WeBWorK is to let you know that you are getting t= he correct answer or to alert +you if you are making some kind of mistake. Usually you can attempt a pr= oblem as many times as you want before +the due date. However, if you are having trouble figuring out your erro= r, you should +consult the book, or ask a fellow student, one of the TA's or +your professor for help. Don't spend a lot of time guessing -- it's not= very efficient or effective. +$PAR +Give 4 or 5 significant digits for (floating point) numerical answers. +For most problems when entering numerical answers, you can if you wish +enter elementary expressions such as \( 2\wedge3 \) instead of 8, \( sin= (3*pi/2) \)instead +of -1, \( e\wedge (ln(2)) \) instead of 2, +\( (2+tan(3))*(4-sin(5))\wedge6-7/8 \) instead of 27620.3413, etc. + Here's the=20 +\{ htmlLink(qq!http://webwork.math.rochester.edu/docs/docs/pglanguage/av= ailableFunctions.html!,"list of the functions") \} + which WeBWorK understands. +$PAR +You can use the Feedback button on each problem +page to send e-mail to the professors.=20 + + +$END_ONE_COLUMN +END_TEXT + +ENDDOCUMENT(); # This should be the last executable line in the p= roblem. \ No newline at end of file --- /dev/null +++ courses/modelCourse/templates/set0.def @@ -0,0 +1,13 @@ +setNumber=3D0 +openDate =3D 1/7/00 at 6:00am +dueDate =3D 1/20/09 at 6:00am +answerDate =3D 1/21/09 at 6:00am +screenHeaderFile =3D setHeader.pg +problemList =3D +localLibrary/set0/prob1.pg, 1 +localLibrary/set0/prob1a.pg, 1 +localLibrary/set0/prob1b.pg, 1 +localLibrary/set0/prob2.pg, 1 +localLibrary/set0/prob3.pg, 1 +localLibrary/set0/prob4/prob4.pg, 1 +localLibrary/set0/prob5.pg, 1 --- /dev/null +++ courses/modelCourse/templates/README @@ -0,0 +1,2 @@ +When transferring this course to another machine you may need to=20 +redefine the symbolic links for the libraries. |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 17:20:22
|
Update of /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/macros In directory devel.webwork.rochester.edu:/home/gage/webwork/webwork-modperl/courses/modelCourse/templates/macros Log Message: Directory /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/macros added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 17:20:21
|
Update of /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/Library In directory devel.webwork.rochester.edu:/var/webwork/Library Log Message: Directory /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/Library added to the repository |
From: Mike G. v. a. <we...@ma...> - 2005-07-28 17:20:20
|
Update of /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/email In directory devel.webwork.rochester.edu:/home/gage/webwork/webwork-modperl/courses/modelCourse/templates/email Log Message: Directory /webwork/cvs/system/webwork-modperl/courses/modelCourse/templates/email added to the repository |