Coder Social home page Coder Social logo

cppquiz's Introduction

This is the source code (but not the content) for https://cppquiz.org

This project is licensed under the GNU General Public License Version 3, see COPYING. (The content on the site is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License, and is not available in this repository.)

Build Status

Requirements

  • Python 3.8 or higher
  • CppQuiz is only tested on Ubuntu and MacOS, but will probably work on many other OSes as well

Contributing

Please refer to CONTRIBUTING.md and CODE_OF_CONDUCT.md.

Running the code locally

Setting up the environment

  • Clone this repository
  • (We recommend using Virtualenv)
  • pip install -r requirements.txt
  • cp cppquiz/local_settings_example.py cppquiz/local_settings.py, then edit at least /path/to/your/code
  • python manage.py migrate
  • python manage.py createsuperuser
  • python manage.py create_questions 10 (Or whatever number, just so you have some dummy questions)
  • python manage.py runserver
  • Click the link displayed to go to the site. Visit /admin to log in with the superuser you created above.

Testing

  • python manage.py test

Formatting

All code is formatted with autopep8 and checked in CI. To format your code, run ./ci/format.sh --fix

Adding / upgrading dependencies

  • Add any new dependencies to requirements.in
  • Run pip-compile --upgrade requirements.in

Deployment

  • Check out the branch you want to deploy
  • Run ./deploy.sh

cppquiz's People

Contributors

dependabot[bot] avatar eoan-ermine avatar knatten avatar rshest avatar tocic avatar vsklamm avatar wrazik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cppquiz's Issues

Question 3 - no explanation

Question 3 could use an explanation. Simple "ambiguous call to overloaded function" would probably suffice.

Show the quiz solution

It would be nice if there was a link to show the quiz solution in case someone cannot answer the question

Improve HTTP 500 page

Add a link to try another question. Even though one page has crashed, the site itself might be fine.

Generate a deterministic quiz

Make it possible to generate a quiz with a given number of questions, so that several people can take the same set of questions.

User-explanations

Allow the user to enter his/her own explanation after answering correctly, to gather more and better explanations

URL converter bugs

It seems like if an URL is at the end of a paragraph, a

is appended to the url.
Also, if it is on the first column of a line, it is not converted.

Filter by difficulty

Categorize questions with difficulty levels. Allow the user to only view questions of one or more levels.

Race mode

Allow several people to take the same quiz at the same time, getting scored by the number of correct answers they gave in a limited time. Announce the winner at the end.
It would be cool if they could see live how the competitors are doing.

Use [syntax] to refer to the standard

Hi, I've just noticed that question #117 (and probably others) refers to a section from the standard as §14.5.7.1, while I think it would be more future-proof to use the syntax that makes use of brackets and the abbreviated title of the section, which in this case would be [temp.alias].1 (I am not sure about how to indicate the fact that you are referring to the first stanza).

Thanks for your work on C++ Quiz!

New Question

include

class A {
public:
virtual void f() { std::cout << "A"; }
};

class B : public A {
private:
void f() { std::cout << "B"; }
};

void g(A& a) { a.f(); }

int main () {
B b;
g(b);
}

you can add this question in cppquiz if you like.
No compile error as compiler only checks for the A function at the compile time. It can not see we are calling with B object.
B function gets called during run time even it is private.

Not an issue, but a suggestion on Q#109

Hi,
On the quiz#109, I tested the following correction with clang and it also worked, and think it works better(less verbose):

replace the call to call_with(print, 42) with
call_with(print, 42);

I think the compiler just needed a little help on the type for T, an explicit specialization should suffice.

Thank you for providing such a great site. I learned a lot from it.

Regards,

Steve

Q 112 explanation

The answer to question #112 is correct, but the explanation given is wrong.

12.8/15 applies to implicitly-defined [copy and] move constructors only. But the move constructor B::B(B&&) is user-defined.

The real reason copy constructor A::A(const A&) is called is that in the move constructor's mem-initializer "a(b.a)", expressions "b" and "b.a" are lvalues, not xvalues.

Question 11

It says variable a is static, but it's not (probably forgot to add static?).

include <iostream>

int a;

int main () {
std::cout << a;
}

Correct!
Since a is a static variable, it is guaranteed to be initialized to its default value, 0. Had a been defined as a local non-static variable inside main(), this would not have happened.

Export questions

Export all questions and given answers under a free license, so that others can play with the data.

Need explanation when you don't know the answer

If the user doesn't know the answer - and guessing is failing - he needs some way to "give up" and let the quiz tell him the answer (in training mode, at least).

Great product! Thanks for setting this up.

The explanation of the answer for Question 17 is wrong

It says:
The base class constructor is called before the inherited constructor. The inherited constructor is called before the base class constructor.

It should say:
The base class constructor is called before the inherited constructor. The inherited destructor is called before the base class destructor.

Coding standard

Go through questions and make them follow a coding standard

Wrong comment to question

The question is

What is the output of this program?

include

class A {
public:
A() { std::cout << 'a'; }
~A() { std::cout << 'A'; }
};

class B
{
public:
B() { std::cout << 'b'; }
~B() { std::cout << 'B'; }
A a;
};

int main () {
B b;
}

The answer is:
Correct!

The base class constructor is called before the inherited constructor. The inherited constructor is called before the base class constructor.


But there is no inheritance in this question. (Copy paste bug from an other question?)
I think you meant that B inherited from A and that B did not have an A member variable

Question #25

I don't think there should be std::endl here:

std::cout << ++i << std::endl;

After bumping into std::endl it's quite obvious, that the answer cannot be compilable and deterministic, because otherwise we would have to deal with inputting std::endl in the answer field and it was nowhere explained how to do that (\n? hit enter?). It gives a huge hint, I didn't even think about the answer and clicked "is undefined" right away because of that.

quiz on constructors/destructors

Does the standard say that std::cout is initialized before the global variable A a; that's ctor uses std::cout or after its destruction . IMHO, the initialization sequence of global variables in different compilation units is unspecified. At least we have been bitten about that in the past, but today compilers, linkers or the standard might be more definitive. Please enlighten me.

Preview-key

Let questions be preview-able by anyone who has a preview-key. This will make it easier to discuss questions which are not published yet.
(There is currently a preview-functionality which requires the user to be logged in as an admin)

Ideas for statistics

Which questions get the most wrong answers
What are the most common answers for each question
Probably a lot more we could do
Publish a blog post at some point about what are common misunderstandings of C++

Log all answers

Log all answers that people give. This can make for some interesting statistics, seeing which questions are most often answered wrongly etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.