Skip to content

Commit

Permalink
Merge pull request openwebwork#8 from mgage/master
Browse files Browse the repository at this point in the history
Restore paths to achievement modules
  • Loading branch information
mgage committed Jun 10, 2012
2 parents d1fce96 + f40c88d commit a3e1f2a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 60 deletions.
1 change: 1 addition & 0 deletions conf/global.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
# overridden by WeBWorK updates.



1; #final line of the file to reassure perl that it was read properly.
1 change: 1 addition & 0 deletions conf/localOverrides.conf.dist
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ $problemDefaults{max_attempts} = -1;
# %showeditors = (
# classlisteditor1 => 1,
# classlisteditor2 => 1,
# classlisteditor3 => 1,
#
# homeworkseteditor1 => 1,
# homeworkseteditor2 => 1,
Expand Down
Empty file modified conf/site.conf.dist
100755 → 100644
Empty file.
7 changes: 7 additions & 0 deletions lib/WeBWorK/AchievementEvaluator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ sub checkForAchievements {
@achievements = sortAchievements(@achievements);
my $globalUserAchievement = $db->getGlobalUserAchievement($user_id);

# If no global data then initialize
if (not $globalUserAchievement) {
$globalUserAchievement = $db->newGlobalUserAchievement();
$globalUserAchievement->user_id($user_id);
$db->addGlobalUserAchievement($globalUserAchievement);
}

#update the problem with stuff from the pg.
# this is kind of a hack. The achievement checking happens *before* the system has
# updated $problem with the new results from $pg. So we cheat and update the
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ $WeBWorK::ContentGenerator::Instructor::Config::ConfigValues = [
type => 'text'},
{ var => 'defaultTheme',
doc => 'Theme (refresh page after saving changes to reveal new theme.)',
doc2 => 'There are currently five themes (or skins) to choose from: ur, math, math2, math3 union. The theme
doc2 => 'There are currently five themes (or skins) to choose from: ur, math, math2, and dgage. The theme
specifies a unified look and feel for the WeBWorK course web pages.',
values => [qw(math math2 math3 ur dgage union)],
type => 'popuplist'},
Expand Down
39 changes: 12 additions & 27 deletions lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -713,20 +713,17 @@ sub links {
print &$makelink("${pfx}Index", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args);
print CGI::start_ul();


print CGI::li(&$makelink("${pfx}UserList", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{classlisteditor1};
print CGI::li(&$makelink("${pfx}UserList2", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{classlisteditor2};;
print CGI::li(&$makelink("${pfx}UserList3", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{classlisteditor3};;


print CGI::start_li(); # Homework Set Editor
print &$makelink("${pfx}ProblemSetList", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)
if $ce->{showeditors}->{homeworkseteditor1};
print "<br/>";
print &$makelink("${pfx}ProblemSetList2", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args)
if $ce->{showeditors}->{homeworkseteditor2};;

print &$makelink("${pfx}ProblemSetList", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args);
## only show editor link for non-versioned sets
if (defined $setID && $setID !~ /,v\d+$/ ) {
print CGI::start_ul();
Expand All @@ -735,14 +732,7 @@ sub links {

if (defined $problemID) {
print CGI::start_ul();
print CGI::li(&$makelink("${pfx}PGProblemEditor", text=>"$problemID", urlpath_args=>{%args,setID=>$setID,problemID=>$problemID}, systemlink_args=>\%systemlink_args, target=>"WW_Editor"))
if $ce->{showeditors}->{pgproblemeditor1};
print CGI::end_ul();
}
if (defined $problemID) {
print CGI::start_ul();
print CGI::li(&$makelink("${pfx}PGProblemEditor2", text=>"--$problemID", urlpath_args=>{%args,setID=>$setID,problemID=>$problemID}, systemlink_args=>\%systemlink_args, target=>"WW_Editor2"))
if $ce->{showeditors}->{pgproblemeditor2};;
print CGI::li(&$makelink("${pfx}PGProblemEditor", text=>"$problemID", urlpath_args=>{%args,setID=>$setID,problemID=>$problemID}, systemlink_args=>\%systemlink_args, target=>"WW_Editor"));
print CGI::end_ul();
}

Expand All @@ -751,12 +741,8 @@ sub links {
}
print CGI::end_li(); # end Homework Set Editor

print CGI::li(&$makelink("${pfx}SetMaker", text=>$r->maketext("Library Browser"), urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{librarybrowser1};
print CGI::li(&$makelink("${pfx}SetMaker2", text=>$r->maketext("Library Browser 2"), urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{librarybrowser2};
print CGI::li(&$makelink("${pfx}SetMaker3", text=>$r->maketext("Library Browser 3"), urlpath_args=>{%args}, systemlink_args=>\%systemlink_args))
if $ce->{showeditors}->{librarybrowser3};
print CGI::li(&$makelink("${pfx}SetMaker", text=>$r->maketext("Library Browser"), urlpath_args=>{%args}, systemlink_args=>\%systemlink_args));
print CGI::li(&$makelink("${pfx}SetMaker2", text=>$r->maketext("Library Browser 2"), urlpath_args=>{%args}, systemlink_args=>\%systemlink_args));
print CGI::start_li(); # Stats
print &$makelink("${pfx}Stats", urlpath_args=>{%args}, systemlink_args=>\%systemlink_args);
if ($userID ne $eUserID or defined $setID) {
Expand Down Expand Up @@ -1085,7 +1071,9 @@ The implementation in this package checks for a note in the request named
sub warnings {
my ($self) = @_;
my $r = $self->r;

print CGI::p("Entering ContentGenerator::warnings") if $TRACE_WARNINGS;

print "\n<!-- BEGIN " . __PACKAGE__ . "::warnings -->\n";
my $warnings = MP2 ? $r->notes->get("warnings") : $r->notes("warnings");
print $self->warningOutput($warnings) if $warnings;
Expand Down Expand Up @@ -1263,10 +1251,8 @@ handled.
sub if_warnings {
my ($self, $arg) = @_;
my $r = $self->r;

if ( (MP2 ? $r->notes->get("warnings") : $r->notes("warnings"))
or ($self->{pgerrors}) )
{

if (MP2 ? $r->notes->get("warnings") : $r->notes("warnings")) {
return $arg;
} else {
!$arg;
Expand Down Expand Up @@ -1652,9 +1638,7 @@ sub hidden_fields {
# $html .= CGI::hidden($param, @values); #MEG
# warn "$param ", join(" ", @values) if @values >1; #this should never happen!!!
my $value = $r->param($param);
# $html .= CGI::hidden($param, $value); # (can't name these items when using real CGI)
$html .= CGI::hidden(-name=>$param, -default=>$value, -id=>"hidden_".$param); # (can't name these items when using real CGI)

$html .= CGI::hidden($param, $value); # (can't name these items when using real CGI)
}
return $html;
}
Expand Down Expand Up @@ -1975,6 +1959,7 @@ problem rendering.
sub errorOutput($$$) {
my ($self, $error, $details) = @_;
my $r = $self->{r};

print "Entering ContentGenerator::errorOutput subroutine</br>" if $TRACE_WARNINGS;
my $time = time2str("%a %b %d %H:%M:%S %Y", time);
my $method = $r->method;
Expand Down
53 changes: 24 additions & 29 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ sub attemptResults {
$answerMessage =~ s/\n/<BR>/g;
$numCorrect += $answerScore >= 1;
$numBlanks++ unless $studentAnswer =~/\S/ || $answerScore >= 1; # unless student answer contains entry
my $resultString = $answerScore >= 1 ? CGI::span({class=>"ResultsWithoutError"}, $r->maketext("Correct")) :
my $resultString = $answerScore >= 1 ? CGI::span({class=>"ResultsWithoutError"}, $r->maketext("correct")) :
$answerScore > 0 ? $r->maketext("[_1]% correct", int($answerScore*100)) :
CGI::span({class=>"ResultsWithError"}, $r->maketext("Incorrect"));
CGI::span({class=>"ResultsWithError"}, $r->maketext("incorrect"));
$fully = $r->maketext("completely") if $answerScore >0 and $answerScore < 1;

push @correct_ids, $name if $answerScore == 1;
Expand Down Expand Up @@ -601,7 +601,7 @@ sub pre_header_initialize {
$problem->problem_seed($problemSeed);
}

my $visiblityStateClass = ($set->visible) ? $r->maketext("Visible") : $r->maketext("Hidden");
my $visiblityStateClass = ($set->visible) ? $r->maketext("visible") : $r->maketext("hidden");
my $visiblityStateText = ($set->visible) ? $r->maketext("visible to students")."." : $r->maketext("hidden from students").".";
$self->addmessage(CGI::span($r->maketext("This set is [_1]", CGI::font({class=>$visiblityStateClass}, $visiblityStateText))));

Expand Down Expand Up @@ -723,19 +723,6 @@ sub pre_header_initialize {
effectivePermissionLevel => $db->getPermissionLevel($effectiveUserName)->permission,
},
);
# sometimes, for example if the file can't be read, $pg->{pgcore} won't be defined
# because the PG file is never run
#
if (defined ($pg->{pgcore}) ) {
my $debug_msg = CGI::br().join( CGI::br(), @{ $pg->{pgcore}->get_debug_messages});
$self->addmessage($debug_msg ) if $debug_msg;
$self->{pgdebug} = $pg->{pgcore}->get_debug_messages;
$self->{pgwarning} = $pg->{pgcore}->get_warning_messages;
$self->{pginternalerrors} = $pg->{pgcore}->get_internal_debug_messages ;
$self->{pgerrors} = @{$self->{pgdebug}} || @{$self->{pgwarning}} || @{$self->{pginternalerrors}}||0;
} else {
$self->{pgerrors}=undef; # unable to obtain errors
}

debug("end pg processing");

Expand All @@ -753,6 +740,7 @@ sub pre_header_initialize {
$self->{will} = \%will;
$self->{pg} = $pg;
}

sub warnings {
my $self = shift;
# print "entering warnings() subroutine internal messages = ", $self->{pgerrors},CGI::br();
Expand Down Expand Up @@ -782,16 +770,15 @@ sub warnings {
"";
}

### #FIXME not clear this is ever used
# sub if_errors($$) {
# my ($self, $arg) = @_;
#
# if ($self->{isOpen}) {
# return $self->{pg}->{flags}->{error_flag} ? $arg : !$arg;
# } else {
# return !$arg;
# }
# }
sub if_errors($$) {
my ($self, $arg) = @_;

if ($self->{isOpen}) {
return $self->{pg}->{flags}->{error_flag} ? $arg : !$arg;
} else {
return !$arg;
}
}

sub head {
my ($self) = @_;
Expand Down Expand Up @@ -951,9 +938,11 @@ sub body {
my $set = $self->{set};
my $problem = $self->{problem};
my $pg = $self->{pg};

print CGI::p("Entering Problem::body subroutine.
This indicates an old style system.template file -- consider upgrading. ",
caller(1), );

my $valid = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::check_invalid($self);
unless($valid eq "valid"){
return $valid;
Expand Down Expand Up @@ -1083,8 +1072,8 @@ sub output_editorLink{

if ($pg->{flags}->{error_flag}) {
if ($authz->hasPermissions($user, "view_problem_debugging_info")) {
print "Call errorOutput</br>";
print $self->errorOutput($pg->{errors}, $pg->{body_text});

print $editorLink;
print $editorLink2;
} else {
Expand Down Expand Up @@ -1128,6 +1117,7 @@ sub output_checkboxes{
),"&nbsp;";
}
if ($can{showHints}) {

print WeBWorK::CGI_labeled_input(
-type => "checkbox",
-id => "showHints_id",
Expand All @@ -1143,8 +1133,6 @@ sub output_checkboxes{
-name => "showHints",
-value => 1,
}


),"&nbsp;";
}
if ($can{showSolutions}) {
Expand Down Expand Up @@ -1221,6 +1209,8 @@ sub output_score_summary{
my $submitAnswers = $self->{submitAnswers};

# score summary
warn "num_correct =", $problem->num_correct,"num_incorrect=",$problem->num_incorrect
unless defined($problem->num_correct) and defined($problem->num_incorrect) ;
my $attempts = $problem->num_correct + $problem->num_incorrect;
#my $attemptsNoun = $attempts != 1 ? $r->maketext("times") : $r->maketext("time");
my $problem_status = $problem->status || 0;
Expand All @@ -1246,6 +1236,7 @@ sub output_score_summary{
# $setClosedMessage .= " Additional attempts will not be recorded.";
# }
#}

unless (defined( $pg->{state}->{state_summary_msg}) and $pg->{state}->{state_summary_msg}=~/\S/) {
my $notCountedMessage = ($problem->value) ? "" : $r->maketext("(This problem will not count towards your grade.)");
print CGI::p(join("",
Expand Down Expand Up @@ -1375,6 +1366,7 @@ sub output_summary{
# do I need to check $will{showCorrectAnswers} to make preflight work??

if (defined($pg->{flags}->{showPartialCorrectAnswers}) and ($pg->{flags}->{showPartialCorrectAnswers} >= 0 and $submitAnswers) ) {

# print this if user submitted answers OR requested correct answers
my $results = $self->attemptResults($pg, 1,
$will{showCorrectAnswers},
Expand Down Expand Up @@ -1432,6 +1424,9 @@ sub output_custom_edit_message{
return "";
}




# output_past_answer_button

# prints out the "Show Past Answers" button
Expand Down
6 changes: 3 additions & 3 deletions lib/WeBWorK/URLPath.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
# Copyright © 2000-2012 The openWeBWorK Project, http://github.com/openwebwork
# $CVSHeader: webwork2/lib/WeBWorK/URLPath.pm,v 1.36 2008/04/29 19:27:34 sh002i Exp $
#
# This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -176,7 +176,7 @@ our %pathTypes = (
set_list => {
name => '$courseID',
parent => 'root',
kids => [ qw/equation_display feedback gateway_quiz proctored_gateway_quiz grades hardcopy
kids => [ qw/equation_display feedback gateway_quiz proctored_gateway_quiz grades hardcopy achievements
logout options instructor_tools problem_list
/ ],
match => qr|^([^/]+)/|,
Expand Down Expand Up @@ -311,7 +311,7 @@ our %pathTypes = (
name => 'Instructor Tools',
parent => 'set_list',
kids => [ qw/instructor_user_list instructor_user_list2 instructor_user_list3 instructor_set_list instructor_set_list2
instructor_add_users
instructor_add_users instructor_achievement_list
instructor_set_assigner instructor_file_manager
instructor_problem_editor instructor_problem_editor2
instructor_set_maker instructor_set_maker2 instructor_set_maker3
Expand Down

0 comments on commit a3e1f2a

Please sign in to comment.