Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons in LB1 to signal problems with math objects and static problems #530

Merged
merged 7 commits into from
Jan 2, 2015
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/OPL-update
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ if($libraryVersion eq '2.5') {
morelt_id int(127) DEFAULT 0 NOT NULL,
level int(15),
language varchar(15),
static TINYINT,
MO TINYINT,
PRIMARY KEY (pgfile_id)
'],
[$tables{keyword}, '
Expand Down Expand Up @@ -644,7 +646,7 @@ sub pgfiles {
my $path_id = safe_get_id($tables{path}, 'path_id',
qq(WHERE path = ?), [$pgpath], 1, "", $pgpath, "", "");

# pgfile table -- set 2 defaults first
# pgfile table -- set 4 defaults first

## TODO this is where we have to deal with crosslists, and pgfileid
## will be an array of id's
Expand All @@ -653,12 +655,14 @@ sub pgfiles {
my $level = $tags->{Level} || 0;
# Default language is English
my $lang = $tags->{Language} || "en";
my $mathobj = $tags->{MO} || 0;
my $static = $tags->{Static} || 0;

my @pgfile_ids = ();

for my $DBsection_id (@DBsection_ids) {
my $pgfile_id = safe_get_id($tables{pgfile}, 'pgfile_id',
qq(WHERE filename = ? AND path_id = ? AND DBsection_id = ? ), [$pgfile, $path_id, $DBsection_id], 1, "", $DBsection_id, $author_id, $tags->{Institution}, $path_id, $pgfile, 0, $level, $lang);
qq(WHERE filename = ? AND path_id = ? AND DBsection_id = ? ), [$pgfile, $path_id, $DBsection_id], 1, "", $DBsection_id, $author_id, $tags->{Institution}, $path_id, $pgfile, 0, $level, $lang, $static, $mathobj);
push @pgfile_ids, $pgfile_id;
}
#if (scalar(@pgfile_ids)>1) {
Expand Down
31 changes: 31 additions & 0 deletions htdocs/helpFiles/UsesMathObjects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>
<!--
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright � 2000-2014 The WeBWorK Project, http://openwebwork.sf.net/
# This program is free software; you can redistribute it and/or modify it under
# the terms of either: (a) the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version, or (b) the "Artistic License" which comes with this package.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
# Artistic License for more details.
################################################################################
-->
<head>
<title>Uses Math Objects</title>
</head>

<body><br>
<p>
Some WeBWorK are programmed using what are called <i>Math Objects</i>.
These problems are preferred by some people because they
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "Some WeBWorK problems"

provide a more consistent collection of messages to faulty student
answers, particularly for answers which are way off base.
</p>


</body>
</html>
Binary file added htdocs/images/pibox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@ sub munge_pg_file_path {
return($pg_path);
}

## Problems straight from the OPL database come with MO and static
## tag information. This is for other times, like next/prev page.

sub getDBextras {
my $r = shift;
my $sourceFileName = shift;

if($sourceFileName =~ /^Library/) {
return WeBWorK::Utils::ListingDB::getDBextras($r, $sourceFileName);
}

my $filePath = $r->ce->{courseDirs}{templates}."/$sourceFileName";
my $tag_obj = WeBWorK::Utils::Tags->new($filePath);
my $isMO = $tag_obj->{MO} || 0;
my $isstatic = $tag_obj->{Static} || 0;

return ($isMO, $isstatic);
}

## With MLT, problems come in groups, so we need to find next/prev
## problems. Return index, or -1 if there are no more.
sub next_prob_group {
Expand Down Expand Up @@ -933,6 +952,11 @@ sub make_data_row {
my $sourceFileData = shift;
my $sourceFileName = $sourceFileData->{filepath};
my $pg = shift;
my $isstatic = $sourceFileData->{static};
my $isMO = $sourceFileData->{MO};
if (not defined $isMO) {
($isMO, $isstatic) = getDBextras($r, $sourceFileName);
}
my $cnt = shift;
my $mltnumleft = shift;

Expand Down Expand Up @@ -1028,7 +1052,8 @@ sub make_data_row {

my $level =0;

my $rerand = '<span style="display: inline-block" onclick="randomize(\''.$sourceFileName.'\',\'render'.$cnt.'\')" title="Randomize"><i class="icon-random" ></i></span>';
my $rerand = $isstatic ? '' : '<span style="display: inline-block" onclick="randomize(\''.$sourceFileName.'\',\'render'.$cnt.'\')" title="Randomize"><i class="icon-random"></i></span>';
my $MOtag = $isMO ? $self->helpMacro("UsesMathObjects",'<img src="/webwork2_files/images/pibox.png" border="0" title="Uses Math Objects" alt="Uses Math Objects" />') : '';

print $mltstart;
# Print the cell
Expand All @@ -1041,7 +1066,7 @@ sub make_data_row {
"\n",CGI::span({-style=>"text-align: left; cursor: pointer"},CGI::span({id=>"filepath$cnt"},"Show path ...")),"\n",
'<script type="text/javascript">settoggle("filepath'.$cnt.'", "Show path ...", "Hide path: '.$sourceFileName.'")</script>',
CGI::span({-style=>"float:right ; text-align: right"},
$inSet, $mlt, $rerand,
$inSet, $MOtag, $mlt, $rerand,
$edit_link, " ", $try_link,
CGI::span({-name=>"dont_show",
-title=>"Hide this problem",
Expand Down Expand Up @@ -1528,7 +1553,7 @@ sub head {
my $ce = $self->r->ce;
my $webwork_htdocs_url = $ce->{webwork_htdocs_url};

print qq!<link rel="stylesheet" href="$webwork_htdocs_url/js/vendor/FontAwesome/css/font-awesome.css">!;
#print qq!<link rel="stylesheet" href="$webwork_htdocs_url/js/vendor/FontAwesome/css/font-awesome.css">!;

print qq!<script src="$webwork_htdocs_url/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>!;
print qq!<script src="$webwork_htdocs_url/js/vendor/jquery/jquery-ui.js"></script>!;
Expand Down
42 changes: 38 additions & 4 deletions lib/WeBWorK/Utils/ListingDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use strict;
use DBI;
use WeBWorK::Utils qw(sortByName);
use WeBWorK::Utils::Tags;
use File::Basename;

use constant LIBRARY_STRUCTURE => {
textbook => { select => 'tbk.textbook_id,tbk.title,tbk.author,tbk.edition',
Expand All @@ -42,7 +43,7 @@ BEGIN
&createListing &updateListing &deleteListing &getAllChapters
&getAllSections &searchListings &getAllListings &getSectionListings
&getAllDBsubjects &getAllDBchapters &getAllDBsections &getDBTextbooks
&getDBListings &countDBListings &getTables
&getDBListings &countDBListings &getTables &getDBextras
);
%EXPORT_TAGS =();
@EXPORT_OK =qw();
Expand Down Expand Up @@ -122,7 +123,7 @@ sub getProblemTags {
my $path = shift;
my $tags = WeBWorK::Utils::Tags->new($path);
my %thash = ();
for my $j ('DBchapter', 'DBsection', 'DBsubject', 'Level') {
for my $j ('DBchapter', 'DBsection', 'DBsubject', 'Level', 'Status') {
$thash{$j} = $tags->{$j};
}
return \%thash;
Expand All @@ -135,11 +136,13 @@ sub setProblemTags {
my $chap = shift;
my $sect = shift;
my $level = shift;
my $status = shift || 0;
my $tags = WeBWorK::Utils::Tags->new($path);
$tags->settag('DBsubject', $subj, 1);
$tags->settag('DBchapter', $chap, 1);
$tags->settag('DBsection', $sect, 1);
$tags->settag('Level', $level, 1);
$tags->settag('Status', $status, 0) if $status;
eval {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity what is the status tag?

$tags->write();
1;
Expand Down Expand Up @@ -182,6 +185,37 @@ sub makeKeywordWhere {
return "AND ( $where )";
}

=item getDBextras($path)
Get flags for whether a pg file uses Math Objects, and if it is static

$r is a Apache request object so we can get the right table names

$path is the path to the file

Out put is an array reference: [MO, static]

=cut

sub getDBextras {
my $r = shift;
my $path = shift;
my %tables = getTables($r->ce);
my $dbh = getDB($r->ce);
my ($mo, $static)=(0,0);

$path =~ s|^Library/||;
my $filename = basename $path;
$path = dirname $path;
my $query = "SELECT pgfile.MO, pgfile.static FROM `$tables{pgfile}` pgfile, `$tables{path}` p WHERE p.path=\"$path\" AND pgfile.path_id=p.path_id AND pgfile.filename=\"$filename\"";
my @res = $dbh->selectrow_array($query);
if(@res) {
$mo = $res[0];
$static = $res[1];
}

return [$mo, $static];
}

=item getDBTextbooks($r)
Returns textbook dependent entries.

Expand Down Expand Up @@ -440,10 +474,10 @@ sub getDBListings {
}
my @results=();
for my $pgid (@pg_ids) {
$query = "SELECT path, filename, morelt_id, pgfile_id FROM `$tables{pgfile}` pgf, `$tables{path}` p
$query = "SELECT path, filename, morelt_id, pgfile_id, static, MO FROM `$tables{pgfile}` pgf, `$tables{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], 'morelt' => $row->[2], 'pgid'=> $row->[3] };
push @results, {'path' => $row->[0], 'filename' => $row->[1], 'morelt' => $row->[2], 'pgid'=> $row->[3], 'static' => $row->[4], 'MO' => $row->[5] };

}
return @results;
Expand Down
4 changes: 2 additions & 2 deletions lib/WeBWorK/Utils/Tags.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ our @EXPORT_OK = qw();
# list_set_versions
#);

use constant BASIC => qw( DBsubject DBchapter DBsection Date Institution Author MLT MLTleader Level Language );
use constant BASIC => qw( DBsubject DBchapter DBsection Date Institution Author MLT MLTleader Level Language Static MO Status );
use constant NUMBERED => qw( TitleText AuthorText EditionText Section Problem );

my $basics = join('|', BASIC);
Expand Down Expand Up @@ -333,7 +333,7 @@ sub copyin {
# }
# }
# Just copy in all basic tags
for my $j (qw( DBsubject DBchapter DBsection Date Institution Author MLT MLTleader Level )) {
for my $j (qw( DBsubject DBchapter DBsection MLT MLTleader Level )) {
$self->settag($j, $ob->{$j}) if(defined($ob->{$j}));
}
# Now copy in keywords
Expand Down