Update of /cvsroot/stack/stack-dev/opaque In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28438/opaque Modified Files: MoodleQuestionDeployment.php MoodleQuestionList.php MoodleDisplayItem.php MoodleStackReport.php StackServer.php newWSDL.wsdl Log Message: Merging 2.2 branch (with some additional fixes to ensure seamless updating for version lines) Index: newWSDL.wsdl =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/newWSDL.wsdl,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** newWSDL.wsdl 5 Feb 2010 11:00:10 -0000 1.11 --- newWSDL.wsdl 30 Sep 2010 16:56:21 -0000 1.12 *************** *** 112,115 **** --- 112,116 ---- <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" /> Index: MoodleStackReport.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleStackReport.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MoodleStackReport.php 16 Sep 2009 12:05:13 -0000 1.4 --- MoodleStackReport.php 30 Sep 2010 16:56:21 -0000 1.5 *************** *** 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.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MoodleDisplayItem.php 11 Jan 2010 17:23:36 -0000 1.12 --- MoodleDisplayItem.php 30 Sep 2010 16:56:21 -0000 1.13 *************** *** 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,226 **** $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 ! // 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='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: MoodleQuestionList.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleQuestionList.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MoodleQuestionList.php 2 Feb 2010 13:44:19 -0000 1.9 --- MoodleQuestionList.php 30 Sep 2010 16:56:21 -0000 1.10 *************** *** 200,207 **** // get keywords array $keywords = $kwdb->getQuestionsKeywords($question['id']); ! $qlistArray[] = new QuestionListDT($question['id'], $question['questionName'], $question['questionDescription'], $question['valid'], $question['questionDateLastEdited'], $question['moodleCategories'], $question['published'], $question['nodeployed'], $keywords); } } ! //$this->logger->finest(print_r($qlistArray,true)); $xhtml .= '<hr />'.$this->HTMLHead; --- 200,207 ---- // 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; *************** *** 283,286 **** --- 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: MoodleQuestionDeployment.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/MoodleQuestionDeployment.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MoodleQuestionDeployment.php 2 Nov 2009 17:55:08 -0000 1.4 --- MoodleQuestionDeployment.php 30 Sep 2010 16:56:21 -0000 1.5 *************** *** 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,109 ---- $this->xhtml = ''; ! $this->logger->debug(print_r($this->param, 1)); ! ! $this->deployment = new Deployment($this->param['id'], $this->param['engineID']); } *************** *** 125,134 **** * List instances */ ! public function getList() { ! if(!$this->deployment->isSingleton()) { ! $this->xhtml .= $this->deployment->size().get_string('FE_deployQuestion_versions', 'stack').'<br />'.$this->deployment->formXHTML(); ! } else { ! $this->xhtml .= get_string('FE_deployQuestion_singletonDeployed', 'stack'); } foreach($this->deployment->getInstances() as $instance) { $item = $this->db->getDisplayItem($instance['id']); --- 130,168 ---- * List instances */ ! public function getList() { ! $itemDB = new StackDBItem(); ! $itemDB->connect(); ! $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>'; ! } ! } ! } 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'); ! } } + */ foreach($this->deployment->getInstances() as $instance) { $item = $this->db->getDisplayItem($instance['id']); *************** *** 136,139 **** --- 170,174 ---- $instancesReturn[] = new StackDeployedInstancesDT($instance['id'], $item->getQuestionNote(), $instance['xhtml'], $item->getQuestionSeed(), $this->deployment->isPrimed($instance['id'])); } + return new StackDeploymentPageDT($this->head, $this->xhtml, $instancesReturn); } Index: StackServer.php =================================================================== RCS file: /cvsroot/stack/stack-dev/opaque/StackServer.php,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** StackServer.php 21 Jan 2010 16:00:40 -0000 1.49 --- StackServer.php 30 Sep 2010 16:56:21 -0000 1.50 *************** *** 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(); *************** *** 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); *************** *** 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 . '".'; *************** *** 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,410 **** $param = array_combine($paramKey, $paramVal); } ! $this->logger->critical("processing deployment with param:".print_r($param, true)); $checkKey = new CheckPassKey($passKey, $userId); if ($checkKey->isValid()) { --- 420,424 ---- $param = array_combine($paramKey, $paramVal); } ! $this->logger->fine("processing deployment with param:".print_r($param, true)); $checkKey = new CheckPassKey($passKey, $userId); if ($checkKey->isValid()) { |