From: Ben H. <bdv...@us...> - 2010-11-22 23:06:00
|
Update of /cvsroot/stack/stack-dev/opaque In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29766/opaque Modified Files: Tag: question_reporting newWSDL.wsdl MoodleQuestionList.php MoodleQuestionDeployment.php MoodleDisplayItem.php soapServer.php CheckPassKey.php StackServer.php MoodleStackReport.php Added Files: Tag: question_reporting StackAttemptServer.php Log Message: Merging from the current HEAD into question_reporting. Apologies in advance if this all goes horribly wrong. Index: newWSDL.wsdl =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/newWSDL.wsdl,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** newWSDL.wsdl 23 Jun 2009 14:39:36 -0000 1.8 --- newWSDL.wsdl 22 Nov 2010 23:05:51 -0000 1.8.4.1 *************** *** 111,122 **** <complexType name="QuestionItem"> <sequence> ! <element name="id" nillable="true" type="xsd:int"/> ! <element name="name" nillable="true" type="soapenc:string"/> ! <element name="description" nillable="true" type="soapenc:string"/> ! <element name="valid" nillable="true" type="xsd:int"/> ! <element name="dateEdited" nillable="true" type="soapenc:string"/> ! <element name="moodleCategories" nillable="true" type="impl:ArrayOf_soapenc_string"/> ! <element name="published" nillable="true" type="soapenc:string"/> ! <element name="nodeployed" nillable="true" type="xsd:int"/> </sequence> </complexType> --- 111,124 ---- <complexType name="QuestionItem"> <sequence> ! <element name="id" nillable="true" type="xsd:int" /> ! <element name="version" nillable="true" type="xsd:int" /> ! <element name="name" nillable="true" type="soapenc:string" /> ! <element name="description" nillable="true" type="soapenc:string" /> ! <element name="valid" nillable="true" type="xsd:int" /> ! <element name="dateEdited" nillable="true" type="soapenc:string" /> ! <element name="moodleCategories" nillable="true" type="impl:ArrayOf_soapenc_string" /> ! <element name="published" nillable="true" type="soapenc:string" /> ! <element name="nodeployed" nillable="true" type="xsd:int" /> ! <element name="keywords" nillable="true" type="impl:ArrayOf_soapenc_string" /> </sequence> </complexType> *************** *** 147,155 **** <complexType name="StackQuestionPage"> <sequence> ! <element name="questionItems" nillable="true" type="impl:ArrayOfQuestionItem"/> ! <element name="publicQuestions" nillable="true" type="impl:ArrayOfQuestionItem"/> ! <element name="xhtml" nillable="true" type="soapenc:base64Binary"/> ! <element name="head" nillable="true" type="soapenc:string"/> ! <element name="categories" nillable="true" type="impl:ArrayOfCategories"/> </sequence> </complexType> --- 149,158 ---- <complexType name="StackQuestionPage"> <sequence> ! <element name="questionItems" nillable="true" type="impl:ArrayOfQuestionItem" /> ! <element name="publicQuestions" nillable="true" type="impl:ArrayOfQuestionItem" /> ! <element name="xhtml" nillable="true" type="soapenc:base64Binary" /> ! <element name="head" nillable="true" type="soapenc:string" /> ! <element name="categories" nillable="true" type="impl:ArrayOfCategories" /> ! <element name="keywords" nillable="true" type="impl:ArrayOf_soapenc_string" /> </sequence> </complexType> *************** *** 161,166 **** type="impl:ArrayOfDeployedInstances"> </element> ! <element name="xhtml" type="string"></element> ! <element name="head" type="string"></element> </sequence> --- 164,169 ---- type="impl:ArrayOfDeployedInstances"> </element> ! <element name="xhtml" type="string" /> ! <element name="head" type="string" /> </sequence> *************** *** 176,179 **** --- 179,183 ---- </complexContent> </complexType> + </schema> *************** *** 811,813 **** </wsdl:service> ! </wsdl:definitions> --- 815,817 ---- </wsdl:service> ! </wsdl:definitions> \ No newline at end of file Index: MoodleStackReport.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleStackReport.php,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** MoodleStackReport.php 16 Sep 2009 12:05:13 -0000 1.4 --- MoodleStackReport.php 22 Nov 2010 23:05:51 -0000 1.4.2.1 *************** *** 40,85 **** { ! if(!empty($param['type'])) ! { $reportType = $param['type']; $xhtml .= $this->report->displayResults($param); - } - $xhtml .= '<br />'; ! if($reportType == NULL) //if still null, display options ! { ! //display filter selector ! $xhtml = "<em>Only very simple reports are currently available</em><br />"; ! $xhtml .= '<p><a href="stackSessionPage.php?page=report&type=question">'.get_string('stackReport_question','stack').'</a></p>'; ! $xhtml .= '<p><a href="stackSessionPage.php?page=report&type=student">'.get_string('stackReport_student','stack').'</a></p>'; ! //$xhtml .= '<p><a href="stackSessionPage.php?page=report&type=markbook">'.get_string('stackReport_markbook','stack').'</a></p>'; ! } ! else ! { ! unset($param['type']); ! unset($param['page']); ! //switch($_GET['reportType']) ! switch($reportType) ! { ! case 'question': ! $xhtml .= $this->report->questionFilterInterface($param); ! break; ! case 'student': ! $xhtml .= $this->report->studentFilterInterface($param); ! break; ! case 'quiz': ! $xhtml .= $this->report->quizFilterInterface($param); ! break; ! case 'markbook': ! $xhtml .= $this->report->markbookFilterInterface($param); ! break; ! } ! $xhtml .= '<br /><br />'; ! $xhtml .= '<a href="stackSessionPage.php?page=report">'.get_string('stackReport_reportType','stack').'</a>'; ! } return $xhtml; --- 40,67 ---- { ! if (isset($param['type'])) { ! $reportType = $param['type']; $xhtml .= $this->report->displayResults($param); ! $xhtml .= '<p><a href="stackSessionPage.php?page=report">'.get_string('stackReport_reportType','stack').'</a></p>'; ! } else { ! ! $xhtml .= '<h1>Select a report type</h1>'; ! $xhtml .= '<div class="section"> ! <h3>Interactive report</h3> ! <p> <a href="stackSessionPage.php?page=report&type=interactive"><button >Load the interactive interface</button></a> </p> ! </div>'; ! $xhtml .= '<form action="stackSessionPage.php?page=report&type=question" method="post">' ! . $report->questionFilterInterface($param) ! . '</form>'; ! $xhtml .= '<form action="stackSessionPage.php?page=report&type=student" method="post">' ! . $report->studentFilterInterface($param) ! . '</form>'; ! } return $xhtml; Index: MoodleDisplayItem.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleDisplayItem.php,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** MoodleDisplayItem.php 30 Sep 2009 10:36:36 -0000 1.11 --- MoodleDisplayItem.php 22 Nov 2010 23:05:51 -0000 1.11.2.1 *************** *** 54,58 **** * @param int quizId */ ! public function __construct($userId, $questionId, $reconstruct=false, $seed=NULL, $quizId=NULL) { $cache = new StackDBCache(); --- 54,58 ---- * @param int quizId */ ! public function __construct($userId, $versionId, $reconstruct=false, $seed=NULL, $quizId=NULL) { $cache = new StackDBCache(); *************** *** 65,69 **** } // Remember: a stateID of 0 indicates no questions deployed. ! $this->stateID = $cache->selectInitialState($seed, $questionId); $this->userID = $userId; $this->progress = 0; --- 65,69 ---- } // Remember: a stateID of 0 indicates no questions deployed. ! $this->stateID = $cache->selectInitialState($seed, $versionId); $this->userID = $userId; $this->progress = 0; *************** *** 168,175 **** // Extract and remove action from posted. ! $action = $posted['stackaction']; unset($posted['stackaction']); - $moodle_event = $posted['event']; unset($posted['event']); if(8 == $moodle_event) $action = 'Finish';// submission hack if(3 == $moodle_event) $action = 'Grade';// review hack --- 168,209 ---- // Extract and remove action from posted. ! $event = MoodleDisplayItem::mapStackEvent($posted); unset($posted['stackaction']); unset($posted['event']); + + // Either return xhtml for current state or invoke process to use cache. + if(0 == $event) { + $xhtml = $cache->getXHTML($this->stateID); + } else { + $xhtml = $this->processItem($posted, true, $event); + } + + $xhtml = $this->fillInputFields($posted, $xhtml); + + // add STACK buttons + // See bug #2890734 + $xhtml .= "<div class='mdl-align'>"; // submitbtns to be hidden in CSS styles.php + $xhtml .= "<input id='stacksubmit' name='stackaction' type='submit' value='".get_string('stackQuiz_button_submit','stack','')."' />"; + /* Some JavaScript hackery below to ensure we don't have to mess with attempt.php: + * We activate the (hidden) finish button with our own and hide our own on + * the review page. Tested with FF and IE. + */ + $xhtml .= "<input type=\"button\" id=\"stackfinish\" value=\"".get_string('stackQuiz_button_finishQuiz','stack','')."\" name=\"finishattempt\" " . + "onclick=\"document.getElementsByName('finishattempt')[0].click();\" />"; + $xhtml .= "<script>if(window.location.href.indexOf('attempt.php') == -1) {" . + "document.getElementById('stacksubmit').style.display = 'none'; " . + "document.getElementById('stackfinish').style.display = 'none'; " . + "}</script>"; + $xhtml .= "</div>"; + return $xhtml; + } + + /** + * Infers our internal STACK event from the post data supplied by Moodle. + * Factored static function to allow other access, e.g. for Diagnostic reporting + */ + public static function mapStackEvent($posted) { + $action = $posted['stackaction']; + $moodle_event = $posted['event']; if(8 == $moodle_event) $action = 'Finish';// submission hack if(3 == $moodle_event) $action = 'Grade';// review hack *************** *** 197,225 **** $event = 0; // default e.g. by navigating away } ! ! // Either return xhtml for current state or invoke process to use cache. ! if(0 == $event) { ! $xhtml = $cache->getXHTML($this->stateID); ! } else { ! $xhtml = $this->processItem($posted, true, $event); ! } ! ! $xhtml = $this->fillInputFields($posted, $xhtml); ! ! // add STACK buttons ! $xhtml .= "<div class='mdl-align'>"; // submitbtns to be hidden in CSS styles.php ! $xhtml .= "<input id='stacksubmit' name='stackaction' type='submit' value='Submit' />"; ! /* Some JavaScript hackery below to ensure we don't have to mess with attempt.php: ! * We activate the (hidden) finish button with our own and hide our own on ! * the review page. Tested with FF and IE. ! */ ! $xhtml .= "<input type=\"button\" id=\"stackfinish\" value=\"Finish Quiz\" name=\"finishattempt\" " . ! "onclick=\"document.getElementsByName('finishattempt')[0].click();\" />"; ! $xhtml .= "<script>if(window.location.href.indexOf('attempt.php') == -1) {" . ! "document.getElementById('stacksubmit').style.display = 'none'; " . ! "document.getElementById('stackfinish').style.display = 'none'; " . ! "}</script>"; ! $xhtml .= "</div>"; ! return $xhtml; } --- 231,235 ---- $event = 0; // default e.g. by navigating away } ! return $event; } Index: StackServer.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/StackServer.php,v retrieving revision 1.47 retrieving revision 1.47.2.1 diff -C2 -d -r1.47 -r1.47.2.1 *** StackServer.php 22 Oct 2009 17:37:56 -0000 1.47 --- StackServer.php 22 Nov 2010 23:05:51 -0000 1.47.2.1 *************** *** 30,33 **** --- 30,34 ---- require_once $root . '/lib/items/Item.php'; require_once $root . '/lib/searching/StackSearch.php'; + require_once $root . '/lib/reporting/DiagnosticReport.php'; require_once $root . '/lib/Logger.php'; *************** *** 85,90 **** } ! public function getQuestionMetadata($questionID, $questionVersion, $questionBaseURL) { ! return 'Question Metadata for ' . "$questionID, $questionVersion, $questionBaseURL"; } --- 86,91 ---- } ! public function getQuestionMetadata($questionID, $line, $questionBaseURL) { ! return 'Question Metadata for ' . "$questionID, $line, $questionBaseURL"; } *************** *** 108,112 **** * */ ! public function start($questionID, $questionVersion, $questionBaseURL, $initialParamNames, $initialParamValues, $cachedResources) { $initialParams = array_combine($initialParamNames, $initialParamValues); --- 109,113 ---- * */ ! public function start($versionID, $version, $questionBaseURL, $initialParamNames, $initialParamValues, $cachedResources) { $initialParams = array_combine($initialParamNames, $initialParamValues); *************** *** 120,125 **** } ! //$this->logger->debug("init params in start ".print_r($initialParams, 1)); ! //$this->logger->debug("timeclose = $timeclose"); $startReturn = new StartReturnDT(); --- 121,130 ---- } ! //$this->logger->debug("init params in start ".print_r($initialParams, 1)); ! //$this->logger->debug("timeclose = $timeclose"); ! //$this->logger->debug("version is ".$version." and lineID is ".$lineID); ! ! // $questionID = substr($version, 1 + strpos($version, '.')); // quicker than regex match ! $questionID = substr($versionID, 1); // lop off leading q $startReturn = new StartReturnDT(); *************** *** 127,131 **** $keyCheck = new CheckPassKey($passKey, $userId); ! if ($keyCheck->checkPasskey() == true) { //generate a session uid for the question --- 132,136 ---- $keyCheck = new CheckPassKey($passKey, $userId); ! if ($keyCheck->isValid()) { //generate a session uid for the question *************** *** 133,138 **** $startReturn->questionSession = $sessionID; - $questionID = substr($questionID, 1); - //check question exists $db = new StackDBItem(); --- 138,141 ---- *************** *** 251,254 **** --- 254,258 ---- global $config; $root = $config->get('docroot'); + $weburl = $config->get('weburl'); $param = array_combine($paramKey, $paramVal); *************** *** 259,263 **** $keyCheck = new CheckPassKey($passkey, $userID); ! if ($keyCheck->checkPasskey() == true) { switch ($pageName) { case 'exporter' : --- 263,267 ---- $keyCheck = new CheckPassKey($passkey, $userID); ! if ($keyCheck->isValid()) { switch ($pageName) { case 'exporter' : *************** *** 299,303 **** case 'search' : - $search = new StackSearch($param, $param['userID'], true); $xhtml .= $search->displaySearchForm(); --- 303,306 ---- *************** *** 309,312 **** --- 312,327 ---- break; + case 'diagnostic' : + $diagnostic = new DiagnosticReport($param['userID'], $param['quiz']); + //$xhtml .= "param=".print_r($param,1); + $xhtml .= $diagnostic->display(); + $head = '<link rel="stylesheet" type="text/css" href="'.$weburl.'/other/jqplot/jquery.jqplot.css" />' . + '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$weburl.'/other/jqplot/excanvas.js"></script><![endif]--> + <script type="text/javascript" src="'.$weburl.'/other/jqplot/jquery-1.3.2.min.js"></script>' . + '<script type="text/javascript" src="'.$weburl.'/other/jqplot/jquery.jqplot.min.js"></script>' . + '<script type="text/javascript" src="'.$weburl.'/other/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>' . + '<script type="text/javascript" src="'.$weburl.'/other/jqplot/plugins/jqplot.barRenderer.min.js"></script>'; + break; + default : $xhtml = 'Could not find page "' . $pageName . '".'; *************** *** 329,333 **** public function stackStartAuthor($passKey, $userID, $questionID = NULL) { $keyCheck = new CheckPassKey($passKey, $userID); ! if ($keyCheck->checkPasskey() == true) { $authorStackQuestion = new AuthorDisplay($userID, $questionID); //$author = new AuthorDisplay('1'); --- 344,348 ---- public function stackStartAuthor($passKey, $userID, $questionID = NULL) { $keyCheck = new CheckPassKey($passKey, $userID); ! if ($keyCheck->isValid()) { $authorStackQuestion = new AuthorDisplay($userID, $questionID); //$author = new AuthorDisplay('1'); *************** *** 378,382 **** /** ! * Returns an array of question id's to question names & description * * @access public --- 393,397 ---- /** ! * Returns an array of question ids to question names & description * * @access public *************** *** 387,391 **** $qList->processOperations(); $returning = $qList->getList(); - return $returning; } --- 402,405 ---- *************** *** 406,412 **** $param = array_combine($paramKey, $paramVal); } ! $this->logger->critical("processing deployment with param:".print_r($param, true)); $checkKey = new CheckPassKey($passKey, $userId); ! if ($checkKey->checkPassKey() == true) { $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); *************** *** 433,437 **** $checkKey = new CheckPassKey($passKey, $userId); ! if ($checkKey->checkPassKey() == true) { switch ($pageName) { case '' : --- 452,456 ---- $checkKey = new CheckPassKey($passKey, $userId); ! if ($checkKey->isValid()) { switch ($pageName) { case '' : *************** *** 555,558 **** --- 574,578 ---- } + /* Separated into StackAttemptServer */ private function loadQuestion($sessionID) { $db = new StackDBOpaque(); *************** *** 588,591 **** --- 608,612 ---- } + private function storeQuestion($question, $sessionID = NULL, $timeclose = 0) { $db = new StackDBOpaque(); *************** *** 603,606 **** --- 624,628 ---- return $result; } + //*/ private function generateSessionId($qid, $uid) { *************** *** 666,670 **** <script type="text/javascript" src="' . $webroot . '/other/moo.fx/prototype.lite.js"></script> <script type="text/javascript" src="' . $webroot . '/other/moo.fx/moo.fx.js"></script> ! <script type="text/javascript" src="' . $webroot . '/other/moo.fx/moo.fx.js"></script> <script type="text/javascript" src="' . $webroot . '/other/jquery.js"></script> --- 688,692 ---- <script type="text/javascript" src="' . $webroot . '/other/moo.fx/prototype.lite.js"></script> <script type="text/javascript" src="' . $webroot . '/other/moo.fx/moo.fx.js"></script> ! <script type="text/javascript" src="' . $webroot . '/other/flyfeedback.js"></script> <script type="text/javascript" src="' . $webroot . '/other/jquery.js"></script> Index: MoodleQuestionDeployment.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleQuestionDeployment.php,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** MoodleQuestionDeployment.php 30 Jun 2009 15:12:07 -0000 1.3 --- MoodleQuestionDeployment.php 22 Nov 2010 23:05:51 -0000 1.3.4.1 *************** *** 45,48 **** --- 45,49 ---- require_once($root.'/opaque/datatypes/CategoryDT.php'); + require_once $root . '/lib/Logger.php'; class MoodleQuestionDeployment *************** *** 55,58 **** --- 56,60 ---- private $db; + private $logger; /** * *************** *** 79,83 **** private $xhtml; - /** * Constructs the question deployment --- 81,84 ---- *************** *** 91,94 **** --- 92,97 ---- public function __construct($passKey, $paramKey, $paramVal, $head, $title=NULL) { + $this->logger = new Logger("MoodleQuestionDeployment"); + $this->db = new StackDBCache(); $this->db->connect(); *************** *** 100,104 **** $this->xhtml = ''; ! $this->deployment = new Deployment($this->param['id']); } --- 103,108 ---- $this->xhtml = ''; ! $this->logger->debug("in MQD constructor: ".print_r($this->param, 1)); ! $this->deployment = new Deployment($this->param['id'], $this->param['engineID']); } *************** *** 109,113 **** // no checking for singleton status required ! // add elements to fit form expected by Deployment switch($param['operation']) { case 'add': --- 113,117 ---- // no checking for singleton status required ! // add elements where necessary to fit form expected by Deployment switch($param['operation']) { case 'add': *************** *** 120,123 **** --- 124,145 ---- } $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']); + } + + if($param['operation'] == 'move') { + $mDB = new MoodleDB(); + $mDB->connect(); + + $mDB->addQuestion($param['id'], $this->deployment->getLine(), $param['userID'], $this->deployment->getEngineID(), $param['category']); + } } *************** *** 125,138 **** * List instances */ ! public function getList() { ! if(!$this->deployment->isSingleton()) { ! $this->xhtml .= '<p>'.$this->deployment->size().get_string('FE_deployQuestion_versions', 'stack').'<br />'.$this->deployment->formXHTML().'</p>'; ! } else { ! $this->xhtml .= '<p>'.get_string('FE_deployQuestion_singletonDeployed', 'stack').'<br />'; } foreach($this->deployment->getInstances() as $instance) { $item = $this->db->getDisplayItem($instance['id']); ! $instancesReturn[] = new StackDeployedInstancesDT($instance['id'], $item->getQuestionnote(), $item->getQuestionSeed()); } return new StackDeploymentPageDT($this->head, $this->xhtml, $instancesReturn); } --- 147,223 ---- * List instances */ ! public function getList() { ! $itemDB = new StackDBItem(); ! $itemDB->connect(); ! $currentVersion = $itemDB->getLatestVersion($this->param['id']); ! ! $earliest = $this->deployment->earliestDeployedVersion(); ! ! $mDB = new MoodleDB(); ! $mDB->connect(); ! // Grab info here before later queries hijack connection ! $attempts = $mDB->attemptsOnQuestion($earliest); ! $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(); ! if($this->deployment->size() > 0) { // don't want to deploy empty versions! ! $this->xhtml .= '<p /><input type="submit" name="submit" value="'.get_string('FE_deployQuestion_moveTo', 'stack').'" '.$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($attempts) { ! $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 /><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>'; ! } ! } ! } else { // this is an old version ! $this->xhtml .= get_string('FE_deployQuestion_newerVersionCannotDeploy', 'stack', $currentVersion); ! $this->xhtml .= '<a href="?id='.$currentVersion.'">deploy latest</a>'; ! } ! ! // original stuff below ! /* ! if($this->deployment->size() > 0 && $this->deployment->getVersion() != $currentVersion) { // out-of-date instances exist ! $this->xhtml .= '<p>'.get_string('FE_deployQuestion_newerVersion', 'stack', $currentVersion).'</p>'; } + else { // can deploy more of this version + if(!$this->deployment->isSingleton()) { + $this->xhtml .= '<p>'.get_string('FE_deployQuestion_xInstances', 'stack', $this->deployment->size()).get_string('FE_deployQuestion_ofVersionXdeployed', 'stack', $this->deployment->getVersion()).'</p>'.$this->deployment->formXHTML(); + } else { + $this->xhtml .= get_string('FE_deployQuestion_singletonDeployed', 'stack'); + } + } + */ + + $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']); ! ! $instancesReturn[] = new StackDeployedInstancesDT($instance['id'], $item->getQuestionNote(), $instance['xhtml'], $item->getQuestionSeed(), $this->deployment->isPrimed($instance['id'])); } + return new StackDeploymentPageDT($this->head, $this->xhtml, $instancesReturn); } --- NEW FILE: StackAttemptServer.php --- <?php /** * * Welcome to STACK. A system for teaching and assessment using a * computer algebra kernel. * * This file is licensed under the GPL License. * * A copy of the license is in your STACK distribution called * license.txt. If you are missing this file you can obtain * it from: * http://www.stack.bham.ac.uk/license.txt * * @author Simon Hammond (s.h...@bh...) * * @package stackOpaque */ require_once ('../config.php'); $config = new stackConfig(); global $config; $root = $config->get('docroot'); require_once ($root . '/lib/ui/DisplayItem.php'); require_once ($root . '/lib/error.php'); require_once ($root . '/lib/stackLegacy.php'); require_once $root . '/lib/items/Item.php'; require_once $root . '/lib/Logger.php'; require_once ('MoodleDisplayItem.php'); require_once 'CheckPassKey.php'; require_once ($root . '/lib/database/StackDBOpaque.php'); require_once ($root . '/lib/database/StackDBItem.php'); require_once ($root . '/opaque/datatypes/Score.php'); require_once ($root . '/opaque/datatypes/StackSoapPageReturn.php'); require_once ($root . '/opaque/datatypes/QuestionListDT.php'); require_once ($root . '/opaque/datatypes/StackQuestionPageDT.php'); require_once ($root . '/opaque/datatypes/CategoryDT.php'); /* * This is a streamlined SOAP server just for handling student attempts. */ class StackAttemptServer { private $errorlog; private $logger; public function __construct() { $this->errorLog = new error(); $this->logger = new Logger('StackAttemptServer'); } private function loadQuestion($sessionID) { $db = new StackDBOpaque(); $db->connect(); $result = $db->getSessionData($sessionID); // fields as an array if ($result['cacheID'] > 0) { // cached MoodleDisplayItem $session = new MoodleDisplayItem($result['userID'], 0); // get new item $session->setStateID($result['cacheID']); // move to right place in cache $session->setProgress($result['progress']); $this->logger->debug("result? ".print_r($result, true)); // get the expired status from the cache state NOT the session $cache = new StackDBCache(); $cache->connect(); $expired = $cache->getExpired($result['cacheID']); // setting a new expired state if necessary if($result['timeclose'] > 0 && $result['timeclose'] < time() && !$expired){ // moving to expired status $session->expire(); // will set expired to true } else { // No change since already expired or not yet time //$this->logger->debug("NOT expiring solution since timeclose is either 0 or >= ".time().")"); $session->setExpired($expired); } } else { $session = $db->base64_unserialize($result['data']); // some other object, e.g. Item } $db->disconnect(); return $session; } private function storeQuestion($question, $sessionID = NULL, $timeclose = 0) { $db = new StackDBOpaque(); $db->connect(); $serialised = $db->base64_serialize($question); if (get_class($question) == 'MoodleDisplayItem') { // can pass $serialised first arg (or NULL, since it'll be cached) $result = $db->storeSession(NULL, $sessionID, $question->getStateID(), $question->getUserID(), $question->getProgress(), $timeclose); } else { $result = $db->storeSession($serialised, $sessionID); // e.g. Authoring session } $db->disconnect(); return $result; } } ?> Index: MoodleQuestionList.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleQuestionList.php,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** MoodleQuestionList.php 22 Oct 2009 17:37:56 -0000 1.7 --- MoodleQuestionList.php 22 Nov 2010 23:05:51 -0000 1.7.2.1 *************** *** 110,114 **** $keyCheck = new CheckPassKey($this->passKey, $param['userID']); ! if($keyCheck->checkPasskey() == true) { --- 110,114 ---- $keyCheck = new CheckPassKey($this->passKey, $param['userID']); ! if($keyCheck->isValid()) { *************** *** 158,162 **** $this->db->connect(); ! $questions = $this->db->getListOfQuestions($param['userID'],true); $this->db->disconnect(); --- 158,162 ---- $this->db->connect(); ! $questions = $this->db->getLines($param['userID'], true, $param['filter'], $param['keywords']); $this->db->disconnect(); *************** *** 191,206 **** else { foreach($questions as $question) { // apply filter if(stack_questionbank_simple_question_filter($param['filter'], $question, isset($param['casesensitive']))) { ! $qlistArray[] = new QuestionListDT($question['id'], $question['questionName'], $question['questionDescription'], $question['valid'], $question['questionDateLastEdited'], $question['moodleCategories'], $question['published'], $question['nodeployed']); } } ! //$this->logger->finest(print_r($qlistArray,true)); $xhtml .= '<hr />'.$this->HTMLHead; ! $questionPage = new StackQuestionPageDT($qlistArray, $xhtml, $this->HTMLHead, $categories); return $questionPage; } --- 191,213 ---- else { + $kwdb = new StackDBKeywords(); + $kwdb->connect(); + foreach($questions as $question) { // apply filter if(stack_questionbank_simple_question_filter($param['filter'], $question, isset($param['casesensitive']))) { ! // get keywords array ! $keywords = $kwdb->getQuestionsKeywords($question['id']); ! $qlistArray[] = new QuestionListDT($question['id'], $question['questionName'], $question['questionDescription'], $question['valid'], stringUtil::prettifyDate($question['questionDateLastEdited']), $question['moodleCategories'], $question['published'], $question['nodeployed'], $keywords); } } ! $this->logger->debug(print_r($qlistArray,true)); $xhtml .= '<hr />'.$this->HTMLHead; ! $keywords = $kwdb->getAllKeywords(true); // active only ! $this->logger->debug($keywords); ! $questionPage = new StackQuestionPageDT($qlistArray, $xhtml, $this->HTMLHead, $categories, $keywords); return $questionPage; } *************** *** 276,279 **** --- 283,287 ---- $mdb = new MoodleDB(); $mdb->connect(); + //$this->logger->debug("cats:".print_r($param['categories'],1)); $result = $mdb->batchAdd($questions, $param['userID'], $param['stackEngine'], $param['categories']); $mdb->disconnect(); Index: soapServer.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/soapServer.php,v retrieving revision 1.10 retrieving revision 1.10.12.1 diff -C2 -d -r1.10 -r1.10.12.1 *** soapServer.php 20 Dec 2007 14:42:56 -0000 1.10 --- soapServer.php 22 Nov 2010 23:05:51 -0000 1.10.12.1 *************** *** 25,29 **** ! $ini = ini_set("soap.wsdl_cache_enabled","0"); //$soap = new SoapServer(null, array('uri' => "http://localhost/opaquetest")); --- 25,29 ---- ! // $ini = ini_set("soap.wsdl_cache_enabled","0"); //$soap = new SoapServer(null, array('uri' => "http://localhost/opaquetest")); Index: CheckPassKey.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/CheckPassKey.php,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** CheckPassKey.php 23 Jun 2009 14:39:36 -0000 1.4 --- CheckPassKey.php 22 Nov 2010 23:05:51 -0000 1.4.4.1 *************** *** 48,52 **** * @return bool */ ! public function checkPasskey() { global $config; --- 48,52 ---- * @return bool */ ! public function isValid() { global $config; |