Skip to content

Commit

Permalink
Updated for Moodle format
Browse files Browse the repository at this point in the history
Eight files were modified to conform to the Moodle programming style.
All files now pass the codechecker and the php checker.
  • Loading branch information
wjunkin committed Oct 3, 2014
1 parent f90881e commit e3d0fd3
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 46 deletions.
3 changes: 1 addition & 2 deletions ipal/add_ejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @copyright 2012 W. F. Junkin, Eckerd College, http://www.eckerd.edu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
//echo '<html><head><title>Adding EJS Activities to IPAL questions</title></head><body>';

require_once('../../config.php');
$cmid = optional_param('cmid', 0, PARAM_INT); // Course_module ID.
Expand Down Expand Up @@ -80,6 +79,6 @@
$newquestiontext = $DB->get_field('question', 'questiontext', array('id' => $qvalue));
echo "\n<br />".$newquestiontext;
}
//echo "\n</body></html>";

// Finish the page.
echo $OUTPUT->footer();
4 changes: 1 addition & 3 deletions ipal/compadre_questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
*/

require_once('../../config.php');
require_once("locallib.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/bank.php');
//require_once("ipal_edit_quizlocallib.php");
require_once($CFG->dirroot . '/mod/ipal/editlib.php');
require_once($CFG->dirroot . '/mod/ipal/quiz/ipal_xmlparser.php');
$cmid = required_param('cmid', PARAM_INT);
Expand Down Expand Up @@ -93,7 +92,6 @@
echo $OUTPUT->header();

echo '<div class="quizcontents" id="quizcontentsblock">';// Modified for ipal.
$debug = 0;
$repaginatingdisabledhtml = '';
$repaginatingdisabled = false;
$courseid = $course->id;
Expand Down
1 change: 0 additions & 1 deletion ipal/compadre_redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
require_once($CFG->dirroot . '/mod/ipal/question/engine/lib.php');// 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("ipal_edit_quizlocallib.php");
require_once($CFG->dirroot . '/mod/ipal/quiz/ipal_xmlparser.php');
$cmid = required_param('cmid', PARAM_INT);
$cm = $DB->get_record('course_modules', array('id' => $cmid));
Expand Down
2 changes: 0 additions & 2 deletions ipal/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@
}

