Skip to content

Commit

Permalink
ipal2014112100
Browse files Browse the repository at this point in the history
This version of IPAL works with Moodle 2.8.1 but not with earlier
versions of Moodle.
  • Loading branch information
wjunkin committed Nov 21, 2014
1 parent 44e7601 commit c7af65f
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 65 deletions.
3 changes: 2 additions & 1 deletion ipal/compadre_questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@

require_once('../../config.php');
require_once($CFG->dirroot . '/mod/ipal/locallib.php');
require_once($CFG->dirroot . '/mod/ipal/question/engine/lib.php');// This is needed for Class 'question_display_options'.
require_once($CFG->dirroot . '/mod/ipal/question/engine/lib.php');// This is needed for class 'question_display_options'.
require_once($CFG->dirroot . '/mod/ipal/question/engine/bank.php');
require_once($CFG->dirroot . '/mod/ipal/editlib.php');
require_once($CFG->dirroot . '/mod/ipal/quiz/ipal_xmlparser.php');
require_once($CFG->dirroot . '/question/editlib.php');// Needed for the function question_edit_setup.
$cmid = required_param('cmid', PARAM_INT);
$cm = $DB->get_record('course_modules', array('id' => $cmid));
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
Expand Down
1 change: 1 addition & 0 deletions ipal/compadre_redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require_once($CFG->dirroot . '/mod/ipal/question/engine/bank.php');
require_once($CFG->dirroot . '/mod/ipal/editlib.php');
require_once($CFG->dirroot . '/mod/ipal/quiz/ipal_xmlparser.php');
require_once($CFG->dirroot . '/question/editlib.php');// Needed for the function question_edit_setup.
$cmid = required_param('cmid', PARAM_INT);
$cm = $DB->get_record('course_modules', array('id' => $cmid));
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
Expand Down
66 changes: 15 additions & 51 deletions ipal/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

require_once('../../config.php');
require_once($CFG->dirroot . '/mod/ipal/quiz/ipal_genericq_create.php');// Creates two generic questions for each IPAL activity.
require_once($CFG->dirroot . '/mod/quiz/editlib.php');
require_once($CFG->dirroot . '/question/editlib.php');
require_once($CFG->dirroot . '/mod/quiz/addrandomform.php');
require_once($CFG->dirroot . '/question/category_class.php');
require_once($CFG->dirroot . '/mod/ipal/editlib.php');
Expand Down Expand Up @@ -77,8 +77,6 @@
$canaddrandom = $contexts->have_cap('moodle/question:useall');
$canaddquestion = (bool) $contexts->having_add_and_use();

$quizhasattempts = quiz_has_attempts($quiz->id);$quizhasattempts = 0;// Attempts don't matter in IPAL.

$PAGE->set_url($thispageurl);

// Get the course object and related bits.
Expand All @@ -87,9 +85,6 @@
print_error('invalidcourseid', 'error');
}

$questionbank = new ipal_question_bank_view($contexts, $thispageurl, $course, $cm, $quiz);
$questionbank->set_quiz_has_attempts($quizhasattempts);

// Log this visit.
$params = array(
'courseid' => $course->id,
Expand Down Expand Up @@ -127,14 +122,12 @@
if (($up = optional_param('up', false, PARAM_INT)) && confirm_sesskey()) {
$quiz->questions = ipal_move_question_up($quiz->questions, $up);
$DB->set_field('ipal', 'questions', $quiz->questions, array('id' => $quiz->id));// Changed for IPAL.
quiz_delete_previews($quiz);
redirect($afteractionurl);
}

if (($down = optional_param('down', false, PARAM_INT)) && confirm_sesskey()) {
$quiz->questions = ipal_move_question_down($quiz->questions, $down);
$DB->set_field('ipal', 'questions', $quiz->questions, array('id' => $quiz->id));// Changed for IPAL.
quiz_delete_previews($quiz);
redirect($afteractionurl);
}

Expand Down Expand Up @@ -164,8 +157,6 @@
ipal_add_quiz_question($key, $quiz);
}
}
quiz_delete_previews($quiz);
quiz_update_sumgrades($quiz);
redirect($afteractionurl);
}

Expand All @@ -187,7 +178,6 @@
// Remove a question from the quiz.
// We require the user to have the 'use' capability on the question.
// So that then can add it back if they remove the wrong one by mistake.
quiz_require_question_use($remove);
ipal_remove_question($quiz, $remove);
$DB->set_field('ipal', 'questions', $quiz->questions, array('id' => $quiz->id));// Added for IPAL.
redirect($afteractionurl);
Expand Down Expand Up @@ -306,12 +296,8 @@
redirect($afteractionurl);
}

