rianadon / CheckPCR

A client for PCR, the homework system formerly used by The Harker School
MIT License
8 stars 3 forks source link

Error Parsing Assignments #13

Open ghost opened 7 years ago

ghost commented 7 years ago

Every time I open Check PCR, a popup shows that says "Are you in week or month view?" This shows even though my regular PCR is on month view. This is copied and pasted from the popup.

Message: Cannot read property '1' of null Stack: TypeError: Cannot read property '1' of null at parse (chrome-extension://nlppblbfamffglclfjgflgpkalncnfni/client.js:482:53) at chrome-extension://nlppblbfamffglclfjgflgpkalncnfni/client.js:282:11 Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Version: 2.24.3

rianadon commented 7 years ago

Hi there!

This is happening where the code extracts assignment types from the titles PCR gives. It might be failing if any of your teachers posted an assignment with a type containing parentheses in it.

Could you go to the PCR website and see if any of the assignments posted there have an assignment type containing parenthesis (you can find the type by hovering over an assignment and looking at the item in parenthesis after the assignment's name)?

Rather than hovering over each assignment you could alternatively run the following in the Developer Console:

console.log(Array.from(new Set(Array.from(document.getElementsByClassName("rsApt rsAptSimple")).map(x=>(a=x.querySelector("span[id$=\"lblTitle\"]"))?a.innerHTML:null))).join("\n"))

This will print out a list of all unique assignment titles, and from their you can look at what's in the parenthesis to find the types.

If there are any assignment types with parenthesis inside, would you be willing to post them so I could see if they're what is causing the problem or not?

Thank you for reporting the issue!

ghost commented 7 years ago

For all of my homework, it just says "(Homework)" after it and the same for Classwork and Tests and Quizzes. I have posted an example for each. anything you like 2017-04-18 at 9 02 47 am anything you like 2017-04-18 at 9 02 55 am anything you like 2017-04-18 at 9 03 03 am

Sometimes it also says labs or Participation.

anything you like 2017-04-18 at 9 04 51 am

I am pretty sure all of my assignments have a parenthesis with the assignment type in it.

ghost commented 7 years ago

Also, sometimes my assignments return but the order they are in is mixed up. I have this week´s assignments first and then I have March 26th to April 15th assignments with next week´s assignments last.

rianadon commented 7 years ago

Okay so it seems as if stuff should be working then.

The examples you posted wouldn't cause the error, so the only way to find out what's causing the error would be to add console.log(title); in between lines 481 and 482 (assignment.body = ... and assignment.type = ...), then open the Developer Console for Check PCR and then post the very last piece of text outputted that looks like an assignment title.

If you have difficulty getting this to work I could also push an update to generate more output for this error.

As for the mixed order, I'm not sure at all what's happening. In my experience the only time the order gets mixed up in Calendar view is when you switch from week view from month view, but then it goes to the correct order after refreshing. Are you perhaps frequently switching date ranges in PCR?

Thanks!

ghost commented 7 years ago

I always stay in month view on PCR, but on Check PCR, I am unable to change to month view. I have attached a picture of the Console. anything you like 2017-04-19 at 9 32 21 am

Also, could you try to push an update?

Thanks so much!

rianadon commented 7 years ago

Okay I'll try to update it soon.

rianadon commented 7 years ago

Sorry for taking so long. I created a new branch named "dev" that should give a more detailed error.

When you can try switching to that branch and resubmitting whatever error that gives (which should hopefully include the problem-causing title).

ghost commented 7 years ago

I believe the issue has been solved. Thank you so much for fixing it.

rianadon commented 7 years ago

That update was only supposed to give more information in the error, not fix the issue. Now that it's May 1st that assignment probably went away and is no longer being parsed.

If an assignment with a similar assignment type ever comes up again, hopefully a more descriptive error message will be generated. I'll leave this issue open as this hasn't been fixed yet, and if a similar error ever pops up again please feel free to post that here.

Thanks!