FromName = mm_convert_encoding($mail->FromName, 'auto'); $mail->Subject = mm_convert_encoding($mail->Subject, 'auto'); $mail->Body = ex_convert_encoding($mail->Body, 'iso-2022-jp', 'auto'); $mail->AltBody = ex_convert_encoding($mail->AltBody, 'iso-2022-jp', 'auto'); $mail->CharSet = 'ISO-2022-JP'; $mail->Encoding = '7bit'; foreach ($mail->to as $i => $temp_mail) { $mail->to[$i][1] = mm_convert_encoding($temp_mail[1], 'auto'); } foreach ($mail->cc as $i => $temp_mail) { $mail->cc[$i][1] = mm_convert_encoding($temp_mail[1], 'auto'); } foreach ($mail->bcc as $i => $temp_mail) { $mail->bcc[$i][1] = mm_convert_encoding($temp_mail[1], 'auto'); } } function lang_convert_encoding($str, $to, $from = '') { require_once dirname(__FILE__).'/jcode.php'; $jc_to = _check_encoding($to); $jc_from = _check_encoding($from); if ($jc_from == 0) { $jc_from = AutoDetect($str); } if ($jc_to == 4) { global $table_jis_utf8; include_once dirname(__FILE__).'/code_table.jis2ucs'; } if ($jc_from == 4) { global $table_utf8_jis; include_once dirname(__FILE__).'/code_table.ucs2jis'; } return JcodeConvert($str, $jc_from, $jc_to); } function _check_encoding($str_encoding) { switch (strtolower($str_encoding)) { case 'e': case 'euc': case 'euc-jp': $jc_encoding = 1; break; case 's': case 'sjis': case 'shift_jis': $jc_encoding = 2; break; case 'j': case 'jis': case 'iso-2022-jp': $jc_encoding = 3; break; case 'u': case 'utf8': case 'utf-8': $jc_encoding = 4; break; default: $jc_encoding = 0; break; } return $jc_encoding; } function simple_text_out($count, $course, $quiz, $data, $average) { $set_usr_agent = define_usr_agent(); if ($set_usr_agent == 1) { $set_return = "\r\n"; } elseif ($set_usr_agent == 2) { $set_return = "\r"; } else { $set_return = "\n"; } header("Content-Type: application/download\n"); if($set_usr_agent) { $quiz->name = ex_convert_encoding($quiz->name, 'sjis', 'auto'); $course->shortname = ex_convert_encoding($course->shortname, 'sjis', 'auto'); } header("Content-Disposition: attachment; filename=$course->shortname ".$quiz->name.".txt"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); header("Pragma: public"); /// Print names of all the fields echo "$quiz->name"; for ($i=1; $i<=$count; $i++) { echo "\t$i"; } echo "$set_return"; /// Print all the user data foreach ($data as $userid => $datum) { if($set_usr_agent) { $temp_dataum = ex_convert_encoding(fullname($datum), 'sjis', 'auto'); } else { $temp_dataum = fullname($datum); } echo $temp_dataum; for ($i=1; $i<=$count; $i++) { echo "\t"; if (isset($datum->grades[$i])) { if($set_usr_agent) { $temp_dataum = ex_convert_encoding($datum->grades[$i], 'sjis', 'auto'); } else { $temp_dataum = $datum->grades[$i]; } echo $temp_dataum; } } echo "$set_return"; } /// Print all the averages echo "\t"; for ($i=1; $i<=$count; $i++) { echo "\t".$average[$i]; } echo "$set_return"; /// Print all the averages as percentages echo "\t%"; for ($i=1; $i<=$count; $i++) { $percent = format_float($average[$i] * 100); echo "\t$percent"; } echo "$set_return"; exit; } function full_text_out($course, $quiz, $data_tally, $qs_in_order, $question_ids, $qcount, $quests, $match_qs, $analysis, $max_choices, $table_colcount) { $set_usr_agent = define_usr_agent(); if ($set_usr_agent == 1) { $set_return = "\r\n"; } elseif ($set_usr_agent == 2) { $set_return = "\r"; } else { $set_return = "\n"; } header("Content-Type: application/download\n"); if($set_usr_agent) { $quiz->name = ex_convert_encoding($quiz->name, 'sjis', 'auto'); $course->shortname = ex_convert_encoding($course->shortname, 'sjis', 'auto'); } header("Content-Disposition: attachment; filename=$course->shortname ".$quiz->name.".txt"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); header("Pragma: public"); /// Print names of all the fields echo "$quiz->name"; echo "$set_return"; /// Print all the user data $colcount = count($question_ids); foreach ($data_tally as $thisuserno=>$thisuser){ foreach($thisuser as $thisattemptno=>$thisattempt){ foreach($thisattempt as $thisitemkey=>$thisitem) { if ($thisitem['score'] < 1) {$mark = "";} else {$mark = "*";} //First two items are name & grade if ($thisitemkey < 2){ if($set_usr_agent) { $temp_dataum = ex_convert_encoding($thisitem, 'sjis', 'auto'); } else { $temp_dataum = $thisitem; } echo $temp_dataum . "\t"; } elseif ($thisitemkey['qtype'] == 2){ if($set_usr_agent) { $temp_dataum = ex_convert_encoding($thisitem['data']['answer'], 'sjis', 'auto'); } else { $temp_dataum = $thisitem['data']['answer']; } echo $temp_dataum . "\t"; } elseif ($thisitem['qtype'] == 5) { if ($thisitem['score'] == 1) {$mark = "*";} else {$mark="";} if(!$thisitem['data'][1]){$thisitem['data'][1]="(No Response)";} if($set_usr_agent) { $temp_dataum_1 = ex_convert_encoding($thisitem['data'][0], 'sjis', 'auto'); $temp_dataum_2 = ex_convert_encoding($thisitem['data'][1], 'sjis', 'auto'); } else { $temp_dataum_1 = $thisitem['data'][0]; $temp_dataum_2 = $thisitem['data'][1]; } echo "{$temp_dataum_1} -- $mark{$temp_dataum_2}\t"; } else { if($set_usr_agent) { $temp_dataum = ex_convert_encoding($thisitem['data'], 'sjis', 'auto'); } else { $temp_dataum = $thisitem['data']; } echo "$mark{$temp_dataum}\t"; } } } echo " $set_return"; } echo " $set_return"; echo "* Asterisk indicates correct response"; echo " $set_return"; //Question numbers for ($i = 1;$i <= $colcount;$i++) { echo "Q-$i\t"; } echo " $set_return"; //Q numbers foreach($qs_in_order as $qid){ $qcount++; if($quests[$qid]['qtype'] == 5) { $i = 0; foreach ($match_qs[$qid] as $nowq){ $i++; echo "Q-$qcount M-$i\t"; } } else { echo "Q-$qcount\t"; } } echo " $set_return"; //Repeat for q answers foreach($qs_in_order as $qid){ $qcount++; if($quests[$qid]['qtype'] == 5) { foreach ($match_qs[$qid] as $nowq){ if($set_usr_agent) { $temp_dataum = ex_convert_encoding($nowq, 'sjis', 'auto'); } else { $temp_dataum = $nowq; } echo $temp_dataum. "\t"; } } else { echo "\t"; } } echo " $set_return"; for ($i = 1; $i<= $max_choices;$i++){ echo "M/C #$i\t"; //display answer tallies for ($j = 1; $j <= $table_colcount; $j++){ //substitute "
" for a "//" $nowdata = $analysis[$i][$j]; if (strpos($nowdata,"//")>0) { $nowdata = str_replace("//"," : ",$nowdata); } if($set_usr_agent) { $temp_dataum = ex_convert_encoding($nowdata, 'sjis', 'auto'); } else { $temp_dataum = $nowdata; } echo $nowdata . "\t"; } echo " $set_return"; } exit; } function define_usr_agent() { $usr_agent_data = getenv('HTTP_USER_AGENT'); if (preg_match('/WIN/i', $usr_agent_data)) { $set_usr_agent = 1; } elseif (preg_match('/MAC/i', $usr_agent_data)) { $set_usr_agent = 2; } else { $set_usr_agent = 0; } return $set_usr_agent; } ?>