';
+ my @grade = grep(/^\Q${version}resource.$respid.$partid.\E[^.]*[.]status$/,
+ keys(%{$record}));
+ foreach my $grade (sort(@grade)) {
+ my ($dim) = ($grade =~/[.]([^.]+)[.]status$/);
+ $result.= '
'.&mt("Dimension: [_1], status [_2] ",
+ $dim, $record->{$grade}).
+ '
';
+ }
+ $result.='
';
+ return $result;
+ }
+ } elsif ( $response =~ m/(?:numerical|formula)/) {
+ $answer =
+ &Apache::loncommon::format_previous_attempt_value('submission',
+ $answer);
}
return $answer;
}
@@ -187,7 +464,8 @@ sub commonJSfunctions {
}
}
} else {
- if (selectOne.selected) return selectOne.value;
+ // only one value it must be the selected one
+ return selectOne.value;
}
}
@@ -197,34 +475,80 @@ COMMONJSFUNCTIONS
#--- Dumps the class list with usernames,list of sections,
#--- section, ids and fullnames for each user.
sub getclasslist {
- my ($getsec,$filterlist) = @_;
- my $classlist=&Apache::loncoursedata::get_classlist();
+ my ($getsec,$filterlist,$getgroup) = @_;
+ my @getsec;
+ my @getgroup;
+ my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status'));
+ if (!ref($getsec)) {
+ if ($getsec ne '' && $getsec ne 'all') {
+ @getsec=($getsec);
+ }
+ } else {
+ @getsec=@{$getsec};
+ }
+ if (grep(/^all$/,@getsec)) { undef(@getsec); }
+ if (!ref($getgroup)) {
+ if ($getgroup ne '' && $getgroup ne 'all') {
+ @getgroup=($getgroup);
+ }
+ } else {
+ @getgroup=@{$getgroup};
+ }
+ if (grep(/^all$/,@getgroup)) { undef(@getgroup); }
+
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
+ &Apache::loncoursedata::get_group_memberships($classlist,$keylist);
#
my %sections;
my %fullnames;
- foreach (keys(%$classlist)) {
- # the following undefs are for 'domain', and 'username' respectively.
- my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
- @{$classlist->{$_}};
+ foreach my $student (keys(%$classlist)) {
+ my $end =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_END()];
+ my $start =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_START()];
+ my $id =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_ID()];
+ my $section =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()];
+ my $fullname =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_FULLNAME()];
+ my $status =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()];
+ my $group =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()];
# filter students according to status selected
- if ($filterlist && $ENV{'form.Status'} ne 'Any') {
- if ($ENV{'form.Status'} ne $status) {
- delete ($classlist->{$_});
+ if ($filterlist && (!($stu_status =~ /Any/))) {
+ if (!($stu_status =~ $status)) {
+ delete($classlist->{$student});
next;
}
}
- $section = ($section ne '' ? $section : 'no');
+ # filter students according to groups selected
+ if (@getgroup) {
+ my $exclude = 1;
+ foreach my $grp(@getgroup) {
+ if ($group eq $grp) {
+ $exclude = 0;
+ }
+ }
+ if ($exclude) {
+ delete($classlist->{$student});
+ }
+ }
+ $section = ($section ne '' ? $section : 'none');
if (&canview($section)) {
- if ($getsec eq 'all' || $getsec eq $section) {
+ if (!@getsec || grep(/^\Q$section\E$/,@getsec)) {
$sections{$section}++;
- $fullnames{$_}=$fullname;
+ if ($classlist->{$student}) {
+ $fullnames{$student}=$fullname;
+ }
} else {
- delete($classlist->{$_});
+ delete($classlist->{$student});
}
} else {
- delete($classlist->{$_});
+ delete($classlist->{$student});
}
}
my %seen = ();
@@ -274,11 +598,11 @@ sub canview {
#--- Retrieve the grade status of a student for all the parts
sub student_gradeStatus {
- my ($url,$symb,$udom,$uname,$partlist) = @_;
- my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my ($symb,$udom,$uname,$partlist) = @_;
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
my %partstatus = ();
foreach (@$partlist) {
- my ($status,$foo) = split(/_/,$record{"resource.$_.solved"},2);
+ my ($status,undef) = split(/_/,$record{"resource.$_.solved"},2);
$status = 'nothing' if ($status eq '');
$partstatus{$_} = $status;
my $subkey = "resource.$_.submitted_by";
@@ -291,7 +615,8 @@ sub student_gradeStatus {
# Use by verifyscript and viewgrades
# Shows a student's view of problem and submission
sub jscriptNform {
- my ($url,$symb) = @_;
+ my ($symb) = @_;
+ my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status'));
my $jscript=''."\n";
$jscript.= '
'."\n".
''."\n";
+ 'value="Next->" />'."\n";
if ($ctr == 0) {
my $num_students=(scalar(keys(%$fullname)));
if ($num_students eq 0) {
- $gradeTable=' There are no students currently enrolled.';
+ $gradeTable=' There are no students currently enrolled.';
} else {
- $gradeTable=' '.
- 'No submissions found for this resource for any students. ('.$num_students.
- ' checked for submissions ';
+ my $submissions='submissions';
+ if ($submitonly eq 'incorrect') { $submissions = 'incorrect submissions'; }
+ if ($submitonly eq 'graded' ) { $submissions = 'ungraded submissions'; }
+ if ($submitonly eq 'queued' ) { $submissions = 'queued submissions'; }
+ $gradeTable=' '.
+ 'No '.$submissions.' found for this resource for any students. ('.$num_students.
+ ' students checked for '.$submissions.') ';
}
} elsif ($ctr == 1) {
$gradeTable =~ s/type=checkbox/type=checkbox checked/;
}
- $gradeTable.=&show_grading_menu_form($symb,$url);
+ $gradeTable.=&show_grading_menu_form($symb);
$request->print($gradeTable);
return '';
}
#---- Called from the listStudents routine
+
+sub check_script {
+ my ($form, $type)=@_;
+ my $chkallscript=''."\n";
+ return $chkallscript;
+}
+
+sub check_buttons {
+ my $buttons.='';
+ $buttons.=' ';
+ $buttons.='';
+ $buttons.=' ';
+ return $buttons;
+}
+
# Displays the submissions for one student or a group of students
sub processGroup {
my ($request) = shift;
my $ctr = 0;
- my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}
- : ($ENV{'form.stuinfo'}));
+ my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo');
my $total = scalar(@stuchecked)-1;
- foreach (@stuchecked) {
- my ($uname,$udom,$fullname) = split(/:/);
- $ENV{'form.student'} = $uname;
- $ENV{'form.userdom'} = $udom;
- $ENV{'form.fullname'} = $fullname;
+ foreach my $student (@stuchecked) {
+ my ($uname,$udom,$fullname) = split(/:/,$student);
+ $env{'form.student'} = $uname;
+ $env{'form.userdom'} = $udom;
+ $env{'form.fullname'} = $fullname;
&submission($request,$ctr,$total);
$ctr++;
}
@@ -625,9 +1105,9 @@ sub sub_page_js {
$request->print(<
function updateRadio(formname,id,weight) {
- var gradeBox = eval("formname.GD_BOX"+id);
- var radioButton = eval("formname.RADVAL"+id);
- var oldpts = eval("formname.oldpts"+id+".value");
+ var gradeBox = formname["GD_BOX"+id];
+ var radioButton = formname["RADVAL"+id];
+ var oldpts = formname["oldpts"+id].value;
var pts = checkSolved(formname,id) == 'update' ? gradeBox.value : oldpts;
gradeBox.value = pts;
var resetbox = false;
@@ -649,7 +1129,7 @@ sub sub_page_js {
var resp = confirm("You entered a value ("+pts+
") greater than the weight for the part. Accept?");
if (resp == false) {
- gradeBox.value = "";
+ gradeBox.value = oldpts;
return;
}
}
@@ -661,18 +1141,17 @@ sub sub_page_js {
}
}
updateSelect(formname,id);
- var stores = eval("formname.stores"+id);
- stores.value = "0";
+ formname["stores"+id].value = "0";
}
function writeBox(formname,id,pts) {
- var gradeBox = eval("formname.GD_BOX"+id);
+ var gradeBox = formname["GD_BOX"+id];
if (checkSolved(formname,id) == 'update') {
gradeBox.value = pts;
} else {
- var oldpts = eval("formname.oldpts"+id+".value");
+ var oldpts = formname["oldpts"+id].value;
gradeBox.value = oldpts;
- var radioButton = eval("formname.RADVAL"+id);
+ var radioButton = formname["RADVAL"+id];
for (var i=0; idir_config('lonIconsURL');
&commonJSfunctions($request);
+
+ my $inner_js_msg_central=<
+ function checkInput() {
+ opener.document.SCORE.msgsub.value = opener.checkEntities(document.msgcenter.msgsub.value);
+ var nmsg = opener.document.SCORE.savemsgN.value;
+ var usrctr = document.msgcenter.usrctr.value;
+ var newval = opener.document.SCORE["newmsg"+usrctr];
+ newval.value = opener.checkEntities(document.msgcenter.newmsg.value);
+
+ var msgchk = "";
+ if (document.msgcenter.subchk.checked) {
+ msgchk = "msgsub,";
+ }
+ var includemsg = 0;
+ for (var i=1; i<=nmsg; i++) {
+ var opnmsg = opener.document.SCORE["savemsg"+i];
+ var frmmsg = document.msgcenter["msg"+i];
+ opnmsg.value = opener.checkEntities(frmmsg.value);
+ var showflg = opener.document.SCORE["shownOnce"+i];
+ showflg.value = "1";
+ var chkbox = document.msgcenter["msgn"+i];
+ if (chkbox.checked) {
+ msgchk += "savemsg"+i+",";
+ includemsg = 1;
+ }
+ }
+ if (document.msgcenter.newmsgchk.checked) {
+ msgchk += "newmsg"+usrctr;
+ includemsg = 1;
+ }
+ imgformname = opener.document.SCORE["mailicon"+usrctr];
+ imgformname.src = "$iconpath/"+((includemsg) ? "mailto.gif" : "mailbkgrd.gif");
+ var includemsg = opener.document.SCORE["includemsg"+usrctr];
+ includemsg.value = msgchk;
+
+ self.close()
+
+ }
+
+INNERJS
+
+ my $inner_js_highlight_central=<
+ function updateChoice(flag) {
+ opener.document.SCORE.kwclr.value = opener.radioSelection(document.hlCenter.kwdclr);
+ opener.document.SCORE.kwsize.value = opener.radioSelection(document.hlCenter.kwdsize);
+ opener.document.SCORE.kwstyle.value = opener.radioSelection(document.hlCenter.kwdstyle);
+ opener.document.SCORE.refresh.value = "on";
+ if (opener.document.SCORE.keywords.value!=""){
+ opener.document.SCORE.submit();
+ }
+ self.close()
+ }
+
+INNERJS
+
+ my $start_page_msg_central =
+ &Apache::loncommon::start_page('Message Central',$inner_js_msg_central,
+ {'js_ready' => 1,
+ 'only_body' => 1,
+ 'bgcolor' =>'#FFFFFF',});
+ my $end_page_msg_central =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
+
+ my $start_page_highlight_central =
+ &Apache::loncommon::start_page('Highlight Central',
+ $inner_js_highlight_central,
+ {'js_ready' => 1,
+ 'only_body' => 1,
+ 'bgcolor' =>'#FFFFFF',});
+ my $end_page_highlight_central =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
+ my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
+ $docopen=~s/^document\.//;
$request->print(<
//===================== Show list of keywords ====================
- function keywords(keyform) {
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);
+ function keywords(formname) {
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
if (nret==null) return;
- keyform.value = nret;
+ formname.keywords.value = nret;
- document.SCORE.refresh.value = "on";
- if (document.SCORE.keywords.value != "") {
- document.SCORE.submit();
+ if (formname.keywords.value != "") {
+ formname.refresh.value = "on";
+ formname.submit();
}
return;
}
@@ -832,10 +1394,9 @@ sub sub_page_kw_js {
}
var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);
if (nret==null) return;
- var curlist = document.SCORE.keywords.value;
- document.SCORE.keywords.value = curlist+" "+nret;
- document.SCORE.refresh.value = "on";
+ document.SCORE.keywords.value = document.SCORE.keywords.value+" "+nret;
if (document.SCORE.keywords.value != "") {
+ document.SCORE.refresh.value = "on";
document.SCORE.submit();
}
return;
@@ -852,21 +1413,23 @@ sub sub_page_kw_js {
var Nmsg = msgform.savemsgN.value;
savedMsgHeader(Nmsg,usrctr,fullname);
var subject = msgform.msgsub.value;
- var rtrchk = eval("document.SCORE.includemsg"+usrctr);
- var msgchk = rtrchk.value;
+ var msgchk = document.SCORE["includemsg"+usrctr].value;
re = /msgsub/;
var shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- displaySubject(subject,shwsel);
+ subject = (document.SCORE.shownSub.value == 0 ? checkEntities(subject) : subject);
+ displaySubject(checkEntities(subject),shwsel);
for (var i=1; i<=Nmsg; i++) {
- var testpt = "savemsg"+i+",";
- re = /testpt/;
+ var testmsg = "savemsg"+i+",";
+ re = new RegExp(testmsg,"g");
shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- var message = eval("document.SCORE.savemsg"+i+".value");
- displaySavedMsg(i,message,shwsel);
+ var message = document.SCORE["savemsg"+i].value;
+ message = (document.SCORE["shownOnce"+i].value == 0 ? checkEntities(message) : message);
+ displaySavedMsg(i,message,shwsel); //I do not get it. w/o checkEntities on saved messages,
+ //any < is already converted to <, etc. However, only once!!
}
- newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
+ newmsg = document.SCORE["newmsg"+usrctr].value;
shwsel = "";
re = /newmsg/;
if (re.test(msgchk)) { shwsel = "checked" }
@@ -875,6 +1438,22 @@ sub sub_page_kw_js {
return;
}
+ function checkEntities(strx) {
+ if (strx.length == 0) return strx;
+ var orgStr = ["&", "<", ">", '"'];
+ var newStr = ["&", "<", ">", """];
+ var counter = 0;
+ while (counter < 4) {
+ strx = strReplace(strx,orgStr[counter],newStr[counter]);
+ counter++;
+ }
+ return strx;
+ }
+
+ function strReplace(strx, orgStr, newStr) {
+ return strx.split(orgStr).join(newStr);
+ }
+
function savedMsgHeader(Nmsg,usrctr,fullname) {
var height = 70*Nmsg+250;
var scrollbar = "no";
@@ -882,62 +1461,20 @@ sub sub_page_kw_js {
height = 600;
scrollbar = "yes";
}
-// if (window.pWin) {window.pWin.close(); window.pWin=null}
var xpos = (screen.width-600)/2;
xpos = (xpos < 0) ? '0' : xpos;
var ypos = (screen.height-height)/2-30;
ypos = (ypos < 0) ? '0' : ypos;
- pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
+ pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
pWin.focus();
pDoc = pWin.document;
- pDoc.write("");
- pDoc.write("Message Central");
-
- pDoc.write("
SUBJAVASCRIPT
}
+sub get_increment {
+ my $increment = $env{'form.increment'};
+ if ($increment != 1 && $increment != .5 && $increment != .25 &&
+ $increment != .1) {
+ $increment = 1;
+ }
+ return $increment;
+}
+
#--- displays the grading box, used in essay type problem and grading by page/sequence
sub gradeBox {
my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
-
- my $checkIcon = '';
-
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
- 'problem weight assigned by computer');
+ 'problem weight assigned by computer');
$wgt = ($wgt > 0 ? $wgt : '1');
my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
- '' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
+ '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt));
my $result=''."\n";
-
+ my $display_part=&get_display_part($partid,$symb);
+ my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
+ [$partid]);
+ my $aggtries = $$record{'resource.'.$partid.'.tries'};
+ if ($last_resets{$partid}) {
+ $aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
+ }
$result.='
'.
- 'Part '.$partid.' Points:
'."\n";
-
+ 'Part: '.$display_part.' Points:
'."\n";
my $ctr = 0;
+ my $thisweight = 0;
+ my $increment = &get_increment();
$result.='
'."\n"; # display radio buttons in a nice table 10 across
- while ($ctr<=$wgt) {
- $result.= '
'."\n");
+
+ if ($env{'form.handgrade'} eq 'no') {
my $checkMark='
Note: Part(s) graded correct by the computer is marked with a '.
$checkIcon.' symbol.'."\n";
$request->print($checkMark);
@@ -1207,108 +1854,139 @@ sub submission {
# option to display problem, only once else it cause problems
# with the form later since the problem has a form.
- if ($ENV{'form.vProb'} eq 'yes' or !$ENV{'form.vProb'}) {
- $request->print(&show_problem($request,$symb,$uname,$udom,0,1));
+ if ($env{'form.vProb'} eq 'yes' or $env{'form.vAns'} eq 'yes') {
+ my $mode;
+ if ($env{'form.vProb'} eq 'yes' && $env{'form.vAns'} eq 'yes') {
+ $mode='both';
+ } elsif ($env{'form.vProb'} eq 'yes') {
+ $mode='text';
+ } elsif ($env{'form.vAns'} eq 'yes') {
+ $mode='answer';
+ }
+ &Apache::lonxml::clear_problem_counter();
+ $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode));
}
-
+
# kwclr is the only variable that is guaranteed to be non blank
# if this subroutine has been called once.
my %keyhash = ();
- if ($ENV{'form.kwclr'} eq '' && $ENV{'form.handgrade'} eq 'yes') {
+ if ($env{'form.kwclr'} eq '' && $env{'form.handgrade'} eq 'yes') {
%keyhash = &Apache::lonnet::dump('nohist_handgrade',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
-
- my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
- $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
- $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
- $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
- $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
- $ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
- $keyhash{$symb.'_subject'} : $ENV{'form.probTitle'};
- $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
- }
-
- $request->print('
'."\n".
+ my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
+ $env{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+ $env{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+ $env{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+ $env{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+ $env{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
+ $keyhash{$symb.'_subject'} : $env{'form.probTitle'};
+ $env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
+ }
+ my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};
+ my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status'));
+ $request->print('
KEYWORDS
#
# Load the other essays for similarity check
#
- my $essayurl=&Apache::lonnet::declutter($url);
- my ($adom,$aname,$apath)=($essayurl=~/^(\w+)\/(\w+)\/(.*)$/);
- $apath=&Apache::lonnet::escape($apath);
+ my (undef,undef,$essayurl) = &Apache::lonnet::decode_symb($symb);
+ my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
+ $apath=&escape($apath);
$apath=~s/\W/\_/gs;
- %oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ %old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
}
}
- if ($ENV{'form.vProb'} eq 'all') {
- $request->print('
') if ($counter > 0);
- $request->print(&show_problem($request,$symb,$uname,$udom,1,1));
+# This is where output for one specific student would start
+ my $bgcolor='#DDEEDD';
+ if (int($counter/2) eq $counter) { $bgcolor='#DDDDEE'; }
+ $request->print("\n\n".
+ '
'.$env{'form.fullname'}.'
');
+
+ if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') {
+ my $mode;
+ if ($env{'form.vProb'} eq 'all' && $env{'form.vAns'} eq 'all') {
+ $mode='both';
+ } elsif ($env{'form.vProb'} eq 'all' ) {
+ $mode='text';
+ } elsif ($env{'form.vAns'} eq 'all') {
+ $mode='answer';
+ }
+ &Apache::lonxml::clear_problem_counter();
+ $request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode));
}
- my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
- my ($partlist,$handgrade) = &response_type($url);
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
+ my ($partlist,$handgrade,$responseType) = &response_type($symb);
# Display student info
$request->print(($counter == 0 ? '' : ' '));
- my $result='
'."\n".
- '
'."\n";
+ my $result='
'."\n".
+ '
'."\n";
- $result.='Fullname: '.$ENV{'form.fullname'}.
- ' Username: '.$uname.
- ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').' '."\n";
+ $result.='Fullname: '.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).' '."\n";
$result.=''."\n";
+ '" value="'.$env{'form.fullname'}.'" />'."\n";
# If any part of the problem is an essay-response (handgraded), then check for collaborators
my @col_fullnames;
my ($classlist,$fullname);
- if ($ENV{'form.handgrade'} eq 'yes') {
+ if ($env{'form.handgrade'} eq 'yes') {
($classlist,undef,$fullname) = &getclasslist('all','0');
for (keys (%$handgrade)) {
my $ncol = &Apache::lonnet::EXT('resource.'.$_.
@@ -1341,8 +2019,10 @@ KEYWORDS
$result.=$$fullname{$_}.' ';
}
$result.=' '."\n";
+ my ($part)=split(/\./,$_);
$result.=''."\n";
+ '" value="'.$part.':'.(join ':',@goodcollaborators).'" />'.
+ "\n";
}
if (scalar(@badcollaborators) > 0) {
$result.='
';
@@ -1367,123 +2047,179 @@ KEYWORDS
# (for multi-response type part)
# (3) Last submission plus the parts info
# (4) The whole record for this student
- if ($ENV{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
- if ($ENV{'form.'.$uname.':'.$udom.':submitted_by'}) {
- my $submitby=''.
- 'Collaborative submission by: '.
- ''.
- $$fullname{$ENV{'form.'.$uname.':'.$udom.':submitted_by'}}.'';
- $request->print($submitby);
- } else {
- my ($string,$timestamp)=
- &get_last_submission (%record);
- my $lastsubonly=''.
- ($$timestamp eq '' ? '' : 'Date Submitted: '.
- $$timestamp)."
\n";
- if ($$timestamp eq '') {
- $lastsubonly.='
'.$$string[0];
- } else {
- for my $part (sort keys(%$handgrade)) {
- my ($responsetype,$foo) = split(/:/,$$handgrade{$part});
- my ($partid,$respid) = split(/_/,$part);
- if (!exists($record{'resource.'.$partid.'.'.$respid.'.submission'})) {
- $lastsubonly.='
Part '.
- $partid.' ( ID '.$respid.
- ' ) Nothing submitted
';
- } else {
- foreach (@$string) {
- my ($partid,$respid) = /^resource\.(\w+)\.(\w+)\.submission/;
- if ($part eq ($partid.'_'.$respid)) {
- my ($ressub,$subval) = split(/:/,$_,2);
- # Similarity check
- my $similar='';
- my ($oname,$odom,$ocrsid,$oessay,$osim)=&most_similar($uname,$udom,$subval);
- if ($osim) {
- $osim=int($osim*100.0);
- $similar='
Essay is '.$osim.
- '% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
- '
'.
- &keywords_highlight($oessay).'
';
- }
- $lastsubonly.='
Part '.
- $partid.' ( ID '.$respid.
- ' ) '.
- ($record{"resource.$partid.$respid.uploadedurl"}?
- ' File uploaded by student '.
- 'Like all files provided by users, '.
- 'this file may contain virusses ':'').
- 'Submitted Answer: '.($responsetype eq 'essay' ? '
'.$$string[0];
+ } else {
+ my %seenparts;
+ my @part_response_id = &flatten_responseType($responseType);
+ foreach my $part (@part_response_id) {
+ next if ($env{'form.lastSub'} eq 'hdgrade'
+ && $$handgrade{$$part[0].'_'.$$part[1]} ne 'yes');
+
+ my ($partid,$respid) = @{ $part };
+ my $display_part=&get_display_part($partid,$symb);
+ if ($env{"form.$uname:$udom:$partid:submitted_by"}) {
+ if (exists($seenparts{$partid})) { next; }
+ $seenparts{$partid}=1;
+ my $submitby='Part: '.$display_part.
+ ' Collaborative submission by: '.
+ ''.
+ $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.' ';
+ $request->print($submitby);
+ next;
+ }
+ my $responsetype = $responseType->{$partid}->{$respid};
+ if (!exists($record{"resource.$partid.$respid.submission"})) {
+ $lastsubonly.='
Part: '.
+ $display_part.' ( ID '.$respid.
+ ' ) '.
+ 'Nothing submitted - no attempts
';
+ next;
+ }
+ foreach (@$string) {
+ my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/;
+ if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; }
+ my ($ressub,$subval) = split(/:/,$_,2);
+ # Similarity check
+ my $similar='';
+ if($env{'form.checkPlag'}){
+ my ($oname,$odom,$ocrsid,$oessay,$osim)=
+ &most_similar($uname,$udom,$subval,\%old_essays);
+ if ($osim) {
+ $osim=int($osim*100.0);
+ my %old_course_desc =
+ &Apache::lonnet::coursedescription($ocrsid,
+ {'one_time' => 1});
+
+ $similar="
".
+ &mt('Essay is [_1]% similar to an essay by [_2] ([_3]:[_4]) in course [_5] (course id [_6]:[_7])',
+ $osim,
+ &Apache::loncommon::plainname($oname,$odom),
+ $oname,$odom,
+ $old_course_desc{'description'},
+ $old_course_desc{'num'},
+ $old_course_desc{'domain'}).
+ '
'.
+ &keywords_highlight($oessay).
+ '
';
+ }
+ }
+ my $order=&get_order($partid,$respid,$symb,$uname,$udom);
+ if ($env{'form.lastSub'} eq 'lastonly' ||
+ ($env{'form.lastSub'} eq 'hdgrade' &&
+ $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
+ my $display_part=&get_display_part($partid,$symb);
+ $lastsubonly.='
Part: '.
+ $display_part.' ( ID '.$respid.
+ ' ) ';
+ my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
+ if (@$files) {
+ $lastsubonly.=' Like all files provided by users, this file may contain virusses ';
+ my $file_counter = 0;
+ foreach my $file (@$files) {
+ $file_counter ++;
+ &Apache::lonnet::allowuploaded('/adm/grades',$file);
+ $lastsubonly.=' '.$file.'';
}
+ $lastsubonly.=' ';
}
+ $lastsubonly.='Submitted Answer: '.
+ &cleanRecord($subval,$responsetype,$symb,$partid,
+ $respid,\%record,$order);
+ if ($similar) {$lastsubonly.="
'."\n");
}
- # essay grading options
- if ($ENV{'form.handgrade'} eq 'yes') {
- $result=''."\n".
- ''."\n".
- ''."\n";
- my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
+ # essay grading message center
+ if ($env{'form.handgrade'} eq 'yes') {
+ my ($lastname,$givenn) = split(/,/,$env{'form.fullname'});
my $msgfor = $givenn.' '.$lastname;
if (scalar(@col_fullnames) > 0) {
my $lastone = pop @col_fullnames;
$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
}
$msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
-# $result.='
'."\n".
+ $result=''."\n".
+ ''."\n";
$result.=' '.
- 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').' '.
+ ',\''.$msgfor.'\');" target="_self">'.
+ &mt('Compose message to student').(scalar(@col_fullnames) >= 1 ? 's' : '').')'.
''."\n".
- ' (Message will be sent when you click on Save & Next below.)'."\n"
- if ($ENV{'form.handgrade'} eq 'yes');
+ ' ('.
+ &mt('Message will be sent when you click on Save & Next below.').")\n";
$request->print($result);
}
+ if ($perm{'vgr'}) {
+ $request->print(' '.
+ &Apache::loncommon::track_student_link(&mt('View recent activity'),
+ $uname,$udom,'check'));
+ }
+ if ($perm{'opa'}) {
+ $request->print(' '.
+ &Apache::loncommon::pprmlink(&mt('Set/Change parameters'),
+ $uname,$udom,$symb,'check'));
+ }
my %seen = ();
my @partlist;
- for (sort keys(%$handgrade)) {
- my ($partid,$respid) = split(/_/);
+ my @gradePartRespid;
+ my @part_response_id = &flatten_responseType($responseType);
+ foreach my $part_response_id (@part_response_id) {
+ my ($partid,$respid) = @{ $part_response_id };
+ my $part_resp = join('_',@{ $part_response_id });
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
+ next if ($$handgrade{$part_resp} ne 'yes'
+ && $env{'form.lastSub'} eq 'hdgrade');
push @partlist,$partid;
-
+ push @gradePartRespid,$partid.'.'.$respid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
}
$result=''."\n";
+ $result.=''."\n" if ($counter == 0);
my $ctr = 0;
while ($ctr < scalar(@partlist)) {
$result.='print('
');
+
+
# print end of form
if ($counter == $total) {
- my $endform='
'.
- ''."\n";
-# if ($ENV{'form.handgrade'} eq 'yes') {
- $endform.=' '."\n";
- my $ntstu =''."\n";
- my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
- $ntstu =~ s/