From: Chris S. <san...@us...> - 2005-10-11 09:57:45
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2925/scripts Modified Files: stackAuthor.php stackFrontend.php stackQuestion.php stackQuiz.php stackSubject.php stackUser.php Log Message: Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** stackAuthor.php 12 Sep 2005 08:07:47 -0000 1.44 --- stackAuthor.php 11 Oct 2005 09:57:44 -0000 1.45 *************** *** 816,820 **** //Check that within current field there is no type tag, otherwise skip $err = ''; ! echo "<tr><td><b>{$stackQuiz[$key]['descript']}</b></td>\n"; if ('quizid' == $key) { echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; --- 816,821 ---- //Check that within current field there is no type tag, otherwise skip $err = ''; ! $fnamekey = 'stackQuiz_'.$key; ! echo "<tr><td><b>".get_string($fnamekey,'stack','')."</b></td>\n"; if ('quizid' == $key) { echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; *************** *** 1243,1247 **** //Check that within current field there is no type tag, otherwise skip $err = ''; ! echo "<tr><td><b>{$stackSubject[$key]['descript']}</b></td>\n"; if ('subjectID' == $key) { echo "<td><input type=\"hidden\" name=\"subject[$key]\" value=\"{$subject[$key]}\" alt=\"$key\" />{$subject[$key]}</td><td>".$err.'</td></tr>'; --- 1244,1249 ---- //Check that within current field there is no type tag, otherwise skip $err = ''; ! $keyname = 'stackQuiz_'.$key; ! echo "<tr><td><b>".get_string($keyname,'stack','')."</b></td>\n"; if ('subjectID' == $key) { echo "<td><input type=\"hidden\" name=\"subject[$key]\" value=\"{$subject[$key]}\" alt=\"$key\" />{$subject[$key]}</td><td>".$err.'</td></tr>'; *************** *** 1543,1550 **** echo "\n<table cellpadding='1'>\n"; echo "\n<tr>\n"; ! echo " <th>{$stackSubject['subjectOrder']['descript']}</th>\n <th>ID</th>\n"; ! echo " <th>{$stackSubject['subjectName']['descript']}</th>\n"; ! echo " <th>{$stackSubject['subjectMode']['descript']}</th>\n"; ! echo " <th>{$stackSubject['subjectDescription']['descript']}</th>\n</tr>\n"; $trcol = FALSE; --- 1545,1552 ---- echo "\n<table cellpadding='1'>\n"; echo "\n<tr>\n"; ! echo " <th>".get_string('stackSubject_subjectOrder','stack','')."</th>\n <th>ID</th>\n"; ! echo " <th>".get_string('stackSubject_subjectName','stack','')."</th>\n"; ! echo " <th>".get_string('stackSubject_subjectMode','stack','')."</th>\n"; ! echo " <th>".get_string('stackSubject_subjectDescription','stack','')."</th>\n</tr>\n"; $trcol = FALSE; Index: stackSubject.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackSubject.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stackSubject.php 4 Sep 2005 21:26:18 -0000 1.2 --- stackSubject.php 11 Oct 2005 09:57:44 -0000 1.3 *************** *** 11,20 **** */ // 'Unique quiz ID - local mySQL value' - $stackSubject['subjectID']['descript'] = 'Subject ID number'; $stackSubject['subjectID']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; $stackSubject['subjectID']['type'] = 'meta'; // 'Subject name' - $stackSubject['subjectName']['descript'] = 'Subject name'; $stackSubject['subjectName']['mysql'] = 'TINYTEXT'; $stackSubject['subjectName']['type'] = 'meta'; --- 11,18 ---- *************** *** 23,27 **** // 'Subject description' - $stackSubject['subjectDescription']['descript'] = 'Description'; $stackSubject['subjectDescription']['mysql'] = 'TINYTEXT'; $stackSubject['subjectDescription']['type'] = 'meta'; --- 21,24 ---- *************** *** 30,53 **** // 'Subject options' - $stackSubject['subjectOptions']['descript'] = 'Subject options'; $stackSubject['subjectOptions']['mysql'] = 'TEXT'; $stackSubject['subjectOptions']['type'] = 'other'; // 'Subject mode' - $stackSubject['subjectMode']['descript'] = 'Mode'; $stackSubject['subjectMode']['mysql'] = 'TINYTEXT'; $stackSubject['subjectMode']['type'] = 'string'; // 'Subject mode' - $stackSubject['subjectOrder']['descript'] = 'Order in Zone'; $stackSubject['subjectOrder']['mysql'] = 'INT(11)'; $stackSubject['subjectOrder']['type'] = 'int'; // Page header and footers - $stackSubject['subjectHTMLHead']['descript'] = 'Subject page header'; $stackSubject['subjectHTMLHead']['mysql'] = 'TEXT'; $stackSubject['subjectHTMLHead']['type'] = 'html'; - $stackSubject['subjectHTMLFoot']['descript'] = 'Subject page header'; $stackSubject['subjectHTMLFoot']['mysql'] = 'TEXT'; $stackSubject['subjectHTMLFoot']['type'] = 'html'; --- 27,45 ---- *************** *** 67,71 **** $stackSubject['subjectKeywords']['metatag'] = 'keyword'; //lom:keyword $stackSubject['subjectKeywords']['metatype'] = 'lom'; - $stackSubject['subjectKeywords']['descript'] = 'Keywords'; //<PDK>Need for display purposes // 'Last edited by'; --- 59,62 ---- *************** *** 211,216 **** echo "\n<table cellpadding='2'>\n"; ! echo "\n<tr>\n <th>{$stackSubject['subjectName']['descript']}</th>\n"; ! echo " <th>{$stackSubject['subjectDescription']['descript']}</th>\n</tr>\n"; foreach ($subject_store as $qs => $subject) { $sID = $subject['subjectID']; --- 202,207 ---- echo "\n<table cellpadding='2'>\n"; ! echo "\n<tr>\n <th>".get_string('stackSubject_subjectName','stack','')."</th>\n"; ! echo " <th>".get_string('stackSubject_subjectDescription','stack','')."</th>\n</tr>\n"; foreach ($subject_store as $qs => $subject) { $sID = $subject['subjectID']; Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** stackQuestion.php 26 Sep 2005 10:15:35 -0000 1.40 --- stackQuestion.php 11 Oct 2005 09:57:44 -0000 1.41 *************** *** 1101,1118 **** */ function stack_question_inst($question,$seed,$options,&$errors) { - // This function actually instantiates a $question with the given $options global $stackQuestion, $stackAnswerTest; $err_when_inst = "<br /><font color=\"red\">".get_string('QInstCASError','stack','')."</font> "; $errs = FALSE; - - $questionInst['questionIDInst'] = $question['questionID']; - $questionInst['questionSeedInst'] = $seed; ! // Create an offset seed. This prevents all questions in a // quiz from having the same seed. Otherwise random number generation // is poor, and plots (which rely on random numbers) do not work. $seedoffset = 0; if (array_key_exists('questionGUID',$question)) { - // Do something useful. $guid = $question['questionGUID']; for ($i = 0; $i < 20; $i+=4) { --- 1101,1114 ---- */ function stack_question_inst($question,$seed,$options,&$errors) { global $stackQuestion, $stackAnswerTest; + $err_when_inst = "<br /><font color=\"red\">".get_string('QInstCASError','stack','')."</font> "; $errs = FALSE; ! // (0) Create an offset seed. This prevents all questions in a // quiz from having the same seed. Otherwise random number generation // is poor, and plots (which rely on random numbers) do not work. $seedoffset = 0; if (array_key_exists('questionGUID',$question)) { $guid = $question['questionGUID']; for ($i = 0; $i < 20; $i+=4) { *************** *** 1124,1131 **** $seed += $seedoffset; ! // Get the implicit local variables, and the stings if ( array_key_exists('questionVars',$question) ) { $locals = $question['questionVars']; ! } else { $locals = ''; } $implicit_locals=''; --- 1120,1147 ---- $seed += $seedoffset; ! // (1) Construct the $questionInst array. ! ! $questionInst['questionIDInst'] = $question['questionID']; ! $questionInst['questionSeedInst'] = $seed; ! ! // Transfer the values from question to instance in a clean way. ! foreach($stackQuestion as $qfield => $val) { ! if (array_key_exists($qfield,$question)) { ! if ('' != $question[$qfield]) { ! $questionInst[$qfield]=$question[$qfield]; ! } ! } ! // except for rawkeyals, ! if ('rawkeyvals' == $stackQuestion[$qfield]['type']) { ! unset($questionInst[$qfield]); // We don't need the rawkeyvals in an instantiated question ! } ! } ! ! // (1) Get the implicit local variables, and the stings if ( array_key_exists('questionVars',$question) ) { $locals = $question['questionVars']; ! } else { ! $locals = ''; ! } $implicit_locals=''; *************** *** 1141,1148 **** } $fname = $qfield.'Inst'; ! $question[$fname]=$ilocs[0]; // Store the replaced string. } else { // There are no substitutions, so we just store the original string. ! $question["{$qfield}Inst"]=$question[$qfield]; ! } }// end if 'castext' } // end of grab implicit locvars loop. --- 1157,1164 ---- } $fname = $qfield.'Inst'; ! $questionInst[$fname]=$ilocs[0]; // Store the replaced string. } else { // There are no substitutions, so we just store the original string. ! $questionInst["{$qfield}Inst"]=$question[$qfield]; ! } }// end if 'castext' } // end of grab implicit locvars loop. *************** *** 1170,1186 **** $imp_locs_Inst = stack_process_vars($all_locals,$seed,$options,$errors); - // Transfer the values from question to instance in a clean way. - foreach($stackQuestion as $qfield => $val) { - if (array_key_exists($qfield,$question)) { - if ('' != $question[$qfield]) { - $questionInst[$qfield]=$question[$qfield]; - } - } - // except for rawkeyals, - if ('rawkeyvals' == $stackQuestion[$qfield]['type']) { - unset($questionInst[$qfield]); // We don't need the rawkeyvals in an instantiated question - } - } - // Get instantiated version of the answer, and any AnswerTest options. foreach($imp_locs_Inst as $lk => $loc ) { --- 1186,1189 ---- *************** *** 1233,1237 **** // Now put the implicit question variables back into the castext strings. // The result of this should be strings suitable to be echo'd to the student. ! $err_when_inst = "<br /><font color=\"red\">CAS ERROR when instantiated!</font> "; $displayed = $options['Display']; --- 1236,1240 ---- // Now put the implicit question variables back into the castext strings. // The result of this should be strings suitable to be echo'd to the student. ! $err_when_inst = "<br /><font color=\"red\">".get_string('CASERRInst','stack','')."</font> "; $displayed = $options['Display']; *************** *** 1240,1244 **** if ('castext' == $stackQuestion[$qfield]['type'] and array_key_exists($qfield,$question)) { $errct = ''; ! $questionInst["{$qfield}Inst"] = stack_castext_to_display($question["{$qfield}Inst"], $imp_locs_Inst, $displayed , $errct); if ('' != $errct) { // We have some errors! $errors[$qfield]=$err_when_inst.$errct; --- 1243,1247 ---- if ('castext' == $stackQuestion[$qfield]['type'] and array_key_exists($qfield,$question)) { $errct = ''; ! $questionInst["{$qfield}Inst"] = stack_castext_to_display($questionInst["{$qfield}Inst"], $imp_locs_Inst, $displayed , $errct); if ('' != $errct) { // We have some errors! $errors[$qfield]=$err_when_inst.$errct; *************** *** 1247,1250 **** --- 1250,1283 ---- } // end of put the implicit locals back + // We do not want the student to be able to type in one of the question variables. + // Hence we add these to the forbidden strings. + // A teacher could always allow these if needed. + if ( array_key_exists('questionVarsInst',$questionInst) ) { + + // (1) Construct a comma separated list of variable keys. + $forbidvars = ''; + foreach($questionInst['questionVarsInst'] as $var) { + $forbidvars .= ', '.$var['key']; + } + + // (2) Get any pre-existing options + $forbid = ''; + if (array_key_exists('questionOptions',$questionInst)) { + if (array_key_exists('Forbid',$questionInst['questionOptions'])) { + $forbid = $questionInst['questionOptions']['Forbid']; + } + } + + // (3) Sort out any comma problems. + if ('' == $forbid) { // knock off the comma + $forbid = substr($forbidvars, 1, strlen($forbidvars)-1); + } else { + $forbid .= $forbidvars; + } + + // (4) Insert these + $questionInst['questionOptions']['Forbid'] = $forbid; + } + // ************************* // End Instantiate question *************** *** 1255,1258 **** --- 1288,1292 ---- } + //show_array($questionInst); return($questionInst); } *************** *** 1474,1522 **** // Returns a $this_attempt if ('' != trim($RawAns) ) { $err = validate_casstring($RawAns,'s'); // parse the student's raw answer ! if ('' != $err) {$errors['RawAns']= $err;} // Check for forbidden words $forbidden = stack_options_forbidden($options); ! if (is_array($forbidden)) { // There are some forbidden words foreach ($forbidden as $key => $fword) { if ( FALSE != strstr( $RawAns, $fword ) ) {// We have the forbidden word ! $errors['Forbid'] .= "<br />Your answer contains the forbidden word <tt> $fword</tt>."; } } } - $this_attempt['Valid']='true'; } else { // An empty answer. $this_attempt['Valid'] = 'false'; $this_attempt['Ans']['display'] = $RawAns; ! $this_attempt['AnswerNote'] = '(n/a)'; ! $this_attempt['RawMark'] = 0; ! $this_attempt['Penalty'] = 0; ! } - // Construct this attempt - $this_attempt['RawAns']=$RawAns; // Check for PHP parser errors. if (stack_check_for_error('RawAns',$errors) ) { ! $this_attempt['Valid']='false'; ! $this_attempt['Ans']['display']=$RawAns; ! $this_attempt['AnswerNote']= ' PHP parse error(s).'; ! $this_attempt['FeedBack']=$errors['RawAns']; ! $this_attempt['Penalty']=0; ! $this_attempt['RawMark']=0; } if ( stack_check_for_error('Forbid',$errors) ) { ! $this_attempt['Valid']='false'; ! $this_attempt['Ans']['display']= $RawAns; ! $this_attempt['AnswerNote'] .= ' Forbidden word(s).'; ! $this_attempt['FeedBack'] .= $errors['Forbid']; ! $this_attempt['Penalty']=0; ! $this_attempt['RawMark']=0; } --- 1508,1568 ---- // Returns a $this_attempt + // Construct this attempt + $this_attempt['RawAns'] =$RawAns; + $this_attempt['RawMark'] = 0; + $this_attempt['Penalty'] = 0; + $this_attempt['Valid'] = 'true'; + $this_attempt['AnswerNote'] = ''; + $this_attempt['FeedBack'] = ''; + + if ('' != trim($RawAns) ) { $err = validate_casstring($RawAns,'s'); // parse the student's raw answer ! if ('' != $err) { ! $errors['RawAns']= $err; ! } // Check for forbidden words $forbidden = stack_options_forbidden($options); ! $foundforbidden = FALSE; ! if (is_array($forbidden)) { // There are some forbidden words + $errstr = ''; foreach ($forbidden as $key => $fword) { if ( FALSE != strstr( $RawAns, $fword ) ) {// We have the forbidden word ! $errstr .= '<br />'.get_string('ForbidWord','stack',$fword); ! ! $foundforbidden = TRUE; } } + if ($foundforbidden) { + $errors['Forbid'] = $errstr; + } } } else { // An empty answer. $this_attempt['Valid'] = 'false'; $this_attempt['Ans']['display'] = $RawAns; ! $this_attempt['Ans']['value'] = $RawAns; ! $this_attempt['AnswerNote'] .= '(n/a)'; ! } // Check for PHP parser errors. if (stack_check_for_error('RawAns',$errors) ) { ! $this_attempt['Valid'] = 'false'; ! $this_attempt['Ans']['display'] = $RawAns; ! $this_attempt['Ans']['value'] = $RawAns; ! $this_attempt['AnswerNote'] .= ' PHP parse error(s).'; ! $this_attempt['FeedBack'] .= $errors['RawAns']; } if ( stack_check_for_error('Forbid',$errors) ) { ! $this_attempt['Valid'] = 'false'; ! $this_attempt['Ans']['display'] = $RawAns; ! $this_attempt['Ans']['value'] = $RawAns; ! $this_attempt['AnswerNote'] .= ' ForbidWord'; ! $this_attempt['FeedBack'] .= $errors['Forbid']; } Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** stackQuiz.php 12 Sep 2005 08:07:47 -0000 1.15 --- stackQuiz.php 11 Oct 2005 09:57:44 -0000 1.16 *************** *** 11,20 **** */ // 'Unique quiz ID - local mySQL value' - $stackQuiz['quizid']['descript'] = 'Quiz ID number'; $stackQuiz['quizid']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; $stackQuiz['quizid']['type'] = 'meta'; // 'Quiz name' - $stackQuiz['quizName']['descript'] = 'Quiz name'; $stackQuiz['quizName']['mysql'] = 'TINYTEXT'; $stackQuiz['quizName']['type'] = 'meta'; --- 11,18 ---- *************** *** 23,27 **** // 'Quiz description' - $stackQuiz['quizDescription']['descript'] = 'Description'; $stackQuiz['quizDescription']['mysql'] = 'TINYTEXT'; $stackQuiz['quizDescription']['type'] = 'meta'; --- 21,24 ---- *************** *** 30,44 **** // 'Quiz options' - $stackQuiz['quizOptions']['descript'] = 'Quiz options'; $stackQuiz['quizOptions']['mysql'] = 'TEXT'; $stackQuiz['quizOptions']['type'] = 'other'; // 'Quiz due date' - $stackQuiz['quizDueDate']['descript'] = 'Due date'; $stackQuiz['quizDueDate']['mysql'] = 'int(10)'; $stackQuiz['quizDueDate']['type'] = 'date'; // 'Quiz mode' - $stackQuiz['quizMode']['descript'] = 'Mode'; $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; $stackQuiz['quizMode']['type'] = 'string'; --- 27,38 ---- *************** *** 58,62 **** $stackQuiz['quizKeywords']['metatag'] = 'keyword'; //lom:keyword $stackQuiz['quizKeywords']['metatype'] = 'lom'; - $stackQuiz['quizKeywords']['descript'] = 'Keywords'; //<PDK>Need for display purposes // 'Last edited by'; --- 52,55 ---- *************** *** 199,203 **** echo "\n<table cellpadding='2'>\n"; ! echo "\n<tr><th>{$stackQuiz['quizName']['descript']}</th><th>{$stackQuiz['quizDescription']['descript']}</th><th>Last mark (%)</th><th>{$stackQuiz['quizDueDate']['descript']}</th>\n</tr>\n"; foreach ($quiz_store as $qs => $quiz) { --- 192,197 ---- echo "\n<table cellpadding='2'>\n"; ! ! echo "\n<tr><th>".get_string('stackQuiz_quizName','stack','')."</th><th>".get_string('stackQuiz_quizDescription','stack','')."</th><th>".get_string('FE_quiz_lastmark','stack','')."</th><th>".get_string('stackQuiz_quizDueDate','stack','')."</th>\n</tr>\n"; foreach ($quiz_store as $qs => $quiz) { Index: stackFrontend.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackFrontend.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stackFrontend.php 4 Sep 2005 21:26:18 -0000 1.3 --- stackFrontend.php 11 Oct 2005 09:57:44 -0000 1.4 *************** *** 231,236 **** echo "\n<table cellpadding='2'>\n"; ! echo "\n<tr><th></th><th>{$stackQuiz['quizName']['descript']}</th> ! <th>{$stackQuiz['quizDescription']['descript']}</th><th></th></tr>"; foreach ($quiz_store as $qs => $quiz) { --- 231,237 ---- echo "\n<table cellpadding='2'>\n"; ! ! echo "\n<tr><th></th><th>".get_string('stackQuiz_quizName','stack','')."</th> ! <th>".get_string('stackQuiz_quizDescription','stack','')."</th><th></th></tr>"; foreach ($quiz_store as $qs => $quiz) { *************** *** 273,279 **** echo "\n<table cellpadding='2'>\n"; echo "\n<tr>\n"; ! echo " <th>ID</th>\n <th>{$stackSubject['subjectOrder']['descript']}</th>\n"; ! echo " <th>{$stackSubject['subjectName']['descript']}</th> ! <th>{$stackSubject['subjectDescription']['descript']}</th><th></th></tr>"; foreach ($subject_store as $qs => $subject) { --- 274,280 ---- echo "\n<table cellpadding='2'>\n"; echo "\n<tr>\n"; ! echo " <th>ID</th>\n <th>".get_string('stackSubject_subjectOrder','stack','')."</th>\n"; ! echo " <th>".get_string('stackSubject_subjectName','stack','')."</th> ! <th>".get_string('stackSubject_subjectDescription','stack','')."</th><th></th></tr>"; foreach ($subject_store as $qs => $subject) { Index: stackUser.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUser.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** stackUser.php 29 Sep 2005 11:03:01 -0000 1.17 --- stackUser.php 11 Oct 2005 09:57:44 -0000 1.18 *************** *** 267,273 **** include_once($stack_root.'/html/helpform.php'); ! echo '<h1>Update user information</h1>'; echo "<form action=\"\" method=\"post\" name=\"register\" id=\"register\">"; ! echo '<p>To update your information, please complete the following form.<p>'; echo '<table><tr><td>Username </td><td><input type="hidden" name="user[username]" size="25" value="'.stack_s($user['username']).'" alt="User name" />'.stack_s($user['username']).'</td><td></td></tr>'; stack_user_edit_form($user,$errors,$admin); --- 267,273 ---- include_once($stack_root.'/html/helpform.php'); ! echo '<h1>'.get_string('FE_index_update_info_title','stack','').'</h1>'; echo "<form action=\"\" method=\"post\" name=\"register\" id=\"register\">"; ! echo '<p>'.get_string('FE_index_update_info_instruct','stack','').'<p>'; echo '<table><tr><td>Username </td><td><input type="hidden" name="user[username]" size="25" value="'.stack_s($user['username']).'" alt="User name" />'.stack_s($user['username']).'</td><td></td></tr>'; stack_user_edit_form($user,$errors,$admin); *************** *** 283,287 **** echo '</table>'; ! echo '<input type="hidden" name="action" value="userupdate" /><input type="submit" value="Update" /></form>'; } --- 283,287 ---- echo '</table>'; ! echo '<input type="hidden" name="action" value="userupdate" /><input type="submit" value="'.get_string('FE_index_update_button','stack','').'" /></form>'; } |