$questionbank->process_actions($thispageurl, $cm);

// End of process commands =====================================================.

$PAGE->requires->skip_link_to('questionbank',
get_string('skipto', 'access', get_string('questionbank', 'question')));
$PAGE->requires->skip_link_to('quizcontentsblock',
get_string('skipto', 'access', get_string('questionsinthisquiz', 'quiz')));
$PAGE->set_title(get_string('editingquizx', 'quiz', format_string($quiz->name)));
Expand Down Expand Up @@ -345,8 +331,6 @@
'strings' => array(),
'async' => false,
);
$PAGE->requires->js_init_call('quiz_edit_init', null, false, $module);


if ($quizqbanktool) {
$bankclass = '';
Expand All @@ -355,53 +339,33 @@
$bankclass = 'collapsed ';
$quizcontentsclass = 'quizwhenbankcollapsed';
}

echo "<table border='0'><tr><td>";
// Question bank display.
// ============.
echo '<div class="questionbankwindow ' . $bankclass . 'block">';
echo '<div class="header"><div class="title"><h2>';
// Offer the opportunity to add an EJS simulation to a question.
ipal_create_genericq($quiz->course);
echo "<h2>Add Questions</h2>";
$returnnewquestionurl = '%2Fmod%2Fipal%2Fedit.php%3Fcmid%3D'.$cmid.'%26addonpage%3D0&cmid=';
$returnnewquestionurl .= $cmid.'&category=2&addonpage=0&appendqnumstring=addquestion';
echo "\n".'<a href="'.$CFG->wwwroot.'/question/addquestion.php?returnurl='.$returnnewquestionurl.'">Add a new question</a>';
echo "\n".'<br /><a href="'.$CFG->wwwroot.'/mod/ipal/ipal_questionbank.php?cmid='.$cmid.'">Add question from questionbank</a>';
require_once($CFG->dirroot . '/mod/ipal/quiz/compadre_access_form.php');
if ($DB->count_records('modules', array('name' => 'ejsapp'))) {
echo "\n<br />Click <a href='".$CFG->wwwroot."/mod/ipal/ejs_ipal.php?cmid=$cmid' style='color: rgb(255,255,255)'>
echo "\nClick <a href='".$CFG->wwwroot."/mod/ipal/ejs_ipal.php?cmid=$cmid'>
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.
ipal_create_genericq($quiz->course);
echo get_string('questionbankcontents', 'quiz') .
' <a href="' . $thispageurl->out(true, array('qbanktool' => '1')) .
'" id="showbankcmd">[' . get_string('show').
']</a>
<a href="' . $thispageurl->out(true, array('qbanktool' => '0')) .
'" id="hidebankcmd">[' . get_string('hide').
']</a>';
echo '</h2></div></div><div class="content">';

echo '<span id="questionbank"></span>';
echo '<div class="container">';
echo '<div id="module" class="module">';
echo '<div class="bd">';
$questionbank->display('editq',
$pagevars['qpage'],
$pagevars['qperpage'],
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'],
$pagevars['qbshowtext']);
echo '</div>';
echo '</div>';
echo '</div>';

echo '</div></div>';
// ...================.
// End of question bank display.

echo "</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td>";
echo '<div class="quizcontents ' . $quizcontentsclass . '" id="quizcontentsblock">';


$repaginatingdisabledhtml = '';
$repaginatingdisabled = false;

echo '<a href="view.php?id='.$quiz->cmid.'">Start polling with '.$quiz->name."</a>\n<br />";
echo $OUTPUT->heading('iPollAll Questions for ' . $quiz->name, 2);// Modified for ipal.
echo $OUTPUT->heading('Current Questions for ' . $quiz->name, 2);// Modified for ipal.
echo $OUTPUT->help_icon('editingipal', 'ipal', get_string('basicideasofipal', 'ipal'));

$tabindex = 0;
Expand All @@ -410,13 +374,13 @@

echo '<div class="editq">';

ipal_print_question_list($quiz, $thispageurl, true, $quizreordertool, $quizqbanktool,
$quizhasattempts, $defaultcategoryobj, $canaddquestion, $canaddrandom);// Modified for IPAL.

$ipal = $quiz;
echo ipal_make_instructor_question_list();
echo '</div>';

// Close <div class="quizcontents">.
echo '</div>';
echo "</td></tr></table>";
$canaddrandom = false;// No random questions allowed in IPAL.

echo $OUTPUT->footer();
52 changes: 50 additions & 2 deletions ipal/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
require_once("$CFG->libdir/formslib.php");
require_once($CFG->dirroot . '/mod/ipal/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/editlib.php');// Needed for the class ipal_question_bank_view.
defined('MOODLE_INTERNAL') || die();

/**
Expand Down Expand Up @@ -255,7 +254,7 @@ function ipal_move_question_down($layout, $questionid) {
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class ipal_question_bank_view extends quiz_question_bank_view {
class ipal_question_bank_view extends mod_quiz\question\bank\custom_view {
/** @var bool the quizhas attempts. */
protected $quizhasattempts = false;
/** @var object the quiz settings. */
Expand Down Expand Up @@ -649,3 +648,52 @@ function ipal_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
}
}// End of if(isset($order).
}


