From: Simon H. <sim...@us...> - 2010-11-01 19:27:14
|
Update of /cvsroot/stack/stack-dev/opaque In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv12921/opaque Modified Files: StackServer.php MoodleQuestionDeployment.php Log Message: Stable interim commit towards deployment updating. Index: StackServer.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/StackServer.php,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** StackServer.php 7 Oct 2010 16:34:05 -0000 1.51 --- StackServer.php 1 Nov 2010 18:18:30 -0000 1.52 *************** *** 420,426 **** $param = array_combine($paramKey, $paramVal); } ! $this->logger->fine("processing deployment with param:".print_r($param, true)); $checkKey = new CheckPassKey($passKey, $userId); if ($checkKey->isValid()) { $deployment = new MoodleQuestionDeployment($passKey, $paramKey, $paramVal, $this->getHTMLHead()); $deployment->processOperations($param); --- 420,431 ---- $param = array_combine($paramKey, $paramVal); } ! $this->logger->debug("in stackDeployOperation with param:".print_r($param, true)); $checkKey = new CheckPassKey($passKey, $userId); if ($checkKey->isValid()) { + $paramKey[] = 'userID'; + $paramVal[] = $userId; + $param['userID'] = $userId; + //$paramKey[] = 'engineID'; + //$paramVal[] = ''? $deployment = new MoodleQuestionDeployment($passKey, $paramKey, $paramVal, $this->getHTMLHead()); $deployment->processOperations($param); Index: MoodleQuestionDeployment.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleQuestionDeployment.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MoodleQuestionDeployment.php 30 Sep 2010 16:56:21 -0000 1.5 --- MoodleQuestionDeployment.php 1 Nov 2010 18:18:30 -0000 1.6 *************** *** 103,108 **** $this->xhtml = ''; ! $this->logger->debug(print_r($this->param, 1)); ! $this->deployment = new Deployment($this->param['id'], $this->param['engineID']); } --- 103,107 ---- $this->xhtml = ''; ! $this->logger->debug("in MQD constructor: ".print_r($this->param, 1)); $this->deployment = new Deployment($this->param['id'], $this->param['engineID']); } *************** *** 125,128 **** --- 124,138 ---- } $this->deployment->processOperations($param); + + // Handle Moodle question bank operations here + if($param['operation'] == 'update') { + $this->logger->debug("about to call hideQuestion with $stackID and engine:".$this->deployment->getEngineID()); + // add new and remove old + $mDB = new MoodleDB(); + $mDB->connect(); + + $mDB->hideQuestion($param['prior'], $this->deployment->getEngineID()); + $mDB->addQuestion($param['id'], $this->deployment->getLine(), $param['userID'], $this->deployment->getEngineID(), $param['category']); + } } *************** *** 135,148 **** $currentVersion = $itemDB->getLatestVersion($this->param['id']); if($currentVersion == $this->deployment->getVersion()) { // this is latest version ! $earliest = $this->deployment->earliestDeployedVersion(); ! if($currentVersion == $earliest || false == $earliest) { if($this->deployment->isSingleton()) $this->xhtml .= get_string('FE_deployQuestion_singletonDeployed', 'stack'); else $this->xhtml .= $this->deployment->formXHTML(); ! } else { ! $this->xhtml .= get_string('FE_deployQuestion_oldVersionDeployed', 'stack'); $this->deployment = new Deployment($earliest); if($this->deployment->size() > 0) { ! $this->xhtml .= '<p><a href="?id='.$this->param['id'].'&dropall='.$earliest.'">'.get_string('FE_deployQuestion_undeployAll', 'stack').'</a>'; } } --- 145,185 ---- $currentVersion = $itemDB->getLatestVersion($this->param['id']); + $earliest = $this->deployment->earliestDeployedVersion(); + + $mDB = new MoodleDB(); + $mDB->connect(); + $categories = $mDB->getQuestionCategory($earliest); + //$this->xhtml .= print_r($categories, 1); + $selector = $mDB->categorySelector('category', $categories[0]); + + if($currentVersion == $this->deployment->getVersion()) { // this is latest version ! //$earliest = $this->deployment->earliestDeployedVersion(); ! if($currentVersion == $earliest || false == $earliest) { // no earlier deployment exists if($this->deployment->isSingleton()) $this->xhtml .= get_string('FE_deployQuestion_singletonDeployed', 'stack'); else $this->xhtml .= $this->deployment->formXHTML(); ! //$this->xhtml .= $selector; ! } else { // earlier version has been deployed - must drop it before we can deploy latest ! //$this->xhtml .= '<div class="warning">'.get_string('FE_deployQuestion_oldVersionDeployed', 'stack')."</div>"; ! $this->xhtml .= "<div class='warning'>Question $currentVersion is a newer version of question $earliest which has already been deployed into a Moodle question bank.<p>You can update the Moodle question bank in a single step with the form below.</div>"; $this->deployment = new Deployment($earliest); if($this->deployment->size() > 0) { ! //$this->xhtml .= '<p><a href="?id='.$this->param['id'].'&dropall='.$earliest.'">'.get_string('FE_deployQuestion_undeployAll', 'stack').'</a>'; ! //get_string('stackDeploy_button_update', 'qtype_opaque') ! $this->xhtml .= '<p><form action="?id='.$this->param['id'].'&dropall='.$earliest.'">'; ! $this->xhtml .= 'Remove question '.$earliest.' and deploy '.$currentVersion.' with '; ! //$this->xhtml .= ' <input type="checkbox"> Replace in Moodle question bank'; ! ! $this->xhtml .= '<input type="text" name="add" id="add" value="'.$this->deployment->size().'" size="3" maxlength="3"/> '.get_string('FE_deployQuestion_newRandomInstances', 'stack'); ! $this->xhtml .= ' into '.$selector;//'category',$mDB->getQuestionCategory($earliest)); ! /*if($mDB->attemptsOnQuestion()) { ! $this->xhtml .= "<br>Already in use in a quiz!"; ! //$this->xhtml .= '<br />Also replace in Moodle quizzes <input onclick="if(this.checked == true) alert(\'Only do this for minor changes to ensure stored student attempts are still valid!\')" type="checkbox">'; // list them and warn! ! } else $this->xhtml .= "<br>Fortunately not in use in a quiz!"; ! ! $this->xhtml .= "<br>Attempts on question: ".$mDB->attemptsOnQuestion($earliest); ! */ ! $this->xhtml .= '<br /><input type="submit" onclick="if($(\'#add\').val() == \'0\') {alert(\'zero\'); return false;}" name="submit" value="'.get_string('stackDeploy_button_update', 'stack').'">'; ! $this->xhtml .= '<input type="hidden" name="prior" value="'.$earliest.'"></form>'; } } *************** *** 165,168 **** --- 202,208 ---- } */ + + $this->xhtml .= '<h3 class="main">'.get_string('FE_deployQuestion_instancesOfQuestion', 'stack', $this->deployment->getVersion()).'</h3>'; + foreach($this->deployment->getInstances() as $instance) { $item = $this->db->getDisplayItem($instance['id']); |