-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
83 changed files
with
1,215 additions
and
4,396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,28 +19,34 @@ | |
* | ||
* @package mod_capquiz | ||
* @author Aleksander Skrede <[email protected]> | ||
* @copyright 2018 NTNU | ||
* @copyright 2018 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_capquiz; | ||
use mod_capquiz\capquiz; | ||
use mod_capquiz\capquiz_action_performer; | ||
|
||
require_once ("../../config.php"); | ||
global $CFG; | ||
|
||
require_once("../../config.php"); | ||
require_once($CFG->libdir . '/formslib.php'); | ||
require_once($CFG->dirroot . '/mod/capquiz/lib.php'); | ||
require_once($CFG->dirroot . '/mod/capquiz/classes/capquiz_action_performer.php'); | ||
|
||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
global $PAGE; | ||
|
||
$cmid = required_param('id', PARAM_INT); | ||
$cm = get_coursemodule_from_id('capquiz', $cmid, 0, false, MUST_EXIST); | ||
require_login($cm->course, false, $cm); | ||
|
||
$context = \context_module::instance($cmid); | ||
$context = context_module::instance($cmid); | ||
require_capability('mod/capquiz:instructor', $context); | ||
|
||
$action = required_param('action', PARAM_TEXT); | ||
|
||
$capquiz = new capquiz($cmid); | ||
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync); | ||
capquiz_action_performer::perform($action, $capquiz); | ||
$PAGE->set_context($context); | ||
$PAGE->set_cm($cm); | ||
$PAGE->set_url(new moodle_url('/mod/capquiz/async.php')); | ||
|
||
capquiz_action_performer::perform($action, new capquiz($cmid)); | ||
|
||
capquiz_urls::redirect_to_dashboard(); | ||
redirect(new moodle_url('/mod/capquiz/view.php', ['id' => $cmid])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,36 +19,42 @@ | |
* | ||
* @package mod_capquiz | ||
* @author Aleksander Skrede <[email protected]> | ||
* @copyright 2018 NTNU | ||
* @copyright 2018 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_capquiz; | ||
use mod_capquiz\capquiz; | ||
use mod_capquiz\capquiz_question_attempt; | ||
use mod_capquiz\capquiz_question_engine; | ||
|
||
require_once('../../config.php'); | ||
require_once(__DIR__ . '/../../config.php'); | ||
|
||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
global $PAGE; | ||
|
||
$cmid = required_param('id', PARAM_INT); | ||
$cm = get_coursemodule_from_id('capquiz', $cmid, 0, false, MUST_EXIST); | ||
require_login($cm->course, false, $cm); | ||
$context = \context_module::instance($cmid); | ||
|
||
$context = context_module::instance($cmid); | ||
require_capability('mod/capquiz:student', $context); | ||
|
||
$action = required_param('action', PARAM_TEXT); | ||
$attemptid = optional_param('attempt', null, PARAM_INT); | ||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
$capquiz = new capquiz($cmid); | ||
$action = required_param('action', PARAM_TEXT); | ||
|
||
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync); | ||
$PAGE->set_context($context); | ||
$PAGE->set_cm($cm); | ||
$PAGE->set_url(new moodle_url('/mod/capquiz/async.php')); | ||
|
||
if ($attemptid !== null) { | ||
$capquiz = new capquiz($cmid); | ||
$user = $capquiz->user(); | ||
$attempt = capquiz_question_attempt::load_attempt($user, $attemptid); | ||
if ($action === 'answered') { | ||
$capquiz->question_engine($user)->attempt_answered($user, $attempt); | ||
(new capquiz_question_engine($capquiz))->attempt_answered($user, $attempt); | ||
} else if ($action === 'reviewed') { | ||
$capquiz->question_engine($user)->attempt_reviewed($attempt); | ||
(new capquiz_question_engine($capquiz))->attempt_reviewed($attempt); | ||
} | ||
capquiz_urls::redirect_to_dashboard(); | ||
redirect(new moodle_url('/mod/capquiz/view.php', ['id' => $cmid])); | ||
} | ||
|
||
capquiz_urls::redirect_to_front_page(); | ||
redirect(new moodle_url('/')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
|
||
namespace mod_capquiz\bank; | ||
|
||
use mod_capquiz\capquiz_urls; | ||
use moodle_url; | ||
use stdClass; | ||
|
||
/** | ||
* Question bank action to add question to quiz. | ||
* | ||
* @package mod_capquiz | ||
* @copyright 2024 NTNU | ||
* @author 2024 Sebastian Gundersen | ||
* @author 2024 Sebastian Gundersen <[email protected]> | ||
* @copyright 2024 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class add_to_quiz_action extends \core_question\local\bank\question_action_base { | ||
|
@@ -38,9 +38,15 @@ class add_to_quiz_action extends \core_question\local\bank\question_action_base | |
* $label - text label to display in the UI (either in the menu, or as a tool-tip on the icon) | ||
*/ | ||
protected function get_url_icon_and_label(stdClass $question): array { | ||
global $PAGE; | ||
if (!question_has_capability_on($question, 'use')) { | ||
return [null, null, null]; | ||
} | ||
return [capquiz_urls::add_question_to_list_url($question->id), 't/add', get_string('addtoquiz', 'quiz')]; | ||
$url = new moodle_url('/mod/capquiz/action.php', [ | ||
'id' => $PAGE->cm->id, | ||
'action' => 'add-question', | ||
'question-id' => $question->id, | ||
]); | ||
return [$url, 't/add', get_string('addtoquiz', 'quiz')]; | ||
} | ||
} |
Oops, something went wrong.