Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sectiontext question on mobile #349

Open
wants to merge 1 commit into
base: MOODLE_400_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ public static function mobile_view_activity($args) {
if ($question->supports_mobile()) {
$pagequestions[] = $question->mobile_question_display($qnum, $questionnaire->autonum);
$responses = array_merge($responses, $question->get_mobile_response_data($response));
$qnum++;

if ($question->type_id != QUESSECTIONTEXT) {
$qnum++;
}
}
}
$data['prevpage'] = 0;
Expand Down Expand Up @@ -254,9 +257,11 @@ protected static function add_pagequestion_data($questionnaire, $pagenum, $respo
$responses = array_merge($responses, $question->get_mobile_response_data($response));
}
}
$qnum++;
if ($question->type_id != QUESSECTIONTEXT) {
$qnum++;
}
}

return ['pagequestions' => $pagequestions, 'responses' => $responses];
}
}
}
37 changes: 36 additions & 1 deletion classes/question/sectiontext.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ public function supports_feedback() {
return true;
}

public function supports_mobile() {
return true;
}

/**
* @param $qnum
* @param $fieldkey
* @param bool $autonum
* @return \stdClass
* @throws \coding_exception
*/
public function mobile_question_display($qnum, $autonum = false) {
$options = ['noclean' => true, 'para' => false, 'filter' => true,
'context' => $this->context, 'overflowdiv' => true];
$mobiledata = (object)[
'id' => $this->id,
'name' => $this->name,
'type_id' => $this->type_id,
'length' => $this->length,
'content' => format_text(file_rewrite_pluginfile_urls($this->content, 'pluginfile.php', $this->context->id,
'mod_questionnaire', 'question', $this->id), FORMAT_HTML, $options),
'content_stripped' => strip_tags($this->content),
'required' => false,
'deleted' => $this->deleted,
'response_table' => $this->responsetable,
'fieldkey' => $this->mobile_fieldkey(),
'precise' => $this->precise,
'qnum' => '',
'errormessage' => get_string('required') . ': ' . $this->name
];

$mobiledata->issectiontext = true;
return $mobiledata;
}

/**
* True if question type supports feedback scores and weights. Same as supports_feedback() by default.
*/
Expand Down Expand Up @@ -180,4 +215,4 @@ protected function form_length(\MoodleQuickForm $mform, $helpname = '') {
protected function form_precise(\MoodleQuickForm $mform, $helpname = '') {
return question::form_precise_hidden($mform);
}
}
}
Empty file.
5 changes: 4 additions & 1 deletion templates/mobile_view_activity_page.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<%#israte%>
<%> mod_questionnaire/mobile_rate_question %>
<%/israte%>
<%#issectiontext%>
<%> mod_questionnaire/mobile_sectiontext_question %>
<%/issectiontext%>
<%/pagequestions%>

<%^pagequestions%>
Expand Down Expand Up @@ -183,4 +186,4 @@
</div>
<%#emptypage%>
<%/emptypage%>
</div>
</div>