📄 v6.php
字号:
$leftitem = $item."['left-item'][0]['#']"; $lefttext = $this->parent->xml_value($tags, $leftitem."['text'][0]['#']"); $rightitem = $item."['right-item'][0]['#']"; $righttext = $this->parent->xml_value($tags, $rightitem."['text'][0]['#']"); if (strlen($righttext)) { $addright = true; } else { $addright = false; } if (strlen($lefttext)) { $this->l_items[] = array( 'text' => $lefttext, 'fixed' => $this->int_value($tags, $leftitem."['fixed'][0]['#']") ); $addright = true; // force right item to be added } if ($addright) { $this->r_items[] = array( 'text' => $righttext, 'fixed' => $this->int_value($tags, $rightitem."['fixed'][0]['#']") ); } $i++; } } function shuffle_jmatch_items(&$items) { // get moveable items $moveable_keys = array(); for($i=0; $i<count($items); $i++) { if(empty($items[$i]['fixed'])) { $moveable_keys[] = $i; } } // shuffle moveable items $this->seed_random_number_generator(); shuffle($moveable_keys); $keys = array(); for($i=0, $ii=0; $i<count($items); $i++) { if(empty($items[$i]['fixed'])) { // moveable items are inserted in a shuffled order $keys[] = $moveable_keys[$ii++]; } else { // fixed items stay where they are $keys[] = $i; } } return $keys; } function seed_random_number_generator() { static $seeded_RNG = FALSE; if (!$seeded_RNG) { srand((double) microtime() * 1000000); $seeded_RNG = TRUE; } } // specials (JMix) // specials (JCloze) function v6_expand_ItemArray() { $q = 0; $str = ''; switch ($this->parent->quiztype) { case 'jcloze': $tags = 'data,gap-fill,question-record'; while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) { $a = 0; $aa = 0; while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $text = $this->js_value($tags, $answer."['text'][0]['#']", true); if (strlen($text)) { if ($aa==0) { // first time only $str .= "\n"; $str .= "I[$q] = new Array();\n"; $str .= "I[$q][1] = new Array();\n"; } $str .= "I[$q][1][$aa] = new Array();\n"; $str .= "I[$q][1][$aa][0] = '$text';\n"; $aa++; } $a++; } // add clue, if any answers were found if ($aa) { $clue = $this->js_value($tags, $question."['clue'][0]['#']", true); $str .= "I[$q][2] = '$clue';\n"; } $q++; } break; case 'jquiz': $str .= "I=new Array();\n"; $tags = 'data,questions,question-record'; while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) { $question_type = $this->int_value($tags, $question."['question-type'][0]['#']"); $weighting = $this->int_value($tags, $question."['weighting'][0]['#']"); $clue = $this->js_value($tags, $question."['clue'][0]['#']", true); $answers = $question."['answers'][0]['#']"; $a = 0; $aa = 0; while (($answer = $answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $text = $this->js_value($tags, $answer."['text'][0]['#']", true); $feedback = $this->js_value($tags, $answer."['feedback'][0]['#']", true); $correct = $this->int_value($tags, $answer."['correct'][0]['#']"); $percent = $this->int_value($tags, $answer."['percent-correct'][0]['#']"); $include = $this->int_value($tags, $answer."['include-in-mc-options'][0]['#']"); if (strlen($text)) { if ($aa==0) { // first time only $str .= "\n"; $str .= "I[$q] = new Array();\n"; $str .= "I[$q][0] = $weighting;\n"; $str .= "I[$q][1] = '$clue';\n"; $str .= "I[$q][2] = '".($question_type-1)."';\n"; $str .= "I[$q][3] = new Array();\n"; } $str .= "I[$q][3][$aa] = new Array('$text','$feedback',$correct,$percent,$include);\n"; $aa++; } $a++; } $q++; } break; } return $str; } function v6_expand_ClozeBody() { $str = ''; // get drop down list of words, if required $dropdownlist = ''; if ($this->v6_use_DropDownList()) { $this->v6_set_WordList(); foreach ($this->wordlist as $word) { $dropdownlist .= '<option value="'.$word.'">'.$word.'</option>'; } } // cache clues flag and caption $includeclues = $this->v6_expand_Clues(); $cluecaption = $this->v6_expand_ClueCaption(); // detect if cloze starts with gap $strpos = strpos($this->parent->source, '<gap-fill><question-record>'); if (is_numeric($strpos)) { $startwithgap = true; } else { $startwithgap = false; } // initialize loop values $q = 0; $tags = 'data,gap-fill'; $question_record = "$tags,question-record"; // loop through text and gaps do { $text = $this->parent->xml_value($tags, "[0]['#'][$q]"); $gap = ''; if (($question="[$q]['#']") && $this->parent->xml_value($question_record, $question)) { $gap .= '<span class="GapSpan" id="GapSpan'.$q.'">'; if ($this->v6_use_DropDownList()) { $gap .= '<select id="Gap'.$q.'"><option value=""></option>'.$dropdownlist.'</select>'; } else { // minimum gap size if (! $gapsize = $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',minimum-gap-size')) { $gapsize = 6; } // increase gap size to length of longest answer for this gap $a = 0; while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($question_record, $answer)) { $answertext = $this->parent->xml_value($question_record, $answer."['text'][0]['#']"); $answertext = preg_replace('|&[#a-zA-Z0-9]+;|', 'x', $answertext); $gapsize = max($gapsize, strlen($answertext)); $a++; } $gap .= '<input type="text" id="Gap'.$q.'" onfocus="TrackFocus('.$q.')" onblur="LeaveGap()" class="GapBox" size="'.$gapsize.'"></input>'; } if ($includeclues) { $clue = $this->parent->xml_value($question_record, $question."['clue'][0]['#']"); if (strlen($clue)) { $gap .= '<button style="line-height: 1.0" class="FuncButton" onfocus="FuncBtnOver(this)" onmouseover="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="ShowClue('.$q.')">'.$cluecaption.'</button>'; } } $gap .= '</span>'; } if ($startwithgap) { $str .= "$gap$text"; } else { $str .= "$text$gap"; } $q++; } while (strlen($text) || strlen($gap)); return $str; } // JCloze quiztype function v6_expand_WordList() { $str = ''; if ($this->v6_include_WordList()) { $this->v6_set_WordList(); $str = implode('    ', $this->wordlist); } return $str; } function v6_include_WordList() { return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-word-list'); } function v6_use_DropDownList() { return $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',use-drop-down-list'); } function v6_set_WordList() { if (isset($this->wordlist)) { // do nothing } else { $this->wordlist = array(); // is the wordlist required if ($this->v6_include_WordList() || $this->v6_use_DropDownList()) { $q = 0; $tags = 'data,gap-fill,question-record'; while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) { $a = 0; $aa = 0; while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $text = $this->parent->xml_value($tags, $answer."['text'][0]['#']"); $correct = $this->int_value($tags, $answer."['correct'][0]['#']"); if ($text && $correct) { // $correct is always true $this->wordlist[] = $text; $aa++; } $a++; } $q++; } $this->wordlist = array_unique($this->wordlist); sort($this->wordlist); } } } function v6_expand_Keypad() { $str = ''; if ($this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-keypad')) { // these characters must always be in the keypad $chars = array(); $this->add_keypad_chars($chars, $this->parent->xml_value('hotpot-config-file,global,keypad-characters')); // append other characters used in the answers $tags = ''; switch ($this->parent->quiztype) { case 'jcloze': $tags = 'data,gap-fill,question-record'; break; case 'jquiz': $tags = 'data,questions,question-record'; break; } if ($tags) { $q = 0; while (($question="[$q]['#']") && $this->parent->xml_value($tags, $question)) { if ($this->parent->quiztype=='jquiz') { $answers = $question."['answers'][0]['#']"; } else { $answers = $question; } $a = 0; while (($answer=$answers."['answer'][$a]['#']") && $this->parent->xml_value($tags, $answer)) { $this->add_keypad_chars($chars, $this->parent->xml_value($tags, $answer."['text'][0]['#']")); $a++; } $q++; } } // remove duplicate characters and sort $chars = array_unique($chars); usort($chars, "hotpot_sort_keypad_chars"); // create keypad buttons for each character foreach ($chars as $char) { $str .= "<button onclick=\"TypeChars('".$this->js_safe($char, true)."'); return false;\">$char</button>"; } } return $str; } function add_keypad_chars(&$chars, $text) { if (preg_match_all('|&[^;]+;|i', $text, $more_chars)) { $chars = array_merge($chars, $more_chars[0]); } } function v6_expand_Correct() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guesses-correct'); } function v6_expand_Incorrect() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',guesses-incorrect'); } function v6_expand_GiveHint() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',next-correct-letter'); } function v6_expand_CaseSensitive() { return $this->bool_value('hotpot-config-file,'.$this->parent->quiztype.',case-sensitive'); } // JCross quiztype function v6_expand_CluesAcrossLabel() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-across'); } function v6_expand_CluesDownLabel() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',clues-down'); } function v6_expand_EnterCaption() { return $this->js_value('hotpot-config-file,'.$this->parent->quiztype.',enter-caption'); } function v6_expand_ShowHideClueList() { $value = $this->int_value('hotpot-config-file,'.$this->parent->quiztype.',include-clue-list'); return empty($value) ? ' style="display: none;"' : ''; } // JCross specials function v6_expand_CluesDown() { return $this->v6_expand_jcross_clues('D'); } function v6_expand_CluesAcross() { return $this->v6_expand_jcross_clues('A'); } function v6_expand_jcross_clues($direction) { // $direction: A(cross) or D(own) $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++) { for($c=0; $c<=$c_max; $c++) { $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 ($aword || $dword) { $i++; // increment clue index // get the definition for this word $def = ''; $word = ($direction=='A') ? $aword : $dword; $clues = $this->parent->xml_values('data,crossword,clues,item'); foreach ($clues as $clue) { if ($clue['word'][0]['#']==$word) { $def = $clue['def'][0]['#']; $def = strtr($def, array('<'=>'<', '>'=>'>', "\n"=>'<br />')); break; } } if (!empty($def)) { $str .= '<tr><td class="ClueNum">'.$i.'. </td><td id="Clue_'.$direction.'_'.$i.'" class="Clue">'.$def.'</td></tr>'; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -