Skip to content

Commit

Permalink
2014-10-13 version
Browse files Browse the repository at this point in the history
EJS now runs without an iframe in the size selected by the instructor.
The add/question interface is not cleaner.
  • Loading branch information
wjunkin committed Oct 13, 2014
1 parent a0ea0e8 commit 44e7601
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 124 deletions.
12 changes: 5 additions & 7 deletions ipal/add_ejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@
echo "\n<br /> Please use the back button and try again.</body></html>";
exit;
}
$ejs = $DB->get_record('modules', array('name' => 'ejsapp'));
$ejsid = $ejs->id;// The id for all EJS module activities.
$ejscoursemodule = $DB->get_record('course_modules', array('instance' => $ejsappid, 'course' => $courseid, 'module' => $ejsid));
$ejscoursemoduleid = $ejscoursemodule->id;
$newcode = "src=\"".$CFG->wwwroot."/mod/ipal/viewejs.php?id=$ejscoursemoduleid\" width='600' height='410'>EJS App";
$newcode = '<iframe '.$newcode.'</iframe>';

require_once('../../mod/ejsapp/external_interface/ejsapp_external_interface.php');
$ejscode = draw_ejsapp_instance($ejsappid);
$ejscode = 'EJS<ejsipal>'.$ejscode."</ejsipal>\n<br />";
echo "\n<be /> Here are the revised question(s):";
foreach ($qid as $qkey => $qvalue) {
echo "\n<br /> question $qvalue";
$questiontext = $DB->get_field('question', 'questiontext', array('id' => $qvalue));
$result = $DB->set_field('question', 'questiontext', $newcode.$questiontext, array('id' => $qvalue));
$result = $DB->set_field('question', 'questiontext', $ejscode.$questiontext, array('id' => $qvalue));
$newquestiontext = $DB->get_field('question', 'questiontext', array('id' => $qvalue));
echo "\n<br />".$newquestiontext;
}
Expand Down
8 changes: 7 additions & 1 deletion ipal/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
$quizeditconfig->dialoglisteners[] = 'addrandomdialoglaunch_' . $pageiter;
}
// Javascript needed so that the quiz formatting tools will work correctly.
echo "\n".'<script type="text/javascript">';
echo "\n"."document.getElementById('page-mod-ipal-edit').id = 'page-mod-quiz-edit';";
echo "\n</script>";

$PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
$PAGE->requires->js('/question/qengine.js');
$module = array(
Expand All @@ -357,7 +362,8 @@
echo '<div class="header"><div class="title"><h2>';
// Offer the opportunity to add an EJS simulation to a question.
if ($DB->count_records('modules', array('name' => 'ejsapp'))) {
echo "\n<br />Click <a href='".$CFG->wwwroot."/mod/ipal/ejs_ipal.php?cmid=$cmid'>to add EJS Apps</a>";
echo "\n<br />Click <a href='".$CFG->wwwroot."/mod/ipal/ejs_ipal.php?cmid=$cmid' style='color: rgb(255,255,255)'>
to add EJS Apps</a>";
}
require_once($CFG->dirroot . '/mod/ipal/quiz/compadre_access_form.php');
// Create a generic multichoice question and a generic essay question if they don't exist in this course.
Expand Down
3 changes: 3 additions & 0 deletions ipal/ejs_ipal.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
$otherquestions[0] = '';
foreach ($qcategories as $categoryid => $value) {
$questions = $DB->get_records('question', array('category' => $categoryid));
$ejsapp = 'ejsapp';
foreach ($questions as $qid => $question) {
if (preg_match("/viewejs/", $question->questiontext)) {
$hasejs[$qid] = $question->name;
} else if (preg_match("/$ejsapp\/jarfiles/", $question->questiontext)) {
$hasejs[$qid] = $question->name;
} else if (in_array($qid, $ipalquestions)) {
$thisipal[$qid] = $question->name;
} else {
Expand Down
10 changes: 7 additions & 3 deletions ipal/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function ipal_get_questions() {

$aquestions = $DB->get_record('question', array('id' => $q));
if (isset($aquestions->questiontext)) {
// Removing any EJS from the ipal/view.php page. Note: A dot does not match a new line without the s option.
$aquestions->questiontext = preg_replace("/EJS<ejsipal>.+<\/ejsipal>/s", "EJS ", $aquestions->questiontext);
$pagearray2[] = array('id' => $q, 'question' => strip_tags($aquestions->questiontext),
'answers' => ipal_get_answers($q));
}
Expand Down Expand Up @@ -441,9 +443,9 @@ function ipal_display_instructor_interface($cmid) {
echo "<br>";
echo "<br>";
echo "<iframe id= \"graphIframe\" src=\"graphics.php?ipalid=".$ipal->id."\" height=\"535\" width=\"723\"></iframe>";
echo "<br><br><a onclick=\"window.open('popupgraph.php?ipalid=".$ipal->id."', '',
'width=620,height=450,toolbar=no,location=no,menubar=no,copyhistory=no,status=no,
directories=no,scrollbars=yes,resizable=yes');
echo "<br><br><a onclick=\"newwindow=window.open('popupgraph.php?ipalid=".$ipal->id."', '',
'width=620,height=450,toolbar=no,location=no,menubar=no,copyhistory=no,status=no,";
echo "directories=no,scrollbars=yes,resizable=yes');
return false;\"
href=\"popupgraph.php?ipalid=".$ipal->id."\" target=\"_blank\">Open a new window for the graph.</a>";
}
Expand All @@ -469,6 +471,8 @@ function ipal_show_current_question() {
if ($DB->record_exists('ipal_active_questions', array('ipal_id' => $ipal->id))) {
$question = $DB->get_record('ipal_active_questions', array('ipal_id' => $ipal->id));
$questiontext = $DB->get_record('question', array('id' => $question->question_id));
// Removing any EJS from the ipal/view.php page. Note: A dot does not match a new line without the s option.
$questiontext->questiontext = preg_replace("/EJS<ejsipal>.+<\/ejsipal>/s", "EJS ", $questiontext->questiontext);
echo "The current question is -> ".strip_tags($questiontext->questiontext);
return(1);
} else {
Expand Down
110 changes: 0 additions & 110 deletions ipal/show_question.php

This file was deleted.

6 changes: 3 additions & 3 deletions ipal/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

defined('MOODLE_INTERNAL') || die();

$module->version = 2014100100; // The current module version (Date: YYYYMMDDXX).
$module->requires = 2011033003; // Requires this Moodle version.
$module->version = 2014101300; // The current module version (Date: YYYYMMDDXX).
$module->requires = 2014051200; // Requires this Moodle version.
$module->cron = 60; // Period for cron to check this module (secs).
$module->release = '2.0.0 (Build: 2014100100';
$module->release = '2.0.1 (Build: 2014101300';

0 comments on commit 44e7601

Please sign in to comment.