'."\n".
''."\n".
'UserId | Domain | '."\n";
- foreach my $part (@parts) {
+ foreach my $part (sort(@parts)) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
$result.=''.$display.' | '."\n";
@@ -449,16 +449,88 @@ ENDUPFORM
return $result;
}
+sub csvupload_javascript_reverse_associate {
+ return(<2) { foundsomething=1; }
+ }
+ if (founduname==0 || founddomain==0) {
+ alert('You need to specify at both the username and domain');
+ return;
+ }
+ if (foundsomething==0) {
+ alert('You need to specify at least one grading field');
+ return;
+ }
+ vf.submit();
+ }
+ function flip(vf,tf) {
+ var nw=eval('vf.f'+tf+'.selectedIndex');
+ var i;
+ //can not pick the same destination field twice
+ for (i=0;i<=vf.nfields.value;i++) {
+ if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
+ eval('vf.f'+i+'.selectedIndex=0;')
+ }
+ }
+ }
+ENDPICK
+}
+
sub csvuploadmap_header {
my ($request,$symb,$url,$datatoken,$distotal)= @_;
my $result;
my $javascript;
if ($ENV{'form.upfile_associate'} eq 'reverse') {
-# $javascript=&csv_upload_javascript_reverse_associate();
+ $javascript=&csvupload_javascript_reverse_associate();
} else {
-# $javascript=&csv_upload_javascript_forward_associate();
+ $javascript=&csvupload_javascript_forward_associate();
}
- my $javascript_validations;#=&javascript_validations($krbdefdom);
$request->print(<
Uploading Class Grades for resource $url
@@ -481,7 +553,6 @@ to this page if the data selected is ins
ENDPICK
return '';
@@ -491,11 +562,11 @@ ENDPICK
sub csvupload_fields {
my ($url) = @_;
my (@parts) = &getpartlist($url);
- my @fields;
- foreach my $part (@parts) {
+ my @fields=(['username','Student Username'],['domain','Student Domain']);
+ foreach my $part (sort(@parts)) {
my @datum;
my $display=&Apache::lonnet::metadata($url,$part.'.display');
- my $name=&Apache::lonnet::metadata($url,$part.'.name');
+ my $name=$part;
if (!$display) { $display = $name; }
@datum=($name,$display);
push(@fields,\@datum);
@@ -549,6 +620,43 @@ sub csvuploadmap {
return '';
}
+sub csvuploadassign {
+ my ($request)= @_;
+ my ($symb,$url)=&get_symb_and_url($request);
+ if (!$symb) {return '';}
+ &Apache::loncommon::load_tmp_file($request);
+ my @gradedata=&Apache::loncommon::upfile_record_sep();
+ my @keyfields = split(/\,/,$ENV{'form.keyfields'});
+ my %fields=();
+ for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
+ if ($ENV{'form.upfile_associate'} eq 'reverse') {
+ if ($ENV{'form.f'.$i} ne 'none') {
+ $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
+ }
+ } else {
+ if ($ENV{'form.f'.$i} ne 'none') {
+ $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
+ }
+ }
+ }
+ $request->print('Assigning Grades');
+ &Apache::lonhomework::showhash(('1'=>\@keyfields));
+ &Apache::lonhomework::showhash(%fields);
+ my $courseid=$ENV{'request.course.id'};
+ my $cdom=$ENV{"course.$courseid.domain"};
+ my $cnum=$ENV{"course.$courseid.num"};
+ my (%classlist) = &getclasslist($cdom,$cnum,'1');
+ foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+ my %newhash;
+ foreach my $grade (@gradedata) {
+ my %entries=&Apache::loncommon::record_sep($grade);
+ foreach my $dest (keys(%fields)) {
+
+ }
+ }
+ }
+}
+
sub send_header {
my ($request)= @_;
$request->print(&Apache::lontexconvert::header());
|