-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
-<?php //$Id$
+<?php
// This file keeps track of upgrades to
// the glossary module
return $result;
}
-?>
+
-$Id$
-
GLOSSARY FORMAT PLUGINS
-----------------------
Starting with Moodle 1.4, the glossary module supports a plugin
-architecture to create your own formats. This plugin system allows
+architecture to create your own formats. This plugin system allows
you to "invent" your own presentations for your glossary data. :-)
-To facilitate the creation process a TEMPLATE format has been created.
+To facilitate the creation process a TEMPLATE format has been created.
You should use it as the base for your own modifications (this requires
some basic PHP skills). The template includes all the available data.
For further reference in this document, we call it "THENAME".
2.-Duplicate the TEMPLATE directory (under mod/glossary/formats/TEMPLATE).
3.-Rename it to THENAME
-4.-Go into the THENAME directory and rename the TEMPLATE_format.php file
+4.-Go into the THENAME directory and rename the TEMPLATE_format.php file
to THENAME_format.php
5.-Edit the THENAME_format.php file. Change every ocurrence of TEMPLATE to
THENAME.
7.-Edit (configure) your glossary. In the Format popup you'll see a new
entry. It will be showed as "displayformatTHENAME". Select it and view
your glossary.
-8.-Edit the THENAME_format.php. Make your format modifications and reload your
- web page to see them in your glossary. This file has been commented to make
+8.-Edit the THENAME_format.php. Make your format modifications and reload your
+ web page to see them in your glossary. This file has been commented to make
things easier to understand (further suggestions welcome!)
9.-If you want to translate your THENAME format name to some nice name to
be showed in the Format popup, simply, edit your lang/XX/glossary.php
-<?php // $Id$
+<?php
function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $ratings=NULL, $aliases=true) {
global $CFG, $USER, $DB, $OUTPUT;
-
+
$user = $DB->get_record('user', array('id'=>$entry->userid));
$strby = get_string('writtenby', 'glossary');
if ($entry) {
-
+
echo '<table class="glossarypost TEMPLATE">';
echo '<tr>';
echo '<td class="entryheader">';
//Comments: Configuration not supported
echo get_string('lastedited').': '. userdate($entry->timemodified) . '<br /></span>';
- //Use this function to show the approval button. It'll be shown if necessary
+ //Use this function to show the approval button. It'll be shown if necessary
//Comments: You can configure this parameters:
//----Define where to show the approval button
$approvalalign = 'right'; //Values: left, center and right (default right)
//Use this function to show the attachment. It'll be showed if necessary
//Comments: You can configure this parameters:
- //----Define how to show the attachment
+ //----Define how to show the attachment
$attachmentformat = 'html'; //Values: html (link) and NULL (inline image if possible) (default NULL)
//----Define where to show the attachment
$attachmentalign = 'right'; //Values: left, center and right (default right)
//Line separator not normally needed now.
//echo "<br />\n";
- //Use this function to show the definition
+ //Use this function to show the definition
//Comments: Configuration not supported
glossary_print_entry_definition($entry, $glossary, $cm);
// use it only if you are really sure!
//$printicons = false;
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
-
+
echo '</td>';
echo '</tr>';
echo "</table>\n";
- } else {
+ } else {
echo '<div style="text-align:center">';
print_string('noentry', 'glossary');
echo '</div>';
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $ratings=NULL, $aliases=false) {
glossary_print_entry_definition($entry, $glossary, $cm);
$entry->alias = '';
echo '</td></tr>';
-
+
echo '<tr valign="top"><td class="entrylowersection">';
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
echo '</td>';
//Call to view function (without icons, ratings and aliases) and return its result
return glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
-
+
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $ratings=NULL, $aliases=true) {
return glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode='',$hook='',$printicons=1,$ratings=NULL, $aliases=true) {
global $CFG, $USER, $DB, $OUTPUT;
echo '<table class="glossarypost encyclopedia" cellspacing="0">';
echo '<tr valign="top">';
echo '<td class="left picture">';
-
+
echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
-
+
echo '</td>';
echo '<th class="entryheader">';
echo '<div class="concept">';
echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
echo '</th>';
-
+
echo '<td class="entryapproval">';
glossary_print_entry_approval($cm, $entry, $mode);
echo '</td>';
-
+
echo '</tr>';
echo '<tr valign="top">';
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings, $aliases);
echo ' ';
}
-
+
echo '</td></tr>';
echo "</table>\n";
-
+
} else {
echo '<div style="text-align:center">';
print_string('noentry', 'glossary');
echo '</div>';
}
-
+
return $return;
}
$entry->definition = '<span class="nolink">'.$entry->definition.'</span>';
//Call to view function (without icons, ratings and aliases) and return its result
-
+
return glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $ratings=NULL, $aliases=true) {
global $USER;
return $return;
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
global $USER;
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
global $CFG, $USER, $DB, $OUTPUT;
if ($entry) {
echo '<table class="glossarypost fullwithauthor" cellspacing="0">';
echo '<tr valign="top">';
-
+
echo '<td class="picture">';
echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
echo '</td>';
-
+
echo '<th class="entryheader">';
echo '<div class="concept">';
echo '<tr valign="top">';
echo '<td class="left"> </td>';
echo '<td colspan="2" class="entrylowersection">';
-
+
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
echo ' ';
echo '</td></tr>';
}
-?>
+
-<?php // $Id$
+<?php
function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
global $CFG, $USER;
echo '</td></tr>';
echo '<tr valign="top"><td colspan="2" class="entrylowersection">';
$return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
-
+
echo ' ';
echo '</td></tr>';
echo "</table>\n";
}
-?>
+
-<?php // $Id$
+<?php
require_once("$CFG->libdir/simpletest/portfolio_testclass.php");
require_once("$CFG->dirroot/mod/glossary/lib.php");
require_once("$CFG->dirroot/$CFG->admin/generator.php");
parent::test_caller_with_plugins();
}
}
-?>
+
/**
* SQL.PHP
* This file is include from view.php and print.php
+ * @version $Id$
* @copyright 2003
**/
-<?php // $Id$
+<?php
if (!isset($sortorder)) {
$sortorder = '';
- }
+ }
if (!isset($sortkey)) {
$sortkey = '';
}
-
+
//make sure variables are properly cleaned
$sortkey = clean_param($sortkey, PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
$sortorder = clean_param($sortorder, PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC)
}
- $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW,
+ $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW,
$CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&mode=letter',
get_string('standardview', 'glossary'));
- $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW,
- $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&mode=cat',
+ $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW,
+ $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&mode=cat',
get_string('categoryview', 'glossary'));
- $browserow[] = new tabobject(GLOSSARY_DATE_VIEW,
+ $browserow[] = new tabobject(GLOSSARY_DATE_VIEW,
$CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&mode=date',
get_string('dateview', 'glossary'));
- $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW,
+ $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW,
$CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&mode=author',
get_string('authorview', 'glossary'));
<div class="entrybox">
<?php
-
+
if (!isset($category)) {
$category = "";
}
-
+
switch ($tab) {
case GLOSSARY_CATEGORY_VIEW:
glossary_print_categories_menu($cm, $glossary, $hook, $category);
glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
if ($mode == 'search' and $hook) {
echo "<h3>$strsearch: $hook</h3>";
- }
+ }
break;
- }
+ }
echo '<hr />';
?>
-<?php // $Id$
+<?php
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of glossary
$module->requires = 2009041700; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
-?>
+
$PAGE->navbar->add($strwaitingapproval);
echo $OUTPUT->header();
echo $OUTPUT->heading($strwaitingapproval);
-} else { /// Print standard header
+} else { /// Print standard header
echo $OUTPUT->header();
}
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
-?>
\ No newline at end of file
This software is provided "AS IS" without a warranty of any kind.
Sponsors who have generously contributed to the development of this software:
- - Agencia de Gestio d'Ajuts Universitaris i de Recerca (AGAUR),
+ - Agencia de Gestio d'Ajuts Universitaris i de Recerca (AGAUR),
Autonomous Government of Catalonia, Spain
(via Josep M. Fontana, Universitat Pompeu Fabra)
- Rikkyo Univeristy, Japan (via Paul Allum)
TO INSTALL OR UPDATE THE HOTPOT MODULE
======================================
- You should install only this module by installing a complete Moodle 1.9 package.
+ You should install only this module by installing a complete Moodle 1.9 package.
- Similarly, the recommended way to upgrade this module is to upgrade to a complete Moodle 1.8 package.
+ Similarly, the recommended way to upgrade this module is to upgrade to a complete Moodle 1.8 package.
However, it is possible to download and unzip a complete Moodle 1.9 package and extract the "mod/hotpot" folder for use on your live Moodle 1.8 site.
5. On the main page for the Moodle course, confirm editing is turned on (click the "Turn editing on" button), then, in the section where you want to add the HotPot activity, select "Hot Potatoes Quiz" on the "Add an activity" drop-down menu .
- If "Hot Potatoes Quiz" does not appear on the "Add an activity" menu, you may need to enable the HotPot module as follows:
+ If "Hot Potatoes Quiz" does not appear on the "Add an activity" menu, you may need to enable the HotPot module as follows:
a) from the site's front page select "Admin" then "Modules"
b) click the "closed eye" icon for the "Hot Potatoes Quiz" module
** Reproduced from the Hot Potatoes site **
Hot Potatoes is offered free to the educational community by the University of Victoria Humanities Computing and Media Centre (formerly the Language Centre), under certain conditions. Hot Potatoes is free for use by state educational institutions which are non-profit making, on the condition that the material produced using the program is freely available to anyone via the WWW. However, you need to purchase a licence under any of the following conditions:
-* You do not work for a public sector educational establishment.
-* You charge money for access to the material you make with Hot Potatoes.
-* You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
+* You do not work for a public sector educational establishment.
+* You charge money for access to the material you make with Hot Potatoes.
+* You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
* You want to use the Masher program included with the Hot Potatoes suite.
For more information on licences, and details on how to purchase one, check out our Website at:
}
}
- // redirect to the next quiz or the course page
+ // redirect to the next quiz or the course page
redirect($next_url, get_string('resultssaved', 'hotpot'));
}
}
// remove "correct" and "wrong" values from "ignored" values
- $response->ignored = array_diff($response->ignored,
+ $response->ignored = array_diff($response->ignored,
$response->correct, $response->wrong, $oldresponse->correct, $oldresponse->wrong
);
// $attempt->status = HOTPOT_STATUS_INPROGRESS;
}
-?>
+
-<?PHP //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//quiz mods
//-----------------------------------------------------------
$search = "/($base)([a-z]+).php\?([a-z]+)\=([0-9]+)/";
return preg_replace($search, '$@HOTPOT*$2*$3*$4@$', $content);
}
-?>
+
-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
$DB->set_field('modules', 'visible', 0, array('name'=>'hotpot'));
/// Install logging support here
-
+
}
-<?php //$Id$
+<?php
// This file keeps track of upgrades to the hotpot module
//
return $result;
}
-?>
+
redirect('view.php?id='.$cm->id);
}
-?>
+
<!--
-// PLEASE NOTE that this version is more recent than the incorrectly
-// numbered v6.1, dated 2003.11.17. From now on, version numbers will
+// PLEASE NOTE that this version is more recent than the incorrectly
+// numbered v6.1, dated 2003.11.17. From now on, version numbers will
// follow those of Hot Potatoes.
/* hot-potatoes.js (v6.0.4.0 - 2005.02.18)
* =======================================
* by Gordon Bateson, February 2003
* Copyright (c) 2003 Gordon Bateson. All Rights Reserved.
*
- * You are hereby granted a royalty free license to use or modify this
- * software provided that this copyright notice appears on all copies.
+ * You are hereby granted a royalty free license to use or modify this
+ * software provided that this copyright notice appears on all copies.
*
* This software is provided "AS IS" without a warranty of any kind.
- *
- * Documentation and downloads may be available from:
+ *
+ * Documentation and downloads may be available from:
* http://www.kanazawa-gu.ac.jp/~gordon/research/hot-potatoes/
*/
-// This JavaScript library modifies the SendResults and StartUp functions
+// This JavaScript library modifies the SendResults and StartUp functions
// used by hotpot v5 and v6, so that more (or less!) details about the
-// student can be input, and more details of a quiz's questions and answers
+// student can be input, and more details of a quiz's questions and answers
// can be submitted to the server when the quiz is finished
-// If the arrays below (Login, DB, JBC, ...) are set BEFORE calling this
-// script, they will NOT be overwritten. Any array that is not set, will
-// use the defaults below. This is useful if you want to use different
+// If the arrays below (Login, DB, JBC, ...) are set BEFORE calling this
+// script, they will NOT be overwritten. Any array that is not set, will
+// use the defaults below. This is useful if you want to use different
// settings for different quizzes.
// ************
// Login Screen
if (window.Login==null) {
Login = new Array();
Login[0] = true; // Show prompt for user name
- // This can also be a string of user names ...
+ // This can also be a string of user names ...
// Login[0] = "Guest,Peter,Paul,Mary,Webmaster";
// or an array of user names (and on-screen texts) (and passwords) ...
// Login[0] = new Array("Guest", "001,Peter,xxxx", "002,Paul,yyyy", "003,Mary,zzzz", "Webmaster");
// new Array("Webmaster")
// );
Login[1] = true; // Show prompt for student's UserID
- // If there is no password prompt (i.e. Logon[3] is false), this value
+ // If there is no password prompt (i.e. Logon[3] is false), this value
// will be checked against the password information, if any, in Login[0]
Login[2] = false; // Show prompt for student's email
- Login[3] = false; // Show prompt for quiz password, and check this value against
+ Login[3] = false; // Show prompt for quiz password, and check this value against
// the password information, if any, in Login[0]
// This can also be a string required to start the quiz ...
// Login[3] = "password";
Login[4] = true; // Show prompt for the cookie expiry date
// If false, cookies expire at the end of the current session
Login[5] = "guest,webmaster"
- // guest user names (case insensitive) ...
- // Login[5] = "guest,webmaster";
+ // guest user names (case insensitive) ...
+ // Login[5] = "guest,webmaster";
// These users do NOT need to fill in other login fields
// and their quiz results are NOT added to the database
- // the Login prompts and error messages
+ // the Login prompts and error messages
// are defined in the MSG array (see below)
}
// *********
if (window.DB==null) {
DB = new Array();
DB[0] = true; // append form fields to database on server
- // If you are NOT using BFormMail's database feature,
+ // If you are NOT using BFormMail's database feature,
// set DB[0]=false, and you can then safely ignore DB[1 to 5]
- DB[1] = "/home/gordon/public_html/cgi/hot-potatoes-data";
+ DB[1] = "/home/gordon/public_html/cgi/hot-potatoes-data";
// append_db folder path (no trailing slash)
// Can be either an absolute path e.g. "/home/gordon/public_html/cgi/hot-potatoes-data"
// or a relative (to CGI bin) path e.g. "hot-potatoes-data"
- DB[2] = "hot-potatoes";
+ DB[2] = "hot-potatoes";
// append_db file name (no extension)
// If left blank, the quiz file name, without extension, will be used
// i.e. each quiz will have its results stored in a different file.
// If filled in, this file will store the results for ALL quizzes.
- // Database files and folders must be set up BEFORE running the quiz
+ // Database files and folders must be set up BEFORE running the quiz
// must have appropriate access privileges (on Unix, use "chmod 666").
DB[3] = ""; // append_db extension (if left blank, ".txt" will be used)
DB[4] = ""; // db_fields (if left blank, ALL quiz fields will be sent)
DB[5] = ""; // db_delimiter (if left blank, tab will be used)
- DB[6] = "REMOTE_ADDR,HTTP_USER_AGENT";
+ DB[6] = "REMOTE_ADDR,HTTP_USER_AGENT";
// env_report ('REMOTE_ADDR','HTTP_USER_AGENT' and a few others)
- // for a complete description of these fields are, see ...
+ // for a complete description of these fields are, see ...
// http://www.infosheet.com/stuff/BFormMail.readme
// Switches DB[7] and DB[8] force the settings in the ResultForm
// In v5 and v6 quizzes, these settings wil be override those in the original quiz
DB[8] = ''; // email address to which results should be sent
// e.g. gordon@kanazawa-gu.ac.jp
}
-// By default the quiz's question's scores will be returned.
+// By default the quiz's question's scores will be returned.
// If you want more detailed information, set the flags below:
// ********
// JBC
// [0] : (unused)
// [1] : array of JCLOZE_ANSWER_TEXTs
// [2] : clue for this answer
-// JCLOZE_ANSWER_TEXT :
+// JCLOZE_ANSWER_TEXT :
// [0] : array (seems unnecessary, just the text would be enough?)
// [0] : text of possible answer
// State : array of JCLOZE_ANSWER_STATEs
-// JCLOZE_ANSWER_STATE (v5) :
+// JCLOZE_ANSWER_STATE (v5) :
// [0] : clue asked for or not
// [1] : number of hints (show next letter) and penalties ('check' an incorrect answer)
// [2] : length of answer matched
// [3] : score for this item
-// [4] : already answered correctly
+// [4] : already answered correctly
// [5] : answer entered in text box (right or not)
// JCLOZE_ANSWER_STATE (v6)
// this.ClueGiven = false;
JCross[8] = true; // show number of checks
// there are no "ignored" answers for JCross quizzes
}
-// JCross quizzes use the following global variables:
+// JCross quizzes use the following global variables:
// L : letters (of correct answers)
// C : clue numbers (CL in v6)
// G : guesses
// 'L', 'C' ('CL') and 'G' are all 2-dimensional arrays (rows x cols)
//
// v5 quizzes additionally use the following single-dimension arrays
-// A : clues for across (horizontal) words
-// D : clues for down (vertical) words
-// N.B. form is only sent when all answers are correct so
+// A : clues for across (horizontal) words
+// D : clues for down (vertical) words
+// N.B. form is only sent when all answers are correct so
// you can't find out what 'wrong' answers were entered
// ********
// JMatch
// [0] : text
// [1] : tag of the F item to which it SHOULD be dragged
// [2] : tag of the F item to which it was dragged (initally 0)
-// N.B. form is only sent when all answers are correct so
+// N.B. form is only sent when all answers are correct so
// you can't find out what 'wrong' answers were entered
// ********
// JMix
JMix[5] = true; // show number of checks
JMix[6] = true; // show number of hints (=show next word)
}
-// JMix quizzes use the global variables
-// 'Segments', 'GuessSequence' and 'Penalties'
+// JMix quizzes use the global variables
+// 'Segments', 'GuessSequence' and 'Penalties'
// Segments : array of JMix_QUESTIONs
// JMix_QUESTION:
// [0] : text
// [0] : array (seems unnecessary, just the text would be enough?)
// [0] : text of possible answer
// Status : array of JQUIZ_ANSWER_STATEs
-// JQUIZ_ANSWER_STATE :
+// JQUIZ_ANSWER_STATE :
// [0] : question done or not
// [1] : number of wrong checks
// [2] : number of hints asked for
// [1] : feedback text
// [2] : correct answer flag (1=a correct answer, 0=a wrong answer)
// [3] : weighted score (as percentage) if correct
-// [4] : flag (usually set to 1, but for hybrid answers that are not
+// [4] : flag (usually set to 1, but for hybrid answers that are not
// to be included in multiple choice options, it is set to 0)
// State : array of JQUIZ_QUESTION_STATEs
-// JQUIZ_QUESTION_STATE :
+// JQUIZ_QUESTION_STATE :
// [0] : score (-1 shows not done yet)
// [1] : array showing on which number try each JQUIZ_ANSWER was selected
// [2] : number of attempts at this question
// [3] : total of weighted scores of correct answers that were selected
-// i.e. each time a correct answer is selected,
+// i.e. each time a correct answer is selected,
// its JQUIZ_ANSWER[3] weighting is added to this total
// so when all the correct answers have been selected, this will be 100
// [4] : penalties incurred for hints (score is set to zero if >= 1)
// [5] : - for multiple choice, short-answer and hybrid questions, this is a
// comma-delimited list showing order in which answers were chosen
-// - for multi-select fields, this is bar-delimted ('|') list of settings
-// showing whether each checkbox was selected ('Y') on not ('N') when the
-// 'Check' button was clicked. The final item in the list will be the
+// - for multi-select fields, this is bar-delimted ('|') list of settings
+// showing whether each checkbox was selected ('Y') on not ('N') when the
+// 'Check' button was clicked. The final item in the list will be the
// settings for the correct answer.
// N.B. JBC, JMatch(v5) and JQuiz(v5) all use global variables 'I' and 'Status'
// JBC : I[0].length==3 && !window.RItems
function getValue(w, n, flag) {
var obj = w.document.forms[0].elements[n];
var TYPE = obj.type.toUpperCase(); // required for ns4 (win)
- if (obj.options && TYPE.indexOf('SELECT')>=0){
+ if (obj.options && TYPE.indexOf('SELECT')>=0){
var v = obj.options[obj.selectedIndex].value;
} else {
var v = obj.value;
if (n=='Password' || (n=='UserID' && !Login[3])) {
var pwd = getPassword(w);
if (pwd && v!=pwd) msg = MSG[n=='Password' ? 13 : 14];
- }
+ }
if (n=='UserEmail' && window.RegExp) {
var r = '(\\w|-)+';
r = r + '(\\.' + r + ')';
// if this is a Netscape browser, check if the referer will be set OK
if (navigator.appName=='Netscape' && (location.protocol=='file:' || navigator.userAgent.indexOf('Netscape6')>=0)) {
// ns4 and ns7 set referer to 'file:// ...' when running a quiz offline
- // ns6.2 (at least) always sets referer to 'about:blank'
+ // ns6.2 (at least) always sets referer to 'about:blank'
// Netscape's setting of referer can cause BFormMail
// to reject the form, so encode the form data as a URL
var url = form.action;
var hp = hpVersion();
var t = hpQuizType();
var v = hpQuizVersion();
- return (t==1) ? GetJbcQuestionDetails(hp, v) :
- (t==2) ? GetJClozeQuestionDetails(hp, v) :
- (t==3) ? GetJCrossQuestionDetails(hp, v) :
- (t==4) ? GetJMatchQuestionDetails(hp, v) :
- (t==5) ? GetJMixQuestionDetails(hp, v) :
+ return (t==1) ? GetJbcQuestionDetails(hp, v) :
+ (t==2) ? GetJClozeQuestionDetails(hp, v) :
+ (t==3) ? GetJCrossQuestionDetails(hp, v) :
+ (t==4) ? GetJMatchQuestionDetails(hp, v) :
+ (t==5) ? GetJMixQuestionDetails(hp, v) :
(t==6) ? GetJQuizQuestionDetails(hp, v) :
(t==7) ? GetRhubarbDetails(hp, v) :
(t==8) ? GetSequiturDetails(hp, v) : '';
qDetails = '';
// check the quiz version
if (hp==5 || hp==6) {
- // get question details
+ // get question details
for(var q=0; q<I.length; q++) {
// initialize strings to hold answer details
var aDetails = new Array();
aDetails[2] = new Array(); // ignored
// get answer details
for(var a=0; a<I[q][1].length; a++) {
- var i = (Status[q][1][a]=='R') ? 0 : (Status[q][1][a]=='0') ? 2 : 1;
+ var i = (Status[q][1][a]=='R') ? 0 : (Status[q][1][a]=='0') ? 2 : 1;
aDetails[i][aDetails[i].length] = (JBC[6] ? a : I[q][1][a][0]);
}
// format 'Q' (a padded, two-digit version of 'q')
for (var row=0; row<L.length; row++) {
for (var col=0; col<L[row].length; col++) {
// increment letter count, if required
- if (L[row][col]) letters++;
+ if (L[row][col]) letters++;
// show answers and clues, if required
var q = (hp==5) ? C[row][col] : CL[row][col];
if (q) {
}
x[i] = a.join('+');
}
- } else if (x) { // multiple-choice, short-answer and hybrid
+ } else if (x) { // multiple-choice, short-answer and hybrid
if (x.charAt(x.length-1)==',') {
// HP 6.0 and 6.1 (always has trailing comma)
x = x.substring(0, x.length-1).split(',');
if (window.MakeIndividualDropdowns) {
var is_wrong = (ii!=0);
g = I[i][1][ii][0];
- } else {
+ } else {
var is_wrong = (ii!=i);
g = I[ii][1][0][0];
}
if (!HP[_guesses][i]) HP[_guesses][i] = new Array();
var ii = HP[_guesses][i].length;
// is this a new guess at this gap?
- if (ii==0 || g!=HP[_guesses][i][ii-1]) {
+ if (ii==0 || g!=HP[_guesses][i][ii-1]) {
HP[_guesses][i][ii] = g;
if (r==1) {
// Rottmeier DropDown 2.4
- // do nothing
+ // do nothing
} else {
var G = g.toUpperCase();
var ii_max = I[i][1].length;
var values = value;
var i_max = values.length;
value = '';
- if (comma==null) comma = ',';
+ if (comma==null) comma = ',';
for (var i=0; i<i_max; i++) {
values[i] = trim(values[i]);
if (values[i]!=null && values[i]!='') {
// get year, month and day
// for an LMS : yyyy-mm-dd
// for email : DayName MonthName dd yyyy
- var s = is_LMS() ?
- obj.getFullYear() + '-' + pad(obj.getMonth()+1, 2) + '-' + pad(obj.getDate(), 2) :
+ var s = is_LMS() ?
+ obj.getFullYear() + '-' + pad(obj.getMonth()+1, 2) + '-' + pad(obj.getDate(), 2) :
MSG[16][obj.getDay()] + ' ' + MSG[17][obj.getMonth()] + ' ' + pad(obj.getDate(), 2) + ' ' + obj.getFullYear()
;
// get hours, minutes and seconds (hh:mm:ss)
// Note: netscape uses double-quote as delimiter, others use single quote
var s = getFuncCode(fn);
var i1 = s.indexOf('prompt') + 8;
- var i2 = s.indexOf(s.charAt(i1-1), i1);
+ var i2 = s.indexOf(s.charAt(i1-1), i1);
var p = (i1>=8 && i2>i1) ? s.substring(i1, i2) : '';
// make sure browser has decoded the unicode prompt properly
// this check is mainly for ns4, but there may be others
}
function getStartUpCode(fn) {
// the main initialization code comes from the StartUp function
- // v5 : the code before "UserName", if any,
+ // v5 : the code before "UserName", if any,
// and the code after the 2nd subsequent '}'
- // v6 : the code before and after 'GetUserName();'
+ // v6 : the code before and after 'GetUserName();'
// i.e. all the code except the call to 'GetUserName();'
var s = getFuncCode(fn);
var i1 = s.indexOf('GetUserName();');
- if (i1>=0) { // v6
+ if (i1>=0) { // v6
var i2 = i1 + 14;
} else { // v5
var i1 = s.indexOf('UserName');
if (a[0]=='ShowHint') {
if (a[1]=='QNum') {
// JQuiz v3, v5-v6[HP5]
- x = 'if(ShowHint)hpClick(1,QNum);';
+ x = 'if(ShowHint)hpClick(1,QNum);';
} else {
// JQuiz v4
x = 'if(ShowHint)hpClick(1,QNum-1);'; // QNum is a global variable
// JCross none
// JMatch HP5 v3, v5, v6: CheckAnswer(), HP5 v4: CheckResults(), HP6: CheckAnswers()
// JMix CheckAnswer(CheckType)
- // JQuiz
+ // JQuiz
// HP5: CheckAnswer(ShowHint, QNum)
// HP6: CheckMCAnswer, CheckMultiSelAnswer, CheckShortAnswer
// Rhubarb CheckWord(InputWord)
if (a[0]=='ShowHint') {
if (a[1]=='QNum') {
// JQuiz v3, v5-v6[HP5]
- x = 'if(!ShowHint&&Status[QNum][0]<1)hpClick(3,QNum);';
+ x = 'if(!ShowHint&&Status[QNum][0]<1)hpClick(3,QNum);';
} else {
// JQuiz v4
x = 'if(!ShowHint&&State[QNum-1][0]<1)hpClick(3,QNum-1);'; // QNum is a global variable
// Sequitur
x = 'if (!(CurrentNumber==TotalSegments||AllDone||Btn.innerHTML==IncorrectIndicator))hpClick(3,Chosen);';
}
- } else if (window.CheckWord) {
+ } else if (window.CheckWord) {
f = 'CheckWord';
var a = getFuncArgs(f, true);
if (a[0]=='InputWord') {
Array.prototype.push = new Function("x", "this[this.length]=x");
}
// add attachEvent function, if required (allows HP5 v6 quizzes to run on ie5mac)
-// NOTE: to allow v6 quizzes on ie5mac, the following code
+// NOTE: to allow v6 quizzes on ie5mac, the following code
// needs to be inserted BEFORE the Hot Potatoes javascript
if (window.attachEvent==null) {
window.attachEvent = new Function('evt', 'fn', 'eval("window."+evt+"="+fn)');
// JBC uses "QForm" form, which contains elements called "FB_*_**" (* and ** start at 0)
// JCloze uses "Cloze" form
// JCross writes out "AnswerForm" from a variable called "GetAnswerOpener"
-// HP5.3: uses "AnswerForm" in "BottomFrame"
+// HP5.3: uses "AnswerForm" in "BottomFrame"
// HP5.5: uses "AnswerForm" in "TopFrame", but it is only there when an answer is being input
// JMatch uses "QForm" form, which contains elements called "sel*" (which disappear by the time the quiz is finished)
// JMix uses "ButtonForm"
// === v6 ===
// JBC uses "QForm" form (elements have no name or id)
// JCloze uses "Cloze" form (elements have no name or id)
-// JCross does not use any forms,
+// JCross does not use any forms,
// HP5: has "GridDiv" in "MainDiv"
// HP6: has "Clues" table in "MainDiv"
// JMatch has "MatchDiv" in "MainDiv"
// HP5: uses "QForm" form, which contains elements called "sel*"
// HP6: uses "QForm" form, which contains elements called "s*_**"
// JMix does not use any forms, but has "SegmentDiv" in "MainDiv"
-// JQuiz
+// JQuiz
// HP5: uses "QForm" form, which contains an element called "Guess"
// HP6: has "Questions" ordered list in "MainDiv"
// === v6+ ===
}
function hpFinished() {
// assume false result
- var x = false;
+ var x = false;
var hp = hpVersion();
var t = hpQuizType();
var v = hpQuizVersion();
}
}
// create form to send results
-if (DB[7] && DB[8] && !is_LMS()) {
+if (DB[7] && DB[8] && !is_LMS()) {
ResultForm = ''
+ '<html><body>'
+ '<form name="Results" action="" method="post" enctype="x-www-form-encoded">'
// do nothing (user is not diplaying this section)
} else {
$hotpots[$hotpot_instance->id] = $hotpot_instance;
- }
+ }
}
}
if (empty($hotpots)) {
if ($concat_field) {
$records = $DB->get_records_sql("
SELECT $concat_field, COUNT(*), hotpot, name
- FROM {hotpot_questions}
+ FROM {hotpot_questions}
WHERE hotpot IN ($hotpotids)
- GROUP BY hotpot, name
+ GROUP BY hotpot, name
HAVING COUNT(*) >1
");
if ($records) {
}
switch ($course->format) {
- case 'weeks' :
+ case 'weeks' :
$title = get_string("week");
break;
- case 'topics' :
+ case 'topics' :
$title = get_string("topic");
break;
- default :
+ default :
$title = '';
break;
}
if ($title) {
- array_push($table->head, $title);
+ array_push($table->head, $title);
array_push($table->align, "center");
}
if (has_capability('moodle/course:manageactivities', $coursecontext)) {
array_push($table->head, $strupdate);
array_push($table->align, "center");
}
- array_push($table->head,
- get_string("name"),
- get_string("quizcloses", "quiz"),
- get_string("bestgrade", "quiz"),
+ array_push($table->head,
+ get_string("name"),
+ get_string("quizcloses", "quiz"),
+ get_string("bestgrade", "quiz"),
get_string("attempts", "quiz")
);
- array_push($table->align,
+ array_push($table->align,
"left", "left", "center", "left"
);
if (has_capability('mod/hotpot:grade', $coursecontext)) {
$bestscore = " ";
} else {
-
+
$cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
// report number of attempts and users
$report = get_string("viewallreports","quiz", $totals[$hotpot->id]->attemptcount);
// Finish the page
echo $OUTPUT->footer();
-?>
+
$event->timeduration = ($hotpot->timeclose - $hotpot->timeopen);
if ($event->timeduration > HOTPOT_MAX_EVENT_LENGTH) { /// Long durations create two events
-
+
$event->name = $hotpot->name.' ('.get_string('hotpotopens', 'hotpot').')';
$event->timeduration = 0;
add_event($event);
-
+
$event->timestart = $hotpot->timeclose;
$event->eventtype = 'close';
$event->name = $hotpot->name.' ('.get_string('hotpotcloses', 'hotpot').')';
if ($rawmods = $DB->get_records_sql($query, $params)) {
// cache $isteacher setting
-
+
$isteacher = has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_COURSE, $course->id));
$explodesection = array();
foreach ($records as $id => $record){
if ($cm = get_coursemodule_from_instance('hotpot', $record->id, $course->id)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+
if (has_capability('mod/hotpot:viewreport', $context)) {
$href = "$CFG->wwwroot/mod/hotpot/view.php?hp=$id";
$name = ' <a href="'.$href.'">'.$record->name.'</a>';
* it it has support for grading and scales. Commented code should be
* modified if necessary. See forum, glossary or journal modules
* as reference.
- *
+ *
* @param int $hotpotid
* @param int $scaleid
* @return bool
$attempt->status = HOTPOT_STATUS_ABANDONED;
$DB->update_record('hotpot_attempts', $attempt);
}
- }
+ }
// create and add new attempt record
$attempt = new stdClass();
/**
* @global object
* @param string $str
- * @return int|string
+ * @return int|string
*/
function hotpot_string_id($str) {
global $DB;
/**
* Called by course/reset.php
- *
+ *
* @param $mform form passed by reference
*/
function hotpot_reset_course_form_definition(&$mform) {
-<?php // $id$
+<?php
//////////////////////////////////////////////////////////////
// Media plugin filtering
-//
-// This filter will replace any links to a media file with
+//
+// This filter will replace any links to a media file with
// a media plugin that plays that media inline
//
//////////////////////////////////////////////////////////////
-/// This is the filtering function itself. It accepts the
+/// This is the filtering function itself. It accepts the
/// courseid and the text to be filtered (in HTML form).
function hotpot_mediaplayer_moodle(&$hotpot, $text) {
$replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
$replace .= '</embed>';
$replace .= '</object> ';
-
+
$text = preg_replace($search, $replace, $text);
}
if ($CFG->filter_mediaplugin_enable_flv) {
$search = '/<a(.*?)href=\"([^<]+)\.flv\"([^>]*)>(.*?)<\/a>/is';
-
+
$replace = '\\0 <object class="mediaplugin flv" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
$replace .= ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
$replace .= ' width="480" height="360" id="flvplayer">';
$replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
$replace .= '</embed>';
$replace .= '</object> ';
-
+
$text = preg_replace($search, $replace, $text);
}
$replace .= '<param name="autoplay" value="false" />';
$replace .= '<embed src="\\2.\\3" width="240" height="180" controller="true" autoplay="false"> </embed>';
$replace .= '</object></p>';
-
+
$text = preg_replace($search, $replace, $text);
}
$replace .= '<param name="autoplay" value="false" />';
$replace .= '<embed src="\\2.avi" width="240" height="180" controller="true" autoplay="false"> </embed>';
$replace .= '</object></p>';
-
+
$text = preg_replace($search, $replace, $text);
}
-
+
if ($CFG->filter_mediaplugin_enable_ram) {
$search = '/<a(.*?)href=\"([^<]+)\.ram\"([^>]*)>(.*?)<\/a>/is';
$text = preg_replace($search, $replace, $text);
}
-
+
if ($CFG->filter_mediaplugin_enable_rpm) {
$search = '/<a(.*?)href=\"([^<]+)\.rpm\"([^>]*)>(.*?)<\/a>/is';
$text = preg_replace($search, $replace, $text);
}
-
+
if ($CFG->filter_mediaplugin_enable_rm) {
$search = '/<a(.*?)href=\"([^<]+)\.rm\"([^>]*)>(.*?)<\/a>/is';
return $text;
}
-?>
\ No newline at end of file
return $errors;
}
}
-?>
\ No newline at end of file
-<?PHP // $Id$
+<?php
// This script uses installed report plugins to print quiz reports
}
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
- }
+ }
if (! $hotpot = $DB->get_record("hotpot", array("id"=>$cm->instance))) {
print_error('invalidhotpotid', 'hotpot');
}
$fields = 'a.*, u.firstname, u.lastname, u.picture';
if ($mode=='click') {
$fields .= ', u.idnumber';
- } else {
- // overview, simple and detailed reports
+ } else {
+ // overview, simple and detailed reports
// get last attempt record in clickreport series
$ids = array();
foreach ($cr_attempts as $cr_attempt) {
}
if (count($ids)) {
list($ids, $idparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'crid0');
- $params = array_merge($params, $idparams);
+ $params = array_merge($params, $idparams);
$select = "hotpot=:hotpotid AND clickreportid $ids";
}
break;
}
//////////////////////////////////////////////
-/// functions to print the report headings and
+/// functions to print the report headings and
/// report selector menus
function hotpot_print_report_heading(&$course, &$cm, &$hotpot, &$mode) {
global $OUTPUT;
$strmodulenameplural = get_string("modulenameplural", "hotpot");
$strmodulename = get_string("modulename", "hotpot");
-
+
$modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if (has_capability('mod/hotpot:viewreport',$modulecontext)) {
if ($mode=='overview' || $mode=='simplestat' || $mode=='fullstat') {
$PAGE->set_heading($course->fullname);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'hotpot'));
echo $OUTPUT->header();
-
+
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
- echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
+ echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
}
echo $OUTPUT->heading($hotpot->name);
// get users who have ever atetmpted this HotPot
$users = $DB->get_records_sql("
- SELECT
+ SELECT
u.id, u.firstname, u.lastname
- FROM
+ FROM
{user} u,
{hotpot_attempts} ha
WHERE
}
return $users[$capability];
}
-?>
+
-<?php // $Id$
+<?php
/// Overview report just displays a big table of all the attempts
class hotpot_report extends hotpot_default_report {
function display(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options) {
if (!function_exists('clean_getstring_data')) { // Moodle 1.4 (and less)
$reportpercentscore = str_replace('%', '%%', $reportpercentscore);
}
- array_push($table->head,
+ array_push($table->head,
get_string('reportthisclick', 'hotpot', get_string('reportquestionstried', 'hotpot')),
get_string('reportsofar', 'hotpot', get_string('reportquestionstried', 'hotpot')),
get_string('reportthisclick', 'hotpot', get_string('reportright', 'hotpot')),
$records = $DB->get_records_sql_menu("
SELECT userid, MIN(time) AS logouttime
FROM {log}
- WHERE userid=? AND action='logout' AND time>?
+ WHERE userid=? AND action='logout' AND time>?
GROUP BY userid
", array($attempt->userid, $attempt->cr_timefinish));
if (empty($records)) {
}
}
} // end class
-?>
+
-<?PHP // $Id$
+<?PHP // $Id$
////////////////////////////////////////////////////////////////////
/// Default class for report plugins
-///
-/// Doesn't do anything on it's own -- it needs to be extended.
-/// This class displays quiz reports. Because it is called from
+///
+/// Doesn't do anything on it's own -- it needs to be extended.
+/// This class displays quiz reports. Because it is called from
/// within /mod/quiz/report.php you can assume that the page header
/// and footer are taken care of.
-///
-/// This file can refer to itself as report.php to pass variables
-/// to itself - all these will also be globally available. You must
+///
+/// This file can refer to itself as report.php to pass variables
+/// to itself - all these will also be globally available. You must
/// pass "id=$cm->id" or q=$quiz->id", and "mode=reportname".
////////////////////////////////////////////////////////////////////
class hotpot_default_report {
- function display($hotpot, $cm, $course, $users, $attempts, $questions, $options) {
+ function display($hotpot, $cm, $course, $users, $attempts, $questions, $options) {
/// This function just displays the report
// it is replaced by the "display" functions in the scripts in the "report" folder
return true;
// add $value to answers array, if it was not there
if ($i==$i_max) {
- $table->legend[$q]['answers'][$i] = $value;
+ $table->legend[$q]['answers'][$i] = $value;
}
// convert $value to alphabetic index (A, B ... AA, AB ...)
foreach($table->legend as $q=>$question) {
$legend->stat[] = array(
- get_string('questionshort', 'hotpot', $q+1),
+ get_string('questionshort', 'hotpot', $q+1),
$question['name']
);
foreach($question['answers'] as $a=>$answer) {
$legend->stat[] = array(
- $this->dec_to_ALPHA($a),
+ $this->dec_to_ALPHA($a),
$answer
);
}
function print_report_finish(&$course, &$hotpot, &$options) {
switch ($options['reportformat']) {
- case 'txt' :
+ case 'txt' :
// do nothing
break;
case 'xls':
$col = 0; // column index
while ($col<$table->colspan && isset($cells[$i])) {
if (empty($skipcol[$col])) {
- $cell = &$cells[$i++];
+ $cell = &$cells[$i++];
$td = $table->td[$col];
if (is_object($cell)) {
$text = $cell->text;
}
function print_text_start(&$course, &$hotpot, &$options) {
$downloadfilename = clean_filename("$course->shortname $hotpot->name.txt");
- header("Content-Type: application/download\n");
+ header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$downloadfilename");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
$this->print_excel_stat($wb, $ws, $table, $row, $options);
$this->print_excel_foot($wb, $ws, $table, $row, $options);
}
-
+
// close the workbook (and send it to the browser)
$wb->close();
}
function print_excel_head(&$wb, &$ws, &$table, &$row, &$options) {
// define format properties
$properties = array(
- 'bold'=>1,
- 'align'=>'center',
+ 'bold'=>1,
+ 'align'=>'center',
'v_align'=>'bottom',
'text_wrap'=>1
);
}
}
-?>
+
-<?php // $Id$
+<?php
/// Overview report just displays a big table of all the attempts
class hotpot_report extends hotpot_default_report {
function display(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options) {
}
// headings for name, attempt number, score/grade and penalties
$table->head = array(
- get_string("name"),
+ get_string("name"),
hotpot_grade_heading($hotpot, $options),
- get_string('attempt', 'quiz'),
+ get_string('attempt', 'quiz'),
);
$table->align = array('left', 'center', 'center');
$table->size = array(150, 80, 10);
// question headings
$this->add_question_headings($questions, $table, 'left', 0, false, 2);
// penalties (not always needed) and raw score
- array_push($table->head,
- get_string('penalties', 'hotpot'),
+ array_push($table->head,
+ get_string('penalties', 'hotpot'),
get_string('score', 'quiz')
);
array_push($table->align, 'center', 'center');
}
$cells = array ($name, $grade, $attemptnumber);
// $name and $grade are only printed on first line per user
- $name = $blank;
+ $name = $blank;
$grade = $blank;
$start_col = count($cells);
foreach ($questionids as $col => $id) {
SHOWHIDE_SET
;
}
-?>
+
-<?php // $Id$
+<?php
/// Overview report just displays a big table of all the attempts
class hotpot_report extends hotpot_default_report {
$table->size[] = 10;
$table->wrap[] = "nowrap";
}
- array_push($table->head,
- get_string("name"),
+ array_push($table->head,
+ get_string("name"),
hotpot_grade_heading($hotpot, $options),
- get_string("attempt", "quiz"),
- get_string("time", "quiz"),
- get_string("reportstatus", "hotpot"),
- get_string("timetaken", "quiz"),
+ get_string("attempt", "quiz"),
+ get_string("time", "quiz"),
+ get_string("reportstatus", "hotpot"),
+ get_string("timetaken", "quiz"),
get_string("score", "quiz")
);
array_push($table->align, "left", "center", "center", "left", "center", "center", "center");
if ($is_html && is_numeric($score) && $score==$user->grade) { // best grade
$score = '<span class="highlight">'.$score.'</span>';
}
- array_push($data,
+ array_push($data,
$attemptnumber,
$checkbox.$starttime,
hotpot_format_status($attempt),
;
} // end function
} // end class
-?>
+
-<?php // $Id$
+<?php
/// Overview report: displays a big table of all the attempts
class hotpot_report extends hotpot_default_report {
function display(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options) {
$table->size[] = 10;
}
// name, grade and attempt number
- array_push($table->head,
+ array_push($table->head,
get_string("name"),
- hotpot_grade_heading($hotpot, $options),
+ hotpot_grade_heading($hotpot, $options),
get_string("attempt", "quiz")
);
array_push($table->align, "left", "center", "center");
// question headings
$this->add_question_headings($questions, $table);
// penalties and raw score
- array_push($table->head,
- get_string('penalties', 'hotpot'),
+ array_push($table->head,
+ get_string('penalties', 'hotpot'),
get_string('score', 'quiz')
);
array_push($table->align, "center", "center");
$tables[] = &$table;
}
} // end class
-?>
+
-<?PHP //$Id$
+<?php
//This php script contains all the stuff to restore hotpot mods
//-----------------------------------------------------------
// This is the "graphical" structure of the hotpot mod:
//-----------------------------------------------------------
//
// hotpot
- // (CL, pk->id,
+ // (CL, pk->id,
// fk->course, files)
// |
// +--------------+---------------+
// | |
// hotpot_attempts hotpot_questions
- // (UL, pk->id, (UL, pk->id,
+ // (UL, pk->id, (UL, pk->id,
// fk->hotpot) fk->hotpot, text)
// | | |
// +-------------------+----------+ |
function hotpot_restore_mods($mod, $restore) {
//This function restores a single hotpot activity
- // This function is called by "restore_create_modules" (in "backup/restorelib.php")
+ // This function is called by "restore_create_modules" (in "backup/restorelib.php")
// which is called by "backup/restore_execute.html" (included by "backup/restore.php")
// $mod is an object
// id : id field in 'modtype' table
// $xml is an XML tree for a hotpot record
// $record is the newly added hotpot record
$foreignkeys = array(
- 'hotpot'=>$record->id,
+ 'hotpot'=>$record->id,
'text'=>'hotpot_strings'
);
return hotpot_restore_records(
// $record_TAG : (optional) the name of an XML tag which starts a single record
// If no $record_TAG is specified, the block of records is assumed to be a single record
// other parameters are explained in "hotpot_restore_record" below
-
+
$i = 0; // index for $records_TAG
do {
unset($xml_records);
// $foreign_keys : array of foreign keys, if any, specifed as $key=>$value
// $key : the name of a field in the current $record
// $value : if $value is numeric, then $record->$key is set to $value.
- // Otherwise $value is assumed to be a table name and $record->$key
+ // Otherwise $value is assumed to be a table name and $record->$key
// is treated as a comma separated list of ids in that table
// $more_restore : optional PHP code to be eval(uated) for each record
- // $secondary_key :
+ // $secondary_key :
// the name of the secondary key field, if any, in the current $record.
// If this field is specified, then the current record will only be added
// if the $record->$secondarykey value does not already exist in $table
static $table_columns = array();
if (empty($table_columns[$table])) {
- global $CFG, $DB;
+ global $CFG, $DB;
$table_columns[$table] = $DB->get_columns($table);
}
}
print "was not restored</li></ul>";
}
- $ok = false;
+ $ok = false;
}
}
}
if (isset($record->old_id)) {
backup_putid($restore->backup_unique_code, $table, $record->old_id, $record->id);
}
- } else {
+ } else {
// failed to add (or find) $record
if (!defined('RESTORE_SILENTLY')) {
print "<ul><li>Record could not be added: table=$table</li></ul>";
break;
case "attempt":
case "submit":
- case "review":
+ case "review":
if ($log->cmid) {
//Get the new_id of the module (to recode the info field)
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
$attemptid = substr(strrchr($log->url,"="),1);
//Get the new_id of the attempt (to recode the url field)
$attempt = backup_getid($restore->backup_unique_code,"hotpot_attempts",$attemptid);
- if ($attempt) {
+ if ($attempt) {
$log->url = "review.php?id=".$log->cmid."&attempt=".$attempt->new_id;
$log->info = $mod->new_id;
$status = true;
return "$CFG->wwwroot/mod/hotpot/$scriptname.php?$paramname=$new_id";
}
-?>
+
}
require_login($course, true, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/hotpot:viewreport',$context)) {
if (!$hotpot->review) {
$value = hotpot_format_status($attempt);
break;
case 'timerecorded':
- $value = empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish);
+ $value = empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish);
break;
case 'timetaken':
- $value = empty($attempt->timefinish) ? '-' : format_time($attempt->timefinish - $attempt->timestart);
+ $value = empty($attempt->timefinish) ? '-' : format_time($attempt->timefinish - $attempt->timestart);
break;
default:
$value = isset($attempt->$field) ? $attempt->$field : NULL;
print "</table>\n";
echo $OUTPUT->box_end();
}
-?>
+
-<?php //$Id$
+<?php
-$settings->add(new admin_setting_configcheckbox('hotpot_showtimes', get_string('showtimes', 'hotpot'),
+$settings->add(new admin_setting_configcheckbox('hotpot_showtimes', get_string('showtimes', 'hotpot'),
get_string('configshowtimes', 'hotpot'), 0) );
$settings->add(new admin_setting_configtext('hotpot_excelencodings', get_string('excelencodings', 'hotpot'),
get_string('configexcelencodings', 'hotpot'), '') );
-?>
+
$rrggbb = '/^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i';
if ((
preg_match($rgb, $x, $x_matches) ||
- preg_match($rrggbb, $x, $x_matches)
+ preg_match($rrggbb, $x, $x_matches)
) && (
preg_match($rgb, $y, $y_matches) ||
preg_match($rrggbb, $y, $y_matches)
return $color;
}
}
-?>
+
-<?PHP
+<?PHP
class hotpot_xml_quiz_template extends hotpot_xml_template_default {
// left and right items for JMatch
function hotpot_xml_quiz_template(&$parent) {
$this->parent = &$parent;
-
+
$get_js = optional_param('js', false);
$get_css = optional_param('css', false);
if (!empty($get_css)) {
// set $this->css
- $this->v6_expand_StyleSheet();
+ $this->v6_expand_StyleSheet();
} else if (!empty($get_js)) {
// set $this->js
return empty($value) ? '' : ('<h3 class="ExerciseSubtitle">'.$value.'</h3>');
}
- // timer
+ // timer
function v6_expand_Timer() {
return $this->int_value('data,timer,include-timer');
return $this->parent->xml_value('data,timer,seconds');
}
- // send results
+ // send results
function v6_expand_SendResults() {
return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',send-email');
}
function v6_expand_NavLightColor() {
$color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
- return $this->get_halfway_color($color, '#ffffff');
+ return $this->get_halfway_color($color, '#ffffff');
}
function v6_expand_NavShadeColor() {
$color = $this->parent->xml_value('hotpot-config-file,global,nav-bar-color');
$value = strtr($value, $ENTITIES);
if (preg_match_all($pattern, $value, $matches)) {
$chars = array_merge($chars, $matches[0]);
- }
+ }
$i++;
}
$str .= '<p class="QuestionText">'.$question_text.'</p>';
if (
- $question_type==HOTPOT_JQUIZ_SHORTANSWER ||
+ $question_type==HOTPOT_JQUIZ_SHORTANSWER ||
$question_type==HOTPOT_JQUIZ_HYBRID
) {
$size = 9; // default size
}
if (
- $question_type==HOTPOT_JQUIZ_MULTICHOICE ||
+ $question_type==HOTPOT_JQUIZ_MULTICHOICE ||
$question_type==HOTPOT_JQUIZ_HYBRID ||
$question_type==HOTPOT_JQUIZ_MULTISELECT
) {
switch ($question_type) {
- case HOTPOT_JQUIZ_MULTICHOICE:
+ case HOTPOT_JQUIZ_MULTICHOICE:
$str .= '<ol class="MCAnswers">'."\n";
break;
case HOTPOT_JQUIZ_HYBRID:
}
return $sort_value;
-}
+}
+
-?>
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
</script>
-</head>
+</head>
-<body onload="TimerStartUp()" id="TheBody" [inclScorm1.2]onunload="CheckLMSFinish()"[/inclScorm1.2]>
+<body onload="TimerStartUp()" id="TheBody" [inclScorm1.2]onunload="CheckLMSFinish()"[/inclScorm1.2]>
<!-- BeginTopNavButtons -->
[inclNavButtons]
FC = new Array();
DC = new Array();
-function onEndDrag(){
+function onEndDrag(){
//Is it dropped on any of the fixed cards?
var Docked = false;
var DropTarget = DroppedOnFixed(CurrDrag);
DC[CurrDrag].tag = 0;
D[CurrDrag][2] = 0;
}
-}
+}
function DroppedOnFixed(DNum){
var Result = -1;
for (var i=0; i<F.length; i++){
CardContent = F[i][0];
FC[i] = new Card('F' + i, 10);
- FC[i].elm.innerHTML = CardContent;
+ FC[i].elm.innerHTML = CardContent;
if (FC[i].GetW() > Widest){
Widest = FC[i].GetW();
}
DC[i] = new Card('D' + i, 10);
CardContent = D[i][0];
// if (CardContent.indexOf('<img ') > -1){CardContent += '<br clear="all" />';} //used to be required for Navigator rendering bug with images
- DC[i].elm.innerHTML = CardContent;
+ DC[i].elm.innerHTML = CardContent;
if (DC[i].GetW() > DragWidth){DC[i].SetW(DragWidth);}
DC[i].css.cursor = 'move';
DC[i].css.backgroundColor = '[strExBGColor]';
TotalCorrect++;
}
else{
-//Change made for version 6.0.3.41: don't send wrong items home,
+//Change made for version 6.0.3.41: don't send wrong items home,
//show them in a more conspicuous way.
// DC[i].GoHome();
DC[i].SetL(DC[i].GetL() + 10);
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
</script>
-</head>
+</head>
-<body onload="TimerStartUp()" id="TheBody" [inclScorm1.2]onunload="CheckLMSFinish()"[/inclScorm1.2]>
+<body onload="TimerStartUp()" id="TheBody" [inclScorm1.2]onunload="CheckLMSFinish()"[/inclScorm1.2]>
<!-- BeginTopNavButtons -->
[inclNavButtons]
}
function CompDrags(a,b){
- return a.GetL() - b.GetL();
+ return a.GetL() - b.GetL();
}
function FindSegment(SegID){
LongestCorrect[k] = TempCorrect[k];
}
HintToReturn = TempHint;
- }
+ }
}
}
if (WhichCorrect > -1){
Locked = true;
Finished = true;
setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
+ WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
}
[inclScorm1.2]
function doDrag(e) {
if (CurrDrag == -1) {return};
if (C.ie){var Ev = window.event}else{var Ev = e}
- var difX = Ev.clientX-window.lastX;
- var difY = Ev.clientY-window.lastY;
- var newX = Cds[CurrDrag].GetL()+difX;
- var newY = Cds[CurrDrag].GetT()+difY;
- Cds[CurrDrag].SetL(newX);
+ var difX = Ev.clientX-window.lastX;
+ var difY = Ev.clientY-window.lastY;
+ var newX = Cds[CurrDrag].GetL()+difX;
+ var newY = Cds[CurrDrag].GetT()+difY;
+ Cds[CurrDrag].SetL(newX);
Cds[CurrDrag].SetT(newY);
- window.lastX = Ev.clientX;
- window.lastY = Ev.clientY;
+ window.lastX = Ev.clientX;
+ window.lastY = Ev.clientY;
return false;
-}
+}
-function beginDrag(e, DragNum) {
+function beginDrag(e, DragNum) {
CurrDrag = DragNum;
if (C.ie){
var Ev = window.event;
}
else{
var Ev = e;
- window.onmousemove=doDrag;
+ window.onmousemove=doDrag;
window.onmouseup=endDrag;
- }
+ }
Cds[CurrDrag].SwapColours();
topZ++;
Cds[CurrDrag].css.zIndex = topZ;
- window.lastX=Ev.clientX;
+ window.lastX=Ev.clientX;
window.lastY=Ev.clientY;
- return true;
-}
+ return true;
+}
-function endDrag(e) {
+function endDrag(e) {
if (CurrDrag == -1) {return};
Cds[CurrDrag].SwapColours();
if (C.ie){document.onmousemove=null}else{window.onmousemove=null;}
onEndDrag();
CurrDrag = -1;
return true;
-}
+}
function onEndDrag(){
//Snap to lines
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
[inclScorm1.2]
initAPI(window);
if (API != null){
- API.LMSInitialize('');
+ API.LMSInitialize('');
API.LMSSetValue('cmi.core.lesson_status', 'browsed');
API.LMSSetValue('cmi.comments', 'This exercise has no checking or scoring features.');
API.LMSCommit('');
font-family: [strFontFace];
[inclPageBGColor] background-color: [strPageBGColor];[/inclPageBGColor]
color: [strTextColor];
-[inclGraphicURL] background-image: url([strGraphicURL]);[/inclGraphicURL]
+[inclGraphicURL] background-image: url([strGraphicURL]);[/inclGraphicURL]
margin-right: 5%;
margin-left: 5%;
font-size: [strFontSize];
text-align: right;
font-size: 150%;
direction: rtl;
- font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
+ font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
}
.CentredRTLText{
text-align: center;
font-size: 150%;
direction: rtl;
- font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
+ font-family: "Simplified Arabic", "Traditional Arabic", "Times New Roman", [strFontFace];
}
button p.RTLText{
this.ua = navigator.userAgent;
this.name = navigator.appName;
- this.ver = navigator.appVersion;
+ this.ver = navigator.appVersion;
//Get data about the browser
this.mac = (this.ver.indexOf('Mac') != -1);
function doDrag(e) {
if (CurrDrag == -1) {return};
if (C.ie){var Ev = window.event}else{var Ev = e}
- var difX = Ev.clientX-window.lastX;
- var difY = Ev.clientY-window.lastY;
- var newX = DC[CurrDrag].GetL()+difX;
- var newY = DC[CurrDrag].GetT()+difY;
- DC[CurrDrag].SetL(newX);
+ var difX = Ev.clientX-window.lastX;
+ var difY = Ev.clientY-window.lastY;
+ var newX = DC[CurrDrag].GetL()+difX;
+ var newY = DC[CurrDrag].GetT()+difY;
+ DC[CurrDrag].SetL(newX);
DC[CurrDrag].SetT(newY);
- window.lastX = Ev.clientX;
- window.lastY = Ev.clientY;
+ window.lastX = Ev.clientX;
+ window.lastY = Ev.clientY;
return false;
-}
+}
-function beginDrag(e, DragNum) {
+function beginDrag(e, DragNum) {
CurrDrag = DragNum;
if (C.ie){
var Ev = window.event;
}
else{
var Ev = e;
- window.onmousemove=doDrag;
+ window.onmousemove=doDrag;
window.onmouseup=endDrag;
- }
+ }
DC[CurrDrag].Highlight();
topZ++;
DC[CurrDrag].css.zIndex = topZ;
- window.lastX=Ev.clientX;
+ window.lastX=Ev.clientX;
window.lastY=Ev.clientY;
- return false;
-}
+ return false;
+}
-function endDrag(e) {
+function endDrag(e) {
if (CurrDrag == -1) {return};
DC[CurrDrag].Unhighlight();
if (C.ie){document.onmousemove=null}else{window.onmousemove=null;}
//Need a bugfix for Opera focus problem here
if (C.opera){FocusAButton();}
return true;
-}
+}
var CurrDrag = -1;
var topZ = 100;
//Display feedback
ShowMessage(Ans);
-//Set the score for this question to 0 if no
+//Set the score for this question to 0 if no
if (State[QNum][0] < 1){
State[QNum][0] = 0;
}
<param name="type" value="audio/x-pn-realaudio-plugin" />
<param name="src" value="[strFilePath]" />
<param name="autostart" value="false" />
-<param name="controls" value="[inclVideo]ImageWindow,[/inclVideo]ControlPanel" />
+<param name="controls" value="[inclVideo]ImageWindow,[/inclVideo]ControlPanel" />
[strContent]</object>[/Real Player]
[Flash Player]<object codebase="[strFilePath]" type="application/x-shockwave-flash" width="[strWidth]" height="[strHeight]" data="[strFilePath]"> <param name="movie" value="[strFilePath]" />[strContent]</object>[/Flash Player]
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"><head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
Page Title
</div>
<div id="MainDiv" class="StdDiv">
-
+
<p>Page content...</p>
</div>
Els[i].style.visibility = 'hidden';
if (C.mac && C.gecko) {Els[i].style.display = 'none';}
}
- }
+ }
else {
// tagName is either input or select (that is, Form Elements)
// ie6 has a problem with Form elements, so manipulate those
function TopSettingWithScrollOffset(TopPercent){
var T = Math.floor(GetViewportHeight() * (TopPercent/100));
- return GetScrollTop() + T;
+ return GetScrollTop() + T;
}
//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;
-function SuppressBackspace(e){
+function SuppressBackspace(e){
if (InTextBox == true){return;}
if (C.ie) {
thisKey = window.event.keyCode;
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
[/inclHint]
-->
-
+
<div id="ClozeDiv">
<form id="Cloze" method="post" action="" onsubmit="return false;">
<div class="ClozeBody">
var Feedback = '';
var Correct = '[strCorrect]';
-var Incorrect = '[strIncorrect]';
+var Incorrect = '[strIncorrect]';
var GiveHint = '[strGiveHint]';
var CaseSensitive = [boolCaseSensitive];
var YourScoreIs = '[strYourScoreIs]';
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
<button id="CheckButton1" class="FuncButton" onmouseover="FuncBtnOver(this)" onfocus="FuncBtnOver(this)" onmouseout="FuncBtnOut(this)" onblur="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="CheckAnswers()"> [strCheckCaption] </button>
-->
-
+
<table class="CrosswordGrid">
<tbody>
var AcrossCaption = '';
var DownCaption = '';
var Correct = '[strCorrect]';
-var Incorrect = '[strIncorrect]';
+var Incorrect = '[strIncorrect]';
var GiveHint = '[strGiveHint]';
var YourScoreIs = '[strYourScoreIs]';
var BuiltGrid = '';
var InTextBox = false;
var Locked = false;
var TimeOver = false;
-var CaseSensitive = [boolCaseSensitive];
+var CaseSensitive = [boolCaseSensitive];
var InputStuff = '<form method="post" action="" onsubmit="return false;"><span class="ClueNum">[strClueNum]: </span>';
InputStuff += '[strClue] <input onfocus="CurrentBox=this;InTextBox=true;" onblur="InTextBox=false;" id="[strBoxId]" type="edit" size="[strEditSize]" maxlength="[strMaxLength]"></input>';
while ((x<L.length)&&(L[x][y].length > 0)){
Result += L[x][y].length;
x++;
- }
+ }
return Result;
}
else{
var AllCorrect = true;
var TotLetters = 0;
var CorrectLetters = 0;
- var LetterFromKey = '';
+ var LetterFromKey = '';
var LetterFromGuess = '';
//Check each letter
LetterFromKey = L[i][j].toUpperCase();
LetterFromGuess = G[i][j].toUpperCase();
}
- if (LetterFromGuess != LetterFromKey){
+ if (LetterFromGuess != LetterFromKey){
G[i][j] = '';
//Blank that square in the grid
SetGridSquareValue(i,j,'');
xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
+
<title></title>
<script type="text/javascript">
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
Parent.removeChild(Select);
Parent.innerHTML = AnsText;
Parent.nextSibling.innerHTML = CorrectIndicator;
- }
+ }
else{
AllDone = false;
Parent = Select.parentNode;
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
LongestCorrect[k] = TempCorrect[k];
}
HintToReturn = TempHint;
- }
+ }
}
}
if (WhichCorrect > -1){
Locked = true;
Finished = true;
setTimeout('Finish()', SubmissionTimeout);
- WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
+ WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
}
[inclScorm1.2]
if (AllDone == true){
[strDublinCoreMetadata]
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainTitle]
<div id="MainDiv" class="StdDiv">
-
+
<div id="QNav" class="QuestionNavigation">
<p style="text-align: right;">
</div>
</div>
-
+
[strQuestionOutput]
[inclKeypad]
}
function SetUpQuestions(){
- var AList = new Array();
+ var AList = new Array();
var QList = new Array();
var i, j;
Qs = document.getElementById('Questions');
function ChangeQ(ChangeBy){
//The following line prevents moving to another question until the current
-//question is answered correctly. Uncomment it to enable this behaviour.
+//question is answered correctly. Uncomment it to enable this behaviour.
// if (State[CurrQNum][0] == -1){return;}
if (((CurrQNum + ChangeBy) < 0)||((CurrQNum + ChangeBy) >= QArray.length)){return;}
QArray[CurrQNum].style.display = 'none';
Score = Math.floor((TotalScore/TotalWeighting)*100);
}
else{
-//if TotalWeighting is 0, no questions so far have any value, so
+//if TotalWeighting is 0, no questions so far have any value, so
//no penalty should be shown.
- Score = 100;
+ Score = 100;
}
}
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"><head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
[strPlainIndexTitle]
font-family: [strFontFace];
[inclPageBGColor] background-color: [strPageBGColor];[/inclPageBGColor]
color: [strTextColor];
-[inclGraphicURL] background-image: url([strGraphicURL]);[/inclGraphicURL]
+[inclGraphicURL] background-image: url([strGraphicURL]);[/inclGraphicURL]
padding-left: 5%;
padding-right: 5%;
font-size: [strFontSize];
-<?PHP // $Id$
+<?php
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of hotpot
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
// DD : day
// X : point release version 1,2,3 etc
// Y : increment between point releases
-?>
+
} else if ($hotpot->subnet && !address_in_subnet(getremoteaddr(), $hotpot->subnet)) {
$error = get_string("subneterror", "quiz");
// check number of attempts
- } else if ($hotpot->attempts && $hotpot->attempts <= $DB->count_records_select('hotpot_attempts', 'hotpot=? AND userid=?', array($hotpot->id, $USER->id), 'COUNT(DISTINCT clickreportid)')) {
+ } else if ($hotpot->attempts && $hotpot->attempts <= $DB->count_records_select('hotpot_attempts', 'hotpot=? AND userid=?', array($hotpot->id, $USER->id), 'COUNT(DISTINCT clickreportid)')) {
$error = get_string("nomoreattempts", "quiz");
// get password
} else if ($hotpot->password && empty($hppassword)) {
}
return $teacherdetails;
}
-?>
+
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//label mods
function label_backup_mods($bf,$preferences) {
global $CFG, $DB;
- $status = true;
+ $status = true;
////Iterate over label table
if ($labels = $DB->get_records ("label","course", array($preferences->backup_course=>"id"))) {
}
return $status;
}
-
+
function label_backup_one_mod($bf,$preferences,$label) {
global $CFG, $DB;
-
+
if (is_numeric($label)) {
$label = $DB->get_record('label', array('id'=>$label));
}
-
+
$status = true;
//Start mod
}
return $info;
}
-
+
//First the course data
$info[0][0] = get_string("modulenameplural","label");
$info[0][1] = $DB->count_records("label", array("course"=>$course));
return $info;
- }
+ }
////Return an array of info (name,value)
function label_check_backup_mods_instances($instance,$backup_unique_code) {
return $info;
}
-?>
+
-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
-<?php //$Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the label module
//
// Sometimes, changes between versions involve
return $result;
}
-?>
+
redirect("$CFG->wwwroot/course/view.php?id=$id");
-?>
+
/**
* This function is used by the reset_course_userdata function in moodlelib.
- *
+ *
* @param object $data the data submitted from the reset course.
* @return array status array
*/
-<?php // $Id$
+<?php
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_label_mod_form extends moodleform_mod {
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//label mods
- //This is the "graphical" structure of the label mod:
+ //This is the "graphical" structure of the label mod:
//
- // label
+ // label
// (CL,pk->id)
//
// Meaning: pk->primary key field of the table
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+
//Now, build the LABEL record structure
$label->course = $restore->course_id;
$label->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$label->intro = backup_todb($info['MOD']['#']['CONTENT']['0']['#']);
$label->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#'];
-
+
//The structure is equal to the db, so insert the label
$newid = $DB->insert_record ("label",$label);
- //Do some output
+ //Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string("modulename","label")." \"".format_string($label->name,true)."\"</li>";
}
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
-
+
} else {
$status = false;
}
//This function returns a log record with all the necessay transformations
//done. It's used by restore_log_module() to restore modules log.
function label_restore_logs($restore,$log) {
-
+
$status = false;
-
+
//Depending of the action, we recode different things
switch ($log->action) {
case "add":
}
return $status;
}
-?>
+
-<?php // $Id$
+<?php
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of label
$module->requires = 2009041700; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
-?>
+
redirect("$CFG->wwwroot/course/view.php?id=$course->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action for adding a branch table. Prints an HTML form.
*
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
-
+
// set of jump array
$jump = array();
$jump[0] = get_string("thispage", "lesson");
-<?php // $Id$
+<?php
/**
* Action for adding a cluster page
*
// first get the preceeding page
// if $pageid = 0, then we are inserting a new page at the beginning of the lesson
$pageid = required_param('pageid', PARAM_INT);
-
+
$timenow = time();
-
+
if ($pageid == 0) {
if (!$page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id))) {
print_error('cannotfindpagerecord', 'lesson');
if ($pageid != 0) {
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
}
-
+
if ($pageid == 0) {
$page->nextpageid = $page->id;
- }
+ }
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action for adding an end of branch page
*
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
-
+
$timenow = time();
// the new page is not the first page (end of branch always comes after an existing page)
$newanswer->timecreated = $timenow;
$newanswer->jumpto = $btpageid;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
-
+
lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
} else {
lesson_set_message(get_string('nobranchtablefound', 'lesson'));
}
-
+
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action for adding an end of cluster page
*
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
-
+
$timenow = time();
-
+
// the new page is not the first page (end of cluster always comes after an existing page)
if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
print_error('cannotfindpages', 'lesson');
}
-
+
// could put code in here to check if the user really can insert an end of cluster
-
+
$newpage = new stdClass;
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
-<?php // $Id$
+<?php
/**
* Action for adding a question page. Prints an HTML form.
*
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
$qtype = optional_param('qtype', LESSON_MULTICHOICE, PARAM_INT);
-
+
// set of jump array
$jump = array();
$jump[0] = get_string("thispage", "lesson");
$jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
}
if (!optional_param('firstpage', 0, PARAM_INT)) {
- $linkadd = "";
+ $linkadd = "";
$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0));
-
+
while (true) {
if ($apageid) {
$title = $DB->get_field("lesson_pages", "title", array("id" => $apageid));
<?php
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo $OUTPUT->help_icon(moodle_help_icon::make("questiontypes", get_string("questiontype", "lesson"), "lesson"))."<br />";
- lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
+ lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
"lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer
echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
- } else {
+ } else {
echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
-<?php // $Id$
+<?php
/**
* Action for confirming the deletion of a page
*
echo $title."<br />\n";
}
}
- echo $OUTPUT->confirm(get_string("confirmdeletionofthispage","lesson"),
+ echo $OUTPUT->confirm(get_string("confirmdeletionofthispage","lesson"),
"lesson.php?action=delete&id=$cm->id&pageid=$pageid",
"view.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* HTML template for continue.php
*
?>
<?php if ($lesson->displayleft) { // Skip navigation anchor ?>
-
+
<a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
-
+
<?php } ?>
<?php
<form id="endoflesson" method ="post" action="<?php echo $CFG->wwwroot ?>/mod/lesson/view.php">
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="pageid" value="<?php echo LESSON_EOL; ?>" />
-
+
<p align="center">
<?php print_string("savechangesandeol", "lesson") ?>
</p>
<p align="center">
<?php print_string("continuetoanswer", "lesson") ?>
</p>
-
+
</form>
<?php } ?>
<?php if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { // Review button back ?>
-
+
<form id="reviewback" method ="post" action="<?php echo $CFG->wwwroot ?>/mod/lesson/view.php">
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="pageid" value="<?php echo $pageid; ?>" />
-
+
<p>
<?php lesson_print_submit_link(get_string('reviewquestionback', 'lesson'), 'reviewback'); ?>
</p>
-
+
</form>
-
+
<?php } ?>
<form id="pageform" method ="post" action="<?php echo $CFG->wwwroot ?>/mod/lesson/view.php">
-<?php // $Id$
+<?php
/**
* Action for processing page answers by users
*
lesson_print_header($cm, $course, $lesson, 'view', true, $page->id);
include(dirname(__FILE__).'/continue.html');
-?>
+
-<?php // $Id$
+<?php
/**
* Action for deleting a page
*
}
lesson_set_message(get_string('deletedpage', 'lesson').': '.format_string($thispage->title, true), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action for editing a page. Prints an HTML form.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
-
+
// get the page
$pageid = required_param('pageid', PARAM_INT);
$redirect = optional_param('redirect', '', PARAM_ALPHA);
-
+
if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
print_error('cannotfindpages', 'lesson');
}
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="action" value="updatepage" />
<input type="hidden" name="pageid" value="<?php echo $pageid ?>" />
- <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
- <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
+ <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
+ <input type="hidden" name="redirect" value="<?php echo $redirect ?>" />
<input type="hidden" name="redisplay" value="0" />
<center>
<?php
case LESSON_MULTICHOICE :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo $OUTPUT->help_icon(moodle_help_icon::make("questiontypes", get_string("questiontype", "lesson"), "lesson"))."<br />";
- lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
+ lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"getElementById('editpage').redisplay.value=1;getElementById('editpage').submit();");
echo "<p><b><label for=\"qoption\">".get_string('multianswer', 'lesson').":</label></b> \n";
case LESSON_SHORTANSWER :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo $OUTPUT->help_icon(moodle_help_icon::make("questiontypes", get_string("questiontype", "lesson"), "lesson"))."<br />";
- lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
+ lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"getElementById('editpage').redisplay.value=1;getElementById('editpage').submit();");
echo "<p><b><label for=\"qoption\">".get_string('casesensitive', 'lesson').":</label></b> \n";
case LESSON_NUMERICAL :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo $OUTPUT->help_icon(moodle_help_icon::make("questiontypes", get_string("questiontype", "lesson"), "lesson"))."<br />";
- lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
+ lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"getElementById('editpage').redisplay.value=1;getElementById('editpage').submit();");
break;
echo "<input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
} else {
echo "<input name=\"display\" type=\"checkbox\" value=\"1\" />";
- }
+ }
echo get_string("displayinleftmenu", "lesson")."\n";
echo "</center></td></tr>\n";
echo "<tr><td><b>".get_string("branchtable", "lesson")."</b> \n";
case LESSON_CLUSTER :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\" />\n";
echo "<tr><td><b>".get_string("clustertitle", "lesson")."</b> \n";
- break;
+ break;
case LESSON_ENDOFCLUSTER :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\" />\n";
echo "<tr><td><b>".get_string("endofclustertitle", "lesson")."</b> \n";
- break;
+ break;
case LESSON_ENDOFBRANCH :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\" />\n";
echo "<tr><td><b>".get_string("endofbranch", "lesson")."</b> \n";
break;
default :
echo "<tr><td>";
- break;
+ break;
}
echo "</td></tr>\n";
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $ncorrected:</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
- "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
+ "<input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" checked=\"checked\" />";
echo $OUTPUT->help_icon(moodle_help_icon::make("useeditor", get_string("useeditor", "lesson"), "lesson"));
echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
case LESSON_TRUEFALSE:
case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER:
- case LESSON_NUMERICAL:
+ case LESSON_NUMERICAL:
echo "<tr><td><b><label for=\"edit-answer[$n]\">".get_string('answer', 'lesson')." $nplus1:</label></b>\n";
if ($flags & LESSON_ANSWER_EDITOR and $page->qtype != LESSON_SHORTANSWER and $page->qtype != LESSON_NUMERICAL) {
echo " [<label for=\"answereditor[$n]\">".get_string("useeditor", "lesson")."</label>: ".
$n++;
if ($page->qtype == LESSON_ESSAY) {
break; // only one answer for essays
- }
+ }
}
}
if ($page->qtype != LESSON_ENDOFBRANCH && $page->qtype != LESSON_CLUSTER && $page->qtype != LESSON_ENDOFCLUSTER) {
// close table and form
?>
</table><br />
- <input type="button" value="<?php print_string("redisplaypage", "lesson") ?>"
+ <input type="button" value="<?php print_string("redisplaypage", "lesson") ?>"
onclick="getElementById('editpage').redisplay.value=1;getElementById('editpage').submit();" />
<input type="submit" value="<?php print_string("savepage", "lesson") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
-<?php // $Id$
+<?php
/**
* Action for processing the form from addpage action and inserts the page.
*
}
$timenow = time();
-
+
$form = data_submitted();
$newpage = new stdClass;
$newanswer = new stdClass;
$newpage->display = clean_param($form->display, PARAM_INT);
} else {
$newpage->display = 0;
- }
+ }
$newpage->title = clean_param($form->title, PARAM_CLEANHTML);
$newpage->contents = trim($form->contents);
$newpage->title = $newpage->title;
$newpage->display = clean_param($form->display, PARAM_INT);
} else {
$newpage->display = 0;
- }
+ }
$newpage->title = clean_param($form->title, PARAM_CLEANHTML);
$newpage->contents = trim($form->contents);
$newpage->title = $newpage->title;
}
}
}
-
+
lesson_set_message(get_string('insertedpage', 'lesson').': '.format_string($newpage->title, true), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action that displays an interface for moving a page
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
-
+
$pageid = required_param('pageid', PARAM_INT);
$title = $DB->get_field("lesson_pages", "title", array("id" => $pageid));
echo $OUTPUT->heading(get_string("moving", "lesson", format_string($title)));
-
+
$params = array ("lessonid" => $lesson->id, "prevpageid" => 0);
if (!$page = $DB->get_record_select("lesson_pages", "lessonid = :lessonid AND prevpageid = :prevpageid", $params)) {
print_error('cannotfindfirstpage', 'lesson');
}
}
echo "</table>\n";
-?>
+
-<?php // $Id$
+<?php
/**
* Action for actually moving the page (database changes)
*
if (!$after) {
// the moved page is the new first page
$newfirstpageid = $pageid;
- // reset $after so that is points to the last page
+ // reset $after so that is points to the last page
// (when the pages are in a ring this will in effect be the first page)
if ($page->nextpageid) {
if (!$after = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "nextpageid" => 0))) {
}
}
// the rest is all unconditional...
-
- // second step. join pages into a ring
+
+ // second step. join pages into a ring
if (!$firstpageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) {
print_error("Moveit: firstpageid not found");
}
if (!$DB->set_field("lesson_pages", "prevpageid", $prevpageid, array("id" => $nextpageid))) {
print_error("Moveit: unable to update link");
}
-
+
// fourth step. insert page to be moved in new place...
if (!$nextpageid = $DB->get_field("lesson_pages", "nextpageid", array("id" => $after))) {
print_error("Movit: nextpageid not found");
if (!$DB->set_field("lesson_pages", "nextpageid", $nextpageid, array("id" => $pageid))) {
print_error("Moveit: unable to update link");
}
-
+
// fifth step. break the ring
if (!$newlastpageid = $DB->get_field("lesson_pages", "prevpageid", array("id" => $newfirstpageid))) {
print_error("Moveit: newlastpageid not found");
}
lesson_set_message(get_string('movedpage', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
-?>
+
-<?php // $Id$
+<?php
/**
* Action for processing the form in editpage action and saves the page
*
* @package lesson
**/
confirm_sesskey();
-
+
$redirect = optional_param('redirect', '', PARAM_ALPHA);
$timenow = time();
$page = new stdClass;
$page->id = clean_param($form->pageid, PARAM_INT);
-
+
// check to see if the cancel button was pushed
if (optional_param('cancel', '', PARAM_ALPHA)) {
if ($redirect == 'navigation') {
$page->title = clean_param($form->title, PARAM_CLEANHTML);
$page->contents = trim($form->contents);
$page->title = $page->title;
-
+
$DB->update_record("lesson_pages", $page);
if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_ESSAY || $page->qtype == LESSON_CLUSTER || $page->qtype == LESSON_ENDOFCLUSTER) {
// there's just a single answer with a jump
$DB->delete_records("lesson_answers", array("id" => $answer->id));
}
}
- }
+ }
$DB->update_record("lesson_answers", $oldanswer);
} else {
// it's an "ordinary" page
}
if (!isset($form->responseeditor[$i])) {
$form->responseeditor[$i] = 0;
- }
+ }
$oldanswer->flags = $form->answereditor[$i] * LESSON_ANSWER_EDITOR +
$form->responseeditor[$i] * LESSON_RESPONSE_EDITOR;
$oldanswer->timemodified = $timenow;
$oldanswer->answer = NULL;
$DB->update_record("lesson_answers", $oldanswer);
- }
+ }
} elseif (!empty($form->answerid[$i])) {
// need to delete blanked out answer
$DB->delete_records("lesson_answers", array("id" => clean_param($form->answerid[$i], PARAM_INT)));
if ($form->redisplay) {
redirect("$CFG->wwwroot/mod/lesson/lesson.php?id=$cm->id&action=editpage&pageid=$page->id&redirect=$redirect");
}
-
+
lesson_set_message(get_string('updatedpage', 'lesson').': '.format_string($page->title, true), 'notifysuccess');
if ($redirect == 'navigation') {
// takes us back to viewing the page
} else {
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
}
-?>
+
-<?php //$Id$
+<?php
/**
* Lesson's backup routine
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
- //This is the "graphical" structure of the lesson mod:
+ //This is the "graphical" structure of the lesson mod:
//
// lesson_default lesson ----------------------------|--------------------------|--------------------------|
- // (UL, pk->id,fk->courseid) (CL,pk->id) | | |
+ // (UL, pk->id,fk->courseid) (CL,pk->id) | | |
// | | | |
// | lesson_grades lesson_high_scores lesson_timer
// | (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid) (UL, pk->id,fk->lessonid)
}
}
}
- return $status;
+ return $status;
}
function lesson_backup_one_mod($bf,$preferences,$lesson) {
global $CFG, $DB;
-
+
if (is_numeric($lesson)) {
$lesson = $DB->get_record('lesson',array ('id' => $lesson));
}
-
+
$status = true;
//Start mod
//Start Attempt
$status =fwrite ($bf,start_tag("ATTEMPT",9,true));
//Print attempt contents
- fwrite ($bf,full_tag("USERID",10,false,$attempt->userid));
- fwrite ($bf,full_tag("RETRY",10,false,$attempt->retry));
- fwrite ($bf,full_tag("CORRECT",10,false,$attempt->correct));
+ fwrite ($bf,full_tag("USERID",10,false,$attempt->userid));
+ fwrite ($bf,full_tag("RETRY",10,false,$attempt->retry));
+ fwrite ($bf,full_tag("CORRECT",10,false,$attempt->correct));
fwrite ($bf,full_tag("USERANSWER",10,false,$attempt->useranswer));
- fwrite ($bf,full_tag("TIMESEEN",10,false,$attempt->timeseen));
+ fwrite ($bf,full_tag("TIMESEEN",10,false,$attempt->timeseen));
//End attempt
$status =fwrite ($bf,end_tag("ATTEMPT",9,true));
}
}
return $status;
}
-
+
// backup lesson_high_score contents (executed from backup_lesson_mods)
function backup_lesson_high_scores($bf, $preferences, $lessonid) {
global $CFG, $DB;
}
return $status;
}
-
+
// backup lesson_default contents (executed from backup_lesson_mods)
function backup_lesson_default ($bf,$preferences) {
global $CFG, $DB;
$default = $DB->get_record("lesson_default", array("course" => $preferences->backup_course));
if ($default) {
//Start mod
- $status =fwrite ($bf,start_tag("DEFAULTS",4,true));
+ $status =fwrite ($bf,start_tag("DEFAULTS",4,true));
//Print default data
fwrite ($bf,full_tag("PRACTICE",5,false,$default->practice));
fwrite ($bf,full_tag("MODATTEMPTS",5,false,$default->modattempts));
fwrite ($bf,full_tag("MAXHIGHSCORES",5,false,$default->maxhighscores));
$status =fwrite ($bf,end_tag("DEFAULTS",4,true));
}
- return $status;
+ return $status;
}
-
+
//Return an array of info (name,value)
function lesson_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
//Now, if requested, the user_data
if ($user_data) {
$info[1][0] = get_string("attempts","lesson");
- if ($ids = lesson_attempts_ids_by_course ($course)) {
+ if ($ids = lesson_attempts_ids_by_course ($course)) {
$info[1][1] = count($ids);
} else {
$info[1][1] = 0;
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("attempts","lesson");
- if ($ids = lesson_attempts_ids_by_instance ($instance->id)) {
+ if ($ids = lesson_attempts_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
// INTERNAL FUNCTIONS. BASED IN THE MOD STRUCTURE
- //Returns an array of lesson id
+ //Returns an array of lesson id
function lesson_ids ($course) {
global $CFG, $DB;
FROM {lesson} l
WHERE l.course = :course", $params);
}
-
+
//Returns an array of lesson_submissions id
function lesson_attempts_ids_by_course ($course) {
FROM {lesson_attempts} a
WHERE a.lessonid = :lessonid", $params);
}
-?>
+
-<?php // $Id$
+<?php
/**
* Capability definitions for the lesson module.
*
-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
-<?php //$Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the lesson module
//
// Sometimes, changes between versions involve
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Provides the interface for overall authoring of lessons
*
$display = optional_param('display', 0, PARAM_INT);
$mode = optional_param('mode', get_user_preferences('lesson_view', 'collapsed'), PARAM_ALPHA);
$pageid = optional_param('pageid', 0, PARAM_INT);
-
+
if ($mode != 'single') {
set_user_preference('lesson_view', $mode);
}
-
+
list($cm, $course, $lesson) = lesson_get_basics($id);
-
+
if ($firstpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
if (!$pages = $DB->get_records('lesson_pages', array('lessonid' => $lesson->id))) {
print_error('cannotfindrecords', 'lesson');
}
}
-
+
if ($pageid) {
if (!$singlepage = $DB->get_record('lesson_pages', array('id' => $pageid))) {
print_error('invalidpageid', 'lesson');
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:manage', $context);
-
+
lesson_print_header($cm, $course, $lesson, $mode);
if (empty($firstpage)) {
$pageid = $firstpage->id;
$prevpageid = 0;
$npages = count($pages);
-
+
switch ($mode) {
case 'collapsed':
$table = new html_table();
$table->cellspacing = 0;
$table->cellpadding = '2px';
$table->data = array();
-
+
while ($pageid != 0) {
$page = $pages[$pageid];
$jumps[] = lesson_get_jump_name($answer->jumpto);
}
}
-
+
$table->data[] = array("<a href=\"$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=single&pageid=".$page->id."\">".format_string($pages[$pageid]->title,true).'</a>',
lesson_get_qtype_name($page->qtype),
implode("<br />\n", $jumps),
);
$pageid = $page->nextpageid;
}
-
+
echo $OUTPUT->table($table);
break;
-
+
case 'single':
// Only viewing a single page in full - change some variables to display just one
$prevpageid = $singlepage->prevpageid;
$pageid = $singlepage->id;
-
+
$pages = array();
$pages[$singlepage->id] = $singlepage;
-
+
case 'full':
echo '<table class="boxaligncenter" cellpadding="5" border="0" style="width:80%;">
<tr>
echo "<tr><td>\n";
echo "<table style=\"width:100%;\" border=\"1\" class=\"generalbox\"><tr><th colspan=\"2\" scope=\"col\">".format_string($page->title)." \n";
lesson_print_page_actions($cm->id, $page, $npages);
- echo "</th></tr>\n";
+ echo "</th></tr>\n";
echo "<tr><td colspan=\"2\">\n";
$options = new stdClass;
$options->noclean = true;
echo "</td></tr>\n";
echo "<tr><td align=\"right\" valign=\"top\"><span class=\"label\">".get_string("response", "lesson")." $i</span>: \n";
echo "</td><td>\n";
- echo format_text($answer->response, FORMAT_MOODLE, $options);
+ echo format_text($answer->response, FORMAT_MOODLE, $options);
echo "</td></tr>\n";
- break;
+ break;
case LESSON_MATCHING:
if ($n < 2) {
if ($answer->answer != NULL) {
if ($n == 0) {
echo "<tr><td align=\"right\" valign=\"top\"><span class=\"label\">".get_string("correctresponse", "lesson")."</span>: \n";
echo "</td><td>\n";
- echo format_text($answer->answer, FORMAT_MOODLE, $options);
+ echo format_text($answer->answer, FORMAT_MOODLE, $options);
echo "</td></tr>\n";
} else {
echo "<tr><td align=\"right\" valign=\"top\"><span class=\"label\">".get_string("wrongresponse", "lesson")."</span>: \n";
echo "</td><td>\n";
- echo format_text($answer->answer, FORMAT_MOODLE, $options);
+ echo format_text($answer->answer, FORMAT_MOODLE, $options);
echo "</td></tr>\n";
}
}
echo "</td></tr>\n";
echo "<tr><td align=\"right\" valign=\"top\"><span class=\"label\">".get_string("matchesanswer", "lesson")." $i</span>: \n";
echo "</td><td>\n";
- echo format_text($answer->response, FORMAT_MOODLE, $options);
+ echo format_text($answer->response, FORMAT_MOODLE, $options);
echo "</td></tr>\n";
}
break;
echo "$jumptitle</td></tr>\n";
}
} else {
- if ($lesson->custom and
- $page->qtype != LESSON_BRANCHTABLE and
+ if ($lesson->custom and
+ $page->qtype != LESSON_BRANCHTABLE and
$page->qtype != LESSON_ENDOFBRANCH and
- $page->qtype != LESSON_CLUSTER and
+ $page->qtype != LESSON_CLUSTER and
$page->qtype != LESSON_ENDOFCLUSTER) {
echo "<tr><td align=\"right\" style=\"width:20%;\"><span class=\"label\">".get_string("score", "lesson")." $i";
echo "</span>: </td><td style=\"width:80%;\">\n";
$DB->set_field("lesson_pages", "prevpageid", $prevpageid, array("id" => $page->id));
debugging("<p>***prevpageid of page $page->id set to $prevpageid***");
}
-
+
if (count($pages) == 1) {
echo "</td></tr>";
break;
}
-
+
$prevpageid = $page->id;
$pageid = $page->nextpageid;
echo "</td></tr>";
echo "</table>";
break;
}
- }
+ }
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
/**
* Provides the interface for grading essay questions
*
$mode = optional_param('mode', 'display', PARAM_ALPHA);
list($cm, $course, $lesson) = lesson_get_basics($id);
-
+
require_login($course->id, false, $cm);
$url = new moodle_url($CFG->wwwroot.'/mod/lesson/essay.php', array('id'=>$id));
$PAGE->navbar->add(get_string('manualgrading','lesson'));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+
require_capability('mod/lesson:edit', $context);
-
+
/// Handle any preprocessing before header is printed - based on $mode
switch ($mode) {
case 'display': // Default view - get the necessary data
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
$params["groupinid"] = $cm->groupingid;
$sql = "SELECT DISTINCT u.*
- FROM {lesson_attempts} a
+ FROM {lesson_attempts} a
INNER JOIN {user} u ON u.id = a.userid
INNER JOIN {groups_members} gm ON gm.userid = u.id
INNER JOIN {groupings_groups} gg ON gm.groupid = :groupinid
break;
case 'grade': // Grading form - get the necessary data
confirm_sesskey();
-
+
$attemptid = required_param('attemptid', PARAM_INT);
if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
if (optional_param('cancel', 0, PARAM_RAW)) {
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
}
-
+
$attemptid = required_param('attemptid', PARAM_INT);
-
+
if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
print_error('cannotfindattempt', 'lesson');
}
$attempt->useranswer = serialize($essayinfo);
$DB->update_record('lesson_attempts', $attempt);
-
+
// Get grade information
$grade = current($grades);
$gradeinfo = lesson_grade($lesson, $attempt->retry, $attempt->userid);
-
+
// Set and update
$updategrade->id = $grade->id;
$updategrade->grade = $gradeinfo->grade;
$DB->update_record('lesson_grades', $updategrade);
// Log it
add_to_log($course->id, 'lesson', 'update grade', "essay.php?id=$cm->id", $lesson->name, $cm->id);
-
+
lesson_set_message(get_string('changessaved'), 'notifysuccess');
// update central gradebook
break;
case 'email': // Sending an email(s) to a single user or all
confirm_sesskey();
-
+
// Get our users (could be singular)
if ($userid = optional_param('userid', 0, PARAM_INT)) {
$queryadd = " AND userid = :userid";
}
$options = new stdClass;
$options->noclean = true;
-
+
foreach ($attempts as $attempt) {
$essayinfo = unserialize($attempt->useranswer);
if ($essayinfo->graded and !$essayinfo->sent) {
// Holds values for the essayemailsubject string for the email message
$a = new stdClass;
-
+
// Set the grade
$params = array ("lessonid" => $lesson->id, "userid" => $attempt->userid);
$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid and userid = :userid", $params, 'completed', '*', $attempt->retry, 1);
$grade = current($grades);
$a->newgrade = $grade->grade;
-
+
// Set the points
if ($lesson->custom) {
$a->earned = $essayinfo->score;
// Subject
$subject = get_string('essayemailsubject', 'lesson', format_string($pages[$attempt->pageid]->title,true));
-
+
$eventdata = new object();
$eventdata->modulename = 'lesson';
$eventdata->userfrom = $USER;
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
break;
}
-
+
// Log it
add_to_log($course->id, 'lesson', 'view grade', "essay.php?id=$cm->id", get_string('manualgrading', 'lesson'), $cm->id);
-
+
lesson_print_header($cm, $course, $lesson, 'essay');
-
+
switch ($mode) {
case 'display':
// Expects $user, $essayattempts and $pages to be set already
-
+
// Group all the essays by userid
$studentessays = array();
foreach ($essayattempts as $essay) {
// Not very nice :) but basically
- // this organizes the essays so we know how many
+ // this organizes the essays so we know how many
// times a student answered an essay per try and per page
- $studentessays[$essay->userid][$essay->pageid][$essay->retry][] = $essay;
+ $studentessays[$essay->userid][$essay->pageid][$essay->retry][] = $essay;
}
-
+
// Setup table
$table = new html_table();
$table->head = array(get_string('name'), get_string('essays', 'lesson'), get_string('email', 'lesson'));
} else {
$essay = end($try);
}
-
+
// Start processing the attempt
$essayinfo = unserialize($essay->useranswer);
-
+
// Different colors for all the states of an essay (graded, if sent, not graded)
if (!$essayinfo->graded) {
$class = ' class="graded"';
$emailalllink = "<a href=\"$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id&mode=email&sesskey=".sesskey().'">'.get_string('emailallgradedessays', 'lesson').'</a>';
$table->data[] = array(' ', ' ', $emailalllink);
-
+
echo $OUTPUT->table($table);
break;
case 'grade':
<input type="hidden" name="id" value="'.$cm->id.'" />
<input type="hidden" name="mode" value="update" />
<input type="hidden" name="attemptid" value="'.$attemptid.'" />
- <input type="hidden" name="sesskey" value="'.sesskey().'" />';
+ <input type="hidden" name="sesskey" value="'.sesskey().'" />';
// All tables will have these settings
$originaltable = new html_table();
$table->data[] = array(format_text($page->contents, FORMAT_MOODLE, $options));
echo $OUTPUT->table($table);
-
+
// Now the user's answer
$essayinfo = unserialize($attempt->useranswer);
-
+
$table = clone($originaltable);
$table = new html_table();
$table->head = array(get_string('studentresponse', 'lesson', fullname($user, true)));
</div>';
break;
}
-
+
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php // $Id$
/**
- * format.php - Default format class for file imports/exports. Doesn't do
+ * format.php - Default format class for file imports/exports. Doesn't do
* everything on it's own -- it needs to be extended.
*
* @version $Id$
function importprocess($filename, $lesson, $pageid) {
global $DB, $OUTPUT;
-
+
/// Processes a given file. There's probably little need to change this
$timenow = time();
echo $OUTPUT->notification("There are no questions in this file!");
return false;
}
-
+
echo $OUTPUT->notification(get_string('importcount', 'lesson', sizeof($questions)));
$count = 0;
// reset $pageid and put the page ID in $question, used in save_question_option()
$pageid = $newpageid;
$question->id = $newpageid;
-
+
$this->questionids[] = $question->id;
// Now to save all the answers and type-specific options
default :
echo $OUTPUT->notification(get_string('unsupportedqtype', 'lesson', $question->qtype));
}
-
+
}
return true;
}
}
function readquestions($lines) {
- /// Parses an array of lines into an array of questions,
- /// where each item is a question object as defined by
- /// readquestion(). Questions are defined as anything
+ /// Parses an array of lines into an array of questions,
+ /// where each item is a question object as defined by
+ /// readquestion(). Questions are defined as anything
/// between blank lines.
-
+
$questions = array();
$currentquestion = array();
function readquestion($lines) {
- /// Given an array of lines known to define a question in
- /// this format, this function converts it into a question
+ /// Given an array of lines known to define a question in
+ /// this format, this function converts it into a question
/// object suitable for processing and insertion into Moodle.
echo "<p>This flash question format has not yet been completed!</p>";
// returns an "empty" question
// Somewhere to specify question parameters that are not handled
// by import but are required db fields.
- // This should not be overridden.
+ // This should not be overridden.
global $CFG;
$question = new stdClass();
$question->length = 1;
$question->qoption = 0;
$question->layout = 1;
-
+
return $question;
}
function importpostprocess() {
/// Does any post-processing that may be desired
- /// Argument is a simple array of question ids that
+ /// Argument is a simple array of question ids that
/// have just been added.
return true;
}
-?>
+
redirect('view.php?id='.$cm->id);
}
-?>
+
$PAGE->set_url($url);
list($cm, $course, $lesson) = lesson_get_basics($id);
-
+
require_login($course->id, false, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-
+
+
switch ($mode) {
case 'add':
// Ensure that we came from view.php
print_error('invalidformdata');
}
break;
-
+
case 'save':
if (confirm_sesskey() and $form = data_submitted($CFG->wwwroot.'/mod/lesson/view.php')) {
$name = trim(optional_param('name', '', PARAM_CLEAN));
-
+
// Make sure it is not empty
if (empty($name)) {
lesson_set_message(get_string('missingname', 'lesson'));
$mode = 'add';
break;
- }
+ }
// Check for censored words
$filterwords = explode(',', get_string('censorbadwords'));
foreach ($filterwords as $filterword) {
if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid", $params, 'completed')) {
print_error('cannotfindfirstgrade', 'lesson');
}
-
- if (!$newgrade = $DB->get_record_sql("SELECT *
- FROM {lesson_grades}
+
+ if (!$newgrade = $DB->get_record_sql("SELECT *
+ FROM {lesson_grades}
WHERE lessonid = :lessonid
- AND userid = :userid
+ AND userid = :userid
ORDER BY completed DESC", $params, true)) {
print_error('cannotfindnewestgrade', 'lesson');
}
-
+
// Check for multiple submissions
if ($DB->record_exists('lesson_high_scores', array('gradeid' => $newgrade->id))) {
print_error('onpostperpage', 'lesson');
}
-
+
// Find out if we need to delete any records
- if ($highscores = $DB->get_records_sql("SELECT h.*, g.grade
- FROM {lesson_grades} g, {lesson_high_scores} h
+ if ($highscores = $DB->get_records_sql("SELECT h.*, g.grade
+ FROM {lesson_grades} g, {lesson_high_scores} h
WHERE h.gradeid = g.id
AND h.lessonid = :lessonid
ORDER BY g.grade DESC", $params)) {
}
if (count($uniquescores) >= $lesson->maxhighscores) {
// Top scores list is full, might need to delete a score
- $flag = true;
+ $flag = true;
// See if the new score is already listed in the top scores list
// if it is listed, then dont need to delete any records
foreach ($highscores as $highscore) {
if ($newgrade->grade == $highscore->grade) {
$flag = false;
}
- }
+ }
if ($flag) {
// Pushing out the lowest score (could be multiple records)
$lowscore = 0;
$newhighscore->nickname = $name;
$DB->insert_record('lesson_high_scores', $newhighscore);
-
+
// Log it
add_to_log($course->id, 'lesson', 'update highscores', "highscores.php?id=$cm->id", $name, $cm->id);
-
+
lesson_set_message(get_string('postsuccess', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&link=1");
} else {
if (!$grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid", $params, "completed")) {
$grades = array();
}
-
+
echo $OUTPUT->heading(get_string("topscorestitle", "lesson", $lesson->maxhighscores), 4);
if (!$highscores = $DB->get_records_select("lesson_high_scores", "lessonid = :lessonid", $params)) {
$topscores[$grade][] = $highscore->nickname;
}
krsort($topscores);
-
+
$table = new html_table();
$table->align = array('center', 'left', 'right');
$table->wrap = array();
$table->width = "30%";
$table->cellspacing = '10px';
$table->size = array('*', '*', '*');
-
+
$table->head = array(get_string("rank", "lesson"), get_string('name'), get_string("scores", "lesson"));
-
+
$printed = 0;
while (true) {
$temp = current($topscores);
$score = key($topscores);
$rank = $printed + 1;
- sort($temp);
+ sort($temp);
foreach ($temp as $student) {
$table->data[] = array($rank, $student, $score.'%');
}
$printed++;
- if (!next($topscores) || !($printed < $lesson->maxhighscores)) {
+ if (!next($topscores) || !($printed < $lesson->maxhighscores)) {
break;
}
}
echo $OUTPUT->table($table);
}
-
+
if (!has_capability('mod/lesson:manage', $context)) { // teachers don't need the links
echo '<div class="mdl-align">';
if ($link) {
}
break;
}
-
+
echo $OUTPUT->footer();
-?>
+
echo $OUTPUT->footer();
-?>
+
* This is a very rough importer for powerpoint slides
* Export a powerpoint presentation with powerpoint as html pages
* Do it with office 2002 (I think?) and no special settings
- * Then zip the directory with all of the html pages
+ * Then zip the directory with all of the html pages
* and the zip file is what you want to upload
- *
+ *
* The script supports book and lesson.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
$url->param('pageid', $pageid);
}
$PAGE->set_url($url);
-
+
if (! $cm = get_coursemodule_from_id('lesson', $id)) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
print_error('coursemisconf');
}
-
+
// allows for adaption for multiple modules
if(! $modname = $DB->get_field('modules', 'name', array('id' => $cm->module))) {
print_error('invalidmoduleid', '', '', $cm->module);
echo $OUTPUT->notification(get_string("uploadnofilefound") );
} else { // Valid file is found
-
+
if ($rawpages = readdata($_FILES, $course->id, $modname)) { // first try to reall all of the data in
$pageobjects = extract_data($rawpages, $course->id, $mod->name, $modname); // parse all the html files into objects
clean_temp(); // all done with files so dump em
-
- $mod_create_objects = $modname.'_create_objects';
- $mod_save_objects = $modname.'_save_objects';
-
+
+ $mod_create_objects = $modname.'_create_objects';
+ $mod_save_objects = $modname.'_save_objects';
+
$objects = $mod_create_objects($pageobjects, $mod->id); // function to preps the data to be sent to DB
-
+
if(! $mod_save_objects($objects, $mod->id, $pageid)) { // sends it to DB
print_error('cannotsavedata');
}
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
-
+
// START OF FUNCTIONS
function readdata($file, $courseid, $modname) {
global $CFG;
// create an upload directory in temp
- make_upload_directory('temp/'.$modname);
+ make_upload_directory('temp/'.$modname);
$base = $CFG->dataroot."/temp/$modname/";
$zipfile = $_FILES["newfile"]["name"];
$tempzipfile = $_FILES["newfile"]["tmp_name"];
-
+
// create our directory
$path_parts = pathinfo($zipfile);
$dirname = substr($zipfile, 0, strpos($zipfile, '.'.$path_parts['extension'])); // take off the extension
// unzip it!
unzip_file($base.$zipfile, $base, false);
-
+
$base = $base.$dirname; // update the base
-
+
// this is the file where we get the names of the files for the slides (in the correct order too)
$outline = $base.'/outline.htm';
-
+
$pages = array();
-
+
if (file_exists($outline) and is_readable($outline)) {
$outlinecontents = file_get_contents($outline);
$filenames = array();
} else {
return false;
}
- }
+ }
} else {
- // cannot find the outline, so grab all files that start with slide
+ // cannot find the outline, so grab all files that start with slide
$dh = opendir($base);
while (false !== ($file = readdir($dh))) { // read throug the directory
if ('slide' == substr($file, 0, 5)) { // check for name (may want to check extension later)
ksort($pages); // order them by file name
}
-
+
if (empty($pages)) {
return false;
}
-
+
return $pages;
}
function extract_data($pages, $courseid, $lessonname, $modname) {
// this function attempts to extract the content out of the slides
// the slides are ugly broken xml. and the xml is broken... yeah...
-
+
global $CFG;
global $matches;
$extratedpages = array();
-
+
// directory for images
- make_upload_directory($courseid.'/moddata/'.$modname, false); // we store our images in a subfolder in here
-
+ make_upload_directory($courseid.'/moddata/'.$modname, false); // we store our images in a subfolder in here
+
$imagedir = $CFG->dataroot.'/'.$courseid.'/moddata/'.$modname;
-
+
require_once($CFG->libdir .'/filelib.php');
$imagelink = get_file_url($courseid.'/moddata/'.$modname);
-
+
// try to make a unique subfolder to store the images
$lessonname = str_replace(' ', '_', $lessonname); // get rid of spaces
$i = 0;
}
$i++;
}
-
+
foreach ($pages as $file => $content) {
// to make life easier on our preg_match_alls, we strip out all tags except
// for div and img (where our content is). We want div because sometimes we
// can identify the content in the div based on the div's class
-
+
$tags = '<div><img>'; // should also allow <b><i>
$string = strip_tags($content,$tags);
//echo s($string);
//(<([\w]+)[^>]*>)([^<\\2>]*)(<\/\\2>) original pattern
//(<(div+)[^>]*>)[^(<div*)](<\/div>) work in progress
- $path_parts = pathinfo($file);
+ $path_parts = pathinfo($file);
$file = substr($path_parts['basename'], 0, strpos($path_parts['basename'], '.')); // get rid of the extension
$imgs = array();
// this foreach keeps the style intact. Found it doesn't help much. But if you want back uncomment
// this foreach and uncomment the line with the comment imgstyle in it. Also need to comment out
// the $page->images[]... line in the next foreach
- /*foreach ($imgs[1] as $img) {
+ /*foreach ($imgs[1] as $img) {
$page->images[] = '<img '.str_replace('src="', "src=\"$imagelink/", $img).' />';
}*/
foreach ($imgs[2] as $img) {
$page->images[] = "<img src=\"$imagelink/$img\" title=\"$img\" />"; // comment out this line if you are using the above foreach loop
}
for($i = 0; $i < count($matches[1]); $i++) { // go through all of our div matches
-
- $class = isolate_class($matches[1][$i]); // first step in isolating the class
-
+
+ $class = isolate_class($matches[1][$i]); // first step in isolating the class
+
// check for any static classes
switch ($class) {
case 'T': // class T is used for Titles
}
/*if (count($page->contents) == 0) { // didnt find anything, grab everything
// potential to pull in a lot of crap
- for($i = 0; $i < count($matches[1]); $i++) {
- //if($class = isolate_class($matches[1][$i])) {
+ for($i = 0; $i < count($matches[1]); $i++) {
+ //if($class = isolate_class($matches[1][$i])) {
//if ($class == 'O') {
if ($matches[3][$i] != ' ') { // odd crap generated... sigh
if (substr($matches[3][$i], 0, 1) == ':') { // check for leading : ... hate MS ...
}*/
// add the page to the array;
$extratedpages[] = $page;
-
+
} // end $pages foreach loop
-
+
return $extratedpages;
}
*/
function build_list($list, &$i, $depth) {
global $matches; // not sure why I global this...
-
+
while($i < count($matches[1])) {
-
+
$class = isolate_class($matches[1][$i]);
if (strstr($class, 'B')) { // make sure we are still working with bullet classes
// end the list and return it
$list .= '</ul>';
return $list;
-
+
}
/**
-Given an html tag, this function will
+Given an html tag, this function will
*/
function isolate_class($string) {
if($class = strstr($string, 'class=')) { // first step in isolating the class
*/
function ppt_clean_text($string) {
$chop = 1; // default: just a single char infront of the content
-
+
// look for any other crazy things that may be infront of the content
if (strstr($string, '<') and strpos($string, '<') == 0) { // look for the < in the sting and make sure it is in the front
$chop = 4; // increase the $chop
}
// may need to add more later....
-
+
$string = substr($string, $chop);
-
+
if ($string != ' ') {
return $string;
} else {
global $CFG;
// this function is broken, use it to clean up later
// should only clean up what we made as well because someone else could be importing ppt as well
- //delDirContents($CFG->dataroot.'/temp/lesson');
+ //delDirContents($CFG->dataroot.'/temp/lesson');
}
/**
$branchtables = array();
$branchtable = new stdClass;
-
+
// all pages have this info
$page->lessonid = $lessonid;
$page->prevpageid = 0;
$page->display = 1;
$page->timecreated = time();
$page->timemodified = 0;
-
+
// all answers are the same
$answer->lessonid = $lessonid;
$answer->jumpto = LESSON_NEXTPAGE;
$answer->jumpto = LESSON_PREVIOUSPAGE;
$answer->answer = "Previous";
-
+
$answers[] = clone($answer);
-
+
$branchtable->answers = $answers;
-
+
$i = 1;
-
- foreach ($pageobjects as $pageobject) {
+
+ foreach ($pageobjects as $pageobject) {
$temp = prep_page($pageobject, $i); // makes our title and contents
$page->title = $temp->title;
$page->contents = $temp->contents;
$chapters = array();
$chapter = new stdClass;
-
+
// same for all chapters
$chapter->bookid = $bookid;
$chapter->pagenum = $DB->count_records('book_chapters', array('bookid'=>$bookid))+1;
$chapter->timemodified = time();
$chapter->subchapter = 0;
- $i = 1;
+ $i = 1;
foreach ($pageobjects as $pageobject) {
$page = prep_page($pageobject, $i); // get title and contents
$chapter->importsrc = $pageobject->source; // add the source
$chapter->title = $page->title;
$chapter->content = $page->contents;
- $chapters[] = $chapter;
-
+ $chapters[] = $chapter;
+
// increment our page number and our counter
$chapter->pagenum = $chapter->pagenum + 1;
$i++;
if ($pageobject->title == '') {
$page->title = "Page $count"; // no title set so make a generic one
} else {
- $page->title = $pageobject->title;
+ $page->title = $pageobject->title;
}
-
+
$page->contents = '';
-
+
// nab all the images first
foreach ($pageobject->images as $image) {
$image = str_replace("\n", '', $image);
$image = str_replace("\r", '', $image);
$image = str_replace("'", '"', $image); // imgstyle
-
+
$page->contents .= $image;
}
// go through the contents array and put <p> tags around each element and strip out \n which I have found to be uneccessary
*/
function lesson_save_objects($branchtables, $lessonid, $after) {
global $DB;
-
+
// first set up the prevpageid and nextpageid
if ($after == 0) { // adding it to the top of the lesson
$prevpageid = 0;
$prevpageid = $after;
$nextpageid = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $after));
}
-
+
foreach ($branchtables as $branchtable) {
-
+
// set the doubly linked list
$branchtable->page->nextpageid = $nextpageid;
$branchtable->page->prevpageid = $prevpageid;
-
+
// insert the page
$id = $DB->insert_record('lesson_pages', $branchtable->page);
-
+
// update the link of the page previous to the one we just updated
if ($prevpageid != 0) { // if not the first page
$DB->set_field("lesson_pages", "nextpageid", $id, array("id" => $prevpageid));
$answer->pageid = $id;
$DB->insert_record('lesson_answers', $answer);
}
-
+
$prevpageid = $id;
}
-
+
// all done with inserts. Now check to update our last page (this is when we import between two lesson pages)
if ($nextpageid != 0) { // if the next page is not the end of lesson
$DB->set_field("lesson_pages", "prevpageid", $id, array("id" => $nextpageid));
}
-
+
return true;
}
*/
function book_save_objects($chapters, $bookid, $pageid='0') {
global $DB;
-
+
// nothing fancy, just save them all in order
foreach ($chapters as $chapter) {
$chapter->id = $DB->insert_record('book_chapters', $chapter);
return true;
}
-?>
+
echo $OUTPUT->footer();
-?>
+
<?php // $Id: lesson.php, v 1.0 25 Jan 2004
/**
* Handles lesson actions
- *
+ *
* ACTIONS handled are:
* addbranchtable
* addendofbranch
require("../../config.php");
require("locallib.php");
-
+
$id = required_param('id', PARAM_INT); // Course Module ID
$action = required_param('action', PARAM_ALPHA); // Action
-
+
list($cm, $course, $lesson) = lesson_get_basics($id);
require_login($course->id, false, $cm);
$PAGE->navbar->add(get_string($action, 'lesson'));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+
/// Set up some general variables
$usehtmleditor = can_use_html_editor();
-
+
/// Process the action
switch ($action) {
case 'addbranchtable':
}
echo $OUTPUT->footer();
-
-?>
+
+
/**
* Next page -> any page not seen before
-*/
+*/
if (!defined("LESSON_UNSEENPAGE")) {
define("LESSON_UNSEENPAGE", 1); // Next page -> any page not seen before
}
}
/**
* Undefined
- */
+ */
if (!defined("LESSON_UNDEFINED")) {
define("LESSON_UNDEFINED", -99);
}
*/
if (!defined("LESSON_SHORTANSWER")) {
define("LESSON_SHORTANSWER", "1");
-}
+}
/**
* True/False question type
*/
/**
* Multichoice question type
*
- * If you change the value of this then you need
+ * If you change the value of this then you need
* to change it in restorelib.php as well.
*/
if (!defined("LESSON_MULTICHOICE")) {
* Matching question type
*
* If you change the value of this then you need
- * to change it in restorelib.php, in mysql.php
+ * to change it in restorelib.php, in mysql.php
* and postgres7.php as well.
*/
if (!defined("LESSON_MATCHING")) {
}
//////////////////////////////////////////////////////////////////////////////////////
-/// Any other lesson functions go here. Each of them must have a name that
+/// Any other lesson functions go here. Each of them must have a name that
/// starts with lesson_
/**
}
/**
- * Returns course module, course and module instance given
+ * Returns course module, course and module instance given
* either the course module ID or a lesson module ID.
*
* @param int $cmid Course Module ID
**/
function lesson_get_basics($cmid = 0, $lessonid = 0) {
global $DB;
-
+
if ($cmid) {
if (!$cm = get_coursemodule_from_id('lesson', $cmid)) {
print_error('invalidcoursemodule');
} else {
print_error('invalidid', 'lesson');
}
-
+
return array($cm, $course, $lesson);
}
**/
function lesson_set_message($message, $class="notifyproblem", $align='center') {
global $SESSION;
-
+
if (empty($SESSION->lesson_messages) or !is_array($SESSION->lesson_messages)) {
$SESSION->lesson_messages = array();
}
-
+
$SESSION->lesson_messages[] = array($message, $class, $align);
-
+
return true;
}
**/
function lesson_print_messages() {
global $SESSION, $OUTPUT;
-
+
if (empty($SESSION->lesson_messages)) {
// No messages to print
return true;
}
-
+
foreach($SESSION->lesson_messages as $message) {
echo $OUTPUT->notification($message[0], $message[1], $message[2]);
}
-
+
// Reset
unset($SESSION->lesson_messages);
-
+
return true;
}
$output = "<div class=\"lessonbutton $class\" $align>\n";
$output .= "<input type=\"submit\" value=\"$name\" $align $id />";
$output .= "</div>\n";
-
+
if ($return) {
return $output;
} else {
$timeleft = $timeleft - ($hours * 3600);
$minutes = floor($timeleft/60);
$secs = $timeleft - ($minutes * 60);
-
+
if ($minutes < 10) {
$minutes = "0$minutes";
}
$output[] = $hours;
$output[] = $minutes;
$output[] = $secs;
-
+
$output = implode(':', $output);
-
+
if ($return) {
return $output;
} else {
}
$actions[] = "<a title=\"".get_string('update')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=editpage&pageid=$page->id\">
<img src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"".get_string('update')."\" /></a>\n";
-
+
$actions[] = "<a title=\"".get_string('preview')."\" href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&pageid=$page->id\">
<img src=\"" . $OUTPUT->old_icon_url('t/preview') . "\" class=\"iconsmall\" alt=\"".get_string('preview')."\" /></a>\n";
**/
function lesson_print_add_links($cmid, $prevpageid, $return = false) {
global $CFG;
-
+
$context = get_context_instance(CONTEXT_MODULE, $cmid);
-
+
$links = '';
if (has_capability('mod/lesson:edit', $context)) {
$links = array();
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/import.php?id=$cmid&pageid=$prevpageid\">".
get_string('importquestions', 'lesson').'</a>';
-
+
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=addcluster&pageid=$prevpageid\">".
get_string('addcluster', 'lesson').'</a>';
-
+
if ($prevpageid != 0) {
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=addendofcluster&pageid=$prevpageid\">".
get_string('addendofcluster', 'lesson').'</a>';
}
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=addbranchtable&pageid=$prevpageid\">".
get_string('addabranchtable', 'lesson').'</a>';
-
+
if ($prevpageid != 0) {
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=addendofbranch&pageid=$prevpageid\">".
get_string('addanendofbranch', 'lesson').'</a>';
}
-
+
$links[] = "<a href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=addpage&pageid=$prevpageid\">".
get_string('addaquestionpagehere', 'lesson').'</a>';
-
+
$links = implode(" | \n", $links);
$links = "\n<div class=\"addlinks\">\n$links\n</div>\n";
}
case LESSON_NUMERICAL :
return $LESSON_QUESTION_TYPE[$qtype];
break;
- case LESSON_BRANCHTABLE :
+ case LESSON_BRANCHTABLE :
return get_string("branchtable", "lesson");
break;
case LESSON_ENDOFBRANCH :
**/
function lesson_get_jump_name($jumpto) {
global $DB;
-
+
if ($jumpto == 0) {
$jumptitle = get_string('thispage', 'lesson');
} elseif ($jumpto == LESSON_NEXTPAGE) {
$jumptitle = '<strong>'.get_string('notdefined', 'lesson').'</strong>';
}
}
-
+
return format_string($jumptitle,true);
}
*
* This is only used when IMPORTING questions and is only called
* from format.php
- * Lifted from mod/quiz/lib.php -
+ * Lifted from mod/quiz/lib.php -
* 1. all reference to oldanswers removed
* 2. all reference to quiz_multichoice table removed
* 3. In SHORTANSWER questions usecase is store in the qoption field
* 4. In NUMERIC questions store the range as two answers
* 5. TRUEFALSE options are ignored
* 6. For MULTICHOICE questions with more than one answer the qoption field is true
- *
+ *
* @param opject $question Contains question data like question, type and answers.
* @return object Returns $result->error or $result->notice.
**/
function lesson_save_question_options($question) {
global $DB;
-
+
$timenow = time();
switch ($question->qtype) {
case LESSON_SHORTANSWER:
$answers = array();
$maxfraction = -1;
-
- // for each answer store the pair of min and max values even if they are the same
+
+ // for each answer store the pair of min and max values even if they are the same
foreach ($question->answer as $key => $dataanswer) {
if ($dataanswer != "") {
$answer = new stdClass;
// $answer->answer = $question->min[$key].":".$question->max[$key]; original line for min/max
$answer->response = $question->feedback[$key];
$answer->id = $DB->insert_record("lesson_answers", $answer);
-
+
$answers[] = $answer->id;
if ($question->fraction[$key] > $maxfraction) {
$maxfraction = $question->fraction[$key];
}
$true->id = $DB->insert_record("lesson_answers", $answer);
- // the lie
+ // the lie
$answer = new stdClass;
$answer->lessonid = $question->lessonid;
$answer->pageid = $question->id;
$answer->response = $question->feedback[$key];
$answer->id = $DB->insert_record("lesson_answers", $answer);
// for Sanity checks
- if ($question->fraction[$key] > 0) {
+ if ($question->fraction[$key] > 0) {
$totalfraction += $question->fraction[$key];
}
if ($question->fraction[$key] > $maxfraction) {
$answer->pageid = $question->id;
$answer->timecreated = $timenow;
$answer->answer = $questiontext;
- $answer->response = $answertext;
+ $answer->response = $answertext;
if ($i == 0) {
// first answer contains the correct answer jump
$answer->jumpto = LESSON_NEXTPAGE;
*
* returns true if jumpto page is (logically) after the pageid page or
* if the jumpto value is a special value. Returns false in all other cases.
- *
+ *
* @param int $pageid Id of the page from which you are jumping from.
* @param int $jumpto The jumpto number.
* @return boolean True or false after a series of tests.
**/
function lesson_iscorrect($pageid, $jumpto) {
global $DB;
-
+
// first test the special values
if (!$jumpto) {
// same page
**/
function lesson_display_branch_jumps($lessonid, $pageid) {
global $DB;
-
+
if($pageid == 0) {
// first page
return false;
if ($lessonpages[$pageid]->qtype == LESSON_BRANCHTABLE) {
return true;
}
-
+
return lesson_is_page_in_branch($lessonpages, $pageid);
}
/**
* Checks to see if a page is a cluster page or is
- * a page that is enclosed by a cluster page and an end of cluster or end of lesson
+ * a page that is enclosed by a cluster page and an end of cluster or end of lesson
* May call this function: {@link lesson_is_page_in_cluster()}
- *
+ *
* @param int $lesson Id of the lesson to which the page belongs.
* @param int $pageid Id of the page.
* @return boolean True or false.
**/
function lesson_display_cluster_jump($lesson, $pageid) {
global $DB;
-
+
if($pageid == 0) {
// first page
return false;
if ($lessonpages[$pageid]->qtype == LESSON_CLUSTER) {
return true;
}
-
+
return lesson_is_page_in_cluster($lessonpages, $pageid);
}
/**
- * Checks to see if a LESSON_CLUSTERJUMP or
+ * Checks to see if a LESSON_CLUSTERJUMP or
* a LESSON_UNSEENBRANCHPAGE is used in a lesson.
*
- * This function is only executed when a teacher is
+ * This function is only executed when a teacher is
* checking the navigation for a lesson.
*
* @param int $lesson Id of the lesson that is to be checked.
**/
function lesson_display_teacher_warning($lesson) {
global $DB;
-
+
// get all of the lesson answers
$params = array ("lessonid" => $lesson);
if (!$lessonanswers = $DB->get_records_select("lesson_answers", "lessonid = :lessonid", $params)) {
return true;
}
}
-
+
// if no answers use either of the two jumps
return false;
}
* This will select a page randomly
* and the page selected will be inbetween a cluster page and end of cluter or end of lesson
* and the page selected will be a page that has not been viewed already
- * and if any pages are within a branch table or end of branch then only 1 page within
+ * and if any pages are within a branch table or end of branch then only 1 page within
* the branch table or end of branch will be randomly selected (sub clustering).
- *
+ *
* @param int $lessonid Id of the lesson.
* @param int $userid Id of the user.
* @param int $pageid Id of the current page from which we are jumping from.
**/
function lesson_cluster_jump($lessonid, $userid, $pageid) {
global $DB;
-
+
// get the number of retakes
if (!$retakes = $DB->count_records("lesson_grades", array("lessonid"=>$lessonid, "userid"=>$userid))) {
$retakes = 0;
}
$pageid = $lessonpages[$pageid]->nextpageid; // move down from the cluster page
-
+
$clusterpages = array();
while (true) { // now load all the pages into the cluster that are not already inside of a branch table.
if ($lessonpages[$pageid]->qtype == LESSON_ENDOFCLUSTER) {
if ($flag && count($branchpages) > 0) {
// add branch table
$unseen[] = $clusterpage;
- }
+ }
} else {
// add any other type of page that has not already been viewed
if (!array_key_exists($clusterpage->id, $seenpages)) {
} else {
return $exitjump; // seen all there is to see, leave the cluster
}
-
+
if ($nextpage->qtype == LESSON_BRANCHTABLE) { // if branch table, then pick a random page inside of it
$branchpages = lesson_pages_in_branch($lessonpages, $nextpage->id);
return $branchpages[rand(0, count($branchpages)-1)]->id;
/**
* Returns pages that are within a branch table and another branch table, end of branch or end of lesson
- *
+ *
* @param array $lessonpages An array of lesson page objects.
* @param int $branchid The id of the branch table that we would like the containing pages for.
* @return array An array of lesson page objects.
function lesson_pages_in_branch($lessonpages, $branchid) {
$pageid = $lessonpages[$branchid]->nextpageid; // move to the first page after the branch table
$pagesinbranch = array();
-
- while (true) {
+
+ while (true) {
if ($pageid == 0) { // EOL
break;
} elseif ($lessonpages[$pageid]->qtype == LESSON_BRANCHTABLE) {
$pagesinbranch[] = $lessonpages[$pageid];
$pageid = $lessonpages[$pageid]->nextpageid;
}
-
+
return $pagesinbranch;
}
/**
* Interprets the LESSON_UNSEENBRANCHPAGE jump.
- *
+ *
* will return the pageid of a random unseen page that is within a branch
*
* @see lesson_pages_in_branch()
**/
function lesson_unseen_question_jump($lesson, $user, $pageid) {
global $DB;
-
+
// get the number of retakes
if (!$retakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson, "userid"=>$user))) {
$retakes = 0;
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
print_error('cannotfindpages', 'lesson');
}
-
+
if ($pageid == LESSON_UNSEENBRANCHPAGE) { // this only happens when a student leaves in the middle of an unseen question within a branch series
$pageid = $seenpages[0]; // just change the pageid to the last page viewed inside the branch table
}
}
$pageid = $lessonpages[$pageid]->prevpageid;
}
-
+
$pagesinbranch = lesson_pages_in_branch($lessonpages, $pageid);
-
+
// this foreach loop stores all the pages that are within the branch table but are not in the $seenpages array
$unseen = array();
- foreach($pagesinbranch as $page) {
+ foreach($pagesinbranch as $page) {
if (!in_array($page->id, $seenpages)) {
$unseen[] = $page->id;
}
**/
function lesson_unseen_branch_jump($lessonid, $userid) {
global $DB;
-
+
if (!$retakes = $DB->count_records("lesson_grades", array("lessonid"=>$lessonid, "userid"=>$userid))) {
$retakes = 0;
}
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
print_error('cannotfindpages', 'lesson');
}
-
+
// this loads all the viewed branch tables into $seen untill it finds the branch table with the flag
// which is the branch table that starts the unseenbranch function
- $seen = array();
+ $seen = array();
foreach ($seenbranches as $seenbranch) {
if (!$seenbranch->flag) {
$seen[$seenbranch->pageid] = $seenbranch->pageid;
/**
* Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE).
- *
+ *
* @param int $lessonid Lesson id.
* @param int $pageid The id of the page that we are jumping from (?)
* @return int The pageid of a random page that is within a branch table
**/
function lesson_random_question_jump($lessonid, $pageid) {
global $DB;
-
+
// get the lesson pages
$params = array ("lessonid" => $lessonid);
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
$pageid = $lessonpages[$pageid]->prevpageid;
}
- // get the pages within the branch
+ // get the pages within the branch
$pagesinbranch = lesson_pages_in_branch($lessonpages, $pageid);
-
+
if(count($pagesinbranch) == 0) {
// there are no pages inside the branch, so return the next page
return $lessonpages[$pageid]->nextpageid;
/**
* Check to see if a page is below a branch table (logically).
- *
+ *
* Will return true if a branch table is found logically above the page.
* Will return false if an end of branch, cluster or the beginning
* of the lesson is found before a branch table.
function lesson_is_page_in_branch($pages, $pageid) {
$pageid = $pages[$pageid]->prevpageid; // move up one
- // go up the pages till branch table
+ // go up the pages till branch table
while (true) {
if ($pageid == 0) { // ran into the beginning of the lesson
return false;
/**
* Check to see if a page is below a cluster page (logically).
- *
+ *
* Will return true if a cluster is found logically above the page.
* Will return false if an end of cluster or the beginning
* of the lesson is found before a cluster page.
function lesson_is_page_in_cluster($pages, $pageid) {
$pageid = $pages[$pageid]->prevpageid; // move up one
- // go up the pages till branch table
+ // go up the pages till branch table
while (true) {
if ($pageid == 0) { // ran into the beginning of the lesson
return false;
nmanual => number of manually graded questions
manualpoints => point value for manually graded questions }
*/
-function lesson_grade($lesson, $ntries, $userid = 0) {
+function lesson_grade($lesson, $ntries, $userid = 0) {
global $USER, $DB;
if (empty($userid)) {
$userid = $USER->id;
}
-
+
// Zero out everything
$ncorrect = 0;
$nviewed = 0;
$earned = 0;
$params = array ("lessonid" => $lesson->id, "userid" => $userid, "retry" => $ntries);
- if ($useranswers = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND
+ if ($useranswers = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND
userid = :userid AND retry = :retry", $params, "timeseen")) {
// group each try with its page
$attemptset = array();
foreach ($useranswers as $useranswer) {
- $attemptset[$useranswer->pageid][] = $useranswer;
+ $attemptset[$useranswer->pageid][] = $useranswer;
}
-
+
// Drop all attempts that go beyond max attempts for the lesson
foreach ($attemptset as $key => $set) {
$attemptset[$key] = array_slice($set, 0, $lesson->maxattempts);
}
-
+
// get only the pages and their answers that the user answered
list($usql, $parameters) = $DB->get_in_or_equal(array_keys($attemptset));
$parameters["lessonid"] = $lesson->id;
$pages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid AND id $usql", $parameters);
$answers = $DB->get_records_select("lesson_answers", "lessonid = :lessonid AND pageid $usql", $parameters);
-
+
// Number of pages answered
$nquestions = count($pages);
// Number of times answered
$nviewed += count($attempts);
}
-
+
if ($lesson->custom) {
$bestscores = array();
// Find the highest possible score per page to get our total
}
}
}
-
+
if ($total) { // not zero
$thegrade = round(100 * $earned / $total, 5);
}
-
+
// Build the grade information object
$gradeinfo = new stdClass;
$gradeinfo->nquestions = $nquestions;
$gradeinfo->grade = $thegrade;
$gradeinfo->nmanual = $nmanual;
$gradeinfo->manualpoints = $manualpoints;
-
+
return $gradeinfo;
}
/**
* Prints the on going message to the user.
*
- * With custom grading On, displays points
+ * With custom grading On, displays points
* earned out of total points possible thus far.
* With custom grading Off, displays number of correct
* answers out of total attempted.
$ntries--;
}
$gradeinfo = lesson_grade($lesson, $ntries);
-
+
$a = new stdClass;
if ($lesson->custom) {
$a->score = $gradeinfo->earned;
/**
* Prints tabs for the editing and adding pages. Each tab is a question type.
- *
+ *
* @param array $qtypes The question types array (may not need to pass this because it is defined in this file)
* @param string $selected Current selected tab
* @param string $link The base href value of the link for the tab
if (!$lesson->progressbar) {
return false;
}
-
+
// catch teachers
if (has_capability('mod/lesson:manage', $context)) {
echo $OUTPUT->notification(get_string('progressbarteacherwarning2', 'lesson'));
}
}
}
-
+
// current attempt number
if (!$ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id))) {
$ntries = 0; // may not be necessary
}
-
+
$viewedpageids = array();
-
+
// collect all of the correctly answered questions
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries);
if ($viewedpages = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND userid = :userid AND retry = :retry AND correct = 1", $params, 'timeseen DESC', 'pageid, id')) {
// Pages found inside of Clusters
// Do not filter out Cluster Page(s) because we count a cluster as one.
// By keeping the cluster page, we get our 1
- $validpages = array();
+ $validpages = array();
while ($pageid != 0) {
if ($pages[$pageid]->qtype == LESSON_CLUSTER) {
$clusterpageid = $pageid; // copy it
$validpages[$clusterpageid] = 1; // add the cluster page as a valid page
$pageid = $pages[$pageid]->nextpageid; // get next page
-
+
// now, remove all necessary viewed paged ids from the viewedpageids array.
while ($pages[$pageid]->qtype != LESSON_ENDOFCLUSTER and $pageid != 0) {
if (in_array($pageid, $viewedpageids)) {
unset($viewedpageids[array_search($pageid, $viewedpageids)]); // remove it
// since the user did see one page in the cluster, add the cluster pageid to the viewedpageids
- if (!in_array($clusterpageid, $viewedpageids)) {
+ if (!in_array($clusterpageid, $viewedpageids)) {
$viewedpageids[] = $clusterpageid;
}
}
$validpages[$pageid] = 1;
$pageid = $pages[$pageid]->nextpageid;
}
- }
-
+ }
+
// progress calculation as a percent
- $progress = round(count($viewedpageids)/count($validpages), 2) * 100;
+ $progress = round(count($viewedpageids)/count($validpages), 2) * 100;
} else {
$progress = 100;
}
echo '</td>';
echo '</tr></table>';
echo '</div>';
-
+
return true;
}
**/
function lesson_displayleftif($lesson) {
global $CFG, $USER, $DB;
-
+
if (!empty($lesson->displayleftif)) {
// get the current user's max grade for this lesson
$params = array ("userid" => $USER->id, "lessonid" => $lesson->id);
return 0; // no grades
}
}
-
+
// if we get to here, keep the original state of displayleft lesson setting
return $lesson->displayleft;
}
/**
- *
+ *
* @param $cm
* @param $lesson
* @param $page
}
/**
- * If there is a media file associated with this
+ * If there is a media file associated with this
* lesson, return a block_contents that displays it.
*
* @param int $cmid Course Module ID for this lesson
$link = html_link::make($url, get_string('mediafilepopup', 'lesson'));
$link->add_action(new popup_action('click', $link->url, $name, $options));
$link->title = get_string('mediafilepopup', 'lesson');
- $content .= $OUTPUT->link($link);
-
+ $content .= $OUTPUT->link($link);
+
$content .= $OUTPUT->help_icon(moodle_help_icon::make("mediafilestudent", get_string("mediafile", "lesson"), "lesson"));
$bc = new block_contents();
// Only process branch tables with display turned on
if ($page->qtype == LESSON_BRANCHTABLE and $page->display) {
- if ($page->id == $currentpageid) {
+ if ($page->id == $currentpageid) {
$content .= '<li class="selected">'.format_string($page->title,true)."</li>\n";
} else {
$content .= "<li class=\"notselected\"><a href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&pageid=$page->id\">".format_string($page->title,true)."</a></li>\n";
}
-
+
}
$pageid = $page->nextpageid;
}
}
if (is_url($lesson->mediafile)) {
- $fullurl = $lesson->mediafile;
+ $fullurl = $lesson->mediafile;
} else {
$fullurl = get_file_url($course->id .'/'. $lesson->mediafile);
}
// find the correct type and print it out
if ($mimetype == "audio/mp3") { // It's an MP3 audio file
-
+
if (!empty($THEME->resource_mp3player_colors)) {
$c = $THEME->resource_mp3player_colors; // You can set this up in your theme/xxx/config.php
} else {
echo '</div>';
} else if (substr($mimetype, 0, 10) == "video/x-ms") { // It's a Media Player file
-
+
echo "<div class=\"lessonmediafilecontrol\"><p>";
echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
echo ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
echo "</p></div>";
} else if ($mimetype == "video/quicktime") { // It's a Quicktime file
-
+
echo "<div class=\"lessonmediafilecontrol\"><p>";
echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
echo ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
echo '</embed>';
echo '</object>';
echo "</p></div>";
-
+
//} else if ($mimetype == "application/x-shockwave-flash") { // It's a flash file
-
+
// print_error('noflash');
-
+
} else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file
-
+
echo '<object id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="600" height="50">';
echo "<param name=\"src\" value=\"$fullurl\">";
echo '<param name="console" value="video">'; // not sure what the console param should equal
echo $OUTPUT->notification(get_string('clicktodownload', 'lesson'));
echo "<a href=\"$fullurl\">".format_string($filename).'</a>';
echo "</p></div>";
-
+
}
-
+
function is_url($test_url) {
// the following is barrowed from resource code. Thanks!
if (strpos($test_url, '://')) { // eg http:// https:// ftp:// etc
echo $OUTPUT->close_window_button();
echo '</div>';
}
-
+
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
/**
* Form to define a new instance of lesson or edit an instance.
* It is used from /course/modedit.php.
return $errors;
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* jjg7:8/9/2004
*
function removedoublecr($filename) {
// This function will adjust a file in roughly Aiken style by replacing extra newlines with <br/> tags
// so that instructors can have newlines wherever they like as long as the overall format is in Aiken
-
+
$filearray = file($filename);
/// Check for Macintosh OS line returns (ie file on one line), and fix
if (preg_match("/\r/", $filearray[0]) AND !preg_match("/\n/", $filearray[0])) {
} else {
$outfile = $filearray;
}
-
+
foreach ($outfile as $line) {
// remove leading and trailing whitespace
trim($line);
}
}
// output modified file to original
- if ( is_writable($filename) ) {
+ if ( is_writable($filename) ) {
- if (! $handle =fopen ($filename ,'w' )) {
+ if (! $handle =fopen ($filename ,'w' )) {
echo "Cannot open file ($filename)" ;
- exit;
- }
+ exit;
+ }
foreach ($outarray as $outline) {
fwrite($handle, $outline);
}
fclose($handle);
- }
- else {
+ }
+ else {
// file not writeable
}
}
$line = trim($line);
// add a space at the end, quick hack to make sure words from different lines don't run together
$line = $line. ' ';
-
+
// ignore lines less than 2 characters
if (strlen($line) < 2) {
continue;
}
-
+
// see if we have the answer line
if ($line[0] =='*') {
if ($line[0] == '*') {
- $answer_found = 1;
+ $answer_found = 1;
$line[0]="\t";
$line = ltrim($line);
$answer = $line[0];
$outlines[$cur_pos] = $outlines[$cur_pos]."\n";
}
-
+
$responses = 1;
// make character uppercase
$line[0]=strtoupper($line[0]);
-
+
// make entry followed by '.'
$line[1]='.';
}
$np = 0;
// this probably could be done cleaner... it escapes me at the moment
while ($line[$np] == '0' OR $line[$np] == '1' OR $line[$np] == '2'
- OR $line[$np] == '3' OR $line[$np] == '4' OR $line[$np] == '5'
+ OR $line[$np] == '3' OR $line[$np] == '4' OR $line[$np] == '5'
OR $line[$np] == '6' OR $line[$np] == '7' OR $line[$np] == '8'
OR $line[$np] == '9' ) {
$np++;
}
// grab everything after '###.'
- $line = substr($line, $np+1, strlen($line));
+ $line = substr($line, $np+1, strlen($line));
if ($responses AND $answer_found) {
$responses = 0;
// output the last answer
$answer = strtoupper($answer);
$outlines[] = "ANSWER: $answer\n\n";
-
+
// output modified file to original
- if ( is_writable($filename) ) {
- if (! $handle =fopen ($filename ,'w' )) {
+ if ( is_writable($filename) ) {
+ if (! $handle =fopen ($filename ,'w' )) {
echo "Cannot open file ($filename)" ;
- exit;
+ exit;
}
foreach ($outlines as $outline) {
fwrite($handle, $outline);
}
fclose($handle);
return true;
- }
- else {
+ }
+ else {
return false;
}
-}
-?>
+}
+
-<?php // $Id$
+<?php
/**
* Displays the lesson statistics.
*
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
$params["groupid"] = $cm->groupingid;
$sql = "SELECT DISTINCT u.*
- FROM {lesson_attempts} a
+ FROM {lesson_attempts} a
INNER JOIN {user} u ON u.id = a.userid
INNER JOIN {groups_members} gm ON gm.userid = u.id
INNER JOIN {groupings_groups} gg ON gm.groupid = :groupid
u.id = a.userid
ORDER BY u.lastname";
}
-
+
if (! $students = $DB->get_records_sql($sql, $params)) {
$nothingtodisplay = true;
}
-
+
// make sure people are where they should be
require_login($course->id, false, $cm);
require_capability('mod/lesson:manage', $context);
/// Process any form data before fetching attempts, grades and times
- if (has_capability('mod/lesson:edit', $context) and
- $form = data_submitted() and
+ if (has_capability('mod/lesson:edit', $context) and
+ $form = data_submitted() and
confirm_sesskey()) {
/// Cycle through array of userids with nested arrays of tries
if (!empty($form->attempts)) {
// So, the modifier makes sure that the submitted try refers to the current try in the
// database - hope this all makes sense :)
$modifier = 0;
-
+
foreach ($tries as $try => $junk) {
$try -= $modifier;
-
+
/// Clean up the timer table
$params = array ("userid" => $userid, "lessonid" => $lesson->id);
- $timeid = $DB->get_field_sql("SELECT id FROM {lesson_timer}
- WHERE userid = :userid AND lessonid = :lessonid
+ $timeid = $DB->get_field_sql("SELECT id FROM {lesson_timer}
+ WHERE userid = :userid AND lessonid = :lessonid
ORDER BY starttime", $params, $try, 1);
-
+
$DB->delete_records('lesson_timer', array('id' => $timeid));
-
+
/// Remove the grade from the grades and high_scores tables
- $gradeid = $DB->get_field_sql("SELECT id FROM {lesson_grades}
- WHERE userid = :userid AND lessonid = :lessonid
+ $gradeid = $DB->get_field_sql("SELECT id FROM {lesson_grades}
+ WHERE userid = :userid AND lessonid = :lessonid
ORDER BY completed", $params, $try, 1);
-
+
$DB->delete_records('lesson_grades', array('id' => $gradeid));
$DB->delete_records('lesson_high_scores', array('gradeid' => $gradeid, 'lessonid' => $lesson->id, 'userid' => $userid));
-
+
/// Remove attempts and update the retry number
$DB->delete_records('lesson_attempts', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
$DB->execute("UPDATE {lesson_attempts} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
-
- /// Remove seen branches and update the retry number
+
+ /// Remove seen branches and update the retry number
$DB->delete_records('lesson_branch', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
$DB->execute("UPDATE {lesson_branch} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) {
$grades = array();
}
-
+
if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) {
$times = array();
}
lesson_print_header($cm, $course, $lesson, $action);
-
+
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
- echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
+ echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
}
} else {
$temp = '';
}
-
+
$temp .= "<a href=\"report.php?id=$cm->id&action=reportdetail&userid=".$try['userid'].'&try='.$try['try'].'">';
if ($try["grade"] !== NULL) { // if NULL then not done yet
// this is what the link does when the user has completed the try
<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
}
echo $OUTPUT->table($table);
-
+
if (has_capability('mod/lesson:edit', $context)) {
echo '<br /><table width="90%" align="center"><tr><td>'.
'<a href="javascript: checkall();">'.get_string('selectall').'</a> / '.
'<a href="javascript: checknone();">'.get_string('deselectall').'</a> ';
-
+
$select = new html_select();
$select->options = array('delete' => get_string('deleteselected'));
$select->name = 'attemptaction';
$select->selectedvalue = 0;
$select->add_action('change', 'submit_form_by_id', array('id' => 'theform'));
- echo $OUTPUT->select($select);
-
+ echo $OUTPUT->select($select);
+
echo '</td></tr></table></form>';
}
-
+
// some stat calculations
if ($numofattempts == 0) {
$avescore = get_string("notcompleted", "lesson");
$answerpage = new stdClass;
$data ='';
$answerdata = new stdClass;
-
+
$answerpage->title = format_string($page->title);
-
+
$options = new stdClass;
$options->noclean = true;
$answerpage->contents = format_text($page->contents, FORMAT_MOODLE, $options);
$answerdata->score = NULL;
$answerdata->response = NULL;
} elseif ($useranswers = $DB->get_records_select("lesson_attempts",
- "lessonid = :lessonid AND userid = :userid AND retry = :retry AND pageid = :pageid",
+ "lessonid = :lessonid AND userid = :userid AND retry = :retry AND pageid = :pageid",
array("lessonid" => $lesson->id, "userid" => $userid, "retry" => $try, "pageid" => $page->id), "timeseen")) {
// get the user's answer for this page
// need to find the right one
if (!empty($userid)) {
// if looking at a students try, print out some basic stats at the top
-
+
// print out users name
//$headingobject->lastname = $students[$userid]->lastname;
//$headingobject->firstname = $students[$userid]->firstname;
//$headingobject->attempt = $try + 1;
//print_heading(get_string("studentattemptlesson", "lesson", $headingobject));
echo $OUTPUT->heading(get_string('attempt', 'lesson', $try+1));
-
+
$table->head = array();
$table->align = array("right", "left");
$table->class = 'generaltable userinfotable';
$table->data[] = array(get_string("notcompleted", "lesson"));
} else {
$user = $students[$userid];
-
+
$gradeinfo = lesson_grade($lesson, $try, $user->id);
-
+
$table->data[] = array(get_string('name').':', $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id)).fullname($user, true));
$table->data[] = array(get_string("timetaken", "lesson").":", format_time($timetotake));
$table->data[] = array(get_string("completed", "lesson").":", userdate($completed));
$table->data[] = array(get_string("grade", "lesson").":", $grade."%");
}
echo $OUTPUT->table($table);
-
+
// Don't want this class for later tables
$table->set_classes();
echo "<br />";
/// Finish the page
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
/**
* This php script contains all the stuff to restore lesson mods
*
* @package lesson
**/
- //This is the "graphical" structure of the lesson mod:
+ //This is the "graphical" structure of the lesson mod:
//
// lesson_default lesson ----------------------------|--------------------------|--------------------------|
// (UL, pk->id,fk->courseid) (CL,pk->id) | | |
$lesson->practice = backup_todb($info['MOD']['#']['PRACTICE']['0']['#']);
$lesson->modattempts = backup_todb($info['MOD']['#']['MODATTEMPTS']['0']['#']);
$lesson->usepassword = backup_todb($info['MOD']['#']['USEPASSWORD']['0']['#']);
- $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
+ $lesson->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
$lesson->dependency = isset($info['MOD']['#']['DEPENDENCY']['0']['#'])?backup_todb($info['MOD']['#']['DEPENDENCY']['0']['#']):'';
$lesson->conditions = isset($info['MOD']['#']['CONDITIONS']['0']['#'])?backup_todb($info['MOD']['#']['CONDITIONS']['0']['#']):'';
$lesson->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
if (!$lessondefault) {
$status = lesson_default_restore_mods($info,$restore);
}
-
+
}
} else {
$status = false;
backup_putid($restore->backup_unique_code,"lesson_pages", $oldid, $newid);
//We have to restore the lesson_answers table now (a page level table)
$status = lesson_answers_restore($lessonid,$newid,$page_info,$restore,$userdata);
-
+
//Need to update useranswer field (which has answer id's in it)
//for matching and multi-answer multi-choice questions
if ($userdata) { // first check to see if we even have to do this
}
}
}
- }
-
+ }
+
// backup branch table info for branch tables.
if ($status && $userdata) {
if (!lesson_branch_restore($lessonid,$newid,$page_info,$restore)) {
if ($newid) {
// need to store the id so we can update the useranswer
// field in attempts. This is done in the lesson_pages_restore_mods
- backup_putid($restore->backup_unique_code,"lesson_answers", $oldid, $newid);
+ backup_putid($restore->backup_unique_code,"lesson_answers", $oldid, $newid);
if ($userdata) {
//We have to restore the lesson_attempts table now (a answers level table)
return $status;
}
-
-
-
+
+
+
//This function restores the lesson_branch
function lesson_branch_restore($lessonid, $pageid, $info, $restore) {
global $CFG, $DB;
if ($user) {
$highscore->userid = $user->new_id;
}
-
+
//The structure is equal to the db, so insert the lesson_grade
$newid = $DB->insert_record ("lesson_high_scores",$highscore);
return $status;
}
-
+
//This function restores the lesson_default
function lesson_default_restore_mods($info, $restore) {
global $CFG, $DB;
//The structure is equal to the db, so insert the lesson_grade
$newid = $DB->insert_record ("lesson_default",$default);
-
+
if ($newid) {
backup_putid($restore->backup_unique_code,'lesson_default',
$restore->course_id, $newid);
}
-
+
//Do some output
if (($i+1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
//in the restore process
function lesson_decode_content_links ($content,$restore) {
global $CFG;
-
+
$result = $content;
-
+
//Link to the list of lessons
-
+
$searchstring='/\$@(LESSONINDEX)\*([0-9]+)@\$/';
//We look for it
preg_match_all($searchstring,$content,$foundset);
if($rec->new_id) {
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/lesson/index.php?id='.$rec->new_id,$result);
- } else {
+ } else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/lesson/index.php?id='.$old_id,$result);
}
function lesson_decode_content_links_caller($restore) {
global $CFG, $DB;
$status = true;
-
+
//Process every lesson PAGE in the course
if ($pages = $DB->get_records_sql("SELECT p.id, p.contents
FROM {lesson_pages} p,
}
return $status;
}
-?>
+
/***
*** General styles (scope: all of lesson)
***/
-
+
.mod-lesson .contents {
text-align: left;
}
***/
/* NOTE: background color, height and width are set in the lesson settings */
-.mod-lesson .slideshow {
+.mod-lesson .slideshow {
overflow: auto;
- padding-right: 16px; /* for the benefit of macIE5 only */
+ padding-right: 16px; /* for the benefit of macIE5 only */
/* \ commented backslash hack - recover from macIE5 workarounds, it will ignore the following rule */
padding-right: 0;
padding: 15px;
}
.mod-lesson .lessonbutton a:link,
-.mod-lesson .lessonbutton a:visited,
+.mod-lesson .lessonbutton a:visited,
.mod-lesson .lessonbutton a:hover {
color: #000;
text-decoration: none;
*/
background-color: green;
padding: 0px;
- margin: 0px;
+ margin: 0px;
}
.mod-lesson .progress_bar_todo {
-<?php // $Id$
+<?php
/**
* Sets up the tabs used by the lesson pages for teachers.
*
/// user attempt count for reports link hover (completed attempts - much faster)
$attemptscount = $DB->count_records('lesson_grades', array('lessonid'=>$lesson->id));
-
+
$row[] = new tabobject('view', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)));
$row[] = new tabobject('edit', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('edit', 'lesson'), get_string('edit', 'moodle', format_string($lesson->name)));
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports2', 'lesson', $attemptscount));
/// sub tabs for edit view (collapsed and expanded aka full)
$inactive[] = 'edit';
$activated[] = 'edit';
-
+
$row = array();
$row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=collapsed", get_string('collapsed', 'lesson'));
$row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=full", get_string('full', 'lesson'));
print_tabs($tabs, $currenttab, $inactive, $activated);
-?>
+
testlength = parseInt(clocksettings.testlength);
}
}
-
- difference = javatime - servertime;
+
+ difference = javatime - servertime;
starttime = starttime + difference;
- var dn = "";
+ var dn = "";
var old = "";
- if (document.all||document.getElementById) {
- document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>');
- } else if (document.layers) {
+ if (document.all||document.getElementById) {
+ document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>');
+ } else if (document.layers) {
document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>');
- } else {
+ } else {
old = "true"; show_clock();
}
-
+
/*function leave() { // feable attempt to run a script when someone leaves a timed test early, failed so far
window.onunload = window.open('http://www.google.com','','toolbar=no,menubar=no,location=no,height=500,width=500');
}
leave();*/
-
+
function show_clock() {
//show clock in NS 4
currentDate = new Date();
current = currentDate.getTime();
current = Math.floor(current/1000);
-
+
if (current > starttime + testlength) {
myclock = '';
myclock += '<font style="color:'+myfont_color+'; font-family:'+myfont_face+'; font-size:'+myfont_size+'pt;">';
hours = Math.floor(timeleft/3600);
timeleft = timeleft - (hours * 3600);
minutes = Math.floor(timeleft/60);
- secs = timeleft - (minutes * 60);
-
+ secs = timeleft - (minutes * 60);
+
if (secs < 10) {
secs = "0"+secs;
}
myclock += hours+":"+minutes+":"+secs;
myclock += '</font>';
}
-
+
if (old == "true") {
document.write(myclock);
old = "die"; return;
-<?php // $Id$
+<?php
/**
* Code fragment to define the version of lesson
* This fragment is called by moodle_needs_upgrading() and /admin/index.php
$module->requires = 2008072401; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
-?>
+
-<?php // $Id$
+<?php
/**
* This page prints a particular instance of lesson
*
/// Mark as viewed
$completion=new completion_info($course);
$completion->set_module_viewed($cm);
-?>
+