Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 43... Línea 43...
43
define('CHOICE_DISPLAY_VERTICAL',    '1');
43
define('CHOICE_DISPLAY_VERTICAL',    '1');
Línea 44... Línea 44...
44
 
44
 
45
define('CHOICE_EVENT_TYPE_OPEN', 'open');
45
define('CHOICE_EVENT_TYPE_OPEN', 'open');
Línea 46... Línea -...
46
define('CHOICE_EVENT_TYPE_CLOSE', 'close');
-
 
47
 
46
define('CHOICE_EVENT_TYPE_CLOSE', 'close');
48
/** @global array $CHOICE_PUBLISH */
-
 
49
global $CHOICE_PUBLISH;
-
 
50
$CHOICE_PUBLISH = array (CHOICE_PUBLISH_ANONYMOUS  => get_string('publishanonymous', 'choice'),
-
 
51
                         CHOICE_PUBLISH_NAMES      => get_string('publishnames', 'choice'));
-
 
52
 
-
 
53
/** @global array $CHOICE_SHOWRESULTS */
-
 
54
global $CHOICE_SHOWRESULTS;
-
 
55
$CHOICE_SHOWRESULTS = array (CHOICE_SHOWRESULTS_NOT          => get_string('publishnot', 'choice'),
-
 
56
                         CHOICE_SHOWRESULTS_AFTER_ANSWER => get_string('publishafteranswer', 'choice'),
-
 
57
                         CHOICE_SHOWRESULTS_AFTER_CLOSE  => get_string('publishafterclose', 'choice'),
-
 
58
                         CHOICE_SHOWRESULTS_ALWAYS       => get_string('publishalways', 'choice'));
-
 
59
 
-
 
60
/** @global array $CHOICE_DISPLAY */
-
 
61
global $CHOICE_DISPLAY;
-
 
62
$CHOICE_DISPLAY = array (CHOICE_DISPLAY_HORIZONTAL   => get_string('displayhorizontal', 'choice'),
-
 
63
                         CHOICE_DISPLAY_VERTICAL     => get_string('displayvertical','choice'));
-
 
64
 
-
 
65
require_once(__DIR__ . '/deprecatedlib.php');
-
 
Línea 66... Línea 47...
66
 
47
 
67
/// Standard functions /////////////////////////////////////////////////////////
48
// Standard functions.
68
 
49
 
69
/**
50
/**
Línea 723... Línea 704...
723
 *
704
 *
724
 * @param MoodleQuickForm $mform form passed by reference
705
 * @param MoodleQuickForm $mform form passed by reference
725
 */
706
 */
726
function choice_reset_course_form_definition(&$mform) {
707
function choice_reset_course_form_definition(&$mform) {
727
    $mform->addElement('header', 'choiceheader', get_string('modulenameplural', 'choice'));
708
    $mform->addElement('header', 'choiceheader', get_string('modulenameplural', 'choice'));
-
 
709
    $mform->addElement('static', 'choicedelete', get_string('delete'));
728
    $mform->addElement('advcheckbox', 'reset_choice', get_string('removeresponses','choice'));
710
    $mform->addElement('advcheckbox', 'reset_choice', get_string('removeresponses', 'choice'));
729
}
711
}
Línea 730... Línea 712...
730
 
712
 
731
/**
713
/**
732
 * Course reset form defaults.
714
 * Course reset form defaults.
Línea 748... Línea 730...
748
 */
730
 */
