Skip to content

Commit f471895

Browse files
author
rtschu
committed
integrate into master changes
1 parent 63de62f commit f471895

File tree

7 files changed

+1955
-1013
lines changed

7 files changed

+1955
-1013
lines changed

amd/build/initialize.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

block_evasys_sync.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function get_content() {
152152
$end = $record->get('enddate');
153153
$recordhasstandardtime = $record->get('usestandardtime');
154154
} else {
155-
if (!$ismodeautomated && $categoryhasstandardtime) {
155+
if ($categoryhasstandardtime) {
156156
$start = $categoryhasstandardtime['start'];
157157
$end = $categoryhasstandardtime['end'];
158158
$recordhasstandardtime = true;
@@ -232,7 +232,7 @@ public function get_content() {
232232
// Append this course.
233233
$courses[] = $course;
234234
}
235-
$standardttimemode = (!$ismodeautomated && $recordhasstandardtime && !$record);
235+
$standardttimemode = ($recordhasstandardtime && !$wasstarted);
236236
// Create the data object for the mustache table.
237237
$data = array(
238238
'href' => $href,
@@ -243,7 +243,7 @@ public function get_content() {
243243
* In case of the automated workflow, we require surveys
244244
* in order to be able to automatically trigger the evaluation. */
245245
'showcontrols' => ($hassurveys || !$ismodeautomated) && count($evasyscourses) > 0 && !$invalidcourses,
246-
'usestandardtimelayout' => (!$ismodeautomated && $recordhasstandardtime && !$wasstarted && !$record),
246+
'usestandardtimelayout' => $standardttimemode,
247247
// Choose mode.
248248
'direct' => $ismodeautomated,
249249
'startdisabled' => $startdisabled || $standardttimemode,

tests/behat/behat_block_evasys_sync.php

+21
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,27 @@ public function the_internal_state_of_course_is($shortname, $mode) {
331331
$record->save();
332332
}
333333

334+
/**
335+
* @Given the recordstandardtimemode for course :shortname is set to :value
336+
*/
337+
public function the_recorstandardtime_for_course_is_set($shortname, $mode) {
338+
global $DB;
339+
$id = $this->get_courseid_by_shortname($shortname);
340+
$record = \block_evasys_sync\course_evaluation_allocation::get_record_by_course($id, false);
341+
if (!$record) {
342+
$record = new \block_evasys_sync\course_evaluation_allocation(0);
343+
$record->set('course', $id);
344+
}
345+
$record->set('usestandardtime', $mode == "true");
346+
$record->save();
347+
}
348+
349+
/**
350+
* @Given the recordstandardtimemode for course :shortname is not set
351+
*/
352+
public function the_recordstandardtimemode_for_course_is_not_set($shortname) {
353+
return;
354+
}
334355

335356
/**
336357
* @Given no courses are mapped to course :shortname

tests/behat/fulltest.feature

+1,855-997
Large diffs are not rendered by default.

tests/behat/generator/generator.py

+64-9
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,44 @@
1515
"idnumber": ["none", "invalid", "one"],
1616
"mapped": ["none", "invalid", "one", "multi"],
1717
"internalstate": ["notopened", "opened", "closed", "manual", "none"],
18-
"actualstate": ["open", "closed", "mixed"]
18+
"actualstate": ["open", "closed", "mixed"],
19+
"recordstandardtime": ["recordstandardtimemode", "recordnonstandardtimemode", "norecordstandardtimemode"]
1920
}
2021

22+
ILLEGALSTATES = [
23+
{"recordstandardtime": "recordstandardtimemode", "internalstate": "none"},
24+
{"recordstandardtime": "recordnonstandardtimemode", "internalstate": "none"},
25+
{"recordstandardtime": "norecordstandardtimemode", "internalstate": "notopened"},
26+
{"recordstandardtime": "norecordstandardtimemode", "internalstate": "opened"},
27+
{"recordstandardtime": "norecordstandardtimemode", "internalstate": "closed"},
28+
{"recordstandardtime": "norecordstandardtimemode", "internalstate": "manual"},
29+
]
30+
31+
32+
def illegal_state(scenario):
33+
for fullillegalstate in ILLEGALSTATES:
34+
illegal = True
35+
for illegalstate in fullillegalstate.keys():
36+
if scenario[list(OPTIONS.keys()).index(illegalstate)] != fullillegalstate[illegalstate]:
37+
illegal = False
38+
break
39+
if illegal:
40+
return True
41+
if scenario[5] == "none" and scenario[7] != "norecordstandardtimemode":
42+
print(scenario)
43+
return False
44+
2145

22-
def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state, actual_state):
46+
def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state, actual_state, recordstandardtimemode):
2347
"""
2448
This Function will take the scenario parameters and construct the resulting checks.
2549
:return: The combined checks for the parameters.
2650
"""
27-
checks = ""
2851
# If there are no mapped courses the Block not offer the option to "Show surveys"
2952
if (idnumber_state == "none") and (mapped_state == "none"):
3053
return "Then I should see \"Change mapping\"\n And I should not see \"Name:\"\n "
3154

55+
checks = ""
3256
# In all other cases (even if there are only invalid entries) we need to click the button to start code execution
3357
checks += "And I load the evasys block\n"
3458

@@ -62,7 +86,7 @@ def get_checks(mode, standardtime, students_state, idnumber_state, mapped_state,
6286
checks += "And I should see \"There are some closed surveys, but all surveys should be open.\"" + "\n"
6387

6488
# if the standardtimemodecheckbox should be present from the start we also want to check that
65-
checks += checks_standardtimemode(standardtime, mode, internal_state, actual_state) + "\n"
89+
checks += checks_standardtimemode(standardtime, mode, internal_state, recordstandardtimemode) + "\n"
6690
# if there are no students that are eligible to evaluate we want to output a warning
6791
checks += student_checks[students_state]
6892
checks = checks.replace("\n", "\n ")
@@ -110,13 +134,15 @@ def get_combi_sentence(set, dictionary, param_name):
110134

111135

112136
def get_combi_description(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state,
113-
actual_state):
137+
actual_state, recordstandardtimemode):
114138
"""
115139
This will construct the description for a scenario that covers multiple states.
116140
:return: String the description of the scenario.
117141
"""
118142
if "none" in mapped_state and "none" in idnumber_state:
119143
return "If there are no related evasys-courses I should not see any.\n "
144+
if not recordstandardtimemode == "norecordstandardtimemode":
145+
standardtime = {1} if recordstandardtimemode == "recordstandardtimemode" else {0}
120146
description = ""
121147
description += get_combi_sentence(standardtime, standardtimemode_descriptions, "standardtime")
122148
description += get_combi_sentence(students_state, students_descriptions, "number of students")
@@ -127,7 +153,7 @@ def get_combi_description(mode, standardtime, students_state, idnumber_state, ma
127153
return description
128154

129155

130-
def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state, actual_state):
156+
def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state, actual_state, recordstandardtimemode):
131157
"""
132158
This constructs the actual scenario by building all courses, states etc.
133159
:return: string the combined enviroment specifiing string for a scenario
@@ -138,6 +164,7 @@ def get_scenario(mode, standardtime, students_state, idnumber_state, mapped_stat
138164
behat_scenario += step_idnumberstate(idnumber_state, actual_state)
139165
behat_scenario += step_mappedstate(mapped_state, actual_state)
140166
behat_scenario += step_internal_state[internal_state].replace("{{course}}", str(coursename)) + "\n"
167+
behat_scenario += step_record_standardtimemode[recordstandardtimemode].replace("{{course}}", str(coursename)) + "\n"
141168
behat_scenario += "And I turn editing mode on\n"
142169
behat_scenario += "And I add the \"EvaSys Sync\" block\n"
143170
behat_scenario += "And I turn editing mode off\n"
@@ -220,6 +247,7 @@ def condense_keep_options(fullarray):
220247
if changed:
221248
break
222249
fullarray = new_array
250+
223251
return fullarray
224252

225253

@@ -252,17 +280,20 @@ def main():
252280
# get the checks for all options to be able to condense options with the same expected outcome
253281
uncondensed_dict = {}
254282
for scenario in cartesianoptions:
255-
check = get_checks(scenario[0], scenario[1], scenario[2], scenario[3], scenario[4], scenario[5], scenario[6])
283+
check = get_checks(scenario[0], scenario[1], scenario[2], scenario[3], scenario[4], scenario[5], scenario[6], scenario[7])
256284
if not check in uncondensed_dict.keys():
257285
uncondensed_dict[check] = []
258286
uncondensed_dict[check].append(scenario)
259287

260288
# condense those scenarios
261289
condensed_dict = {}
262290
if CONDENSE_TESTS:
291+
i = 0
263292
for check in uncondensed_dict.keys():
264293
scenarios = uncondensed_dict[check]
265294
condensed_dict[check] = condense_keep_options(scenarios)
295+
i += 1
296+
print("Condensed " + str(i) + " of " + str(len(uncondensed_dict.keys())))
266297
else:
267298
for check in uncondensed_dict.keys():
268299
fullarray = uncondensed_dict[check]
@@ -284,18 +315,42 @@ def main():
284315
# do a deep-copy of the scenario because sets can only be accessed by pop which alters the set itself
285316
scenario_copy = copy.deepcopy(scenario)
286317
desc = get_combi_description(scenario[0], scenario[1], scenario[2], scenario[3], scenario[4], scenario[5],
287-
scenario[6])
318+
scenario[6], scenario[7])
288319
mode = scenario_copy[0].pop()
289320
standardtime = scenario_copy[1].pop()
290321
students_state = scenario_copy[2].pop()
291322
idnumber_state = scenario_copy[3].pop()
292323
mapped_state = scenario_copy[4].pop()
293324
internal_state = scenario_copy[5].pop()
294325
actual_state = scenario_copy[6].pop()
326+
recordstandardtime = scenario_copy[7].pop()
295327
if actual_state == "mixed" and len(scenario_copy[6]) > 0:
296328
actual_state = scenario_copy[6].pop()
329+
330+
corrected = True
331+
illegal = False
332+
illegals = []
333+
while corrected:
334+
corrected = False
335+
if illegal_state([mode, standardtime, students_state, idnumber_state, mapped_state, internal_state,
336+
actual_state, recordstandardtime]):
337+
corrected = True
338+
illegals.append([mode, standardtime, students_state, idnumber_state, mapped_state, internal_state,
339+
actual_state, recordstandardtime])
340+
if len(scenario_copy[5]) >= 1:
341+
internal_state = scenario_copy[5].pop()
342+
elif len(scenario_copy[7]) >= 1:
343+
recordstandardtime = scenario_copy[7].pop()
344+
else:
345+
if len(illegals) > 1:
346+
print("Illegal multiscenario")
347+
print(illegals)
348+
illegal = True
349+
corrected = False
350+
if illegal:
351+
continue
297352
scen_text = get_scenario(mode, standardtime, students_state, idnumber_state, mapped_state, internal_state,
298-
actual_state)
353+
actual_state, recordstandardtime)
299354
if not scen_text:
300355
print("Warning impossible scenario!!!")
301356
continue

tests/behat/generator/steps.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
"none": "And there is no internal record of course {{course}}"
6464
}
6565

66+
step_record_standardtimemode = {
67+
"norecordstandardtimemode": "And the recordstandardtimemode for course {{course}} is not set",
68+
"recordstandardtimemode": "And the recordstandardtimemode for course {{course}} is set to true",
69+
"recordnonstandardtimemode": "And the recordstandardtimemode for course {{course}} is set to false",
70+
}
71+
6672
step_students_state = {
6773
"none": "And no students enrolled in course " + coursename,
6874
"onlytutors": "And only tutors enrolled in course " + coursename,
@@ -154,14 +160,16 @@ def step_mappedstate(state, openstate):
154160
return x
155161

156162

157-
def checks_standardtimemode(standardtime, auto_mode, internal_state, actual_state):
163+
def checks_standardtimemode(standardtime, auto_mode, internal_state, recordstandardtimemode):
158164
"""
159165
The standardtimemode check is a little tricky since the checkbox showing is dependent on 3 states
160166
:param standardtime: standardtimemode
161-
:param auto_mode: auto or manual mode
167+
:param recordstandardtimemode: the recordstandardtimemode may overwrite the standardtimemode for the category
162168
:param internal_state: internal state
163169
:return: A string checking for the presence or absence of the standardtime checkbox
164170
"""
171+
if not recordstandardtimemode == "norecordstandardtimemode":
172+
standardtime = 1 if recordstandardtimemode == "recordstandardtimemode" else 0
165173
if standardtime == 1 and auto_mode == "manual" and (internal_state == "none" or internal_state == "notopened"):
166174
return standardtimemode_checks[1]
167175
return standardtimemode_checks[0]

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
defined('MOODLE_INTERNAL') || die();
1919

2020
$plugin->component = 'block_evasys_sync';
21-
$plugin->version = 2019203100; // YYYYMMDDHH (year, month, day, 24-hr time).
21+
$plugin->version = 2020230410; // YYYYMMDDHH (year, month, day, 24-hr time).
2222
$plugin->requires = 2017111300; // YYYmoYMMDDHH (This is the release version for Moodle 2.0).
2323
$plugin->maturity = MATURITY_RC;
2424

0 commit comments

Comments
 (0)