[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Wed Apr 15 14:56:19 EDT 2015


raeburn		Wed Apr 15 18:56:19 2015 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Add $res->answerable() method to Apache::lonnavmaps::resource
    for use by lonnet::get_commblock_resources().
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.506 loncom/interface/lonnavmaps.pm:1.507
--- loncom/interface/lonnavmaps.pm:1.506	Mon Apr 13 16:46:43 2015
+++ loncom/interface/lonnavmaps.pm	Wed Apr 15 18:56:15 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.506 2015/04/13 16:46:43 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.507 2015/04/15 18:56:15 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -5624,6 +5624,39 @@
 
 =pod
 
+B<Answerable>
+
+The answerable method differs from the completable method in its handling of problem parts
+for which feedback on correctness is suppressed, but the student still has tries left, and
+the problem part is not past due, (i.e., the student could submit a different answer if
+he/she so chose). For that case completable will return 0, whereas answerable will return 1.
+
+=cut
+
+sub answerable {
+    my $self = shift;
+    if (!$self->is_problem()) { return 0; }
+    my $partCount = $self->countParts();
+    foreach my $part (@{$self->parts()}) {
+        if ($part eq '0' && $partCount != 1) { next; }
+        my $status = $self->status($part);
+        if ($self->getCompletionStatus($part) == ATTEMPTED() ||
+            $self->getCompletionStatus($part) == CREDIT_ATTEMPTED() ||
+            $status == ANSWER_SUBMITTED() ) {
+            if ($self->tries($part) < $self->maxtries($part) || !$self->maxtries($part)) {
+                return 1;
+            }
+        }
+        if ($status == OPEN() || $status == TRIES_LEFT() || $status == NETWORK_FAILURE()) {
+            return 1;
+        }
+    }
+    # None of the parts were answerable, so neither is this problem.
+    return 0;
+}
+
+=pod
+
 =head2 Resource/Nav Map Navigation
 
 =over 4
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1282 loncom/lonnet/perl/lonnet.pm:1.1283
--- loncom/lonnet/perl/lonnet.pm:1.1282	Wed Apr 15 04:11:17 2015
+++ loncom/lonnet/perl/lonnet.pm	Wed Apr 15 18:56:19 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1282 2015/04/15 04:11:17 raeburn Exp $
+# $Id: lonnet.pm,v 1.1283 2015/04/15 18:56:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7332,7 +7332,7 @@
                             if ($timesup > $now) {
                                 my $activeblock;
                                 foreach my $res (@to_test) {
-                                    if ($res->completable()) {
+                                    if ($res->answerable()) {
                                         $activeblock = 1;
                                         last;
                                     }




More information about the LON-CAPA-cvs mailing list