forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPGProblemEditor.html.ep
More file actions
220 lines (220 loc) · 9.04 KB
/
PGProblemEditor.html.ep
File metadata and controls
220 lines (220 loc) · 9.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
% use Mojo::URL;
% use Mojo::Util qw(url_escape);
%
% use WeBWorK::Utils qw(not_blank x getAssetURL);
% use WeBWorK::Utils::Files qw(readFile);
% use WeBWorK::Utils::Sets qw(format_set_name_display);
% use WeBWorK::HTML::CodeMirrorEditor qw(generate_codemirror_html output_codemirror_static_files);
%
% content_for js => begin
<%= output_codemirror_static_files($c) =%>
<%= javascript getAssetURL($ce, 'js/ActionTabs/actiontabs.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/PGProblemEditor/pgproblemeditor.js'), defer => undef =%>
% end
%
% unless ($authz->hasPermissions(param('user'), 'access_instructor_tools')) {
<div class="alert alert-danger p-1 mb-0"><%= maketext('You are not authorized to access instructor tools.') %></div>
% last;
% }
%
% unless ($authz->hasPermissions(param('user'), 'modify_problem_sets')) {
<div class="alert alert-danger p-1 mb-0"><%= maketext('You are not authorized to modify problems.') %></div>
% last;
% }
%
% if (!$c->{file_type}) {
%= include("ContentGenerator/Instructor/PGProblemEditor/file_chooser");
% last;
% }
%
% if (stash('file_error')) {
<div class="alert alert-danger p-1 mb-0"><%= stash('file_error') %></div>
% last;
% }
%
% my %titles = (
% blank_problem => x('Editing <strong>new problem</strong> template "[_1]".'),
% sample_problem => x('Editing <strong>sample problem</strong> file "[_1]".'),
% set_header => x('Editing <strong>set header</strong> file "[_1]".'),
% hardcopy_header => x('Editing <strong>hardcopy header</strong> file "[_1]".'),
% hardcopy_theme => x('Editing <strong>hardcopy theme</strong> file "[_1]".'),
% course_info => x('Editing <strong>course information</strong> file "[_1]".'),
% '' => x('Editing <strong>unknown file type</strong> in file "[_1]".'),
% source_path_for_problem_file => x('Editing <strong>unassigned problem</strong> file "[_1]".')
% );
%
% my $setName = stash('setID') // '';
% my $fullSetName = $c->{fullSetID} // $setName;
%
% my $fileInfo = begin
<div class="mb-2">
<%= tag 'div', class => 'set-file-info' . ($c->isTempEditFilePath($c->{inputFilePath}) ? ' temporaryFile' : ''),
begin =%>
<i>
<%== $c->{file_type} eq 'problem'
? maketext(
'Editing <strong>problem [_1] of set [_2]</strong> in file "[_3]".',
$c->{prettyProblemNumber},
tag('span', dir => 'ltr', format_set_name_display($fullSetName)),
tag('span', dir => 'ltr', class => 'current-file',
data => { tmp_file => $c->shortPath($c->{tempFilePath}) },
$c->shortPath($c->{inputFilePath}))
)
: maketext(
$titles{ $c->{file_type} },
tag('span', dir => 'ltr', class => 'current-file',
data => { tmp_file => $c->shortPath($c->{tempFilePath}) },
$c->shortPath($c->{inputFilePath}))
) =%>
</i>
<% end =%>
</div>
% end
<%= $fileInfo->() %>
%
<%= form_for current_route, method => 'POST', id => 'editor', name => 'editor',
enctype => 'application/x-www-form-urlencoded', class => 'col-12', begin =%>
<%= $c->hidden_authen_fields =%>
<%= hidden_field file_type => $c->{file_type} =%>
<%= hidden_field courseID => $c->{courseID} =%>
% if (defined $setName) {
<%= hidden_field hidden_set_id => $setName =%>
% }
% if (not_blank($c->{sourceFilePath})) {
<%= hidden_field sourceFilePath => $c->{sourceFilePath} =%>
% }
% if (($c->{file_type} eq 'problem' || $c->{file_type} eq 'source_path_for_problem_file')
% && not_blank($c->{editFilePath}))
% {
<%= hidden_field edit_file_path => $c->getRelativeSourceFilePath($c->{editFilePath}) =%>
% }
% if (not_blank($c->{tempFilePath})) {
<%= hidden_field temp_file_path => $c->{tempFilePath} =%>
% }
% if ($c->{file_type} eq 'sample_problem' && param('sampleProblemFile')) {
<%= hidden_field sampleProblemFile => param('sampleProblemFile') =%>
% }
% if ($c->{file_type} eq 'hardcopy_theme') {
<%= hidden_field hardcopy_theme => param('hardcopy_theme') =%>
% }
%
% if ($c->{is_pg}) {
% # PG problem authoring resource links
<div class="mb-2">
<%= link_to maketext('Sample Problems') => url_for('sample_problem_index'),
target => 'techniques_window',
title => maketext('Sample problem code with documentation.'),
class => 'reference-link btn btn-sm btn-info',
data => { bs_toggle => 'tooltip', bs_placement => 'top' } =%>
<%= link_to maketext('Math Objects') => $ce->{webworkURLs}{MathObjectsHelpURL},
target => 'math_objects',
title => maketext('Wiki summary page for MathObjects'),
class => 'reference-link btn btn-sm btn-info',
data => { bs_toggle => 'tooltip', bs_placement => 'top' } =%>
% # PG POD served locally
<%= link_to maketext('POD') => url_for('pod_index'),
target => 'pod_docs',
title => maketext('Documentation from source code for PG modules and macro files.'),
class => 'reference-link btn btn-sm btn-info',
data => { bs_toggle => 'tooltip', bs_placement => 'top' } =%>
% # PGML lab problem rendered as an unattached problem in a new window.
% my $pgml_lab_source = readFile("$ce->{webworkDirs}{assets}/pg/PGMLLab/PGML-lab.pg");
<%= tag 'button', type => 'button',
title => maketext(
'PG markdown syntax used to format WeBWorK questions. '
. 'This interactive lab can help you to learn the techniques.'
),
class => 'reference-link pgml-lab btn btn-sm btn-info',
data => { source => url_escape($pgml_lab_source), bs_toggle => 'tooltip', bs_placement => 'top' },
'PGML' =%>
<%= link_to maketext('Author Info') => $ce->{webworkURLs}{AuthorHelpURL},
target => 'author_info',
title => maketext('Top level of author information on the wiki.'),
class => 'reference-link btn btn-sm btn-info',
data => { bs_toggle => 'tooltip', bs_placement => 'top' } =%>
% # Only show the report bugs in problem button if editing an OPL or Contrib problem.
% if ($ce->{webworkURLs}{OPLBugReporter}
% && $c->{editFilePath} =~ m|^$ce->{courseDirs}{templates}/([^/]*)/|
% && ($1 eq 'Library' || $1 eq 'Contrib'))
% {
<%= link_to maketext('Report Bugs in this Problem') =>
Mojo::URL->new($ce->{webworkURLs}{OPLBugReporter})
->query(
title => $c->getRelativeSourceFilePath($c->{editFilePath}),
body => "Problem Seed: " . (param('action.view.seed') // $c->{problemSeed})
),
target => 'bug_report',
title => maketext(
'Report bugs in a WeBWorK question/problem using this link. '
. 'The very first time you do this you will need to register with an email address so that '
. 'information on the bug fix can be reported back to you.'
),
class => 'reference-link btn btn-sm btn-info',
data => { bs_toggle => 'tooltip', bs_placement => 'top' } =%>
% }
</div>
% }
<div class="row mb-2">
<div class="col-lg-6 col-md-12 order-last order-lg-first">
<%= generate_codemirror_html(
$c,
'problemContents',
$problemContents,
{ course_info => 'html', hardcopy_theme => 'xml' }->{ $c->{file_type} } // 'pg'
) =%>
</div>
<div class="col-lg-6 col-md-12 mb-lg-0 mb-2 order-first order-lg-last">
<div class="p-0" id="pgedit-render-area">
<div class="placeholder d-flex flex-column justify-content-center
align-items-center bg-secondary h-100">
<div class="fs-1"><%= maketext('Loading...') %></div>
<i class="fa-solid fa-spinner fa-spin fa-2x"></i>
</div>
</div>
</div>
</div>
<%= $fileInfo->() %>
%
% # Output action forms
% my $default_choice;
%
% for my $actionID (@$formsToShow) {
% my $line_contents = include("ContentGenerator/Instructor/PGProblemEditor/${actionID}_form");
% my $active = '';
% my $disabled =
% $actionID eq 'revert'
% && (!defined($c->{tempFilePath}) || !-e $c->{tempFilePath})
% && !$c->getBackupTimes ? ' disabled' : '';
%
% if (($line_contents && $line_contents ne '') || $actionID eq 'revert') {
% unless ($default_choice) { $active = ' active'; $default_choice = $actionID; }
% content_for 'tab-list' => begin
<li class="nav-item" role="presentation">
<%= link_to maketext($actionFormTitles->{$actionID}) => "#$actionID",
class => "nav-link action-link$active$disabled",
id => "$actionID-tab",
data => { action => $actionID, bs_toggle => 'tab', bs_target => "#$actionID" },
role => 'tab',
'aria-controls' => $actionID,
'aria-selected' => $active ? 'true' : 'false' =%>
</li>
% end
% content_for 'tab-content' => begin
<div class="tab-pane fade <%= $active ? "show$active" : '' %>"
id="<%= $actionID %>" role="tabpanel" aria-labelledby="<%= $actionID %>-tab">
<%= $line_contents %>
</div>
% end
% }
% }
%
<%= hidden_field action => $default_choice, id => 'current_action' =%>
<div>
<ul class="nav nav-tabs mb-2" role="tablist"><%= content 'tab-list' =%></ul>
<div class="tab-content"><%= content 'tab-content' %></div>
</div>
<div>
<%= submit_button maketext($actionFormTitles->{$default_choice}), name => 'submit', id => 'take_action',
class => 'btn btn-primary' =%>
</div>
<% end =%>