749
function choice_reset_userdata($data) {
731
function choice_reset_userdata($data) {
750
    global $CFG, $DB;
732
    global $CFG, $DB;
Línea 751... Línea 733...
751
 
733
 
752
    $componentstr = get_string('modulenameplural', 'choice');
734
    $componentstr = get_string('modulenameplural', 'choice');
Línea 753... Línea 735...
753
    $status = array();
735
    $status = [];
754
 
736
 
755
    if (!empty($data->reset_choice)) {
737
    if (!empty($data->reset_choice)) {
756
        $choicessql = "SELECT ch.id
738
        $choicessql = "SELECT ch.id
Línea 757... Línea 739...
757
                       FROM {choice} ch
739
                       FROM {choice} ch
-
 
740
                       WHERE ch.course=?";
-
 
741
 
758
                       WHERE ch.course=?";
742
        $DB->delete_records_select('choice_answers', "choiceid IN ($choicessql)", [$data->courseid]);
-
 
743
        $status[] = [
-
 
744
            'component' => $componentstr,
759
 
745
            'item' => get_string('removeresponses', 'choice'),
Línea 760... Línea 746...
760
        $DB->delete_records_select('choice_answers', "choiceid IN ($choicessql)", array($data->courseid));
746
            'error' => false,
761
        $status[] = array('component'=>$componentstr, 'item'=>get_string('removeresponses', 'choice'), 'error'=>false);
747
        ];
762
    }
748
    }
763
 
749
 
764
    /// updating dates - shift may be negative too
750
    // Updating dates - shift may be negative too.
-
 
751
    if ($data->timeshift) {
-
 
752
        // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
765
    if ($data->timeshift) {
753
        // See MDL-9367.
-
 
754
        shift_course_mod_dates('choice', ['timeopen', 'timeclose'], $data->timeshift, $data->courseid);
-
 
755
        $status[] = [
766
        // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
756
            'component' => $componentstr,
Línea 767... Línea 757...
767
        // See MDL-9367.
757
            'item' => get_string('date'),
768
        shift_course_mod_dates('choice', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
758
            'error' => false,
Línea 769... Línea 759...
769
        $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
759
        ];
-
 
760
    }
-
 
761
 
770
    }
762
    return $status;
771
 
763
}
772
    return $status;
764
 
773
}
765
/**
774
 
766
 * Get response data for a choice and group.
775
/**
767
 *
776
 * @global object
768
 * @global object
777
 * @global object
769
 * @global object
-
 
770
 * @global object
778
 * @global object
771
 * @uses CONTEXT_MODULE
779
 * @uses CONTEXT_MODULE
772
 * @param object $choice
780
 * @param object $choice
773
 * @param object $cm
781
 * @param object $cm
774
 * @param int $groupmode
Línea 782... Línea 775...
782
 * @param int $groupmode
775
 * @param bool $onlyactive Whether to get response data for active users only.
Línea 783... Línea -...
783
 * @param bool $onlyactive Whether to get response data for active users only.
-
 
784
 * @return array
776
 * @param int $groupid Group id, null for current group if choice has groups.
-
 
777
 * @return array
-
 
778
 */
785
 */
779
function choice_get_response_data($choice, $cm, $groupmode, $onlyactive, ?int $groupid = null) {
-
 
780
    global $CFG, $USER, $DB;
786
function choice_get_response_data($choice, $cm, $groupmode, $onlyactive) {
781
 
787
    global $CFG, $USER, $DB;
782
    $context = context_module::instance($cm->id);
788
 
783
 
Línea 789... Línea 784...
789
    $context = context_module::instance($cm->id);
784
    if ($groupmode > 0) {
790
 
785
        if (is_null($groupid)) {
Línea 791... Línea 786...
791
/// Get the current group
786
            // Get the current group.
792
    if ($groupmode > 0) {
787
            $groupid = groups_get_activity_group($cm);
793
        $currentgroup = groups_get_activity_group($cm);
788
        }
794
    } else {
789
    } else {
795
        $currentgroup = 0;
790
        $groupid = 0;
796
    }
791
    }
797
 
792
 
Línea 798... Línea 793...
798
/// Initialise the returned array, which is a matrix:  $allresponses[responseid][userid] = responseobject
793
/// Initialise the returned array, which is a matrix:  $allresponses[responseid][userid] = responseobject
799
    $allresponses = array();
794
    $allresponses = array();
Línea 878... Línea 873...
878
    $module_pagetype = array('mod-choice-*'=>get_string('page-mod-choice-x', 'choice'));
873
    $module_pagetype = array('mod-choice-*'=>get_string('page-mod-choice-x', 'choice'));
879
    return $module_pagetype;
874
    return $module_pagetype;
880
}
875
}
Línea 881... Línea 876...
881
 
876
 
882
/**
-
 
883
 * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
-
 
884
 */
-
 
885
function choice_print_overview() {
-
 
886
    throw new coding_exception('choice_print_overview() can not be used any more and is obsolete.');
-
 
887
}
-
 
888
 
-
 
889
 
-
 
890
/**
877
/**
891
 * Get responses of a given user on a given choice.
878
 * Get responses of a given user on a given choice.
892
 *
879
 *
893
 * @param stdClass $choice Choice record
880
 * @param stdClass $choice Choice record
894
 * @param int $userid User id
881
 * @param int $userid User id
Línea 1266... Línea 1253...
1266
        $event->trigger();
1253
        $event->trigger();
1267
    }
1254
    }
1268
}
1255
}
Línea 1269... Línea 1256...
1269
 
1256
 
1270
/**
-
 
1271
 * Get icon mapping for font-awesome.
-
 
1272
 */
-
 
1273
function mod_choice_get_fontawesome_icon_map() {
-
 
1274
    return [
-
 
1275
        'mod_choice:row' => 'fa-info',
-
 
1276
        'mod_choice:column' => 'fa-columns',
-
 
1277
    ];
-
 
1278
}
-
 
1279
 
-
 
1280
/**
1257
/**
1281
 * Add a get_coursemodule_info function in case any choice type wants to add 'extra' information
1258
 * Add a get_coursemodule_info function in case any choice type wants to add 'extra' information
1282
 * for the course (see resource).
1259
 * for the course (see resource).
1283
 *
1260
 *
1284
 * Given a course_module object, this function returns any "extra" information that may be needed
1261
 * Given a course_module object, this function returns any "extra" information that may be needed