'.
- ''.
- ' Select Username '.
- ' Fullname Domain ';
- foreach (sort(@$partlist)) {
- $result.=' Part ID '.$_.' Status ';
+ $gradeTable .=
+ &build_section_inputs().
+ ' '."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n".
+ ' '."\n";
+
+ if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) {
+ $gradeTable.=' '."\n";
+ } else {
+ $gradeTable.=&mt('Student Status: [_1]',
+ &Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);')).' ';
}
- $request->print($result.' '."\n");
- foreach my $student (sort(@{ $$classlist{$getsec} }) ) {
+ $gradeTable.=&mt('To '.lc($viewgrade).' a submission or a group of submissions, click on the check box(es) '.
+ 'next to the student\'s name(s). Then click on the Next button.').' '."\n".
+ ' '."\n";
+
+# checkall buttons
+ $gradeTable.=&check_script('gradesub', 'stuinfo');
+ $gradeTable.=' '."\n";
+ $gradeTable.=&check_buttons();
+ $gradeTable.=' '.&mt('Check For Plagiarism').' ';
+ my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup);
+ $gradeTable.= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row();
+ my $loop = 0;
+ while ($loop < 2) {
+ $gradeTable.=''.&mt('No.').' '.&mt('Select').' '.
+ ''.&nameUserString('header').' '.&mt('Section/Group').' ';
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
+ foreach my $part (sort(@$partlist)) {
+ my $display_part=
+ &get_display_part((split(/_/,$part))[0],$symb);
+ $gradeTable.=
+ ''.&mt('Part: [_1] Status',$display_part).' ';
+ }
+ } elsif ($submitonly eq 'queued') {
+ $gradeTable.=''.&mt('Queue Status').' ';
+ }
+ $loop++;
+# $gradeTable.=' ' if ($loop%2 ==1);
+ }
+ $gradeTable.=&Apache::loncommon::end_data_table_header_row()."\n";
+
+ my $ctr = 0;
+ foreach my $student (sort
+ {
+ if (lc($$fullname{$a}) ne lc($$fullname{$b})) {
+ return (lc($$fullname{$a}) cmp lc($$fullname{$b}));
+ }
+ return $a cmp $b;
+ }
+ (keys(%$fullname))) {
my ($uname,$udom) = split(/:/,$student);
- my (%status) = &student_gradeStatus($ENV{'form.url'},$udom,$uname,$partlist);
- my $statusflg = '';
- foreach (keys(%status)) {
- $statusflg = 1 if ($status{$_} ne 'nothing');
- my ($foo,$partid,$foo) = split(/\./,$_);
- if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
- $statusflg = '';
- $request->print(' ');
- }
- }
- next if ($statusflg eq '' && $submitonly eq 'yes');
-
- if ( $Apache::grades::viewgrades eq 'F' ) {
- $result=''.
- ' '."\n".
- ' '.$uname.' '."\n".
- ' '.$$fullname{$student}.' '."\n".
- ' '.$udom.' '."\n";
+
+ my %status = ();
+
+ if ($submitonly eq 'queued') {
+ my %queue_status =
+ &Apache::bridgetask::get_student_status($symb,$cdom,$cnum,
+ $udom,$uname);
+ next if (!defined($queue_status{'gradingqueue'}));
+ $status{'gradingqueue'} = $queue_status{'gradingqueue'};
+ }
+
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
+ (%status) =&student_gradeStatus($symb,$udom,$uname,$partlist);
+ my $submitted = 0;
+ my $graded = 0;
+ my $incorrect = 0;
+ foreach (keys(%status)) {
+ $submitted = 1 if ($status{$_} ne 'nothing');
+ $graded = 1 if ($status{$_} =~ /^ungraded/);
+ $incorrect = 1 if ($status{$_} =~ /^incorrect/);
+
+ my ($foo,$partid,$foo1) = split(/\./,$_);
+ if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+ $submitted = 0;
+ my ($part)=split(/\./,$partid);
+ $gradeTable.=' ';
+ }
+ }
- foreach (sort keys(%status)) {
- next if (/^resource.*?submitted_by$/);
- $result.=' '.$status{$_}.' '."\n";
+ next if (!$submitted && ($submitonly eq 'yes' ||
+ $submitonly eq 'incorrect' ||
+ $submitonly eq 'graded'));
+ next if (!$graded && ($submitonly eq 'graded'));
+ next if (!$incorrect && $submitonly eq 'incorrect');
+ }
+
+ $ctr++;
+ my $section = $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()];
+ my $group = $classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()];
+ if ( $perm{'vgr'} eq 'F' ) {
+ if ($ctr%2 ==1) {
+ $gradeTable.= &Apache::loncommon::start_data_table_row();
+ }
+ $gradeTable.=''.$ctr.' '.
+ ' '."\n".''.
+ &nameUserString(undef,$$fullname{$student},$uname,$udom).
+ ' '.$section.($group ne '' ?'/'.$group:'').' '."\n";
+
+ if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ foreach (sort(keys(%status))) {
+ next if ($_ =~ /^resource.*?submitted_by$/);
+ $gradeTable.=' '.&mt($status{$_}).' '."\n";
+ }
}
- $request->print($result.' '."\n");
+# $gradeTable.=' ' if ($ctr%2 ==1);
+ if ($ctr%2 ==0) {
+ $gradeTable.=&Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
+ }
+ if ($ctr%2 ==1) {
+ $gradeTable.=' ';
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
+ foreach (@$partlist) {
+ $gradeTable.=' ';
+ }
+ } elsif ($submitonly eq 'queued') {
+ $gradeTable.=' ';
+ }
+ $gradeTable.=&Apache::loncommon::end_data_table_row();
+ }
+
+ $gradeTable.=&Apache::loncommon::end_data_table()."\n".
+ ' '."\n";
+ if ($ctr == 0) {
+ my $num_students=(scalar(keys(%$fullname)));
+ if ($num_students eq 0) {
+ $gradeTable=' '.&mt('There are no students currently enrolled.').' ';
+ } else {
+ 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=' '.
+ &mt('No '.$submissions.' found for this resource for any students. ([_1] students checked for '.$submissions.')',
+ $num_students).
+ ' ';
}
+ } elsif ($ctr == 1) {
+ $gradeTable =~ s/type="checkbox"/type="checkbox" checked="checked"/;
+ }
+ $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;
- if ($stuchecked[0] eq '') {
- &userError($request,'No student was selected for viewing/grading.');
- return;
- }
- foreach (@stuchecked) {
- my ($uname,$udom,$fullname) = split(/:/);
- $ENV{'form.student'} = $uname;
- $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++;
}
return '';
}
-sub userError {
- my ($request, $reason, $step) = @_;
- $request->print('LON-CAPA User Error '."\n");
- $request->print('Reason: '.$reason.' '."\n");
- $request->print('Step: '.($step ne '' ? $step : 'Use your browser back button to correct')
- .' '."\n");
- return '';
-}
+#------------------------------------------------------------------------------------
+#
+#-------------------------- Next few routines handles grading by student, essentially
+# handles essay response type problem/part
+#
+#--- Javascript to handle the submission page functionality ---
+sub sub_page_js {
+ my $request = shift;
+ $request->print(<
+ function updateRadio(formname,id,weight) {
+ 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;
+ if (isNaN(pts) || pts < 0) {
+ alert("A number equal or greater than 0 is expected. Entered value = "+pts);
+ for (var i=0; i weight) {
+ var resp = confirm("You entered a value ("+pts+
+ ") greater than the weight for the part. Accept?");
+ if (resp == false) {
+ gradeBox.value = oldpts;
+ return;
+ }
}
- return ($name,$domain);
- } else {
- return ($ENV{'user.name'},$ENV{'user.domain'});
+
+ for (var i=0; i spec on what type of data to accept and provide an
-#interface based on that, also do that to above function.
-sub setstudentgrade {
- my ($url,$symb,$courseid,$student,@parts) = @_;
- my $result ='';
- my ($stuname,$domain) = split(/:/,$student);
- my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
- my %newrecord;
+ function updateSelect(formname,id) {
+ formname["GD_SEL"+id][0].selected = true;
+ return;
+ }
- foreach my $part (@parts) {
- my ($temp,$part,$type)=split(/_/,$part);
- my $oldscore=$record{"resource.$part.$type"};
- my $newscore=$ENV{"form.GRADE.$student.$part.$type"};
- if ($type eq 'solved') {
- my $update=0;
- if ($newscore eq 'nothing' ) {
- if ($oldscore ne '') {
- $update=1;
- $newscore = '';
+//=========== Check that a point is assigned for all the parts ============
+ function checksubmit(formname,val,total,parttot) {
+ formname.gradeOpt.value = val;
+ if (val == "Save & Next") {
+ for (i=0;i<=total;i++) {
+ for (j=0;j \n";
- if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
- if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
- if ($newscore eq 'excused') { $newscore = 'excused'; }
- if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
- } else {
- #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
}
- if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
- } else {
- if ($oldscore ne $newscore) {
- $newrecord{"resource.$part.$type"}=$newscore;
- $result.="Updating $student"."'s status for $part.$type to $newscore \n";
+
+ }
+ if (val == "Grade Student") {
+ formname.showgrading.value = "yes";
+ if (formname.Status.value == "") {
+ formname.Status.value = "Active";
+ }
+ formname.studentNo.value = total;
+ }
+ formname.submit();
+ }
+
+//======= Check that a score is assigned for all the problems (page/sequence grading only) =========
+ function checkSubmitPage(formname,total) {
+ noscore = new Array(100);
+ var ptr = 0;
+ for (i=1;i \n";
+ var i = 0;
+ while (i < ptr-1) {
+ prolist += noscore[i]+", ";
+ i++;
+ }
+ prolist += "and "+noscore[i];
+ }
+ var resp = confirm("You did not assign any score for the following problem"+sense+prolist+". Continue?");
+ if (resp == false) {
+ return false;
+ }
+ }
+
+ formname.submit();
+ }
+
+SUBJAVASCRIPT
+}
+
+#--- javascript for essay type problem --
+sub sub_page_kw_js {
+ my $request = shift;
+ my $iconpath = $request->dir_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(formname) {
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
+ if (nret==null) return;
+ formname.keywords.value = nret;
+
+ if (formname.keywords.value != "") {
+ formname.refresh.value = "on";
+ formname.submit();
+ }
+ return;
+ }
+
+//===================== Script to view submitted by ==================
+ function viewSubmitter(submitter) {
+ document.SCORE.refresh.value = "on";
+ document.SCORE.NCT.value = "1";
+ document.SCORE.unamedom0.value = submitter;
+ document.SCORE.submit();
+ return;
+ }
+
+//===================== Script to add keyword(s) ==================
+ function getSel() {
+ if (document.getSelection) txt = document.getSelection();
+ else if (document.selection) txt = document.selection.createRange().text;
+ else return;
+ var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
+ if (cleantxt=="") {
+ alert("Please select a word or group of words from document and then click this link.");
+ return;
+ }
+ var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);
+ if (nret==null) return;
+ document.SCORE.keywords.value = document.SCORE.keywords.value+" "+nret;
+ if (document.SCORE.keywords.value != "") {
+ document.SCORE.refresh.value = "on";
+ document.SCORE.submit();
+ }
+ return;
+ }
+
+//====================== Script for composing message ==============
+ // preload images
+ img1 = new Image();
+ img1.src = "$iconpath/mailbkgrd.gif";
+ img2 = new Image();
+ img2.src = "$iconpath/mailto.gif";
+
+ function msgCenter(msgform,usrctr,fullname) {
+ var Nmsg = msgform.savemsgN.value;
+ savedMsgHeader(Nmsg,usrctr,fullname);
+ var subject = msgform.msgsub.value;
+ var msgchk = document.SCORE["includemsg"+usrctr].value;
+ re = /msgsub/;
+ var shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ subject = (document.SCORE.shownSub.value == 0 ? checkEntities(subject) : subject);
+ displaySubject(checkEntities(subject),shwsel);
+ for (var i=1; i<=Nmsg; i++) {
+ var testmsg = "savemsg"+i+",";
+ re = new RegExp(testmsg,"g");
+ shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ 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 = document.SCORE["newmsg"+usrctr].value;
+ shwsel = "";
+ re = /newmsg/;
+ if (re.test(msgchk)) { shwsel = "checked" }
+ newMsg(newmsg,shwsel);
+ msgTail();
+ 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";
+ if (height > 600) {
+ height = 600;
+ scrollbar = "yes";
+ }
+ 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', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
+ pWin.focus();
+ pDoc = pWin.document;
+ pDoc.$docopen;
+ pDoc.write('$start_page_msg_central');
+
+ pDoc.write("