Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
843 liveuser 6
    Copyright (C) 2015~2025 Min-Jhin,Chen
1 liveuser 7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
namespace qbpwcf;
25
 
247 liveuser 26
/*
27
類別說明:
28
跟考試應用相關的類別.
29
備註:
30
無.
31
*/
1 liveuser 32
class exam{
33
 
34
	/*
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
39
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
40
	#$result["function"],當前執行的函式名稱.
41
	#必填參數:
42
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
47
	public function __call($method,$arguments){
48
 
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
51
 
52
		#設置執行不正常
53
		$result["status"]="false";
54
 
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
 
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
60
 
61
		#回傳結果
62
		return $result;
63
 
64
		}#function __call end
65
 
66
	/*
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
71
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
72
	#$result["function"],當前執行的函式名稱.
73
	#必填參數:
74
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
79
	public static function __callStatic($method,$arguments){
80
 
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
83
 
84
		#設置執行不正常
85
		$result["status"]="false";
86
 
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
 
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
92
 
93
		#回傳結果
94
		return $result;
95
 
96
		}#function __callStatic end
97
 
98
	/*
99
	#函式說明:
100
	#根據座位表csv檔與坐者csv檔來隨機安排座位,並自動下載安排好的座位表csv檔.
290 liveuser 101
	#回傳結果:
1 liveuser 102
	#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
103
	#$result["error"],錯誤訊息陣列.
104
	#$result["function"],當前執行的函數名稱
105
	#$result["content"],處理好的座位表csv檔位置.
290 liveuser 106
	#必填參數:
1 liveuser 107
	#$conf["seaterList"],字串,坐者的csv檔位置與名稱,單攔,每一列為坐者的代稱.
108
	$conf["seaterList"]="";
109
	#$conf["seatMap"],字串,座位表示意csv檔位置與名稱,格子內容為0代表非座位,1為座位.
110
	$conf["seatMap"]="";
111
	#$conf["outputAddress"],字串,csv檔要輸出到哪邊,不用加csv副檔名.
112
	$conf["outputAddress"]="";		
113
	#$conf["fileArgu"],字串,__FILE__的內容.
114
	$conf["fileArgu"]=__FILE__;
290 liveuser 115
	#可省略參數:
1 liveuser 116
	#$conf["emptySeatName"],字串,要空下來的座位,其代稱要用什麼?預設為empty.
117
	#$conf["emptySeatName"]="empty";
118
	#$conf["repeat"],字串,能否連續兩個位置的名稱都一樣,"false"代表不連續重複,"true"代表允許連續重複,預設為"false".
119
	#$conf["repeat"]="false"
120
	#$conf["noDownload"],字串,是否不要立馬下載處理好的坐位表csv檔,"true"代表不要要立馬下載處理好的坐位表csv檔.
121
	#$conf["noDownload"]="true";
290 liveuser 122
	#參考資料:
123
	#無.
124
	#備註:
125
	#無.
1 liveuser 126
	*/
289 liveuser 127
	public static function randomSeater(&$conf){
1 liveuser 128
 
129
		#初始化要回傳的內容
130
		$result=array();
131
 
132
		#取得當前執行的函數名稱
133
		$result["function"]=__FUNCTION__;
134
 
135
		#如果 $conf 不為陣列
136
		if(gettype($conf)!="array"){
137
 
138
			#設置執行失敗
139
			$result["status"]="false";
140
 
141
			#設置執行錯誤訊息
142
			$result["error"][]="\$conf變數須為陣列形態";
143
 
144
			#如果傳入的參數為 null
145
			if($conf==null){
146
 
147
				#設置執行錯誤訊息
148
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
149
 
150
				}#if end
151
 
152
			#回傳結果
153
			return $result;
154
 
155
			}#if end
156
 
157
		#檢查參數
158
		#函式說明:
159
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
160
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
161
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
162
		#$result["function"],當前執行的函式名稱.
163
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
164
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
165
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
166
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
167
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
168
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
169
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
170
		#必填寫的參數:
171
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
172
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
173
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
174
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("seaterList","seatMap","outputAddress","fileArgu");
175
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
176
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string");
177
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
178
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
179
		#可以省略的參數:
180
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
181
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
182
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
183
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("emptySeatName","noDownload","repeat");
184
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
185
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
186
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
187
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("empty","true","false");
188
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
189
		#$conf["arrayCountEqualCheck"][]=array();
190
		#參考資料來源:
191
		#array_keys=>http://php.net/manual/en/function.array-keys.php
192
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
193
		unset($conf["variableCheck::checkArguments"]);
194
 
195
		#如果 $checkResult["status"] 等於 "false"
196
		if($checkResult["status"]=="false"){
197
 
198
			#設置執行錯誤
199
			$result["status"]="false";
200
 
201
			#設置錯誤訊息
202
			$result["error"]=$checkResult;
203
 
204
			#回傳結果
205
			return $result;
206
 
207
			}#if end
208
 
209
		#如果 $checkResult["passed"] 等於 "false"
210
		if($checkResult["passed"]=="false"){
211
 
212
			#設置執行錯誤
213
			$result["status"]="false";
214
 
215
			#設置錯誤訊息
216
			$result["error"]=$checkResult;
217
 
218
			#回傳結果
219
			return $result;
220
 
221
			}#if end
222
 
223
		#讀座位表csv檔
224
		#涵式說明:
225
		#讀取csv檔案的內容
226
		#回傳得結果:
227
		#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
228
		#$result["error"],錯誤訊息陣列.
229
		#$result["csvFileContent"],csv檔案內容的陣列
230
			#$result["csvFileContent"]["$i"]["$j"]代表第$i+1列第$j+1欄位的內容.
231
			#如果 $conf["firstLineVarName"]爲"true"的話則會回傳 $result["csvFileContent"]["第幾列"]["第一列各個欄位的名稱"]
232
		#$result["lineArray"],csv檔案逐列內容的陣列.
233
		#$result["lineArrayCount"],總共幾列資料
234
		#必填的參數:
235
		$conf["csv"]["loadCsvFile"]["csvFilePositionAndName"]=$conf["seatMap"];#csv檔案的位置
236
		$conf["csv"]["loadCsvFile"]["fileArgu"]=$conf["fileArgu"];
237
		#可省略的參數:
238
		$conf["csv"]["loadCsvFile"]["firstLineVarName"]="false";#第一行是否爲變數名稱(各個欄位的名稱)
239
		#參考資料來源:
240
		#http://www.php.net/manual/en/function.str-split.php
241
		#參考資料來源
242
		#http://chuangmaster.pixnet.net/blog/post/33560606-%5B%E8%BD%89%E8%B2%BC%5D%E9%97%9C%E6%96%BC%E5%9B%9E%E8%BB%8A(%5Cr)%E8%88%87%E6%8F%9B%E8%A1%8C(%5Cn)
243
		$seatMap=csv::loadCsvFile($conf["csv"]["loadCsvFile"]);
244
		unset($conf["csv"]["loadCsvFile"]);
245
 
246
		#如果 $seatMap["status"] 等於 "false"
247
		if($seatMap["status"]=="false"){
248
 
249
			#設置執行錯誤
250
			$result["status"]="false";
251
 
252
			#設置錯誤訊息
253
			$result["error"]=$seatMap;
254
 
255
			#回傳結果
256
			return $result;
257
 
258
			}#if end
259
 
260
		#讀取坐者csv檔
261
		#涵式說明:
262
		#讀取csv檔案的內容
263
		#回傳得結果:
264
		#$result["status"],執行是否正常,"true"代表正常;"false"代表不正常.
265
		#$result["error"],錯誤訊息陣列.
266
		#$result["csvFileContent"],csv檔案內容的陣列
267
			#$result["csvFileContent"]["$i"]["$j"]代表第$i+1列第$j+1欄位的內容.
268
			#如果 $conf["firstLineVarName"]爲"true"的話則會回傳 $result["csvFileContent"]["第幾列"]["第一列各個欄位的名稱"]
269
		#$result["lineArray"],csv檔案逐列內容的陣列.
270
		#$result["lineArrayCount"],總共幾列資料
271
		#必填的參數:
272
		$conf["csv"]["loadCsvFile"]["csvFilePositionAndName"]=$conf["seaterList"];#csv檔案的位置
273
		$conf["csv"]["loadCsvFile"]["fileArgu"]=$conf["fileArgu"];
274
		#可省略的參數:
275
		$conf["csv"]["loadCsvFile"]["firstLineVarName"]="false";#第一行是否爲變數名稱(各個欄位的名稱)
276
		#參考資料來源:
277
		#http://www.php.net/manual/en/function.str-split.php
278
		#參考資料來源
279
		#http://chuangmaster.pixnet.net/blog/post/33560606-%5B%E8%BD%89%E8%B2%BC%5D%E9%97%9C%E6%96%BC%E5%9B%9E%E8%BB%8A(%5Cr)%E8%88%87%E6%8F%9B%E8%A1%8C(%5Cn)
280
		$seaterList=csv::loadCsvFile($conf["csv"]["loadCsvFile"]);
281
		unset($conf["csv"]["loadCsvFile"]);
282
 
283
		#如果 $seaterList["status"] 等於 "false"
284
		if($seaterList["status"]=="false"){
285
 
286
			#設置執行錯誤
287
			$result["status"]="false";
288
 
289
			#設置錯誤訊息
290
			$result["error"]=$seaterList;
291
 
292
			#回傳結果
293
			return $result;
294
 
295
			}#if end
296
 
297
		#取得坐者的數量
298
		$seaterCount=$seaterList["lineArrayCount"];
299
 
300
		#取得座位表的空位數
301
		#函式說明:
302
		#計屬csv檔裡面的關鍵字.
303
		#回傳的結果:
304
		#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
305
		#$result["error"],錯誤訊息陣列.
306
		#$result["content"],找到的關鍵字數量.
307
		#必填的參數:
308
		#$conf["csvFileAddress"],字串,csv檔案的位置與名稱.
309
		$conf["csv"]["keyWordsCount"]["csvFileAddress"]=$conf["seatMap"];
310
		#$conf["keyWord"],字串,要尋找的關鍵字.
311
		$conf["csv"]["keyWordsCount"]["keyWord"]="1";
312
		$conf["csv"]["keyWordsCount"]["fileArgu"]=$conf["fileArgu"];
313
		#可省略的參數: 
314
		$conf["csv"]["keyWordsCount"]["firstLineVarName"]="false";#第一行是否爲變數名稱(各個欄位的名稱),"true"表示第一列不在搜尋範圍裡.
315
		$seatCount=csv::keyWordsCount($conf["csv"]["keyWordsCount"]);
316
		unset($conf["csv"]["keyWordsCount"]);
317
 
318
		#如果 $seatCount["status"] 等於 "false" 
319
		if($seatCount["status"]=="false"){
320
 
321
			#設置執行錯誤
322
			$result["status"]="false";
323
 
324
			#設置錯誤訊息
325
			$result["error"]=$seatCount;
326
 
327
			#回傳結果
328
			return $result;
329
 
330
			}#if end
331
 
332
		#如果空座位數小於坐者
333
		if($seatCount["content"]<$seaterCount){
334
 
335
			#設置執行錯誤
336
			$result["status"]="false";
337
 
338
			#設置錯誤訊息
339
			$result["error"][]="座位數量不足,至少需要".$seaterCount."個座位";
340
 
341
			#回傳結果
342
			return $result;
343
 
344
			}#if end
345
 
346
		#初始化儲存坐者清單的一維陣列
347
		$seaterListArray=array();
348
 
349
		#根據坐者csv檔清單裡每列內容
350
		foreach($seaterList["csvFileContent"] as $row){
351
 
352
			#根據每列的欄元素
353
			foreach($row as $col){
354
 
355
				#取得每個元素內容
356
				$seaterListArray[]=$col;
357
 
358
				}#foreach end
359
 
360
			}#foreach end
361
 
362
		#取得座位表跟坐者的差
363
		$range=$seatCount["content"]-$seaterCount;	
364
 
365
		#將坐者清單加上代表沒人坐的名單,讓其數量跟座位數一樣
366
		#缺幾個名單就執行幾次
367
		for($i=0;$i<$range;$i++){
368
 
369
			#將沒有要坐的名稱設為$conf["emptySeatName"]
370
			$seaterListArray[]=$conf["emptySeatName"];
371
 
372
			}#for end
373
 
374
		#根據座位表csv檔裡每列內容
375
		foreach($seatMap["csvFileContent"] as $rowKey=>$rowValue){
376
 
377
			#根據每列的欄元素
378
			foreach($rowValue as $colKey=>$colValue){
379
 
380
				#初始化沒有上一位坐者
381
				$lastSeat=null;
382
 
383
				#如果該地方是座位(等於1)
384
				if($colValue=="1"){
385
 
386
					#隨機安排坐者						
387
					#函式說明: 
388
					#亂數產生特定陣列裡面的內容
389
					#回傳的結果:
390
					#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
391
					#$result["error"],錯誤訊息陣列.
392
					#$result["content"]["name"],產生的元素在$conf["randomArray"]裡面的key是?
393
					#$result["content"]["value"],產生的元素內容.
394
					#必填參數:
395
					#$conf["randomArray"],字串陣列,要隨機產生的元素.
396
					$conf["math"]["randomFromArray"]["randomArray"]=$seaterListArray;
397
					#可省略參數:
398
					#無
399
					$randomResult=math::randomFromArray($conf["math"]["randomFromArray"]);
400
					unset($conf["math"]["randomFromArray"]);
401
 
402
					#如果 $randomResult["status"] 等於 "false" 
403
					if($randomResult["status"]=="false"){
404
 
405
						#設置執行錯誤
406
						$result["status"]="false";
407
 
408
						#設置錯誤訊息
409
						$result["error"]=$randomResult;
410
 
411
						#回傳結果
412
						return $result;
413
 
414
						}#if end
415
 
416
					#如果座位不能重複
417
					if($conf["repeat"]=="false"){
418
 
419
						#如果上一位坐者不為 null
420
						if($lastSeat!=null){
421
 
422
							#如果抽出來的坐者是連續的
423
							while($randomResult["content"]["value"]==$lastSeat){
424
 
425
								#若這是最後一個坐者了
426
								if(count($seaterListArray)==1){
427
 
428
									#跳出
429
									break;
430
 
431
									}#if end
432
 
433
								#初始化是否要繼續執行的辨別變數
434
								$continue="false";
435
 
436
								#若剩下坐者全部跟 $lastSeat(上一個坐者) 一樣
437
								foreach($seaterListArray as $seaterName){
438
 
439
									#如果剩下的坐者有跟 $lastSeat(上一個坐者) 不一樣
440
									if($seaterName!=$lastSeat){
441
 
442
										#設置繼續執行
443
										$continue="true";
444
 
445
										#跳出 foreach
446
										break;
447
 
448
										}#if end
449
 
450
									}#foreach end
451
 
452
								#如果不繼續執行
453
								if($continue=="false"){
454
 
455
									#跳出 while
456
									break;
457
 
458
									}#if end
459
 
460
								#隨機安排坐者						
461
								#函式說明: 
462
								#亂數產生特定陣列裡面的內容
463
								#回傳的結果:
464
								#$result["status"],執行正常與否,"true"為正常,"false"為不正常.
465
								#$result["error"],錯誤訊息陣列.
466
								#$result["content"]["name"],產生的元素在$conf["randomArray"]裡面的key是?
467
								#$result["content"]["value"],產生的元素內容.
468
								#必填參數:
469
								#$conf["randomArray"],字串陣列,要隨機產生的元素.
470
								$conf["math"]["randomFromArray"]["randomArray"]=$seaterListArray;
471
								#可省略參數:
472
								#無
473
								$randomResult=math::randomFromArray($conf["math"]["randomFromArray"]);
474
								unset($conf["math"]["randomFromArray"]);
475
 
476
								#如果 $randomResult["status"] 等於 "false" 
477
								if($randomResult["status"]=="false"){
478
 
479
									#設置執行錯誤
480
									$result["status"]="false";
481
 
482
									#設置錯誤訊息
483
									$result["error"]=$randomResult;
484
 
485
									#回傳結果
486
									return $result;
487
 
488
									}#if end
489
 
490
								}#while end
491
 
492
							}#if end
493
 
494
						}#if end
495
 
496
					#將其欄位內容置換為坐者代稱
497
					$seatMap["csvFileContent"][$rowKey][$colKey]=$randomResult["content"]["value"];
498
 
499
					#涵式說明:
500
					#將陣列中特定元素剔除,並重新按照順序排序
501
					#回傳的結果:
502
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
503
					#$result["error"],錯誤訊息
504
					#$result["function"],當前執行的函數
505
					#$result["content"]["byName"],剔除掉特定元素的陣列,使用原來陣列的key來儲存.
506
					#$result["content"]["byNumber"],剔除掉特定元素的陣列,使用從0開始的整數key來儲存.
507
					#必填的參數:
508
					$conf["arrays"]["eraseElement"]["rawInputArray"]=$seaterListArray;#要處理的原始數字陣列
509
					$conf["arrays"]["eraseElement"]["eraseElementKey"]=(string)$randomResult["content"]["key"];#要移除的元素key值  
510
					$eraseElement=arrays::eraseElement($conf["arrays"]["eraseElement"]);
511
					unset($conf["arrays"]["eraseElement"]);
512
 
513
					#如果移除元素失敗
514
					if($eraseElement["status"]=="false"){
515
 
516
						#設置執行錯誤
517
						$result["status"]="false";
518
 
519
						#設置錯誤訊息
520
						$result["error"]=$eraseElement;
521
 
522
						#回傳結果
523
						return $result;
524
 
525
						}#if end
526
 
527
					}#if end
528
 
529
				#反之為 0(不是位置)
530
				else{
531
 
532
					#設為沒有上一位坐者
533
					$lastSeat=null;
534
 
535
					}#else end
536
 
537
				}#foreach end
538
 
539
			}#foreach end
540
 
541
		#輸出排好的座位表csv檔
542
		#涵式說明:
543
		#快速建立一個csv檔案,並且要求使用者下載。
544
		#回傳的結果:
545
		#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
546
		#$result["error"],錯誤訊息陣列.
547
		#$result["content"],輸出的csv檔案位置.
548
		#如果有設置$conf["noDownload"]爲"true"的話,則會回傳檔案的位置
549
		#必填的參數:
550
		$conf["csv"]["create"]["dataArray"]=$seatMap["csvFileContent"];#要寫入的文字,
551
			#$conf["dataArray"][$i],代表第 $i 行的內容,
552
			#$conf["dataArray"][$i][$j],代表第 $i 第 $j個欄位的內容.
553
		$conf["csv"]["create"]["fileArgu"]=$conf["fileArgu"];
554
		#可省略的參數:
555
		$conf["csv"]["create"]["csvFilePathAndName"]=$conf["outputAddress"];#輸出的csv檔案路徑與名稱,預設爲系統時間,副檔名"csv"會自動加上.
556
 
557
		#如果 $conf["noDownload"] 存在
558
		if(isset($conf["noDownload"])){
559
 
560
			#如果 $conf["noDownload"] 等於 "true"
561
			if($conf["noDownload"]=="true"){
562
 
563
				#設為 "true"
564
				$conf["csv"]["create"]["noDownload"]="true";
565
 
566
				}#if end
567
 
568
			}#if end
569
 
570
		#參考資料來源:
571
		#http://php.net/manual/en/function.str-split.php
572
		$createCsvResult=csv::create($conf["csv"]["create"]);
573
		unset($conf["csv"]["create"]);
574
 
575
		#如果 $createCsvResult["status"] 等於 "false"
576
		if($createCsvResult["status"]=="false"){
577
 
578
			#設置執行錯誤
579
			$result["status"]="false";
580
 
581
			#設置錯誤訊息
582
			$result["error"]=$createCsvResult;
583
 
584
			#回傳結果
585
			return $result;
586
 
587
			}#if end
588
 
589
		#設置執行正常
590
		$result["status"]="true";
591
 
592
		#設置建立的csv檔案位置
593
		$result["content"]=$createCsvResult["content"];
594
 
595
		#回傳結果
596
		return $result;
597
 
598
		}#funtion randomSeater end
599
 
600
	}#class exam end
601
 
602
?>