Skip to content

Commit 947a4fe

Browse files
committed
Adição de módulo hotpot
1 parent d0c97dd commit 947a4fe

File tree

455 files changed

+63335
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

455 files changed

+63335
-0
lines changed

mod/hotpot/attempt.php

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
// This file is part of Moodle - http://moodle.org/
4+
//
5+
// Moodle is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Moodle is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17+
18+
/**
19+
* Display an attempt page of a hotpot activity
20+
*
21+
* @package mod-hotpot
22+
* @copyright 2010 Gordon Bateson <[email protected]>
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
26+
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
27+
require_once(dirname(__FILE__).'/locallib.php');
28+
29+
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
30+
$hp = optional_param('hp', 0, PARAM_INT); // hotpot instance ID
31+
32+
if ($id) {
33+
$cm = get_coursemodule_from_id('hotpot', $id, 0, false, MUST_EXIST);
34+
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
35+
$hotpot = $DB->get_record('hotpot', array('id' => $cm->instance), '*', MUST_EXIST);
36+
} else {
37+
$hotpot = $DB->get_record('hotpot', array('id' => $hp), '*', MUST_EXIST);
38+
$course = $DB->get_record('course', array('id' => $hotpot->course), '*', MUST_EXIST);
39+
$cm = get_coursemodule_from_instance('hotpot', $hotpot->id, $course->id, false, MUST_EXIST);
40+
}
41+
42+
// Check login
43+
require_login($course, true, $cm);
44+
require_capability('mod/hotpot:attempt', $PAGE->context);
45+
hotpot_add_to_log($course->id, 'hotpot', 'attempt', 'view.php?id='.$cm->id, $hotpot->id, $cm->id);
46+
47+
// Set editing mode
48+
if ($PAGE->user_allowed_editing()) {
49+
hotpot::set_user_editing();
50+
}
51+
52+
// Create an object to represent the current HotPot activity
53+
$hotpot = hotpot::create($hotpot, $cm, $course, $PAGE->context);
54+
55+
// initialize $PAGE (and compute blocks)
56+
$PAGE->set_url($hotpot->attempt_url());
57+
$PAGE->set_title($hotpot->name);
58+
$PAGE->set_heading($course->fullname);
59+
60+
// allow the HotPot activity to set its preferred page layout
61+
$hotpot->set_preferred_pagelayout($PAGE);
62+
63+
/// Create an object to manage all the other (non-roles) access rules.
64+
//$timenow = time();
65+
//$canignoretimelimits = has_capability('mod/hotpot:ignoretimelimits', $PAGE->context, null, false);
66+
//$accessmanager = new hotpot_access_manager($hotpot, $timenow, $canignoretimelimits);
67+
//$messages = $accessmanager->describe_rules();
68+
69+
70+
// get renderer subtype (e.g. attempt_hp_6_jcloze_xml)
71+
// and load the appropriate renderer class for this attempt
72+
if (! $subtype = $hotpot->get_attempt_renderer_subtype()) {
73+
echo $OUTPUT->header();
74+
echo get_string('unrecognizedsourcefile', 'mod_hotpot', $hotpot->sourcefile);
75+
echo $OUTPUT->footer();
76+
exit;
77+
}
78+
79+
$subdir = str_replace('_', '/', $subtype);
80+
require_once($CFG->dirroot.'/mod/hotpot/'.$subdir.'/renderer.php');
81+
82+
// create the renderer for this attempt
83+
$output = $PAGE->get_renderer('mod_hotpot', $subtype);
84+
85+
// print access warnings, if required
86+
if ($warnings = $output->entrywarnings($hotpot)) {
87+
echo $output->header();
88+
echo $warnings;
89+
echo $output->footer();
90+
exit;
91+
}
92+
93+
////////////////////////////////////////////////////////////////////////////////
94+
// Output starts here //
95+
////////////////////////////////////////////////////////////////////////////////
96+
97+
echo $output->render_attempt($hotpot);
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// This file is part of Moodle - http://moodle.org/
2+
//
3+
// Moodle is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// Moodle is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
16+
/**
17+
* mod/hotpot/attempt/hp/6/jcloze/anctscan.js
18+
*
19+
* @package mod-hotpot
20+
* @copyright 2010 Gordon Bateson <[email protected]>
21+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22+
*/
23+
24+
/**
25+
* JCloze_ANCT_Scan
26+
*
27+
* @param xxx sendallclicks
28+
* @param xxx ajax
29+
*/
30+
function JCloze_ANCT_Scan(sendallclicks, ajax) {
31+
this.quiztype = 'JCloze';
32+
33+
/**
34+
* initQuestion
35+
*
36+
* @param xxx i
37+
*/
38+
this.initQuestion = function (i) {
39+
this.questions[i].name = parseInt(i)+1; // gap number
40+
this.questions[i].type = 2; // 2 = JCloze
41+
this.questions[i].text = I[i][1][0][0]; // the correct word
42+
this.questions[i].guesses = new Array();
43+
}
44+
45+
/**
46+
* onclickCheck
47+
*
48+
* @param xxx iscorrect
49+
* @param xxx i
50+
* @param xxx g
51+
*/
52+
this.onclickCheck = function (iscorrect,i,g) {
53+
if (window.Finished) {
54+
return; // quiz is already finished
55+
}
56+
57+
if (i>=GapList.length) {
58+
i = GapList.length - 1;
59+
}
60+
61+
// shortcut to this question
62+
var question = this.questions[i];
63+
64+
// increment check count (even if gap content has not changed)
65+
question.checks++;
66+
67+
var g_max = question.guesses.length;
68+
if (g_max && g==question.guesses[g_max-1]) {
69+
// gap content has not changed
70+
return;
71+
}
72+
question.guesses[g_max] = g;
73+
74+
// create shortcut ot array of correct or wrong responses
75+
if (iscorrect) {
76+
var responses = question.correct;
77+
} else {
78+
var responses = question.wrong;
79+
}
80+
81+
var r_max = responses.length;
82+
for (var r=0; r<r_max; r++) {
83+
if (responses[r]==g) {
84+
// this guess has been entered before
85+
break;
86+
}
87+
}
88+
89+
if (r==r_max) {
90+
// if this is a new g(uess), i.e. it has not been entered before
91+
// append g(uess) to the end of the array of responses
92+
responses[r] = g;
93+
}
94+
} // end function
95+
96+
/**
97+
* setQuestionScore
98+
*
99+
* @param xxx q
100+
*/
101+
this.setQuestionScore = function (q) {
102+
this.questions[q].score = 0; // no scores for individual gaps
103+
}
104+
105+
/**
106+
* setScoreAndPenalties
107+
*
108+
* @param xxx forceRecalculate
109+
*/
110+
this.setScoreAndPenalties = function (forceRecalculate) {
111+
if (forceRecalculate) {
112+
window.Score = 0;
113+
var TotGaps = GapList.length;
114+
if (TotGaps){
115+
var TotCorrectChoices = 0;
116+
for (var i=0; i<TotGaps; i++){
117+
if (GapList[i][1].ErrorFound){
118+
TotCorrectChoices++;
119+
}
120+
}
121+
if (TotCorrectChoices > TotWrongChoices){
122+
window.Score = Math.floor(100 * (TotCorrectChoices - TotWrongChoices) / TotGaps);
123+
}
124+
}
125+
}
126+
this.score = window.Score || 0;
127+
this.penalties = window.Penalties || 0;
128+
}
129+
130+
this.init(I.length, sendallclicks, ajax);
131+
}
132+
JCloze_ANCT_Scan.prototype = new hpQuizAttempt();
+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// This file is part of Moodle - http://moodle.org/
2+
//
3+
// Moodle is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// Moodle is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
16+
/**
17+
* mod/hotpot/attempt/hp/6/jcloze/dropdown.js
18+
*
19+
* @package mod-hotpot
20+
* @copyright 2010 Gordon Bateson <[email protected]>
21+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22+
*/
23+
24+
/**
25+
* JClozeDropDown
26+
*
27+
* @param xxx sendallclicks
28+
* @param xxx ajax
29+
*/
30+
function JClozeDropDown(sendallclicks, ajax) {
31+
this.quiztype = 'JCloze';
32+
33+
/**
34+
* initQuestion
35+
*
36+
* @param xxx i
37+
*/
38+
this.initQuestion = function (i) {
39+
this.questions[i].name = parseInt(i)+1; // gap number
40+
this.questions[i].type = 2; // 2 = JCloze
41+
this.questions[i].text = I[i][2]; // clue text
42+
this.questions[i].guesses = new Array();
43+
}
44+
45+
/**
46+
* onclickCheck
47+
*
48+
* @param xxx setScores
49+
*/
50+
this.onclickCheck = function (setScores) {
51+
var i_max = this.questions.length;
52+
for (var i=0; i<i_max; i++) {
53+
54+
if (GapList[i][1].GapLocked) {
55+
// already correct
56+
continue;
57+
}
58+
59+
var ii = Get_SelectedDropValue(i);
60+
if (isNaN(ii) || ii<0) {
61+
// nothing selected yet
62+
continue;
63+
}
64+
65+
if (window.MakeIndividualDropdowns) {
66+
var is_wrong = (ii!=0);
67+
var g = I[i][1][ii][0];
68+
var MaxNumOfTrials = I[i][1].length;
69+
} else {
70+
var is_wrong = (ii!=i);
71+
var g = I[ii][1][0][0];
72+
var MaxNumOfTrials = GapList.length;
73+
}
74+
if (! g) {
75+
// no gap content - shouldn't happen
76+
continue;
77+
}
78+
if (setScores) {
79+
if (MaxNumOfTrials && MaxNumOfTrials > GapList[i][1].NumOfTrials){
80+
GapList[i][1].Score = 1 - (GapList[i][1].NumOfTrials / MaxNumOfTrials);
81+
} else {
82+
GapList[i][1].Score = 0;
83+
}
84+
if (GapList[i][1].ClueAskedFor){
85+
GapList[i][1].Score /= 2;
86+
}
87+
}
88+
89+
// shortcut to this question
90+
var question = this.questions[i];
91+
92+
// increment check count (even if gap content has not changed)
93+
question.checks++;
94+
95+
var g_max = question.guesses.length;
96+
if (g_max && g==question.guesses[g_max-1]) {
97+
// gap content has not changed
98+
continue;
99+
}
100+
101+
// create shortcut ot array of correct or wrong responses
102+
if (is_wrong) {
103+
var responses = question.wrong;
104+
} else {
105+
var responses = question.correct;
106+
}
107+
var r_max = responses.length;
108+
for (var r=0; r<r_max; r++) {
109+
if (responses[r]==g) {
110+
// this guess has been entered before
111+
break;
112+
}
113+
}
114+
if (r==r_max) {
115+
// if this is a new g(uess), i.e. it has not been entered before
116+
// append g(uess) to the end of the array of responses
117+
responses[r] = g;
118+
}
119+
} // end for loop
120+
121+
if (setScores) {
122+
var TotalScore = 0;
123+
for (var i=0; i<i_max; i++) {
124+
TotalScore += GapList[i][1].Score;
125+
}
126+
window.Score = Math.floor((TotalScore * 100) / i_max);
127+
}
128+
} // end function
129+
130+
/**
131+
* setQuestionScore
132+
*
133+
* @param xxx q
134+
*/
135+
this.setQuestionScore = function (q) {
136+
if (GapList[q]) {
137+
this.questions[q].score = Math.max(0, 100 * GapList[q][1].Score) + '%';
138+
}
139+
}
140+
141+
this.init(I.length, sendallclicks, ajax);
142+
}
143+
JClozeDropDown.prototype = new hpQuizAttempt();

0 commit comments

Comments
 (0)