📄 v6.php
字号:
} } } return $str; } // jcross6.js_ function v6_expand_LetterArray() { $row = NULL; $r_max = 0; $c_max = 0; $this->v6_get_jcross_grid($row, $r_max, $c_max); $str = ''; for($r=0; $r<=$r_max; $r++) { $str .= "L[$r] = new Array("; for($c=0; $c<=$c_max; $c++) { $str .= ($c>0 ? ',' : '')."'".$this->js_safe($row[$r]['cell'][$c]['#'], true)."'"; } $str .= ");\n"; } return $str; } function v6_expand_GuessArray() { $row = NULL; $r_max = 0; $c_max = 0; $this->v6_get_jcross_grid($row, $r_max, $c_max); $str = ''; for($r=0; $r<=$r_max; $r++) { $str .= "G[$r] = new Array('".str_repeat("','", $c_max)."');\n"; } return $str; } function v6_expand_ClueNumArray() { $row = NULL; $r_max = 0; $c_max = 0; $this->v6_get_jcross_grid($row, $r_max, $c_max); $i = 0; // clue index $str = ''; for($r=0; $r<=$r_max; $r++) { $str .= "CL[$r] = new Array("; for($c=0; $c<=$c_max; $c++) { if ($c>0) { $str .= ','; } $aword = $this->get_jcross_aword($row, $r, $r_max, $c, $c_max); $dword = $this->get_jcross_dword($row, $r, $r_max, $c, $c_max); if (empty($aword) && empty($dword)) { $str .= 0; } else { $i++; // increment the clue index $str .= $i; } } $str .= ");\n"; } return $str; } function v6_expand_GridBody() { $row = NULL; $r_max = 0; $c_max = 0; $this->v6_get_jcross_grid($row, $r_max, $c_max); $i = 0; // clue index; $str = ''; for($r=0; $r<=$r_max; $r++) { $str .= '<tr id="Row_'.$r.'">'; for($c=0; $c<=$c_max; $c++) { if (empty($row[$r]['cell'][$c]['#'])) { $str .= '<td class="BlankCell"> </td>'; } else { $aword = $this->get_jcross_aword($row, $r, $r_max, $c, $c_max); $dword = $this->get_jcross_dword($row, $r, $r_max, $c, $c_max); if (empty($aword) && empty($dword)) { $str .= '<td class="LetterOnlyCell"><span id="L_'.$r.'_'.$c.'"> </span></td>'; } else { $i++; // increment clue index $str .= '<td class="NumLetterCell"><a href="javascript:void(0);" class="GridNum" onclick="ShowClue('.$i.','.$r.','.$c.')">'.$i.'</a><span class="NumLetterCellText" id="L_'.$r.'_'.$c.'" onclick="ShowClue('.$i.','.$r.','.$c.')"> </span></td>'; } } } $str .= '</tr>'; } return $str; } function v6_get_jcross_grid(&$row, &$r_max, &$c_max) { $row = $this->parent->xml_values('data,crossword,grid,row'); $r_max = 0; $c_max = 0; if (isset($row) && is_array($row)) { for($r=0; $r<count($row); $r++) { if (isset($row[$r]['cell']) && is_array($row[$r]['cell'])) { for($c=0; $c<count($row[$r]['cell']); $c++) { if (!empty($row[$r]['cell'][$c]['#'])) { $r_max = max($r, $r_max); $c_max = max($c, $c_max); } } // end for $c } } // end for $r } } function get_jcross_dword(&$row, $r, $r_max, $c, $c_max) { $str = ''; if (($r==0 || empty($row[$r-1]['cell'][$c]['#'])) && $r<$r_max && !empty($row[$r+1]['cell'][$c]['#'])) { $str = $this->get_jcross_word($row, $r, $r_max, $c, $c_max, true); } return $str; } function get_jcross_aword(&$row, $r, $r_max, $c, $c_max) { $str = ''; if (($c==0 || empty($row[$r]['cell'][$c-1]['#'])) && $c<$c_max && !empty($row[$r]['cell'][$c+1]['#'])) { $str = $this->get_jcross_word($row, $r, $r_max, $c, $c_max, false); } return $str; } function get_jcross_word(&$row, $r, $r_max, $c, $c_max, $go_down=false) { $str = ''; while ($r<=$r_max && $c<=$c_max && !empty($row[$r]['cell'][$c]['#'])) { $str .= $row[$r]['cell'][$c]['#']; if ($go_down) { $r++; } else { $c++; } } return $str; } // specials (JQuiz) function v6_expand_QuestionOutput() { $str = ''; $str .= '<ol class="QuizQuestions" id="Questions">'."\n"; $q = 0; $tags = 'data,questions,question-record'; while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) { // get question $question_text = $this->parent->xml_value($tags, $question."['question'][0]['#']"); $question_type = $this->parent->xml_value($tags, $question."['question-type'][0]['#']"); $first_answer_text = $this->parent->xml_value($tags, $question."['answers'][0]['#']['answer'][0]['#']['text'][0]['#']"); // check we have a question (or at least one answer) if (($question_text || $first_answer_text) && $question_type) { $str .= '<li class="QuizQuestion" id="Q_'.$q.'" style="display: none;">'; $str .= '<p class="QuestionText">'.$question_text.'</p>'; if ( $question_type==HOTPOT_JQUIZ_SHORTANSWER || $question_type==HOTPOT_JQUIZ_HYBRID ) { $size = 9; // default size $a = 0; $answers = $question."['answers'][0]['#']"; while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']"); $text = preg_replace('/&[#a-zA-Z0-9]+;/', 'x', $text); $size = max($size, strlen($text)); $a++; } $str .= '<div class="ShortAnswer" id="Q_'.$q.'_SA"><form method="post" action="" onsubmit="return false;"><div>'; if ($size<=25) { // text box $str .= '<input type="text" id="Q_'.$q.'_Guess" onfocus="TrackFocus('."'".'Q_'.$q.'_Guess'."'".')" onblur="LeaveGap()" class="ShortAnswerBox" size="'.$size.'"></input>'; } else { // textarea (29 cols wide) $str .= '<textarea id="Q_'.$q.'_Guess" onfocus="TrackFocus('."'".'Q_'.$q.'_Guess'."'".')" onblur="LeaveGap()" class="ShortAnswerBox" cols="29" rows="'.ceil($size/25).'"></textarea>'; } $str .= '<br /><br />'; $caption = $this->v6_expand_CheckCaption(); $str .= $this->v6_expand_jquiz_button($caption, "CheckShortAnswer($q)"); if ($this->v6_expand_Hint()) { $caption = $this->v6_expand_HintCaption(); $str .= $this->v6_expand_jquiz_button($caption, "ShowHint($q)"); } if ($this->v6_expand_ShowAnswer()) { $caption = $this->v6_expand_ShowAnswerCaption(); $str .= $this->v6_expand_jquiz_button($caption, "ShowAnswers($q)"); } $str .= '</div></form></div>'; } if ( $question_type==HOTPOT_JQUIZ_MULTICHOICE || $question_type==HOTPOT_JQUIZ_HYBRID || $question_type==HOTPOT_JQUIZ_MULTISELECT ) { switch ($question_type) { case HOTPOT_JQUIZ_MULTICHOICE: $str .= '<ol class="MCAnswers">'."\n"; break; case HOTPOT_JQUIZ_HYBRID: $str .= '<ol class="MCAnswers" id="Q_'.$q.'_Hybrid_MC" style="display: none;">'."\n"; break; case HOTPOT_JQUIZ_MULTISELECT: $str .= '<ol class="MSelAnswers">'."\n"; break; } $a = 0; $aa = 0; $answers = $question."['answers'][0]['#']"; while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']"); if ($text) { switch ($question_type) { case HOTPOT_JQUIZ_MULTICHOICE: case HOTPOT_JQUIZ_HYBRID: $include = $this->int_value($tags, $answer."['include-in-mc-options'][0]['#']"); if ($include) { $str .= '<li id="Q_'.$q.'_'.$aa.'"><button class="FuncButton" onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseover="FuncBtnOver(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" id="Q_'.$q.'_'.$aa.'_Btn" onclick="CheckMCAnswer('.$q.','.$aa.',this)"> ? </button> '.$text.'</li>'."\n"; } break; case HOTPOT_JQUIZ_MULTISELECT: $str .= '<li id="Q_'.$q.'_'.$aa.'"><form method="post" action="" onsubmit="return false;"><div><input type="checkbox" id="Q_'.$q.'_'.$aa.'_Chk" class="MSelCheckbox" />'.$text.'</div></form></li>'."\n"; break; } $aa++; } $a++; } $str .= '</ol>'; if ($question_type==HOTPOT_JQUIZ_MULTISELECT) { $caption = $this->v6_expand_CheckCaption(); $str .= $this->v6_expand_jquiz_button($caption, "CheckMultiSelAnswer($q)"); } } $str .= "</li>\n"; } $q++; } // end while $question $str .= "</ol>\n"; return $str; } function v6_expand_jquiz_button($caption, $onclick) { return '<button class="FuncButton" onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseover="FuncBtnOver(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="'.$onclick.'">'.$caption.'</button>'; } // jquiz.js_ function v6_expand_MultiChoice() { return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_MULTICHOICE); } function v6_expand_ShortAnswer() { return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_SHORTANSWER); } function v6_expand_MultiSelect() { return $this->v6_jquiz_question_type(HOTPOT_JQUIZ_MULTISELECT); } function v6_jquiz_question_type($type) { // does this quiz have any questions of the given $type? $flag = false; $q = 0; $tags = 'data,questions,question-record'; while (($question = "[$q]['#']") && $this->parent->xml_value($tags, $question)) { $question_type = $this->parent->xml_value($tags, $question."['question-type'][0]['#']"); if ($question_type==$type || ($question_type==HOTPOT_JQUIZ_HYBRID && ($type==HOTPOT_JQUIZ_MULTICHOICE || $type==HOTPOT_JQUIZ_SHORTANSWER))) { $flag = true; break; } $q++; } return $flag; } function v6_expand_CorrectFirstTime() { return $this->js_value('hotpot-config-file,global,correct-first-time'); } function v6_expand_ContinuousScoring() { return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',continuous-scoring'); } function v6_expand_ShowCorrectFirstTime() { return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',show-correct-first-time'); } function v6_expand_ShuffleAs() { return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',shuffle-answers'); } function v6_expand_DefaultRight() { return $this->v6_expand_GuessCorrect(); } function v6_expand_DefaultWrong() { return $this->v6_expand_GuessIncorrect(); } function v6_expand_ShowAllQuestionsCaptionJS() { return $this->v6_expand_ShowAllQuestionsCaption(); } function v6_expand_ShowOneByOneCaptionJS() { return $this->v6_expand_ShowOneByOneCaption(); } // hp6checkshortanswers.js_ (JQuiz) function v6_expand_CorrectList() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',correct-answers'); } function v6_expand_HybridTries() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',short-answer-tries-on-hybrid-q'); } function v6_expand_PleaseEnter() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',enter-a-guess'); } function v6_expand_PartlyIncorrect() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',partly-incorrect'); } function v6_expand_ShowAnswerCaption() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',show-answer-caption'); } function v6_expand_ShowAlsoCorrect() { return $this->bool_value('hotpot-config-file,global,show-also-correct'); }} // end classfunction hotpot_sort_keypad_chars($a, $b) { $a = hotpot_keypad_sort_value($a); $b = hotpot_keypad_sort_value($b); return ($a<$b) ? -1 : ($a==$b ? 0 : 1);}function hotpot_keypad_sort_value($char) { // hexadecimal if (preg_match('|&#x([0-9A-F]+);|ie', $char, $matches)) { $ord = hexdec($matches[1]); // decimal } else if (preg_match('|&#(\d+);|i', $char, $matches)) { $ord = intval($matches[1]); // other html entity } else if (preg_match('|&[^;]+;|', $char, $matches)) { $char = html_entity_decode($matches[0]); $ord = empty($char) ? 0 : ord($char); // not an html entity } else { $char = trim($char); $ord = empty($char) ? 0 : ord($char); } // lowercase letters (plain or accented) if (($ord>=97 && $ord<=122) || ($ord>=224 && $ord<=255)) { $sort_value = ($ord-31).'.'.sprintf('%04d', $ord); // all other characters } else { $sort_value = $ord; } return $sort_value;}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -