From: Simon H. <sim...@us...> - 2010-11-01 18:18:38
|
Update of /cvsroot/stack/stack-dev/opaque/moodleModule/opaque/stack In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv12921/opaque/moodleModule/opaque/stack Modified Files: stackDeploy.php stackLib.php Log Message: Stable interim commit towards deployment updating. Index: stackDeploy.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/moodleModule/opaque/stack/stackDeploy.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** stackDeploy.php 30 Sep 2010 16:56:21 -0000 1.5 --- stackDeploy.php 1 Nov 2010 18:18:30 -0000 1.6 *************** *** 21,29 **** require_once($CFG->libdir . '/formslib.php'); require_once($CFG->libdir . '/datalib.php'); require_once(dirname(__FILE__) . '/../locallib.php'); ! require_once('stackLib.php'); require_once('../../../editlib.php'); - // Check the user is logged in. require_login(); --- 21,29 ---- require_once($CFG->libdir . '/formslib.php'); require_once($CFG->libdir . '/datalib.php'); + require_once(dirname(__FILE__) . '/../locallib.php'); ! //require_once('stackLib.php'); require_once('../../../editlib.php'); // Check the user is logged in. require_login(); *************** *** 46,52 **** redirect('stackEngineSelector.php'); } ! //print_r($_POST); ! if(!empty($_POST['submit'])) { --- 46,53 ---- redirect('stackEngineSelector.php'); } ! //*/ //print_r($_POST); ! //print_r($USER); ! //exit(); if(!empty($_POST['submit'])) { *************** *** 78,81 **** --- 79,93 ---- } break; + + case get_string('stackDeploy_button_update', 'qtype_opaque'): + if(!is_numeric($_POST['prior'])) break; + $specs['id'] = $_GET['id']; // not sure this is needed but, hey. + $specs['prior'] = $_POST['prior']; + $specs['number'] = $_POST['add']; + $specs['category'] = $_POST['category']; + $specs['operation'] = 'update'; + //print_r($specs); + stackUpdateDeployment($SESSION->stackSelectedEngine, $specs); + break; } } *************** *** 113,117 **** $engineName = getEngineName($SESSION->stackSelectedEngine); ! $strtitle = get_string('instancesOf', 'qtype_opaque').$param['id'];//.' : '.$engineName.get_string('qEngine', 'qtype_opaque'); $navlinks = array(); $navlinks[] = array('name' => get_string('StackQuestions', 'qtype_opaque', ''), 'link' => 'stackQuestionList.php', 'type' => 'title'); --- 125,129 ---- $engineName = getEngineName($SESSION->stackSelectedEngine); ! $strtitle = get_string('deployingQuestion', 'qtype_opaque').' '.$param['id'];//.' : '.$engineName.get_string('qEngine', 'qtype_opaque'); $navlinks = array(); $navlinks[] = array('name' => get_string('StackQuestions', 'qtype_opaque', ''), 'link' => 'stackQuestionList.php', 'type' => 'title'); *************** *** 123,130 **** print_heading($strtitle); - echo '<p>'.get_string('nodeployed', 'qtype_opaque').': '.count($deployedList); - echo "<form method='POST' action='?id=".$_GET['id']."'>"; echo $deployedPage->xhtml; // may include form fields //echo " <input type='checkbox' name='autoprime' checked='checked'> ".get_string('stackDeploy_autoprime', 'qtype_opaque'); //echo " <input type='checkbox' name='autoprime' ".(isset($_POST['autoprime'])?'checked="checked"':"")."> ".get_string('stackDeploy_autoprime', 'qtype_opaque'); --- 135,142 ---- print_heading($strtitle); echo "<form method='POST' action='?id=".$_GET['id']."'>"; + echo $deployedPage->xhtml; // may include form fields + //echo " <input type='checkbox' name='autoprime' checked='checked'> ".get_string('stackDeploy_autoprime', 'qtype_opaque'); //echo " <input type='checkbox' name='autoprime' ".(isset($_POST['autoprime'])?'checked="checked"':"")."> ".get_string('stackDeploy_autoprime', 'qtype_opaque'); *************** *** 136,139 **** --- 148,153 ---- else { + echo '<p>'.get_string('nodeployed', 'qtype_opaque').': '.count($deployedList); + $opts = new stdClass; $opts->noclean = true; *************** *** 147,151 **** echo '<th align="center" class="header">'.get_string('actions', 'qtype_opaque').'</th>'; echo '<th class="header">'.get_string('qNote', 'qtype_opaque').'</th>'; ! echo '<th align="center" class="header">'.get_string('stackDeploy_primed?', 'qtype_opaque').'</th></tr>'; $i = 0; foreach($deployedList as $instance) { --- 161,166 ---- echo '<th align="center" class="header">'.get_string('actions', 'qtype_opaque').'</th>'; echo '<th class="header">'.get_string('qNote', 'qtype_opaque').'</th>'; ! //echo '<th align="center" class="header">'.get_string('stackDeploy_primed?', 'qtype_opaque').'</th>'; ! echo '</tr>'; $i = 0; foreach($deployedList as $instance) { *************** *** 156,165 **** echo '<td align="center">' . '<a href="stackSessionPage.php?page=try&id='.$param['id'].'&instance='.$instance->id.'&seed='.$instance->seed.'" /><img alt="'.get_string('preview', 'qtype_opaque').'" title="'.get_string('preview', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/preview.gif" /></a> '. ! '<a href="stackDeploy.php?id='.$param['id'].'&prime='.$instance->id.'"><img alt="'.get_string('primed?', 'qtype_opaque').'" title="'.get_string('prime', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/go.gif" /></a> '. '<a onclick="return confirm(\''.get_string('confirmUndeploy', 'qtype_opaque').'\')" href="stackDeploy.php?id='.$param['id'].'&drop='.$instance->id.'" ><img alt="'.get_string('undeploy', 'qtype_opaque').'" title="'.get_string('undeploy', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/delete.gif" /></a></td>'; $qID = 'q'.$instance->id; $previewBox = ' <a href="javascript:;" onClick="$(\'#'.$qID.'\').slideToggle(\'fast\')" /><small>'.get_string('stackDeploy_showStem', 'qtype_opaque').'</small></a><div style="clear:both; border:#999 solid 1px; display:none; padding:10px" id="'.$qID.'">'.$instance->xhtml; echo '<td align="left">'.format_text($instance->qNote.$previewBox.'</div>', FORMAT_MOODLE, $opts).'</td>'; ! echo '<td align="center">'.($instance->isPrimed ? '<img alt="'.get_string('primed', 'qtype_opaque').'." src="'.$CFG->wwwroot.'/pix/i/tick_green_small.gif" />':'').'</td>'; echo '</tr>'; } --- 171,180 ---- echo '<td align="center">' . '<a href="stackSessionPage.php?page=try&id='.$param['id'].'&instance='.$instance->id.'&seed='.$instance->seed.'" /><img alt="'.get_string('preview', 'qtype_opaque').'" title="'.get_string('preview', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/preview.gif" /></a> '. ! //'<a href="stackDeploy.php?id='.$param['id'].'&prime='.$instance->id.'"><img alt="'.get_string('primed?', 'qtype_opaque').'" title="'.get_string('prime', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/go.gif" /></a> '. '<a onclick="return confirm(\''.get_string('confirmUndeploy', 'qtype_opaque').'\')" href="stackDeploy.php?id='.$param['id'].'&drop='.$instance->id.'" ><img alt="'.get_string('undeploy', 'qtype_opaque').'" title="'.get_string('undeploy', 'qtype_opaque').'" src="'.$CFG->wwwroot.'/pix/t/delete.gif" /></a></td>'; $qID = 'q'.$instance->id; $previewBox = ' <a href="javascript:;" onClick="$(\'#'.$qID.'\').slideToggle(\'fast\')" /><small>'.get_string('stackDeploy_showStem', 'qtype_opaque').'</small></a><div style="clear:both; border:#999 solid 1px; display:none; padding:10px" id="'.$qID.'">'.$instance->xhtml; echo '<td align="left">'.format_text($instance->qNote.$previewBox.'</div>', FORMAT_MOODLE, $opts).'</td>'; ! //echo '<td align="center">'.($instance->isPrimed ? '<img alt="'.get_string('primed', 'qtype_opaque').'." src="'.$CFG->wwwroot.'/pix/i/tick_green_small.gif" />':'').'</td>'; echo '</tr>'; } *************** *** 167,171 **** echo '<a href="javascript:;" onclick="$(\'.groupCB\').click()">'.get_string('invertSelection', 'qtype_opaque').'</a><br /><b>'.get_string('withSelected', 'qtype_opaque').':</b>'; echo '<input type="submit" value="'.get_string('stackDeploy_button_undeploy', 'qtype_opaque').'" name="submit" Xonclick="return confirm(\''.get_string('confirmUndeploy','qtype_opaque').'\')" />'; ! echo '<input type="submit" value="'.get_string('stackDeploy_button_prime', 'qtype_opaque').'" name="submit" />'; echo '</form>'; } --- 182,186 ---- echo '<a href="javascript:;" onclick="$(\'.groupCB\').click()">'.get_string('invertSelection', 'qtype_opaque').'</a><br /><b>'.get_string('withSelected', 'qtype_opaque').':</b>'; echo '<input type="submit" value="'.get_string('stackDeploy_button_undeploy', 'qtype_opaque').'" name="submit" Xonclick="return confirm(\''.get_string('confirmUndeploy','qtype_opaque').'\')" />'; ! //echo '<input type="submit" value="'.get_string('stackDeploy_button_prime', 'qtype_opaque').'" name="submit" />'; echo '</form>'; } Index: stackLib.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/moodleModule/opaque/stack/stackLib.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** stackLib.php 30 Sep 2010 16:56:21 -0000 1.20 --- stackLib.php 1 Nov 2010 18:18:30 -0000 1.21 *************** *** 398,404 **** $values[] = $param['version']; - $keys[] = 'engine'; - $values[] = $engineID; - echo soap_call($connection, 'stackDeployOperation', array($passkey, $USER->id, $keys, $values)); } --- 398,401 ---- *************** *** 449,453 **** /** ! * primes an instance (or version) of a question. * * @param int engineID --- 446,450 ---- /** ! * Primes an instance of a question. * * @param int engineID *************** *** 488,491 **** --- 485,536 ---- } + + /** + * Replaces one deployment to the Moodle quesiton bank with another. + * + * @param array + */ + function stackUpdateDeployment($engineID, $param) { + $engine = load_engine_def($engineID); + if(is_string($engine)) + { + echo $engine; //error occured. + } + else + { + $connection = connect_to_engine($engine); + if (is_string($connection)) + { + echo $connection; + } + + global $USER; + $keys[] = 'userID'; + $values[] = $USER->id; + + $keys[] = 'id'; + $values[] = $param['id']; + + $passkey = stackGetPassKey($engineID, $USER->id); + + $keys[] = 'operation'; + $values[] = 'update'; + + $keys[] = 'prior'; + $values[] = $param['prior']; + + $keys[] = 'number'; + $values[] = $param['number']; + + $keys[] = 'category'; + $values[] = $param['category']; + + $keys[] = 'engineID'; + $values[] = $engineID; + + echo soap_call($connection, 'stackDeployOperation', array($passkey, $USER->id, $keys, $values)); + } + } + /** * Returns the name of the engine from its id |