1
0
mirror of https://github.com/moodle/moodle.git synced 2025-03-03 07:19:09 +01:00

my stupid editor has been eating whitespace

This commit is contained in:
gustav_delius 2005-05-14 20:16:31 +00:00
parent a0a3649235
commit 8f015ea595
6 changed files with 110 additions and 110 deletions

@ -33,7 +33,7 @@ $QUIZ_QUESTION_TYPE = array ( MULTICHOICE => get_string("multichoice", "quiz")
// add remote question types
if ($rqp_types = get_records('quiz_rqp_types')) {
foreach($rqp_types as $type) {
$QUIZ_QUESTION_TYPE[100+$type->id] = $type->name;
$QUIZ_QUESTION_TYPE[100+$type->id] = $type->name;
}
}

@ -3,9 +3,9 @@
require_once($CFG->dirroot . '/mod/quiz/questiontypes/rqp/lib.php');
if (empty($question->id)) {
if (!isset($typeid)) {
error('No remote question type specified');
}
if (!isset($typeid)) {
error('No remote question type specified');
}
$question->options->type = $typeid;
$question->options->source = '';
$question->options->format = '';
@ -15,7 +15,7 @@
}
if (!$type = get_record('quiz_rqp_types', 'id', $question->options->type = $typeid)) {
error("Invalid remote question type");
error("Invalid remote question type");
}
print_heading_with_help(get_string('editingrqp', 'quiz', $type->name), 'rqp', 'quiz');

@ -120,9 +120,9 @@ function quiz_rqp_print_serverinfo($serverinfo) {
function quiz_rqp_debug_soap($item) {
global $CFG;
if ($CFG->debug) {
echo 'Here is the dump of the soap fault:<pre>';
var_dump($item);
echo '<pre>';
echo 'Here is the dump of the soap fault:<pre>';
var_dump($item);
echo '<pre>';
}
}
?>

@ -58,7 +58,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
}
if (is_soap_fault($item)) {
$result->notice = get_string('invalidsource', 'quiz', $item);
quiz_rqp_debug_soap($item);
quiz_rqp_debug_soap($item);
return $result;
}
if ($item->sourceErrors) {
@ -238,13 +238,13 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
} else {
// Otherwise perform a render operation
if (!$output = remote_render($question, $state, false,
$options->readonly ? 'readonly' : 'normal')) {
notify(get_string('noconnection', 'quiz'));
exit;
}
$options->readonly ? 'readonly' : 'normal')) {
notify(get_string('noconnection', 'quiz'));
exit;
}
if (is_soap_fault($output)) {
notify(get_string('errorrendering', 'quiz'));
quiz_rqp_debug_soap($output);
quiz_rqp_debug_soap($output);
unset($output);
exit;
}
@ -402,10 +402,10 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
function get_config_options() {
global $CFG;
// for the time being disable rqp unless we have php 5
if(!check_php_version('5.0.0')) {
return false;
}
// for the time being disable rqp unless we have php 5
if(!check_php_version('5.0.0')) {
return false;
}
$link->name = 'managetypes';
$link->link = 'types.php';

@ -37,21 +37,21 @@ function remote_connect($typeid) {
global $remote_connections;
if (!array_key_exists($typeid, $remote_connections)) {
// get the available servers
if (!$servers = get_records('quiz_rqp_servers', 'typeid', $typeid)) {
// we don't have a server for this question type
return false;
}
// put them in a random order
shuffle($servers);
// go through them and try to connect to each until we are successful
foreach ($servers as $server) {
if ($remote_connections[$typeid] = rqp_connect($server->url)) {
break; // we have a connection
} else {
// We have a dead server here, should somehow flag that
}
}
// get the available servers
if (!$servers = get_records('quiz_rqp_servers', 'typeid', $typeid)) {
// we don't have a server for this question type
return false;
}
// put them in a random order
shuffle($servers);
// go through them and try to connect to each until we are successful
foreach ($servers as $server) {
if ($remote_connections[$typeid] = rqp_connect($server->url)) {
break; // we have a connection
} else {
// We have a dead server here, should somehow flag that
}
}
}
// check that we did get a connection
if (!$remote_connections[$typeid]) {
@ -71,11 +71,11 @@ function remote_connect($typeid) {
function remote_server_info($url) {
if (!$connection = rqp_connect($url)) {
return false;
return false;
}
$return = rqp_server_info($connection);
if (is_soap_fault($return)) {
$return = false;
$return = false;
}
$return->url = $url;
return $return;

@ -25,10 +25,10 @@
$strmodulename = get_string('modulename', 'quiz');
$stritemtypes = get_string('itemtypes', 'quiz');
$navigation = '<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/index.php">' . get_string('admin') . '</a> -> ' .
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/configure.php">' . get_string('configuration') . '</a> -> ' .
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/modules.php">' . get_string('managemodules') . '</a> -> ' .
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/module.php?module=quiz&amp;sesskey=' . sesskey() . '">' .
get_string('modulename', 'quiz') . '</a> -> ' . $stritemtypes;
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/configure.php">' . get_string('configuration') . '</a> -> ' .
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/modules.php">' . get_string('managemodules') . '</a> -> ' .
'<a href="' . s($CFG->wwwroot) . '/' . s($CFG->admin) . '/module.php?module=quiz&amp;sesskey=' . sesskey() . '">' .
get_string('modulename', 'quiz') . '</a> -> ' . $stritemtypes;
print_header($site->shortname . ': ' . $strmodulename . ': ' . $stritemtypes, $site->fullname, $navigation, '', '', true, '', '');
$straddtypeurl = 'http://';
@ -37,75 +37,75 @@
/// Process submitted data
if ($form = data_submitted() and confirm_sesskey()) {
while (isset($form->add)) { // using like if but with support for break
// check name was given
if (empty($form->name)) {
notify(get_string('missingitemtypename', 'quiz'));
break;
}
// check url was given
if (empty($form->url)) {
notify(get_string('missingitemtypeurl', 'quiz'));
break;
}
// Check server exists and works
if (!$serverinfo = remote_server_info($form->url)) {
notify(get_string('renderingserverconnectfailed', 'quiz', $form->url));
break;
}
// add new type to database unless it exists already
if (!$type = get_record('quiz_rqp_types', 'name', $form->name)) {
$type->name = $form->name;
if (!$type->id = insert_record('quiz_rqp_types', $type)) {
error("Could not save type $type");
}
}
// add new server to database unless it exists already
if (!$server = get_record('quiz_rqp_servers', 'url', $form->url)) {
$server->typeid = $type->id;
$server->url = $form->url;
$server->can_render = $serverinfo->rendering ? 1 : 0;
if (!insert_record('quiz_rqp_servers', $server)) {
error("Could not save server $form->url");
}
}
// print info about new server
print_heading(get_string('serveradded', 'quiz'));
quiz_rqp_print_serverinfo($serverinfo);
while (isset($form->add)) { // using like if but with support for break
// check name was given
if (empty($form->name)) {
notify(get_string('missingitemtypename', 'quiz'));
break;
}
// check url was given
if (empty($form->url)) {
notify(get_string('missingitemtypeurl', 'quiz'));
break;
}
// Check server exists and works
if (!$serverinfo = remote_server_info($form->url)) {
notify(get_string('renderingserverconnectfailed', 'quiz', $form->url));
break;
}
// add new type to database unless it exists already
if (!$type = get_record('quiz_rqp_types', 'name', $form->name)) {
$type->name = $form->name;
if (!$type->id = insert_record('quiz_rqp_types', $type)) {
error("Could not save type $type");
}
}
// add new server to database unless it exists already
if (!$server = get_record('quiz_rqp_servers', 'url', $form->url)) {
$server->typeid = $type->id;
$server->url = $form->url;
$server->can_render = $serverinfo->rendering ? 1 : 0;
if (!insert_record('quiz_rqp_servers', $server)) {
error("Could not save server $form->url");
}
}
// print info about new server
print_heading(get_string('serveradded', 'quiz'));
quiz_rqp_print_serverinfo($serverinfo);
break;
break;
}
}
}
if ($delete and confirm_sesskey()) { // delete server
if ($confirm) {
delete_records('quiz_rqp_servers', 'id', $delete);
} else {
if (!$server = get_record('quiz_rqp_servers', 'id', $delete)) {
error('Invalid server id');
}
if ((count_records('quiz_rqp_servers', 'typeid', $server->typeid) == 1) // this is the last server of its type
and record_exists('quiz_rqp', 'type', $server->typeid)) { // and there are questions using it
$type = get_record('quiz_rqp_types', 'id', $server->typeid);
notify(get_string('serverinuse', 'quiz', $type->name));
}
notice_yesno(get_string('confirmserverdelete', 'quiz', $server->url), 'types.php?delete='.$delete.'&amp;sesskey='.sesskey().'&amp;confirm=true', 'types.php');
}
if ($confirm) {
delete_records('quiz_rqp_servers', 'id', $delete);
} else {
if (!$server = get_record('quiz_rqp_servers', 'id', $delete)) {
error('Invalid server id');
}
if ((count_records('quiz_rqp_servers', 'typeid', $server->typeid) == 1) // this is the last server of its type
and record_exists('quiz_rqp', 'type', $server->typeid)) { // and there are questions using it
$type = get_record('quiz_rqp_types', 'id', $server->typeid);
notify(get_string('serverinuse', 'quiz', $type->name));
}
notice_yesno(get_string('confirmserverdelete', 'quiz', $server->url), 'types.php?delete='.$delete.'&amp;sesskey='.sesskey().'&amp;confirm=true', 'types.php');
}
}
if ($info) { // show info for server
if (!$server = get_record('quiz_rqp_servers', 'id', $info)) {
error('Invalid server id');
}
// Check server exists and works
if (!$serverinfo = remote_server_info($server->url)) {
notify(get_string('renderingserverconnectfailed', 'quiz', $server->url));
} else {
// print the info
print_heading(get_string('serverinfo', 'quiz'));
quiz_rqp_print_serverinfo($serverinfo);
}
if (!$server = get_record('quiz_rqp_servers', 'id', $info)) {
error('Invalid server id');
}
// Check server exists and works
if (!$serverinfo = remote_server_info($server->url)) {
notify(get_string('renderingserverconnectfailed', 'quiz', $server->url));
} else {
// print the info
print_heading(get_string('serverinfo', 'quiz'));
quiz_rqp_print_serverinfo($serverinfo);
}
}
@ -139,15 +139,15 @@
if ($types) {
foreach ($types as $type) {
if (!$servers = get_records('quiz_rqp_servers', 'typeid', $type->id)) {
delete_records('quiz_rqp_types', 'id', $type->id);
} else {
foreach ($servers as $server) {
$actions = '<a title="' . $strinfo . '" href="types.php?info='.$server->id.'&amp;sesskey='.sesskey().'"><img src="../../../../pix/i/info.gif" border="0" alt="'.$strinfo.'" align="absbottom" /></a>&nbsp;<a title="'.$strdelete.'" href="types.php?delete='.$server->id.'&amp;sesskey='.sesskey().'"><img src="../../../../pix/t/delete.gif" border="0" alt="'.$strdelete.'" /></a>';
$serverurl = ($info == $server->id) ? '<b>'.$server->url.'</b>' : $server->url;
$table->add_data(array($type->name, $serverurl, $actions));
}
$table->add_data(array('','',''));
}
delete_records('quiz_rqp_types', 'id', $type->id);
} else {
foreach ($servers as $server) {
$actions = '<a title="' . $strinfo . '" href="types.php?info='.$server->id.'&amp;sesskey='.sesskey().'"><img src="../../../../pix/i/info.gif" border="0" alt="'.$strinfo.'" align="absbottom" /></a>&nbsp;<a title="'.$strdelete.'" href="types.php?delete='.$server->id.'&amp;sesskey='.sesskey().'"><img src="../../../../pix/t/delete.gif" border="0" alt="'.$strdelete.'" /></a>';
$serverurl = ($info == $server->id) ? '<b>'.$server->url.'</b>' : $server->url;
$table->add_data(array($type->name, $serverurl, $actions));
}
$table->add_data(array('','',''));
}
}
}