")
- newWindow.document.write('$end_page')
- newWindow.document.close()
- newWindow.focus()
-}
END_OF_ONE
if ($source eq "PreviousPage") {
$$jsref .= qq|
@@ -411,262 +414,166 @@ function setElements() {
var iter = 0
var selParam = 0
|;
- foreach my $item (keys %env) {
- if ($item =~ m/^form\.(\w+)$/) {
+ foreach my $item (keys(%env)) {
+ if ($item =~ m/^form\.(probfile_\d+)$/) {
my $name = $1;
my $value = $env{"form.$name"};
- unless ($value eq "") {
- if ($name eq "newdir") {
- $$jsref .= qq( document.forms.dataForm.$name.value = "$value"\n);
- }
+ if ($value ne '') {
+ $$jsref .= qq( document.dataForm.$name.value = "$value"\n);
}
}
}
$$jsref .= "}";
}
-}
+ $$jsref .= '
+function verify() {
+';
+ my $blocks = 0;
+ if ( exists( $env{'form.blocks'}) ) {
+ $blocks = $env{'form.blocks'};
+ }
+ my $numitems = 0;
+ for (my $i=0; $i<$blocks; $i++) {
+ my $count = 0;
+ if (($env{"form.start_$i"} ne '') && ($env{"form.end_$i"} ne '')) {
+ $count = $env{"form.end_$i"} - $env{"form.start_$i"} +1;
+ }
+ $numitems += $count;
+ }
+ if ($numitems > 0) {
+ my $maxnum = $numitems - 1;
+ my %lt = &Apache::lonlocal::texthash(
+ fnmb => 'File names must be unique',
+ isum => 'is used more than once',
+ );
+ $$jsref .= qq|
+ for (var j=$maxnum; j>0; j--) {
+ var currname = document.dataForm.elements['probfile_'+j].value;
+ for (var k=j-1; k>=0; k--) {
+ var comparename = document.dataForm.elements['probfile_'+k].value;
+ if (currname == comparename) {
+ alert("$lt{fnmb} - "+currname+" $lt{isum}");
+ return false;
+ }
+ }
+ }
+|;
+ }
+ $$jsref .= '
+ return true;
+}
+';
+ $$jsref .= &Apache::loncommon::check_uncheck_jscript();
+ return;
+}
# ---------------------------------------------------------------- Jscript Four
sub jscript_four {
- my ($jsref,$fullpath) = @_;
+ my ($jsref,$webpath) = @_;
$$jsref = qq|
function backtoStart() {
- document.location.href="$fullpath"
+ document.location.href="$webpath"
}
-function backpage() {
+function backPage() {
document.forms.verify.go.value="PreviousPage"
- document.forms.verify.submit()
+ document.forms.verify.submit();
}
|;
}
# ---------------------------------------------------------------- Display Zero
sub display_zero {
- my ($r,$uname,$fn,$page,$fullpath) = @_;
- $r->print(qq|
-
-
-
-
-The Testbank Upload utility can be used by LON-CAPA authors to convert multiple choice, multiple answer correct, fill-in-the-blank, ordering/ranking, true/false and essay questions from a plain text testbank file to LON-CAPA problem files. Five requirements must be met to ensure that you will succeed in converting your plain text file of testbank questions to functioning LON-CAPA problems.
-
-
The questions and answers you upload must be in plain text format. Any header lines should occur before the text containing the questions and answers.
-
All questions (including question text and all foils) must occur before any of the answers. Each question should begin on a new line, and should start with the question number. Questions should be numbered sequentially using a number followed immediately by a space, a period, or enclosed in parentheses, i.e., 1 , 1., (1), 1), or (1 .
-
Multiple choice and multiple answer correct questions should consist of: (i) the question number followed by (ii) the question text beginning on the same line and (iii) two or more foils, with each foil beginning on a new line and prefixed by a unique letter, or Roman numeral, listed in alphabetic or numeric order, beginning at a (alphabetic) or i (Roman numeral), followed by a period, or enclosed in parentheses, i.e., a., (a), i., or (i).
-
One or more correct answers should be provided for all questions (although blank answers may be provided for essay questions). Answers should be numbered sequentially, using the same scheme as used for the questions, and must occur after all the questions.
-
If fill-in-the-blank or multiple answer questions have more than one correct answer, each answer should appear in a comma-, tab-, space-, or new line-delimited list. For a ranking/ordering question, the "answer" should contain the foil identifiers correctly ordered in a similarly delimited list.
-
-Five steps are involved in the import process.
-
-
Provide information about the question format - i.e., question numbering style, and the number of blocks of questions of each question type.
-
Provide information about the questions in each block, including question type, start and end question numbers for each block, and foil labelling style and answer format where required.
-
Create a new directory where you will store the converted testbank questions.
-
Complete the import of questions to the selected pool.
-
-
-
-
-
-
-
-
- |);
+ $r->print(''.&mt('Incomplete file upload').' '.&mt('Return to the [_1]construction space menu[_2] to upload a file','',''));
+ }
+ $r->print(&mt('The Testbank Upload utility can be used by LON-CAPA authors to generate LON-CAPA problem files from a testbank file of questions/answers.').' '.
+ &mt('The following question types can be converted:').'
+
+
'.&mt('multiple choice').'
+
'.&mt('multiple answer correct').'
+
'.&mt('fill-in-the-blank').'
+
'.&mt('ordering/ranking').'
+
'.&mt('true/false').'
+
'.&mt('essay').'
+
+ '.&mt('The file of questions (in plain text, RTF or HTML format) must meet certain requirements for the conversion process to generate functioning LON-CAPA problems.').&Apache::loncommon::help_open_topic('Testbank_Formatting').' '.
+ &mt('Five steps are involved in the conversion process.').'
+
+
'.&mt('Optionally create a new sub-directory where the converted testbank questions will be saved.').'
+
'.&mt('Provide information about the question format - i.e., question numbering style, and the number of blocks of questions of each question type.').'
+
'.&mt('Provide information about the questions in each block, including question type, start and end question numbers for each block, and foil labelling style and answer format where required.').'
+
'.&mt('Review the identified questions, choose which to convert, and (optionally) override the default filename to be used for each problem file.').'
+
'.&mt('Complete the import of questions.').'
+ ');
}
-
# ---------------------------------------------------------------- Display One
sub display_one {
- my ($r,$uname,$fn,$page,$textref) = @_;
- $r->print(qq|
-
- |);
+ my ($r,$uname,$fn,$page,$textref,$header) = @_;
+ my %topics;
+ $topics{2} = &mt('Select the format of the question number - e.g., 1, 1., 1), (1 or (1) - ').'
+ '."\n";
+ $topics{3} = &mt('Indicate the number of blocks of different question types in the testbank file.').' ';
+ $r->print('
'.&mt('Identification of blocks of questions').'
'."\n".
+ '');
+ return;
}
# ---------------------------------------------------------------- Display Two
sub display_two {
- my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
+ my ($r,$uname,$fn,$page,$textref,$header,$qcount) = @_;
my $blocks = $env{'form.blocks'};
my $qnumformat = $env{'form.qnumformat'};
my @types = ("MC","MA","TF","Ess","FIB","Ord");
@@ -685,210 +592,84 @@ sub display_two {
leadparen => "(1",
trailparen => "1)",
);
- my @bgcolors = ('#ffffff','#eeeeee');
my $bl1st = '';
my $bl1end = '';
if ($blocks == 1) {
$bl1st = '1';
$bl1end = $qcount;
}
- $r->print(<<"END_OF_FUNC");
-
Step 3: Classification of blocks
-');
+ return;
+}
+
# ---------------------------------------------------------------- Display Three
-sub display_three {
- my ($r,$uname,$fn,$page,$textref,$qcount) = @_;
+sub display_three {
+ my ($r,$uname,$fn,$page,$textref,$res,$header,$urlpath,$qcount) = @_;
my $qnumformat = $env{'form.qnumformat'};
my $filename = $env{'form.filename'};
my $source = $env{'form.go'};
my $blocks = $env{'form.blocks'};
- my @items = ();
- my @bgcolors = ('#ffffff','#eeeeee');
- my @types = ("MC","MA","TF","Ess","FIB","Ord");
- my @alphabet = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
- my @romans = ("i","ii","iii","iv","v","vi","vii","viii","ix","x","xi","xii","xiii","xiv","xv","xvi","xvii","xviii","xix","xx","xxi","xxii","xxiii","xxiv","xxv","xxvi");
+ my ($alphabet,$romans) = &get_constants();
my @start = ();
my @end = ();
my @nums = ();
@@ -897,6 +678,15 @@ sub display_three {
my @ansrtypes = ();
my %multparts = ();
my $numitems = 0;
+ my %lt = &Apache::lonlocal::texthash (
+ crt => 'Create?',
+ typ => 'Type',
+ fnam => 'File Name',
+ ques => 'Question',
+ answ => 'Answer',
+ chka => 'check all',
+ unch => 'uncheck all',
+ );
for (my $i=0; $i<$blocks; $i++) {
if (($env{"form.start_$i"} ne '') && ($env{"form.end_$i"} ne '')) {
$start[$i] = $env{"form.start_$i"};
@@ -918,202 +708,165 @@ sub display_three {
}
$numitems += $nums[$i];
}
-
- my $import = join//,@{$textref};
- @items = &file_split(\@start,\@end,\@nums,$qnumformat,\@foilformats,$textref,\%multparts,$numitems,\@qtype,$blocks);
- $r->print(<<"END_OF_ONE");
-
Step 4: Review and selection of destination directory
-
-
-
-
-
-
-
-
-
-
-
-Based on your previous responses your data have been split into a total of $numitems questions.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#
Type
Question
Answer
-END_OF_ONE
+ my ($items,$ids,$footer) = &file_split(\@start,\@end,\@nums,$qnumformat,\@foilformats,$textref,\%multparts,$numitems,\@qtype,$blocks);
+ my ($showheader,$showcss);
+ if ($res eq 'application/rtf' || $res eq 'text/html') {
+ if ($header ne '') {
+ $showheader = &HTML::Entities::decode($header);
+ if ($res eq 'text/html') {
+ $showheader = &build_image_url($urlpath,$showheader);
+ }
+ }
+ }
+ $r->print('
'.&mt('Review and selection of problems to convert').'
'."\n".
+ '
'."\n".
+ &mt('Based on your previous responses your data have been split into a total of [quant,_1,question].',$numitems).
+ &topic_bar(5,&mt('Choose which problems to convert and names to use for individual problem files')));
+ if ($showheader) {
+ $r->print($showheader.' ');
+ }
+ $r->print('
+
- Create a directory to store your testbank questions.
-
-
-
-
-
-
-
-
-
-Please choose a destination LON-CAPA directory in which to store your uploaded questions.
-
-
-
-
-
-
-
-
If you are satisfied with the questions and answers extracted from your uploaded text file, as shown above, and you have created a destination directory click the "Continue to step 5" button to convert the questions in your testbank to LON-CAPA problem files.
'.&mt('Individual problem files have been created from the following problems included in the testbank file:').' '.$successes.'
'.
+ &mt('The problems must be published before they can be used in a course').'
');
+ }
+ if ($failures) {
+ $r->print('
'.&mt('An error occurred when opening files for the following problems, so they have not been created:').' '.$failures.'
');
+ }
+ if ($existing) {
+ $r->print('
'.&mt('The following files already existed, and were not overwritten so these problems generated from the testbank have not been saved:').' '.$existing.'
No destination file was selected or created, so import of your questions could not proceed.
- Please return to the previous page and select a valid file into which to import the questions.
-
-
-
-
-
-
-
-
- |);
- for (my $i=0; $i<$blocks; $i++) {
- $r->print(qq|
-
-
-
-
-
- |);
- }
- $r->print(<<"END_OF_FAIL");
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-END_OF_FAIL
+ $state = 'nodir';
+ $r->print('
'.&mt('No destination directory was available so import of questions could not proceed.').'