/**
* This function displays the list of questions in the edit page.
* This was needed because of changed made in Moodle 2.8 so that the core functions were difficult to use
* @param int $cmid The ipal id for this ipal instance.
*/
function ipal_display_question_list($cmid) {
global $DB;
global $ipal;
global $cm;

$state = $DB->get_record('ipal', array('id' => $ipal->id));

echo "<table><tr><td>".instructor_buttons()."</td><td>".ipal_show_compadre($cmid)."</td><td>".
ipal_toggle_view($newstate)."</td>";
if ($ipal->mobile) {
$timecreated = $ipal->timecreated;
$ac = $ipal->id.substr($timecreated, strlen($timecreated) - 2, 2);
echo "<td>access code=$ac</td>";
}
echo "</tr></table>";
echo ipal_make_instructor_question_list();
echo "<br><br>";
$state = $DB->get_record('ipal', array('id' => $ipal->id));
if ($state->preferredbehaviour == "Graph") {
if (ipal_show_current_question() == 1) {
echo "<br>";
echo "<br>";
echo "<iframe id= \"graphIframe\" src=\"graphics.php?ipalid=".$ipal->id."\" height=\"535\" width=\"723\"></iframe>";
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>";
}
} else {
echo "<br>";
echo "<br>";
echo "<iframe id= \"graphIframe\" src=\"gridview.php?id=".$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');
return false;\"
href=\"popupgraph.php?ipalid=".$ipal->id."\" target=\"_blank\">Open a new window for the graph.</a>";
}
}

7 changes: 4 additions & 3 deletions ipal/ejs_ipal.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@

