0
假設,我在全局頁面上(不在課程頁面中)。
我想做一個新的測驗。
我得到了其中的課程編號,我想添加到測驗中。
而我使用add_moduleinfo。
我想知道,如何才能啓動$ course參數,我需要在add_moduleinfo中調用。
P.S.它會添加相關部分嗎?我明白它會的,儘管它對我來說看起來很奇怪。
另一件事,
我用add_moduleinfo這樣的:
$s=array('name' => 'אוטומציה', 'introeditor' => array ('text' => '', 'format' => '1', 'itemid' => 892971641,), 'timeopen' => 0, 'timeclose' => 0, 'timelimit' => 0, 'overduehandling' => 'autosubmit', 'graceperiod' => 0, 'gradecat' => '1', 'gradepass' => NULL, 'grade' => 10, 'attempts' => '0', 'grademethod' => '1', 'questionsperpage' => '1', 'navmethod' => 'free', 'shuffleanswers' => '1', 'preferredbehaviour' => 'deferredfeedback', 'canredoquestions' => '0', 'attemptonlast' => '0', 'attemptimmediately' => '1', 'correctnessimmediately' => '1', 'marksimmediately' => '1', 'specificfeedbackimmediately' => '1', 'generalfeedbackimmediately' => '1', 'rightanswerimmediately' => '1', 'overallfeedbackimmediately' => '1', 'attemptopen' => '1', 'correctnessopen' => '1', 'marksopen' => '1', 'specificfeedbackopen' => '1', 'generalfeedbackopen' => '1', 'rightansweropen' => '1', 'overallfeedbackopen' => '1', 'attemptclosed' => '1', 'correctnessclosed' => '1', 'marksclosed' => '1', 'specificfeedbackclosed' => '1', 'generalfeedbackclosed' => '1', 'rightanswerclosed' => '1', 'overallfeedbackclosed' => '1', 'showuserpicture' => '0', 'decimalpoints' => '2', 'questiondecimalpoints' => '-1', 'showblocks' => '0', 'quizpassword' => '', 'subnet' => '', 'delay1' => 0, 'delay2' => 0, 'browsersecurity' => '-', 'boundary_repeats' => 4, 'feedbacktext' => array (0 => array ('text' => '', 'format' => '1', 'itemid' => '941466359',), 1 => array ('text' => '', 'format' => '1', 'itemid' => '864816352',), 2 => array ('text' => '', 'format' => '1', 'itemid' => '101278785',), 3 => array ('text' => '', 'format' => '1', 'itemid' => '773833773',), 4 => array ('text' => '', 'format' => '1', 'itemid' => 291053486,),), 'feedbackboundaries' => array (0 => '', 1 => '', 2 => '', 3 => '',), 'visible' => '1', 'cmidnumber' => '', 'groupmode' => '0', 'groupingid' => '0', 'course' => 2, 'coursemodule' => 0, 'section' => 0, 'module' => 16, 'modulename' => 'quiz', 'instance' => 0, 'add' => 'quiz', 'update' => 0, 'return' => 0, 'sr' => 0, 'submitbutton2' => 'שמירת שינויים וחזרה לקורס',);
function tt($s,$t=null)
{
if(!$t)
$t=new stdClass();
//the problem is that the interior array wasn't convert into an object, so the sql gests mess with array syntax of php
foreach ($s as $key=>$value)
{
$z=$value;
if(is_array($z))
$z=tt($z);
$t->$key=$z;
}
return $t;
}
//var_dump(tt($s));
$newcm = new stdClass();
$newcm->id=2;
//to fix: making course an object, that fits modlib!!!
var_dump(add_moduleinfo(tt($s),$newcm));
並沒有什麼在數據庫中被改變,我在哪裏錯了?
謝謝。