if (($down = optional_param('down', false, PARAM_INT)) && confirm_sesskey()) {
//echo "\n<br />debug501 in edit and quiz-questions is ".$quiz->questions." and down is ".$down;
$quiz->questions = ipal_move_question_down($quiz->questions, $down);
//echo "\n<br />debug503 in edit and quiz-questions is ".$quiz->questions;exit;
$DB->set_field('ipal', 'questions', $quiz->questions, array('id' => $quiz->id));// Changed for IPAL.
quiz_delete_previews($quiz);
redirect($afteractionurl);
Expand Down
35 changes: 18 additions & 17 deletions ipal/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
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
require_once($CFG->dirroot . '/mod/quiz/editlib.php');// Needed for the class ipal_question_bank_view.
defined('MOODLE_INTERNAL') || die();

/**
Expand Down Expand Up @@ -193,7 +193,14 @@ function ipal_remove_question($quiz, $questionid) {
$DB->set_field('ipal', 'questions', $quiz->questions, array('id' => $quiz->id));
}

// Private function used by the following two.
/**
* Private function used by the next two functions.
* Needed because Moodle 2.7 no longer has a question list.
* @param string $layout the existinng layout, $quiz->questions.
* @param int $questionid the id of a question.
* @param int $shift how far to shift the question (up or down).
* @return the updated layout
*/
function _ipal_move_question($layout, $questionid, $shift) {
if (!$questionid || !($shift == 1 || $shift == -1)) {
return $layout;
Expand Down Expand Up @@ -238,7 +245,7 @@ function ipal_move_question_up($layout, $questionid) {
* @return the updated layout
*/
function ipal_move_question_down($layout, $questionid) {
return _ipal_move_question($layout, $questionid, +1);
return _ipal_move_question($layout, $questionid, + 1);
}

/**
Expand All @@ -255,17 +262,12 @@ class ipal_question_bank_view extends quiz_question_bank_view {
protected $quiz = false;

/**
* Constructor
* @param question_edit_contexts $contexts
* @param moodle_url $pageurl
* @param object $course course settings
* @param object $cm activity settings.
* @param object $quiz quiz settings.
* Function to provide the correct URL for use in IPAL.
* This provides the cahnge needed to use the class quiz_question_bank_view in IPAL.
*
* @param int $questionid The id of the question.
* @return object the correct url for IPAL.
*/
public function __construct($contexts, $pageurl, $course, $cm, $quiz) {
parent::__construct($contexts, $pageurl, $course, $cm,$quiz);
}

public function add_to_quiz_url($questionid) {
global $CFG;
$params = $this->baseurl->params();
Expand Down Expand Up @@ -318,8 +320,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
} else {
$disabled = '';
}
$randomusablequestions =
question_bank::get_qtype('random')->get_available_questions_from_category(
$randomusablequestions = question_bank::get_qtype('random')->get_available_questions_from_category(
$category->id, $recurse);
$maxrand = count($randomusablequestions);$maxrand = 0;// Adding random questions is not an IPAL option.
if ($maxrand > 0) {
Expand Down Expand Up @@ -477,8 +478,8 @@ function ipal_print_question_list($quiz, $pageurl, $allowdelete, $reordertool,
$reordercontrols2top = '<div class="moveselectedonpage">' .
get_string('moveselectedonpage', 'quiz', $a) .
'<input type="submit" name="savechanges" value="' .
$strmove . '" ' . $pagingdisabled . ' />' . '
<br /><input type="submit" name="savechanges" value="' .
$strmove . '" ' . $pagingdisabled . ' />' .
'<br /><input type="submit" name="savechanges" value="' .
$strreorderquestions . '" /></div>';
$reordercontrols2bottom = '<div class="moveselectedonpage">' .
'<input type="submit" name="savechanges" value="' .
Expand Down
15 changes: 3 additions & 12 deletions ipal/ejs_ipal.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@
* @copyright 2012 W. F. Junkin, Eckerd College, http://www.eckerd.edu
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/*
?>
<html>
<head>
<title>Adding EJS Activities to IPAL questions</title>
</head>
<body>
<?php
*/

require_once('../../config.php');
$cmid = optional_param('cmid', 0, PARAM_INT); // Course_module ID.
if ($cmid) {
Expand Down Expand Up @@ -119,7 +111,6 @@
echo "\n<br />".$qhasejtitle;
}
}
//echo "</body>\n</html>";
// Finish the page.
echo $OUTPUT->footer();

// Finish the page.
echo $OUTPUT->footer();
18 changes: 11 additions & 7 deletions ipal/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ function ipal_count_questions($questionid) {

return( "?data=".implode(",", $data)."&labels=".implode(",", $labels)."&total=10");
}

/**
* This function creates the HTML tag for the preview icon.
*/
function ipal_create_preview_icon ( ) {
function ipal_create_preview_icon() {
global $CFG;
global $PAGE;
$previewimageurl = $CFG->wwwroot.'/theme/image.php/'.$PAGE->theme->name.'/core/'.$CFG->themerev.'/t/preview';
Expand All @@ -229,7 +230,9 @@ function ipal_make_instructor_form() {
$myform = "<form action=\"?".$_SERVER['QUERY_STRING']."\" method=\"post\">\n";
$myform .= "\n";
foreach (ipal_get_questions() 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';
$previewurl = $CFG->wwwroot.'/question/preview.php?id='.
$items['id'].'&cmid='.$cm->id.
'&behaviour=deferredfeedback&correctness=0&marks=1&markdp=-2&feedback&generalfeedback&rightanswer&history';
$myform .= "\n<input type=\"radio\" name=\"question\" value=\"".$items['id']."\" />";
$myform .= "\n<a href=\"$previewurl\" onclick=\"return ipalpopup('".$items['id']."')\" target=\"_blank\">";
$myform .= ipal_create_preview_icon()."</a>";
Expand Down Expand Up @@ -421,13 +424,14 @@ function ipal_display_instructor_interface($cmid) {
\n function ipalpopup(id) {
\n\t url = 'http://localhost/moodle27_1/question/preview.php?id='+id+'&amp;cmid=";
echo $cm->id;
echo "&amp;behaviour=deferredfeedback&amp;correctness=0&amp;marks=1&amp;markdp=-2&amp;feedback&amp;generalfeedback&amp;rightanswer&amp;history';
\n\t newwindow=window.open(url,'Question Preview','height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,resizable,toolbar,status,directories=0,fullscreen=0,dependent');
\n\t if (window.focus) {newwindow.focus()}
echo "&amp;behaviour=deferredfeedback&amp;correctness=0&amp;marks=1&amp;markdp=-2";
echo "&amp;feedback&amp;generalfeedback&amp;rightanswer&amp;history';";
echo "\n\t newwindow=window.open(url,'Question Preview','height=600,width=800,top=0,left=0,menubar=0,";
echo "location=0,scrollbars,resizable,toolbar,status,directories=0,fullscreen=0,dependent');"
echo "\n\t if (window.focus) {newwindow.focus()}
\n\t return false;
\n }
\n </script>\n"
;
\n </script>\n";

echo ipal_make_instructor_form();
echo "<br><br>";
Expand Down
2 changes: 0 additions & 2 deletions ipal/viewejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,3 @@
$externalsize->height = 380;
echo $OUTPUT->heading(draw_ejsapp_instance($ejsapp->id, null, $externalsize->width, $externalsize->height));
echo "\n</div></body></html>";
// Finish the page.
// Echo $OUTPUT->footer().

0 comments on commit e3d0fd3

Please sign in to comment.