echo "\n<br />Information: IPAL id is $ipalid.";
$ipalquestions = explode(",", $ipal->questions);
echo " There are ".count($ipalquestions)." ipal questions in this IPAL activity.";
$numberofquestions = count($ipalquestions) - 1;
echo " There are $numberofquestions ipal questions in this IPAL activity.";
$courseid = $coursemodules->course;
if (!$ejsapps = $DB->get_records('ejsapp', array('course' => $courseid))) {
echo "\n<br />You must create at least one EJS App activity in this course before you can add it to questions.";
Expand Down Expand Up @@ -97,8 +98,8 @@
}
}
if (count($otherquestions) > 1) {
echo "\n<br /><br />Here are other questions which are not in this IPAL activity.
You may add the selected EJS App activity to these questions as well.";
echo "\n<br /><br />Here are other questions which are not in this IPAL activity.";
echo " You may add the selected EJS App activity to these questions as well.";
foreach ($otherquestions as $qotherid => $qothertitle) {
if ($qotherid) {
echo "\n<br /><input type='checkbox' value='$qotherid' name='qid[$qcount]'>".$qothertitle;$qcount++;
Expand Down
94 changes: 94 additions & 0 deletions ipal/ipal_questionbank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Displays the questions that may be added to an IPAL instance.
*
* @package mod_ipal
* @copyright 2012 W. F. Junkin, Eckerd College, http://www.eckerd.edu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once('../../config.php');
require_once($CFG->dirroot . '/mod/ipal/locallib.php');
$cmid = optional_param('cmid', 0, PARAM_INT); // Course_module ID.
if ($cmid) {
$module = $DB->get_record('modules', array('name' => 'ipal'));
$coursemodules = $DB->get_record('course_modules', array('id' => $cmid, 'module' => $module->id));
} else {
echo "You must supply the cmid value for the IPAL activity.";
exit;
}
$ipalid = $coursemodules->instance;
$ipal = $DB->get_record('ipal', array('id' => $ipalid));
$course = $DB->get_record('course', array('id' => $ipal->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('ipal', $ipal->id, $course->id, false, MUST_EXIST);
require_login($course, true, $cm);
$contextinstance = context_module::instance($cm->id);
$PAGE->set_url('/mod/ipal/ipal_questionbank.php', array('id' => $cm->id));
$PAGE->set_title('Questiong that can be added to the '.$ipal->name.' activity');
$PAGE->set_heading($course->shortname);

// Output starts here.
echo $OUTPUT->header();
// Only authorized people can access this site.
if (!(has_capability('mod/ipal:instructoraccess', $contextinstance))) {
echo "\n<br />You must be authorized to access this site";
echo $OUTPUT->footer();
exit;
}
foreach ($_GET as $key => $value) {
$$key = $value;
if ($key == 'qid') {
foreach ($_GET['qid'] as $qkey => $qvalue) {
$qid[$qkey] = $qvalue;
}
}
}
echo "Click <a href='".$CFG->wwwroot."/mod/ipal/edit.php?cmid=$cmid'>here</a> to return to IPAL activity.";

$coursecontext = $DB->get_record('context', array('instanceid' => $course->id, 'contextlevel' => 50));

echo "\n<form method = 'post' action = '".$CFG->wwwroot."/mod/ipal/edit.php?cmid=$cmid&add=1&sesskey=".$USER->sesskey."'>";
$myform = '';
$myform .= "\n<script language=\"javascript\" type=\"text/javascript\">
\n function ipalpopup(id) {
\n\t url = '".$CFG->wwwroot."/question/preview.php?id='+id+'&amp;cmid=";
$myform .= $cm->id;
$myform .= "&amp;behaviour=deferredfeedback&amp;correctness=0&amp;marks=1&amp;markdp=-2";
$myform .= "&amp;feedback&amp;generalfeedback&amp;rightanswer&amp;history';";
$myform .= "\n\t newwindow=window.open(url,'Question Preview','height=600,width=800,top=0,left=0,menubar=0,";
$myform .= "location=0,scrollbars,resizable,toolbar,status,directories=0,fullscreen=0,dependent');";
$myform .= "\n\t if (window.focus) {newwindow.focus()}
\n\t return false;
\n }
\n </script>\n";
foreach (ipal_get_questionbank_questions($coursecontext->id, $cmid, $ipalid) as $items) {
$previewurl = $CFG->wwwroot.'/question/preview.php?id='.
$items['id'].'&cmid='.$cm->id.
'&behaviour=deferredfeedback&correctness=0&marks=1&markdp=-2&feedback&generalfeedback&rightanswer&history';
$addquestionurl = $CFG->wwwroot.'/mod/ipal/edit.php?cmid='.$cmid.'&addquestion='.$items['id'].'&sesskey='.$USER->sesskey;
$myform .= "\n<input type=\"checkbox\" name=\"q".$items['id']."\" value=\"1\" />";
$myform .= "\n<a href=\"$previewurl\" onclick=\"return ipalpopup('".$items['id']."')\" target=\"_blank\">";
$myform .= ipal_create_preview_icon()."</a>";
$myform .= "\n<a href=\"$addquestionurl\">";
$myform .= ipal_create_standard_icon('add')."</a>";
$myform .= "\n".$items['question']."<br /><br />\n";
}
echo $myform;
echo "\n<br /><input type='submit' value='Add selected questions to IPAL'></form>";
// Finish the page.
echo $OUTPUT->footer();
6 changes: 3 additions & 3 deletions ipal/lang/en/ipal.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
$string['eventeditpageviewed'] = 'Ipal edit page viewed';
$string['ipal'] = 'ipal';
$string['ipalfieldset'] = 'Custom example fieldset';
$string['ipalmobile'] = 'Enable clickers';
$string['ipalmobile_error'] = 'You must choose between No and Yes';
$string['ipalmobile_help'] = 'Choose Yes to allow students to respond using clickers. This displays the IPAL access code for the teacher on the IPAL polling page. ';
$string['ipalmobile'] = 'Enable clickers (Mobile Apps)';
$string['ipalmobile_error'] = 'You must choose between No and Mobile App';
$string['ipalmobile_help'] = 'Choose Mobile App to allow students to respond using a Mobile App. This displays the IPAL access code for the teacher on the IPAL polling page. ';
$string['ipalname'] = 'IPAL Name';
$string['ipalname_help'] = 'This is the content of the help tooltip associated with the ipalname field. Markdown syntax is supported.';
$string['ipaltype'] = 'IPAL Type';
Expand Down
Loading

0 comments on commit c7af65f

Please sign in to comment.