From: Chris S. <san...@us...> - 2005-06-18 21:01:19
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8957/scripts Modified Files: Tag: frontend_dev stackQuestion.php stackQuiz.php stackUtility.php stackXML.php Log Message: Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** stackQuiz.php 17 Jun 2005 10:54:52 -0000 1.1.2.1 --- stackQuiz.php 18 Jun 2005 21:01:04 -0000 1.1.2.2 *************** *** 26,28 **** --- 26,71 ---- $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; + /* + * Displays the student quiz selection screen + * @param array $quize_store The list of quizzes + * @param $user + * @return void + */ + function stack_quiz_student_select($quiz_store, $user) { + global $stack_root; + + require_once("{$stack_root}/html/quizjava.html"); + echo "<h1>Please choose a quiz to try</h1>"; + global $stackQuiz; + if (is_array($quiz_store)) { + echo "<p>\n<form name='quizform' action='quiz.php' method='POST'> + <input type='hidden' name='quizid' value='-1'> + <input type='hidden' name='action' value='continue_quiz'>"; + echo "\n<table cellpadding='2'>\n"; + echo "\n<tr><th>{$stackQuiz['quizName']['descript']}</th><th>{$stackQuiz['quizDescription']['descript']}</th><th>Last mark (%)</th></tr>"; + foreach ($quiz_store as $qs => $quiz) { + $qname = $quiz['quizName']; + $qID = $quiz['quizid']; + $mark = '-'; + if (is_array($user)) { + if (array_key_exists('id',$user)) { + $userinfo = stack_db_quiz_quizattempt_getlast($qID,$user['id']); + if (is_array($userinfo)) { + if (NULL != $userinfo['mark']) { + $mark = round(100*$userinfo['mark']/$userinfo['maxmark'],2); + } + } + } + } + + echo "<tr><td><a href=\"javascript:takeaction('continue_quiz','$qID');\">{$qname}</a></td>\n"; + echo "<td>".$quiz['quizDescription']."</td><td align='center'>$mark</td></tr>\n"; + } + echo "\n</table>\n</form>\n</p>"; + } else { + echo "<p>You have no quizzes available to try.</p>"; + } + } + + ?> Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** stackXML.php 1 Apr 2005 18:59:31 -0000 1.2 --- stackXML.php 18 Jun 2005 21:01:05 -0000 1.2.4.1 *************** *** 66,70 **** $xml .= $pad." <{$tag}_ord order=\"$key\">\n".stack_xml_create_question_frag($orderdata,$depth+6)."$pad </{$tag}_ord>\n"; } ! $xml .= $pad."</$tag>\n";; } else { // Just a regular open tag. --- 66,70 ---- $xml .= $pad." <{$tag}_ord order=\"$key\">\n".stack_xml_create_question_frag($orderdata,$depth+6)."$pad </{$tag}_ord>\n"; } ! $xml .= $pad."</$tag>\n"; } else { // Just a regular open tag. *************** *** 127,132 **** function stack_xml_write_quiz_file($quiz, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory ! ! $xml_file_name = 'stack_quiz.xml'; // create the file we will use for writing --- 127,133 ---- function stack_xml_write_quiz_file($quiz, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory ! ! ! $xml_file_name = 'stack_quiz_'.time().'.xml'; // create the file we will use for writing Index: stackUtility.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUtility.php,v retrieving revision 1.22.2.2 retrieving revision 1.22.2.3 diff -C2 -d -r1.22.2.2 -r1.22.2.3 *** stackUtility.php 18 Jun 2005 09:54:13 -0000 1.22.2.2 --- stackUtility.php 18 Jun 2005 21:01:04 -0000 1.22.2.3 *************** *** 14,17 **** --- 14,18 ---- } require_once("{$stack_root}/scripts/stackQuiz.php"); + require_once("{$stack_root}/scripts/stackUser.php"); require_once("{$stack_root}/frontend_general/frontend_util.php"); *************** *** 27,31 **** /** ! * Synonym for the PHP function htmlspecialchars * * @param string $str The input string. --- 28,32 ---- /** ! * Synonym for the PHP function htmlspecialchars. See the Moodle function s(.) * * @param string $str The input string. *************** *** 109,113 **** * @return array Field [0] contains the string between the two characters, Field [1] contains the start position of -1 if it does not exist and Field [2] contains the end position of -1 if there was no match. */ ! function GrabBetween($strin,$leftc,$rightc,$start) { // Starting at $start, (a number) // Find the first occurance of $leftc, match with an occurance of --- 110,114 ---- * @return array Field [0] contains the string between the two characters, Field [1] contains the start position of -1 if it does not exist and Field [2] contains the end position of -1 if there was no match. */ ! function stack_util_grabbetween($strin,$leftc,$rightc,$start) { // Starting at $start, (a number) // Find the first occurance of $leftc, match with an occurance of Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.19.2.3 retrieving revision 1.19.2.4 diff -C2 -d -r1.19.2.3 -r1.19.2.4 *** stackQuestion.php 18 Jun 2005 09:54:13 -0000 1.19.2.3 --- stackQuestion.php 18 Jun 2005 21:01:04 -0000 1.19.2.4 *************** *** 331,335 **** } } else { ! $errors[$qfield] = get_string('QValidRequiredField','stack','');; $question[$qfield] = ''; } --- 331,335 ---- } } else { ! $errors[$qfield] = get_string('QValidRequiredField','stack',''); $question[$qfield] = ''; } *************** *** 443,447 **** foreach ($cas_keywords as $cas_kw) { if (in_array($locvar['key'],$stack_cas[$cas_kw])) { ! $errors[$keyvals_name_raw][$locvar['key']] = $locvar['key']." ".get_string('QValidMaximaName','stack','');; } } --- 443,447 ---- foreach ($cas_keywords as $cas_kw) { if (in_array($locvar['key'],$stack_cas[$cas_kw])) { ! $errors[$keyvals_name_raw][$locvar['key']] = $locvar['key']." ".get_string('QValidMaximaName','stack',''); } } *************** *** 595,601 **** global $stackQuestion,$stackQuestionPotResp; $errstr = ''; - if (is_array($errors)) { ! $errstr = "<b>The item is invalid, and the following field(s) contain errors.</b><br />\n\n"; $errstr .= "<table border='1' cellpadding='2'>"; foreach ($errors as $qfield => $err) { --- 595,600 ---- global $stackQuestion,$stackQuestionPotResp; $errstr = ''; if (is_array($errors)) { ! $errstr = '<b>'.get_string('QValidSummaryTable0','stack')."</b><br />\n\n"; $errstr .= "<table border='1' cellpadding='2'>"; foreach ($errors as $qfield => $err) { *************** *** 603,607 **** if ('questionPotResp' == $qfield) { foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td colspan='2'><b>Potential response '$varname' </b></td></tr>\n"; foreach ($varerr as $prf => $pre) { if (is_array($pre) ) { --- 602,606 ---- if ('questionPotResp' == $qfield) { foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td colspan='2'><b>".get_string('QValidSummaryTable3','stack',$varname)." </b></td></tr>\n"; foreach ($varerr as $prf => $pre) { if (is_array($pre) ) { *************** *** 620,627 **** } ! if ('questionVarsRaw' == $qfield) { ! $errstr .= "\n<tr><td colspan='2'>One or more of the <b>".$stackQuestion[$qfield]['descript']."</b> contained error(s), as follows.</td></tr>"; foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td>The variable '$varname': </td><td>".$varerr."</td></tr>\n"; } $errstr .= "<tr><td> </td><td> </td></tr>\n"; --- 619,627 ---- } ! if ('questionVarsRaw' == $qfield or 'questionAnsVarsRaw' == $qfield) { ! $a = get_string('stackQuestion_'.$qfield,'stack'); ! $errstr .= "\n<tr><td colspan='2'>".get_string('QValidSummaryTable1','stack',$a).'</td></tr>'; foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td>".get_string('QValidSummaryTable2','stack',$varname)."</td><td>".$varerr."</td></tr>\n"; } $errstr .= "<tr><td> </td><td> </td></tr>\n"; *************** *** 629,633 **** } else { ! $errstr .= '<tr><td><b>'.$stackQuestion[$qfield]['descript'].":</b></td><td> ".$err."</td></tr>\n\n"; } --- 629,634 ---- } else { ! $fname = get_string('stackQuestion_'.$qfield,'stack'); ! $errstr .= '<tr><td><b>'.$fname.":</b></td><td> ".$err."</td></tr>\n\n"; } *************** *** 1845,1849 **** echo $options['FeedBackGenericCorrect']; } else if (0==$this_attempt['RawMark']) { ! echo $options['FeedBackGenericIncorrect'];; } else { echo $options['FeedBackGenericPCorrect']; --- 1846,1850 ---- echo $options['FeedBackGenericCorrect']; } else if (0==$this_attempt['RawMark']) { ! echo $options['FeedBackGenericIncorrect']; } else { echo $options['FeedBackGenericPCorrect']; |